ออกคำสั่งลูกจ้างชั่วคราว

This commit is contained in:
Kittapath 2024-06-12 12:52:12 +07:00
parent 576f83d12f
commit f1cdec9076

View file

@ -18,7 +18,7 @@ import { AppDataSource } from "../database/data-source";
import HttpSuccess from "../interfaces/http-success"; import HttpSuccess from "../interfaces/http-success";
import HttpStatus from "../interfaces/http-status"; import HttpStatus from "../interfaces/http-status";
import HttpError from "../interfaces/http-error"; 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 { OrgRevision } from "../entities/OrgRevision";
import { calculateRetireDate, calculateRetireLaw } from "../interfaces/utils"; import { calculateRetireDate, calculateRetireLaw } from "../interfaces/utils";
import { EmployeePosMaster } from "../entities/EmployeePosMaster"; import { EmployeePosMaster } from "../entities/EmployeePosMaster";
@ -560,7 +560,7 @@ export class ProfileEmployeeController extends Controller {
where: { where: {
id: Not(id), id: Not(id),
citizenId: body.citizenId, citizenId: body.citizenId,
employeeClass: String(body.employeeClass) employeeClass: String(body.employeeClass),
}, },
})); }));
@ -694,7 +694,7 @@ export class ProfileEmployeeController extends Controller {
_data.profileEmployeeEmployment.length == 0 _data.profileEmployeeEmployment.length == 0
? null ? null
: _data.profileEmployeeEmployment.reduce((latest, current) => { : _data.profileEmployeeEmployment.reduce((latest, current) => {
return (latest.date > current.date) ? latest : current; return latest.date > current.date ? latest : current;
}).date; }).date;
return { return {
id: _data.id, id: _data.id,
@ -937,7 +937,7 @@ export class ProfileEmployeeController extends Controller {
_data.profileEmployeeEmployment.length == 0 _data.profileEmployeeEmployment.length == 0
? null ? null
: _data.profileEmployeeEmployment.reduce((latest, current) => { : _data.profileEmployeeEmployment.reduce((latest, current) => {
return (latest.date > current.date) ? latest : current; return latest.date > current.date ? latest : current;
}).date; }).date;
return { return {
id: _data.id, id: _data.id,
@ -2576,7 +2576,7 @@ export class ProfileEmployeeController extends Controller {
@Get("information/{profileEmployeeId}") @Get("information/{profileEmployeeId}")
async getInformationById(@Path() profileEmployeeId: string) { async getInformationById(@Path() profileEmployeeId: string) {
const profileInformation = await this.profileRepo.findOne({ const profileInformation = await this.profileRepo.findOne({
where: { id: profileEmployeeId } where: { id: profileEmployeeId },
}); });
if (!profileInformation) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!profileInformation) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -2781,4 +2781,28 @@ export class ProfileEmployeeController extends Controller {
return new HttpSuccess(); 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();
}
} }