diff --git a/src/controllers/PersonalController.ts b/src/controllers/PersonalController.ts index a47e561..5cd7ddd 100644 --- a/src/controllers/PersonalController.ts +++ b/src/controllers/PersonalController.ts @@ -115,10 +115,23 @@ export class PersonalController extends Controller { * */ @Get("list") - async ListPersonal(@Request() request: RequestWithUser) { + async ListPersonal( + @Query() status: string = "", + @Query("page") page: number = 1, + @Query("pageSize") pageSize: number = 10, + @Request() request: RequestWithUser + ) { await new permission().PermissionList(request, "SYS_PROBATION"); - const lists = await this.personalRepository.find({ + const conditions: any = {}; + if (status) { + conditions.probation_status = status; + } + + const [lists, total] = await this.personalRepository.findAndCount({ order: { createdAt: "DESC" }, + where: conditions, + skip: (page - 1) * pageSize, + take: pageSize, }); if (!lists) { @@ -133,7 +146,9 @@ export class PersonalController extends Controller { await Promise.all( lists.map(async (item, index) => { const probation_no = await this.assignRepository.count({ - where: { personal_id: item.personal_id }, + where: { + personal_id: item.personal_id, + }, }); await result.push({ @@ -151,7 +166,7 @@ export class PersonalController extends Controller { }) ); - return new HttpSuccess(result); + return new HttpSuccess({ data: result, total: total }); } /**