จัดลำดับแสดงผลเครื่องราชอิสริยาภรณ์
This commit is contained in:
parent
806fb21c61
commit
0fcfcdf790
1 changed files with 33 additions and 0 deletions
|
|
@ -197,4 +197,37 @@ export class InsigniaController extends Controller {
|
||||||
}));
|
}));
|
||||||
return new HttpSuccess(mapInsigniaAll);
|
return new HttpSuccess(mapInsigniaAll);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API จัดลำดับแสดงผลเครื่องราชอิสริยาภรณ์
|
||||||
|
*
|
||||||
|
* @summary ORG_038 - จัดลำดับแสดงผลเครื่องราชอิสริยาภรณ์ (ADMIN) #
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Post("sort")
|
||||||
|
async Sort(@Body() requestBody: { insigniaTypeId: string; sortId: string[] }) {
|
||||||
|
|
||||||
|
const insigniaType = await this.insigniaTypeRepository.findOne({
|
||||||
|
where: { id: requestBody.insigniaTypeId }
|
||||||
|
});
|
||||||
|
if (!insigniaType) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลลำดับเครื่องราชอิสริยาภรณ์นี้");
|
||||||
|
}
|
||||||
|
|
||||||
|
const insignia = await this.insigniaRepository.find({
|
||||||
|
select: ["id", "level"],
|
||||||
|
where: { insigniaTypeId: requestBody.insigniaTypeId }
|
||||||
|
});
|
||||||
|
if (!insignia) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลเครื่องราชอิสริยาภรณ์นี้");
|
||||||
|
}
|
||||||
|
|
||||||
|
const sortLevel = insignia.map((data) => ({
|
||||||
|
id: data.id,
|
||||||
|
level: requestBody.sortId.indexOf(data.id) + 1,
|
||||||
|
}));
|
||||||
|
|
||||||
|
await this.insigniaRepository.save(sortLevel);
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue