diff --git a/src/controllers/InsigniaController.ts b/src/controllers/InsigniaController.ts index 84d97877..25e428b2 100644 --- a/src/controllers/InsigniaController.ts +++ b/src/controllers/InsigniaController.ts @@ -194,6 +194,7 @@ export class InsigniaController extends Controller { "lastUpdateFullName", "isActive", "note", + "insigniaTypeId", ], order: { level: "ASC" }, }); @@ -202,7 +203,7 @@ export class InsigniaController extends Controller { id: item.id, name: item.name, shortName: item.shortName, - insigniaTypeId: item.insigniaTypeId, + insigniaTypeId: item.insigniaTypeId??null, insigniaTypeName: item.insigniaType == null ? null : item.insigniaType.name, //ลำดับชั้นเครื่องราช createdAt: item.createdAt, lastUpdatedAt: item.lastUpdatedAt, diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index 4ac23db0..7ad0b1d8 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -619,12 +619,12 @@ export class ProfileEmployeeController extends Controller { */ @Delete("{id}") async deleteProfile(@Path() id: string) { - const result = await this.profileRepo.delete({ id }); - - if (result.affected == undefined || result.affected <= 0) { - throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); - } - + const result = await this.profileRepo.findOne({ where: { id: id } }); + if (!result) { + throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); + } + await this.informationHistoryRepository.delete({profileEmployeeId: id}); + await this.profileRepo.remove(result); return new HttpSuccess(); }