diff --git a/src/controllers/ProfileAbilityController.ts b/src/controllers/ProfileAbilityController.ts index bc6fc5a6..523353e5 100644 --- a/src/controllers/ProfileAbilityController.ts +++ b/src/controllers/ProfileAbilityController.ts @@ -66,7 +66,6 @@ export class ProfileAbilityController extends Controller { @Path() abilityId: string, @Request() req: RequestWithUser, ) { - const _record = await this.profileAbilityRepo.findOne({ where: { id: abilityId }, }); diff --git a/src/controllers/ProfileAbilityEmployeeController.ts b/src/controllers/ProfileAbilityEmployeeController.ts index 8963c260..aaa49f16 100644 --- a/src/controllers/ProfileAbilityEmployeeController.ts +++ b/src/controllers/ProfileAbilityEmployeeController.ts @@ -64,8 +64,8 @@ export class ProfileAbilityEmployeeController extends Controller { return new HttpSuccess(getProfileAbilityId); } - @Get("history/{abilityId}") - public async getProfileAbilityHistory( + @Get("admin/history/{abilityId}") + public async getProfileAdminAbilityHistory( @Path() abilityId: string, @Request() req: RequestWithUser, ) { @@ -87,6 +87,20 @@ export class ProfileAbilityEmployeeController extends Controller { return new HttpSuccess(record); } + @Get("history/{abilityId}") + public async getProfileAbilityHistory( + @Path() abilityId: string, + ) { + const record = await this.profileAbilityHistoryRepo.find({ + where: { profileAbilityId: abilityId }, + order: { createdAt: "DESC" }, + }); + if (!record) { + throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); + } + return new HttpSuccess(record); + } + @Post() public async newProfileAbility( @Request() req: RequestWithUser, diff --git a/src/controllers/ProfileAbilityEmployeeTempController.ts b/src/controllers/ProfileAbilityEmployeeTempController.ts index 949eaf90..dc03509f 100644 --- a/src/controllers/ProfileAbilityEmployeeTempController.ts +++ b/src/controllers/ProfileAbilityEmployeeTempController.ts @@ -64,8 +64,8 @@ export class ProfileAbilityEmployeeTempController extends Controller { return new HttpSuccess(getProfileAbilityId); } - @Get("history/{abilityId}") - public async getProfileAbilityHistory( + @Get("admin/history/{abilityId}") + public async getProfileAdminAbilityHistory( @Path() abilityId: string, @Request() req: RequestWithUser, ) { @@ -83,6 +83,20 @@ export class ProfileAbilityEmployeeTempController extends Controller { return new HttpSuccess(record); } + @Get("history/{abilityId}") + public async getProfileAbilityHistory( + @Path() abilityId: string, + ) { + const record = await this.profileAbilityHistoryRepo.find({ + where: { profileAbilityId: abilityId }, + order: { createdAt: "DESC" }, + }); + if (!record) { + throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); + } + return new HttpSuccess(record); + } + @Post() public async newProfileAbility( @Request() req: RequestWithUser,