diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index 28ff8630..f585d499 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -2884,6 +2884,23 @@ export class OrganizationController extends Controller { return new HttpSuccess(data.map((x) => x.id)); } + /** + * API + * + * @summary + * + */ + @Get("active/root/latest") + async GetActiveRootIdLatest() { + const orgRevisionActive = await this.orgRevisionRepository.findOne({ + where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false }, + }); + if (!orgRevisionActive) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบโครงสร้างที่เผยแพร๋อยู่ตอนนี้"); + } + return new HttpSuccess(orgRevisionActive.id); + } + /** * API หาสำนักทั้งหมด by revision * diff --git a/src/controllers/ProfileDisciplineController.ts b/src/controllers/ProfileDisciplineController.ts index eb28e723..62fc4256 100644 --- a/src/controllers/ProfileDisciplineController.ts +++ b/src/controllers/ProfileDisciplineController.ts @@ -52,7 +52,17 @@ export class ProfileDisciplineController extends Controller { public async getDiscipline(@Path() profileId: string) { const lists = await this.disciplineRepository.find({ where: { profileId: profileId }, - select: ["id", "date", "level", "detail", "unStigma", "refCommandNo", "refCommandDate"], + select: [ + "id", + "date", + "level", + "detail", + "unStigma", + "refCommandNo", + "refCommandDate", + "lastUpdateFullName", + "lastUpdatedAt", + ], }); return new HttpSuccess(lists); } @@ -85,7 +95,17 @@ export class ProfileDisciplineController extends Controller { public async disciplineHistory(@Path() disciplineId: string) { const record = await this.disciplineHistoryRepository.find({ where: { profileDisciplineId: disciplineId }, - select: ["id", "date", "level", "detail", "unStigma", "refCommandNo", "refCommandDate"], + select: [ + "id", + "date", + "level", + "detail", + "unStigma", + "refCommandNo", + "refCommandDate", + "lastUpdateFullName", + "lastUpdatedAt", + ], order: { createdAt: "DESC" }, }); return new HttpSuccess(record); diff --git a/src/controllers/ProfileGovernmentController.ts b/src/controllers/ProfileGovernmentController.ts index 611d8e79..dcfb2f28 100644 --- a/src/controllers/ProfileGovernmentController.ts +++ b/src/controllers/ProfileGovernmentController.ts @@ -188,7 +188,7 @@ export class ProfileGovernmentHistoryController extends Controller { historyData.lastUpdateFullName = req.user.name; historyData.lastUpdateFullName = req.user.name; - await Promise.all([this.profileRepo.save(record)]); + await Promise.all([this.profileRepo.save(record), this.govRepo.save(historyData)]); return new HttpSuccess(); }