fix total
This commit is contained in:
parent
bf12751bfa
commit
906edd7050
3 changed files with 9 additions and 22 deletions
|
|
@ -280,15 +280,12 @@ export class Salary extends Controller {
|
|||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query("keyword") keyword?: string,
|
||||
) {
|
||||
//ssss total ผิด
|
||||
// try {
|
||||
const [salary, total] = await this.salaryRepository.findAndCount({
|
||||
relations: ["posLevel_", "posType_"],
|
||||
order: {
|
||||
startDate: "DESC",
|
||||
},
|
||||
skip: (page - 1) * pageSize,
|
||||
take: pageSize,
|
||||
...(keyword ? {} : { skip: (page - 1) * pageSize, take: pageSize }),
|
||||
});
|
||||
if (keyword != undefined && keyword !== "") {
|
||||
const filteredSalary = salary.filter(
|
||||
|
|
@ -318,8 +315,8 @@ export class Salary extends Controller {
|
|||
endDate: item.endDate,
|
||||
details: item.details,
|
||||
}));
|
||||
|
||||
return new HttpSuccess({ data: formattedData, total: formattedData.length });
|
||||
const slicedData = formattedData.slice((page - 1) * pageSize, page * pageSize);
|
||||
return new HttpSuccess({ data: slicedData, total: formattedData.length });
|
||||
}
|
||||
|
||||
const formattedData = salary.map((item) => ({
|
||||
|
|
@ -337,9 +334,7 @@ export class Salary extends Controller {
|
|||
details: item.details,
|
||||
}));
|
||||
return new HttpSuccess({ data: formattedData, total });
|
||||
// } catch (error: any) {
|
||||
// throw new Error(error);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue