From 8fd229fa8a931c33bff568089c3b7af0b361c0eb Mon Sep 17 00:00:00 2001 From: JoolsoftAdmin Date: Thu, 17 Oct 2024 10:37:16 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=AD=E0=B8=AD=E0=B8=81=E0=B8=84=E0=B8=B3?= =?UTF-8?q?=E0=B8=AA=E0=B8=B1=E0=B9=88=E0=B8=87=2010?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ReportController.ts | 69 +++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 7514029..d708e8d 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -16,6 +16,7 @@ import { EvaluateCommander } from "../entities/EvaluateCommander" import CallAPI from "../interfaces/call-api" import { Double, In } from "typeorm" import Extension from "../interfaces/extension" +import { Appoint } from "../entities/Appoint" @Route("api/v1/probation/report") @Tags("Report") @@ -30,6 +31,7 @@ export class ReportController extends Controller { private assignDirectorRepository = AppDataSource.getRepository(AssignDirector) private evaluateAchievementRepository = AppDataSource.getRepository(EvaluateAchievement) private evaluateCommanderRepository = AppDataSource.getRepository(EvaluateCommander) + private appointRepository = AppDataSource.getRepository(Appoint) /** * API สำหรับออกรายงาน @@ -1199,4 +1201,71 @@ export class ReportController extends Controller { ) return new HttpSuccess() } + + @Post("command10/officer/report/excecute") + public async command10Excecute( + @Request() request: RequestWithUser, + @Body() + body: { + refIds: { + refId: string + commandAffectDate: Date | null + commandNo: string | null + commandYear: number + templateDoc: string | null + amount: Double | null + positionSalaryAmount: Double | null + mouthSalaryAmount: Double | null + }[] + } + ) { + const lists = await this.appointRepository.find({ + where: { id: In(body.refIds.map(x => x.refId)) }, + }) + await Promise.all( + lists.map(async list => { + list.status = "DONE" + await this.appointRepository.save(list) + }) + ) + return new HttpSuccess() + } + @Post("command10/officer/report") + public async command10( + @Request() req: RequestWithUser, + @Body() + body: { + refIds: string[] + } + ) { + const lists = await this.appointRepository.find({ + where: { id: In(body.refIds) }, + }) + await Promise.all( + lists.map(async list => { + list.status = "PENDING" + await this.appointRepository.save(list) + }) + ) + return new HttpSuccess() + } + @Post("command10/officer/report/delete") + public async command10Delete( + @Request() req: RequestWithUser, + @Body() + body: { + refIds: string[] + } + ) { + const lists = await this.appointRepository.find({ + where: { id: In(body.refIds) }, + }) + await Promise.all( + lists.map(async list => { + list.status = "REPORT" + await this.appointRepository.save(list) + }) + ) + return new HttpSuccess() + } }