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.
This commit is contained in:
@@ -68,8 +68,17 @@ describe('PlansService', () => {
|
||||
weekday: 'monday',
|
||||
startBranchId: 'br-1',
|
||||
endBranchId: 'br-2',
|
||||
startBranch: { id: 'br-1', code: 'B1', name: 'Start' },
|
||||
endBranch: { id: 'br-2', code: 'B2', name: 'End' },
|
||||
routeGeometry: geometry,
|
||||
destinations: [{ id: 'cd-1', customerId: 'cus-1', sortOrder: 0 }],
|
||||
destinations: [
|
||||
{
|
||||
id: 'cd-1',
|
||||
customerId: 'cus-1',
|
||||
customer: { id: 'cus-1', code: 'C1', name: 'Acme' },
|
||||
sortOrder: 0,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
status: Status.create('active'),
|
||||
@@ -77,6 +86,9 @@ describe('PlansService', () => {
|
||||
updatedAt: now,
|
||||
createdBy: 'user-1',
|
||||
updatedBy: 'user-1',
|
||||
employee: { id: 'emp-1', code: 'E1', name: 'Ada' },
|
||||
createdByUser: { id: 'user-1', username: 'admin' },
|
||||
updatedByUser: { id: 'user-1', username: 'admin' },
|
||||
};
|
||||
|
||||
const plan: Plan = {
|
||||
@@ -87,14 +99,28 @@ describe('PlansService', () => {
|
||||
startBranchId: 'br-1',
|
||||
endBranchId: 'br-2',
|
||||
routeGeometry: geometry,
|
||||
destinations: [{ id: 'pd-1', customerId: 'cus-1', sortOrder: 0 }],
|
||||
destinations: [
|
||||
{
|
||||
id: 'pd-1',
|
||||
customerId: 'cus-1',
|
||||
customer: { id: 'cus-1', code: 'C1', name: 'Acme' },
|
||||
sortOrder: 0,
|
||||
},
|
||||
],
|
||||
invoiceIds: [],
|
||||
packingSlipIds: [],
|
||||
invoices: [],
|
||||
packingSlips: [],
|
||||
startBranch: { id: 'br-1', code: 'B1', name: 'Start' },
|
||||
endBranch: { id: 'br-2', code: 'B2', name: 'End' },
|
||||
employee: { id: 'emp-1', code: 'E1', name: 'Ada' },
|
||||
status: Status.create('active'),
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
createdBy: 'user-1',
|
||||
updatedBy: 'user-1',
|
||||
createdByUser: { id: 'user-1', username: 'admin' },
|
||||
updatedByUser: { id: 'user-1', username: 'admin' },
|
||||
};
|
||||
|
||||
beforeEach(async () => {
|
||||
@@ -196,7 +222,12 @@ describe('PlansService', () => {
|
||||
...plan,
|
||||
destinations: [
|
||||
...plan.destinations,
|
||||
{ id: 'pd-2', customerId: 'cus-2', sortOrder: 1 },
|
||||
{
|
||||
id: 'pd-2',
|
||||
customerId: 'cus-2',
|
||||
customer: { id: 'cus-2', code: 'C2', name: 'Beta' },
|
||||
sortOrder: 1,
|
||||
},
|
||||
],
|
||||
});
|
||||
await service.addDestination('pln-1', 'cus-2', undefined, user);
|
||||
|
||||
Reference in New Issue
Block a user