sort edu by level
This commit is contained in:
parent
4b05629c29
commit
587fe5d5b6
11 changed files with 229 additions and 266 deletions
|
|
@ -63,6 +63,13 @@ export class InsigniaController extends Controller {
|
|||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ข้อมูล Row นี้มีอยู่ในระบบแล้ว");
|
||||
}
|
||||
|
||||
const _insignia = await this.insigniaRepository.findOne({
|
||||
select: ["id", "level", "insigniaTypeId"],
|
||||
where: { insigniaTypeId: requestBody.insigniaTypeId },
|
||||
order: { level: "DESC" },
|
||||
});
|
||||
|
||||
insignia.level = _insignia == null ? 1 : _insignia.level + 1;
|
||||
insignia.createdUserId = request.user.sub;
|
||||
insignia.createdFullName = request.user.name;
|
||||
insignia.lastUpdateUserId = request.user.sub;
|
||||
|
|
@ -131,6 +138,19 @@ export class InsigniaController extends Controller {
|
|||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลเครื่องราชอิสริยาภรณ์นี้");
|
||||
}
|
||||
await this.insigniaRepository.remove(delInsignia);
|
||||
|
||||
const insignia = await this.insigniaRepository.find({
|
||||
select: ["id", "level", "insigniaTypeId"],
|
||||
where: { insigniaTypeId: delInsignia.insigniaTypeId },
|
||||
order: { level: "DESC" },
|
||||
});
|
||||
|
||||
const sortLevel = insignia.map((data, i) => ({
|
||||
id: data.id,
|
||||
level: i + 1,
|
||||
}));
|
||||
await this.insigniaRepository.save(sortLevel);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
|
|
@ -284,7 +304,7 @@ export class InsigniaController extends Controller {
|
|||
}
|
||||
|
||||
const insignia = await this.insigniaRepository.find({
|
||||
select: ["id", "level"],
|
||||
select: ["id", "level", "insigniaTypeId"],
|
||||
where: { insigniaTypeId: insigniaTypeId },
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue