ปรับ API ทดลองงาน ==> personal/list?status=2
This commit is contained in:
parent
0703810fa3
commit
918d295d53
1 changed files with 19 additions and 4 deletions
|
|
@ -115,10 +115,23 @@ export class PersonalController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("list")
|
@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");
|
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" },
|
order: { createdAt: "DESC" },
|
||||||
|
where: conditions,
|
||||||
|
skip: (page - 1) * pageSize,
|
||||||
|
take: pageSize,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!lists) {
|
if (!lists) {
|
||||||
|
|
@ -133,7 +146,9 @@ export class PersonalController extends Controller {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
lists.map(async (item, index) => {
|
lists.map(async (item, index) => {
|
||||||
const probation_no = await this.assignRepository.count({
|
const probation_no = await this.assignRepository.count({
|
||||||
where: { personal_id: item.personal_id },
|
where: {
|
||||||
|
personal_id: item.personal_id,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
await result.push({
|
await result.push({
|
||||||
|
|
@ -151,7 +166,7 @@ export class PersonalController extends Controller {
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
return new HttpSuccess(result);
|
return new HttpSuccess({ data: result, total: total });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue