diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index 5ad7c11c..83b407a6 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -7915,4 +7915,31 @@ export class OrganizationController extends Controller { return new HttpSuccess(); } + + /** + * API ลบคนในโครงสร้าง + * + * @summary - ลบคนในโครงสร้าง (ADMIN) + * + */ + @Get("delete/profile/org/{orgRevisionId}") + async deleteRetireInOrg(@Path() orgRevisionId: string, @Request() request: RequestWithUser) { + const posMasters = await this.posMasterRepository.find({ + where: { + orgRevisionId: orgRevisionId, + current_holder: { + isLeave: true, + }, + }, + }); + + await Promise.all( + posMasters.map(async (posMaster) => { + posMaster.current_holderId = null; + await this.posMasterRepository.save(posMaster); + }), + ); + + return new HttpSuccess(); + } }