diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index 075251b9..ba6c374e 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -18,7 +18,7 @@ import { AppDataSource } from "../database/data-source"; import HttpSuccess from "../interfaces/http-success"; import HttpStatus from "../interfaces/http-status"; import HttpError from "../interfaces/http-error"; -import { Brackets, IsNull, Like, Not } from "typeorm"; +import { Brackets, In, IsNull, Like, Not } from "typeorm"; import { OrgRevision } from "../entities/OrgRevision"; import { calculateRetireDate, calculateRetireLaw } from "../interfaces/utils"; import { EmployeePosMaster } from "../entities/EmployeePosMaster"; @@ -557,10 +557,10 @@ export class ProfileEmployeeController extends Controller { const exists = !!body.citizenId && (await this.profileRepo.findOne({ - where: { - id: Not(id), - citizenId: body.citizenId, - employeeClass: String(body.employeeClass) + where: { + id: Not(id), + citizenId: body.citizenId, + employeeClass: String(body.employeeClass), }, })); @@ -690,12 +690,12 @@ export class ProfileEmployeeController extends Controller { : _data.current_holders[0].orgRoot != null ? `${_data.current_holders[0].orgRoot.orgRootShortName}${_data.current_holders[0].posMasterNo}` : null; - const dateEmployment = + const dateEmployment = _data.profileEmployeeEmployment.length == 0 ? null : _data.profileEmployeeEmployment.reduce((latest, current) => { - return (latest.date > current.date) ? latest : current; - }).date; + return latest.date > current.date ? latest : current; + }).date; return { id: _data.id, prefix: _data.prefix, @@ -933,12 +933,12 @@ export class ProfileEmployeeController extends Controller { : _data.current_holders[0].orgRoot != null ? `${_data.current_holders[0].orgRoot.orgRootShortName}${_data.current_holders[0].posMasterNo}` : null; - const dateEmployment = + const dateEmployment = _data.profileEmployeeEmployment.length == 0 ? null : _data.profileEmployeeEmployment.reduce((latest, current) => { - return (latest.date > current.date) ? latest : current; - }).date; + return latest.date > current.date ? latest : current; + }).date; return { id: _data.id, prefix: _data.prefix, @@ -2569,33 +2569,33 @@ export class ProfileEmployeeController extends Controller { /** * API ข้อมูลลูกจ้างชั่วคราว * - * @summary ข้อมูลลูกจ้างชั่วคราว (ADMIN) + * @summary ข้อมูลลูกจ้างชั่วคราว (ADMIN) * * @param {string} profileEmployeeId profileEmployeeId ทะเบียนประวัติลูกจ้างชั่วคราว */ @Get("information/{profileEmployeeId}") async getInformationById(@Path() profileEmployeeId: string) { const profileInformation = await this.profileRepo.findOne({ - where: { id: profileEmployeeId } + where: { id: profileEmployeeId }, }); if (!profileInformation) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); const mapData = { - id: profileInformation.id, - positionEmployeeGroupId: profileInformation.positionEmployeeGroupId, - positionEmployeeLineId: profileInformation.positionEmployeeLineId, - positionEmployeePositionId: profileInformation.positionEmployeePositionId, - employeeOc: profileInformation.employeeOc, - employeeTypeIndividual: profileInformation.employeeTypeIndividual, - employeeWage: profileInformation.employeeWage, - employeeMoneyIncrease: profileInformation.employeeMoneyIncrease, - employeeMoneyAllowance: profileInformation.employeeMoneyAllowance, - employeeMoneyEmployee: profileInformation.employeeMoneyEmployee, - employeeMoneyEmployer: profileInformation.employeeMoneyEmployer, + id: profileInformation.id, + positionEmployeeGroupId: profileInformation.positionEmployeeGroupId, + positionEmployeeLineId: profileInformation.positionEmployeeLineId, + positionEmployeePositionId: profileInformation.positionEmployeePositionId, + employeeOc: profileInformation.employeeOc, + employeeTypeIndividual: profileInformation.employeeTypeIndividual, + employeeWage: profileInformation.employeeWage, + employeeMoneyIncrease: profileInformation.employeeMoneyIncrease, + employeeMoneyAllowance: profileInformation.employeeMoneyAllowance, + employeeMoneyEmployee: profileInformation.employeeMoneyEmployee, + employeeMoneyEmployer: profileInformation.employeeMoneyEmployer, }; return new HttpSuccess(mapData); } - + /** * API ประวัติการแก้ไขข้อมูลลูกจ้างชั่วคราว * @@ -2781,4 +2781,28 @@ export class ProfileEmployeeController extends Controller { return new HttpSuccess(); } + + /** + * API ออกคำสั่งลูกจ้าง + * + * @summary ORG_038 - ออกคำสั่งลูกจ้าง (ADMIN) # + * + */ + @Post("report") + async sendReport(@Request() request: RequestWithUser, @Body() requestBody: { id: string[] }) { + const profiles = await this.profileRepo.find({ where: { id: In(requestBody.id) } }); + + const _profiles = await Promise.all( + profiles.map(async (item: any) => { + return { + ...item, + statusTemp: "REPORT", + lastUpdateUserId: request.user.sub, + lastUpdateFullName: request.user.name, + }; + }), + ); + await this.profileRepo.save(_profiles); + return new HttpSuccess(); + } }