Files
trackgo-be/src/modules/privileges/privilege.ts
T
shancheas 4c45a4371e Enhance pagination and ordering capabilities in API responses
- Updated pagination-response and read-write-controllers documentation to include `orderBy` and `orderType` parameters for sorting results.
- Introduced new `order-clause` module to handle ordering logic, including validation for order types and columns.
- Enhanced `PaginationQueryDto` to support ordering fields in API requests.
- Updated various repository and service classes to implement ordering in database queries.
- Added unit tests for new ordering functionality and ensured existing tests cover the updated behavior.
- Refactored related DTOs to include user and code relations for better data representation in responses.
2026-08-27 13:09:41 +07:00

79 lines
2.0 KiB
TypeScript

import type { UserRelation } from '../../common/http/response';
import { DateTime } from '../../common/value-objects/date-time/date-time';
import { Status } from '../../common/value-objects/status/status';
import type { PrivilegeAction } from './privilege-action';
export type PrivilegeDetail = {
readonly id: string;
readonly privilegeKeyId: string;
readonly keyCode: string;
readonly keyLabel: string;
readonly sortOrder: number;
readonly action: PrivilegeAction;
readonly value: boolean;
};
export type Privilege = {
readonly id: string;
readonly name: string;
readonly code: string;
readonly status: Status;
readonly createdAt: DateTime;
readonly updatedAt: DateTime;
readonly createdBy: string;
readonly updatedBy: string;
readonly createdByUser: UserRelation;
readonly updatedByUser: UserRelation;
};
export type PrivilegeWithDetails = Privilege & {
readonly details: readonly PrivilegeDetail[];
};
export type PrivilegeDetailInput = {
readonly privilegeKeyId: string;
readonly action: PrivilegeAction;
readonly value: boolean;
};
export type CreatePrivilegeInput = {
readonly name: string;
readonly code: string;
readonly status?: Status;
readonly details?: readonly PrivilegeDetailInput[];
readonly userId: string;
};
export type UpdatePrivilegeInput = {
readonly name?: string;
readonly code?: string;
readonly details?: readonly PrivilegeDetailInput[];
readonly userId: string;
};
export type PrivilegeKey = {
readonly id: string;
readonly code: string;
readonly label: string;
readonly sortOrder: number;
};
export type ListPrivilegesFilters = {
readonly name?: string;
readonly code?: string;
readonly status?: string;
readonly search?: string;
readonly orderBy?: string;
readonly orderType?: string;
readonly limit: number;
readonly offset: number;
};
export type ListPrivilegeKeysFilters = {
readonly search?: string;
readonly orderBy?: string;
readonly orderType?: string;
readonly limit: number;
readonly offset: number;
};