เพิ่มเครื่องราชฯ เพิ่มหน้ากรองลูกจ้างประจำก่อนประมวลผล

This commit is contained in:
kittapath 2025-01-25 01:19:18 +07:00
parent a462f2bddd
commit c60beef7e3
13 changed files with 1745 additions and 1 deletions

View file

@ -18,7 +18,7 @@ import HttpStatus from "../interfaces/http-status";
import HttpError from "../interfaces/http-error";
import { RequestWithUser } from "../middlewares/user";
import { Profile } from "../entities/Profile";
import { Brackets, IsNull, Not } from "typeorm";
import { Brackets, In, IsNull, Not } from "typeorm";
import { OrgRevision } from "../entities/OrgRevision";
import { OrgRoot } from "../entities/OrgRoot";
import { ProfileEmployee } from "../entities/ProfileEmployee";
@ -2353,6 +2353,154 @@ export class OrganizationDotnetController extends Controller {
return new HttpSuccess(mapProfile);
}
/**
* 3. API Get Profile keycloak id
*
* @summary 3. API Get Profile keycloak id
*
* @param {string} keycloakId Id keycloak
*/
@Post("find/employee/position")
async GetProfileByPositionEmpAsync(
@Request() req: RequestWithUser,
@Body()
body: {
empPosId: string[];
},
) {
const findRevision = await this.orgRevisionRepo.findOne({
where: { orgRevisionIsCurrent: true },
});
const profiles = await this.profileEmpRepo.find({
relations: [
"posLevel",
"posType",
"profileSalary",
"profileInsignias",
"profileInsignias.insignia",
"current_holders",
"current_holders.orgRevision",
"current_holders.orgRoot",
"current_holders.orgChild1",
"current_holders.orgChild2",
"current_holders.orgChild3",
"current_holders.orgChild4",
],
where: {
current_holders: {
positions: { id: In(body.empPosId), positionIsSelected: true },
orgRevisionId: findRevision?.id,
},
},
order: {
profileSalary: {
date: "DESC",
},
profileInsignias: {
receiveDate: "DESC",
},
},
});
const mapProfile = profiles.map((profile) => {
const shortName =
profile.current_holders.length == 0
? null
: profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4 !=
null
? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
?.orgChild3 != null
? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
?.orgChild2 != null
? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild2.orgChild2ShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) !=
null &&
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
?.orgChild1 != null
? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild1.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
: profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id) !=
null &&
profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
?.orgRoot != null
? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
: null;
return {
id: profile.id,
avatar: profile.avatar,
avatarName: profile.avatarName,
rank: profile.rank ?? "",
prefix: profile.prefix ?? "",
firstName: profile.firstName ?? "",
lastName: profile.lastName ?? "",
citizenId: profile.citizenId ?? "",
position: profile.position ?? "",
posLevelId: profile.posLevelId,
email: profile.email,
phone: profile.phone,
keycloak: profile.keycloak,
isProbation: profile.isProbation,
isLeave: profile.isLeave,
leaveReason: profile.leaveReason,
dateRetire: profile.dateRetire,
dateAppoint: profile.dateAppoint,
dateRetireLaw: profile.dateRetireLaw,
dateStart: profile.dateStart,
govAgeAbsent: profile.govAgeAbsent,
govAgePlus: profile.govAgePlus,
birthDate: profile.birthDate ?? new Date(),
reasonSameDate: profile.reasonSameDate,
telephoneNumber: profile.telephoneNumber,
nationality: profile.nationality,
gender: profile.gender ?? "",
relationship: profile.relationship ?? "",
religion: profile.religion ?? "",
bloodGroup: profile.bloodGroup ?? "",
registrationAddress: profile.registrationAddress,
registrationProvinceId: profile.registrationProvinceId,
registrationDistrictId: profile.registrationDistrictId,
registrationSubDistrictId: profile.registrationSubDistrictId,
registrationZipCode: profile.registrationZipCode,
currentAddress: profile.currentAddress,
currentProvinceId: profile.currentProvinceId,
currentSubDistrictId: profile.currentSubDistrictId,
currentZipCode: profile.currentZipCode,
// dutyTimeId: profile.dutyTimeId,
// dutyTimeEffectiveDate: profile.dutyTimeEffectiveDate,
posLevel: profile.posLevel?.posLevelName ?? "",
posType: profile.posType?.posTypeName ?? "",
profileSalary: profile.profileSalary,
profileInsignia: profile.profileInsignias.map((x) => {
return { ...x, insignia: x.insignia.name };
}),
amount: profile.amount,
positionSalaryAmount: profile.positionSalaryAmount,
mouthSalaryAmount: profile.mouthSalaryAmount,
profileType: "EMPLOYEE",
root:
profile?.current_holders?.find(
(x) =>
x.orgRevision?.orgRevisionIsDraft == false &&
x.orgRevision?.orgRevisionIsCurrent == true,
)?.orgRoot?.orgRootName ?? null,
rootId:
profile?.current_holders?.find(
(x) =>
x.orgRevision?.orgRevisionIsDraft == false &&
x.orgRevision?.orgRevisionIsCurrent == true,
)?.orgRootId ?? null,
posNo: shortName ?? "",
};
});
return new HttpSuccess(mapProfile);
}
/**
* 7.1 Get GetUserFullName
*

View file

@ -0,0 +1,204 @@
import {
Body,
Controller,
Delete,
Get,
Patch,
Path,
Post,
Request,
Route,
Security,
Tags,
} from "tsoa";
import { AppDataSource } from "../database/data-source";
import { Profile } from "../entities/Profile";
import {
CreateProfileActposition,
ProfileActposition,
UpdateProfileActposition,
} from "../entities/ProfileActposition";
import { ProfileActpositionHistory } from "../entities/ProfileActpositionHistory";
import { RequestWithUser } from "../middlewares/user";
import HttpError from "../interfaces/http-error";
import HttpStatus from "../interfaces/http-status";
import HttpSuccess from "../interfaces/http-success";
import permission from "../interfaces/permission";
import { setLogDataDiff } from "../interfaces/utils";
@Route("api/v1/org/profile/actposition")
@Tags("ProfileActposition")
@Security("bearerAuth")
export class ProfileActpositionController extends Controller {
private profileRepo = AppDataSource.getRepository(Profile);
private profileActpositionRepo = AppDataSource.getRepository(ProfileActposition);
private profileActpositionHistoryRepo = AppDataSource.getRepository(ProfileActpositionHistory);
@Get("user")
public async detailProfileActpositionUser(@Request() request: { user: Record<string, any> }) {
const profile = await this.profileRepo.findOneBy({ keycloak: request.user.sub });
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
const getProfileActpositionId = await this.profileActpositionRepo.find({
where: { profileId: profile.id },
order: { createdAt: "ASC" },
});
if (!getProfileActpositionId) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess(getProfileActpositionId);
}
@Get("{profileId}")
public async detailProfileActposition(
@Path() profileId: string,
@Request() req: RequestWithUser,
) {
let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_OFFICER");
if (_workflow == false)
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
const getProfileActpositionId = await this.profileActpositionRepo.find({
where: { profileId: profileId },
order: { createdAt: "ASC" },
});
if (!getProfileActpositionId) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess(getProfileActpositionId);
}
@Get("admin/history/{actpositionId}")
public async getProfileActpositionAdminHistory(
@Path() actpositionId: string,
@Request() req: RequestWithUser,
) {
const _record = await this.profileActpositionRepo.findOneBy({ id: actpositionId });
if (_record) {
let _workflow = await new permission().Workflow(req, actpositionId, "SYS_REGISTRY_OFFICER");
if (_workflow == false)
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
}
const record = await this.profileActpositionHistoryRepo.find({
where: { profileActpositionId: actpositionId },
order: { createdAt: "DESC" },
});
if (!record) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess(record);
}
@Get("history/{actpositionId}")
public async getProfileActpositionHistory(@Path() actpositionId: string) {
const record = await this.profileActpositionHistoryRepo.find({
where: { profileActpositionId: actpositionId },
order: { createdAt: "DESC" },
});
if (!record) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess(record);
}
@Post()
public async newProfileActposition(
@Request() req: RequestWithUser,
@Body() body: CreateProfileActposition,
) {
if (!body.profileId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
}
const profile = await this.profileRepo.findOneBy({ id: body.profileId });
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id);
const before = null;
const data = new ProfileActposition();
const meta = {
createdUserId: req.user.sub,
createdFullName: req.user.name,
lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
};
Object.assign(data, { ...body, ...meta });
const history = new ProfileActpositionHistory();
Object.assign(history, { ...data, id: undefined });
await this.profileActpositionRepo.save(data, { data: req });
setLogDataDiff(req, { before, after: data });
history.profileActpositionId = data.id;
await this.profileActpositionHistoryRepo.save(history, { data: req });
//setLogDataDiff(req, { before, after: history });
return new HttpSuccess();
}
@Patch("{actpositionId}")
public async editProfileActposition(
@Body() body: UpdateProfileActposition,
@Request() req: RequestWithUser,
@Path() actpositionId: string,
) {
const record = await this.profileActpositionRepo.findOneBy({ id: actpositionId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", record.profileId);
const history = new ProfileActpositionHistory();
const before = structuredClone(record);
// const before_null = null;
Object.assign(record, body);
Object.assign(history, { ...record, id: undefined });
history.profileActpositionId = actpositionId;
record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub;
history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([
this.profileActpositionRepo.save(record, { data: req }),
setLogDataDiff(req, { before, after: record }),
this.profileActpositionHistoryRepo.save(history, { data: req }),
// setLogDataDiff(req, { before: before_null, after: history }),
]);
return new HttpSuccess();
}
@Delete("{actpositionId}")
public async deleteProfileActposition(
@Path() actpositionId: string,
@Request() req: RequestWithUser,
) {
const _record = await this.profileActpositionRepo.findOneBy({ id: actpositionId });
if (_record) {
await new permission().PermissionOrgUserDelete(
req,
"SYS_REGISTRY_OFFICER",
_record.profileId,
);
}
await this.profileActpositionHistoryRepo.delete({
profileActpositionId: actpositionId,
});
const result = await this.profileActpositionRepo.delete({ id: actpositionId });
if (result.affected == undefined || result.affected <= 0)
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
return new HttpSuccess();
}
}

View file

@ -0,0 +1,211 @@
import {
Body,
Controller,
Delete,
Get,
Patch,
Path,
Post,
Request,
Route,
Security,
Tags,
} from "tsoa";
import { AppDataSource } from "../database/data-source";
import {
CreateProfileActpositionEmployee,
ProfileActposition,
UpdateProfileActposition,
} from "../entities/ProfileActposition";
import { ProfileActpositionHistory } from "../entities/ProfileActpositionHistory";
import { RequestWithUser } from "../middlewares/user";
import HttpError from "../interfaces/http-error";
import HttpStatus from "../interfaces/http-status";
import HttpSuccess from "../interfaces/http-success";
import { ProfileEmployee } from "../entities/ProfileEmployee";
import permission from "../interfaces/permission";
import { setLogDataDiff } from "../interfaces/utils";
@Route("api/v1/org/profile-employee/actposition")
@Tags("ProfileActpositionEmployee")
@Security("bearerAuth")
export class ProfileActpositionEmployeeController extends Controller {
private profileEmployeeRepo = AppDataSource.getRepository(ProfileEmployee);
private profileActpositionRepo = AppDataSource.getRepository(ProfileActposition);
private profileActpositionHistoryRepo = AppDataSource.getRepository(ProfileActpositionHistory);
@Get("user")
public async detailProfileActpositionUser(@Request() request: { user: Record<string, any> }) {
const profile = await this.profileEmployeeRepo.findOneBy({ keycloak: request.user.sub });
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
const getProfileActpositionId = await this.profileActpositionRepo.find({
where: { profileEmployeeId: profile.id },
order: { createdAt: "ASC" },
});
if (!getProfileActpositionId) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess(getProfileActpositionId);
}
@Get("{profileEmployeeId}")
public async detailProfileActposition(
@Path() profileEmployeeId: string,
@Request() req: RequestWithUser,
) {
let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_EMP");
if (_workflow == false)
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
const getProfileActpositionId = await this.profileActpositionRepo.find({
where: { profileEmployeeId: profileEmployeeId },
order: { createdAt: "ASC" },
});
if (!getProfileActpositionId) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess(getProfileActpositionId);
}
@Get("admin/history/{actpositionId}")
public async getProfileAdminActpositionHistory(
@Path() actpositionId: string,
@Request() req: RequestWithUser,
) {
const _record = await this.profileActpositionRepo.findOneBy({ id: actpositionId });
if (_record) {
let _workflow = await new permission().Workflow(req, actpositionId, "SYS_REGISTRY_EMP");
if (_workflow == false)
await new permission().PermissionOrgUserGet(
req,
"SYS_REGISTRY_EMP",
_record.profileEmployeeId,
);
}
const record = await this.profileActpositionHistoryRepo.find({
where: { profileActpositionId: actpositionId },
order: { createdAt: "DESC" },
});
if (!record) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess(record);
}
@Get("history/{actpositionId}")
public async getProfileActpositionHistory(@Path() actpositionId: string) {
const record = await this.profileActpositionHistoryRepo.find({
where: { profileActpositionId: actpositionId },
order: { createdAt: "DESC" },
});
if (!record) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess(record);
}
@Post()
public async newProfileActposition(
@Request() req: RequestWithUser,
@Body() body: CreateProfileActpositionEmployee,
) {
if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId");
}
const profile = await this.profileEmployeeRepo.findOneBy({ id: body.profileEmployeeId });
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profile.id);
const before = null;
const data = new ProfileActposition();
const meta = {
createdUserId: req.user.sub,
createdFullName: req.user.name,
lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
};
Object.assign(data, { ...body, ...meta });
const history = new ProfileActpositionHistory();
Object.assign(history, { ...data, id: undefined });
await this.profileActpositionRepo.save(data, { data: req });
setLogDataDiff(req, { before, after: data });
history.profileActpositionId = data.id;
await this.profileActpositionHistoryRepo.save(history, { data: req });
//setLogDataDiff(req, { before, after: history });
return new HttpSuccess();
}
@Patch("{actpositionId}")
public async editProfileActposition(
@Body() body: UpdateProfileActposition,
@Request() req: RequestWithUser,
@Path() actpositionId: string,
) {
const record = await this.profileActpositionRepo.findOneBy({ id: actpositionId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
await new permission().PermissionOrgUserUpdate(
req,
"SYS_REGISTRY_EMP",
record.profileEmployeeId,
);
const before = structuredClone(record);
// const before_null = null;
const history = new ProfileActpositionHistory();
Object.assign(record, body);
Object.assign(history, { ...record, id: undefined });
history.profileActpositionId = actpositionId;
record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub;
history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([
this.profileActpositionRepo.save(record, { data: req }),
setLogDataDiff(req, { before, after: record }),
this.profileActpositionHistoryRepo.save(history, { data: req }),
// setLogDataDiff(req, { before: before_null, after: history }),
]);
return new HttpSuccess();
}
@Delete("{actpositionId}")
public async deleteProfileActposition(
@Path() actpositionId: string,
@Request() req: RequestWithUser,
) {
const _record = await this.profileActpositionRepo.findOneBy({ id: actpositionId });
if (_record) {
await new permission().PermissionOrgUserDelete(
req,
"SYS_REGISTRY_EMP",
_record.profileEmployeeId,
);
}
await this.profileActpositionHistoryRepo.delete({
profileActpositionId: actpositionId,
});
const result = await this.profileActpositionRepo.delete({ id: actpositionId });
if (result.affected == undefined || result.affected <= 0) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess();
}
}

View file

@ -0,0 +1,198 @@
import {
Body,
Controller,
Delete,
Get,
Patch,
Path,
Post,
Request,
Route,
Security,
Tags,
} from "tsoa";
import { AppDataSource } from "../database/data-source";
import {
CreateProfileActpositionEmployee,
ProfileActposition,
UpdateProfileActposition,
} from "../entities/ProfileActposition";
import { ProfileActpositionHistory } from "../entities/ProfileActpositionHistory";
import { RequestWithUser } from "../middlewares/user";
import HttpError from "../interfaces/http-error";
import HttpStatus from "../interfaces/http-status";
import HttpSuccess from "../interfaces/http-success";
import { ProfileEmployee } from "../entities/ProfileEmployee";
import permission from "../interfaces/permission";
import { setLogDataDiff } from "../interfaces/utils";
@Route("api/v1/org/profile-temp/actposition")
@Tags("ProfileActpositionEmployee")
@Security("bearerAuth")
export class ProfileActpositionEmployeeTempController extends Controller {
private profileEmployeeRepo = AppDataSource.getRepository(ProfileEmployee);
private profileActpositionRepo = AppDataSource.getRepository(ProfileActposition);
private profileActpositionHistoryRepo = AppDataSource.getRepository(ProfileActpositionHistory);
@Get("user")
public async detailProfileActpositionUser(@Request() request: { user: Record<string, any> }) {
const profile = await this.profileEmployeeRepo.findOneBy({ keycloak: request.user.sub });
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
const getProfileActpositionId = await this.profileActpositionRepo.find({
where: { profileEmployeeId: profile.id },
order: { createdAt: "ASC" },
});
if (!getProfileActpositionId) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess(getProfileActpositionId);
}
@Get("{profileEmployeeId}")
public async detailProfileActposition(
@Path() profileEmployeeId: string,
@Request() req: RequestWithUser,
) {
let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_TEMP");
if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const getProfileActpositionId = await this.profileActpositionRepo.find({
where: { profileEmployeeId: profileEmployeeId },
order: { createdAt: "ASC" },
});
if (!getProfileActpositionId) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess(getProfileActpositionId);
}
@Get("admin/history/{actpositionId}")
public async getProfileAdminActpositionHistory(
@Path() actpositionId: string,
@Request() req: RequestWithUser,
) {
const _record = await this.profileActpositionRepo.findOneBy({ id: actpositionId });
if (_record) {
let _workflow = await new permission().Workflow(req, actpositionId, "SYS_REGISTRY_TEMP");
if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
}
const record = await this.profileActpositionHistoryRepo.find({
where: { profileActpositionId: actpositionId },
order: { createdAt: "DESC" },
});
if (!record) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess(record);
}
@Get("history/{actpositionId}")
public async getProfileActpositionHistory(@Path() actpositionId: string) {
const record = await this.profileActpositionHistoryRepo.find({
where: { profileActpositionId: actpositionId },
order: { createdAt: "DESC" },
});
if (!record) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess(record);
}
@Post()
public async newProfileActposition(
@Request() req: RequestWithUser,
@Body() body: CreateProfileActpositionEmployee,
) {
if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId");
}
const profile = await this.profileEmployeeRepo.findOneBy({ id: body.profileEmployeeId });
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");
const before = null;
const data = new ProfileActposition();
const meta = {
createdUserId: req.user.sub,
createdFullName: req.user.name,
lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
};
Object.assign(data, { ...body, ...meta });
const history = new ProfileActpositionHistory();
Object.assign(history, { ...data, id: undefined });
await this.profileActpositionRepo.save(data, { data: req });
setLogDataDiff(req, { before, after: data });
history.profileActpositionId = data.id;
await this.profileActpositionHistoryRepo.save(history, { data: req });
//setLogDataDiff(req, { before, after: history });
return new HttpSuccess();
}
@Patch("{actpositionId}")
public async editProfileActposition(
@Body() body: UpdateProfileActposition,
@Request() req: RequestWithUser,
@Path() actpositionId: string,
) {
const record = await this.profileActpositionRepo.findOneBy({ id: actpositionId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");
const before = structuredClone(record);
// const before_null = null;
const history = new ProfileActpositionHistory();
Object.assign(record, body);
Object.assign(history, { ...record, id: undefined });
history.profileActpositionId = actpositionId;
record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub;
history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([
this.profileActpositionRepo.save(record, { data: req }),
setLogDataDiff(req, { before, after: record }),
this.profileActpositionHistoryRepo.save(history, { data: req }),
// setLogDataDiff(req, { before: before_null, after: history }),
]);
return new HttpSuccess();
}
@Delete("{actpositionId}")
public async deleteProfileActposition(
@Path() actpositionId: string,
@Request() req: RequestWithUser,
) {
const _record = await this.profileActpositionRepo.findOneBy({ id: actpositionId });
if (_record) {
await new permission().PermissionDelete(req, "SYS_REGISTRY_TEMP");
}
await this.profileActpositionHistoryRepo.delete({
profileActpositionId: actpositionId,
});
const result = await this.profileActpositionRepo.delete({ id: actpositionId });
if (result.affected == undefined || result.affected <= 0) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess();
}
}

View file

@ -0,0 +1,201 @@
import {
Body,
Controller,
Delete,
Get,
Patch,
Path,
Post,
Request,
Route,
Security,
Tags,
} from "tsoa";
import { AppDataSource } from "../database/data-source";
import { Profile } from "../entities/Profile";
import {
CreateProfileAssistance,
ProfileAssistance,
UpdateProfileAssistance,
} from "../entities/ProfileAssistance";
import { ProfileAssistanceHistory } from "../entities/ProfileAssistanceHistory";
import { RequestWithUser } from "../middlewares/user";
import HttpError from "../interfaces/http-error";
import HttpStatus from "../interfaces/http-status";
import HttpSuccess from "../interfaces/http-success";
import permission from "../interfaces/permission";
import { setLogDataDiff } from "../interfaces/utils";
@Route("api/v1/org/profile/assistance")
@Tags("ProfileAssistance")
@Security("bearerAuth")
export class ProfileAssistanceController extends Controller {
private profileRepo = AppDataSource.getRepository(Profile);
private profileAssistanceRepo = AppDataSource.getRepository(ProfileAssistance);
private profileAssistanceHistoryRepo = AppDataSource.getRepository(ProfileAssistanceHistory);
@Get("user")
public async detailProfileAssistanceUser(@Request() request: { user: Record<string, any> }) {
const profile = await this.profileRepo.findOneBy({ keycloak: request.user.sub });
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
const getProfileAssistanceId = await this.profileAssistanceRepo.find({
where: { profileId: profile.id },
order: { createdAt: "ASC" },
});
if (!getProfileAssistanceId) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess(getProfileAssistanceId);
}
@Get("{profileId}")
public async detailProfileAssistance(@Path() profileId: string, @Request() req: RequestWithUser) {
let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_OFFICER");
if (_workflow == false)
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
const getProfileAssistanceId = await this.profileAssistanceRepo.find({
where: { profileId: profileId },
order: { createdAt: "ASC" },
});
if (!getProfileAssistanceId) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess(getProfileAssistanceId);
}
@Get("admin/history/{assistanceId}")
public async getProfileAssistanceAdminHistory(
@Path() assistanceId: string,
@Request() req: RequestWithUser,
) {
const _record = await this.profileAssistanceRepo.findOneBy({ id: assistanceId });
if (_record) {
let _workflow = await new permission().Workflow(req, assistanceId, "SYS_REGISTRY_OFFICER");
if (_workflow == false)
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
}
const record = await this.profileAssistanceHistoryRepo.find({
where: { profileAssistanceId: assistanceId },
order: { createdAt: "DESC" },
});
if (!record) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess(record);
}
@Get("history/{assistanceId}")
public async getProfileAssistanceHistory(@Path() assistanceId: string) {
const record = await this.profileAssistanceHistoryRepo.find({
where: { profileAssistanceId: assistanceId },
order: { createdAt: "DESC" },
});
if (!record) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess(record);
}
@Post()
public async newProfileAssistance(
@Request() req: RequestWithUser,
@Body() body: CreateProfileAssistance,
) {
if (!body.profileId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
}
const profile = await this.profileRepo.findOneBy({ id: body.profileId });
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id);
const before = null;
const data = new ProfileAssistance();
const meta = {
createdUserId: req.user.sub,
createdFullName: req.user.name,
lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
};
Object.assign(data, { ...body, ...meta });
const history = new ProfileAssistanceHistory();
Object.assign(history, { ...data, id: undefined });
await this.profileAssistanceRepo.save(data, { data: req });
setLogDataDiff(req, { before, after: data });
history.profileAssistanceId = data.id;
await this.profileAssistanceHistoryRepo.save(history, { data: req });
//setLogDataDiff(req, { before, after: history });
return new HttpSuccess();
}
@Patch("{assistanceId}")
public async editProfileAssistance(
@Body() body: UpdateProfileAssistance,
@Request() req: RequestWithUser,
@Path() assistanceId: string,
) {
const record = await this.profileAssistanceRepo.findOneBy({ id: assistanceId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", record.profileId);
const history = new ProfileAssistanceHistory();
const before = structuredClone(record);
// const before_null = null;
Object.assign(record, body);
Object.assign(history, { ...record, id: undefined });
history.profileAssistanceId = assistanceId;
record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub;
history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([
this.profileAssistanceRepo.save(record, { data: req }),
setLogDataDiff(req, { before, after: record }),
this.profileAssistanceHistoryRepo.save(history, { data: req }),
// setLogDataDiff(req, { before: before_null, after: history }),
]);
return new HttpSuccess();
}
@Delete("{assistanceId}")
public async deleteProfileAssistance(
@Path() assistanceId: string,
@Request() req: RequestWithUser,
) {
const _record = await this.profileAssistanceRepo.findOneBy({ id: assistanceId });
if (_record) {
await new permission().PermissionOrgUserDelete(
req,
"SYS_REGISTRY_OFFICER",
_record.profileId,
);
}
await this.profileAssistanceHistoryRepo.delete({
profileAssistanceId: assistanceId,
});
const result = await this.profileAssistanceRepo.delete({ id: assistanceId });
if (result.affected == undefined || result.affected <= 0)
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
return new HttpSuccess();
}
}

View file

@ -0,0 +1,211 @@
import {
Body,
Controller,
Delete,
Get,
Patch,
Path,
Post,
Request,
Route,
Security,
Tags,
} from "tsoa";
import { AppDataSource } from "../database/data-source";
import {
CreateProfileAssistanceEmployee,
ProfileAssistance,
UpdateProfileAssistance,
} from "../entities/ProfileAssistance";
import { ProfileAssistanceHistory } from "../entities/ProfileAssistanceHistory";
import { RequestWithUser } from "../middlewares/user";
import HttpError from "../interfaces/http-error";
import HttpStatus from "../interfaces/http-status";
import HttpSuccess from "../interfaces/http-success";
import { ProfileEmployee } from "../entities/ProfileEmployee";
import permission from "../interfaces/permission";
import { setLogDataDiff } from "../interfaces/utils";
@Route("api/v1/org/profile-employee/assistance")
@Tags("ProfileAssistanceEmployee")
@Security("bearerAuth")
export class ProfileAssistanceEmployeeController extends Controller {
private profileEmployeeRepo = AppDataSource.getRepository(ProfileEmployee);
private profileAssistanceRepo = AppDataSource.getRepository(ProfileAssistance);
private profileAssistanceHistoryRepo = AppDataSource.getRepository(ProfileAssistanceHistory);
@Get("user")
public async detailProfileAssistanceUser(@Request() request: { user: Record<string, any> }) {
const profile = await this.profileEmployeeRepo.findOneBy({ keycloak: request.user.sub });
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
const getProfileAssistanceId = await this.profileAssistanceRepo.find({
where: { profileEmployeeId: profile.id },
order: { createdAt: "ASC" },
});
if (!getProfileAssistanceId) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess(getProfileAssistanceId);
}
@Get("{profileEmployeeId}")
public async detailProfileAssistance(
@Path() profileEmployeeId: string,
@Request() req: RequestWithUser,
) {
let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_EMP");
if (_workflow == false)
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
const getProfileAssistanceId = await this.profileAssistanceRepo.find({
where: { profileEmployeeId: profileEmployeeId },
order: { createdAt: "ASC" },
});
if (!getProfileAssistanceId) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess(getProfileAssistanceId);
}
@Get("admin/history/{assistanceId}")
public async getProfileAdminAssistanceHistory(
@Path() assistanceId: string,
@Request() req: RequestWithUser,
) {
const _record = await this.profileAssistanceRepo.findOneBy({ id: assistanceId });
if (_record) {
let _workflow = await new permission().Workflow(req, assistanceId, "SYS_REGISTRY_EMP");
if (_workflow == false)
await new permission().PermissionOrgUserGet(
req,
"SYS_REGISTRY_EMP",
_record.profileEmployeeId,
);
}
const record = await this.profileAssistanceHistoryRepo.find({
where: { profileAssistanceId: assistanceId },
order: { createdAt: "DESC" },
});
if (!record) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess(record);
}
@Get("history/{assistanceId}")
public async getProfileAssistanceHistory(@Path() assistanceId: string) {
const record = await this.profileAssistanceHistoryRepo.find({
where: { profileAssistanceId: assistanceId },
order: { createdAt: "DESC" },
});
if (!record) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess(record);
}
@Post()
public async newProfileAssistance(
@Request() req: RequestWithUser,
@Body() body: CreateProfileAssistanceEmployee,
) {
if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId");
}
const profile = await this.profileEmployeeRepo.findOneBy({ id: body.profileEmployeeId });
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profile.id);
const before = null;
const data = new ProfileAssistance();
const meta = {
createdUserId: req.user.sub,
createdFullName: req.user.name,
lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
};
Object.assign(data, { ...body, ...meta });
const history = new ProfileAssistanceHistory();
Object.assign(history, { ...data, id: undefined });
await this.profileAssistanceRepo.save(data, { data: req });
setLogDataDiff(req, { before, after: data });
history.profileAssistanceId = data.id;
await this.profileAssistanceHistoryRepo.save(history, { data: req });
//setLogDataDiff(req, { before, after: history });
return new HttpSuccess();
}
@Patch("{assistanceId}")
public async editProfileAssistance(
@Body() body: UpdateProfileAssistance,
@Request() req: RequestWithUser,
@Path() assistanceId: string,
) {
const record = await this.profileAssistanceRepo.findOneBy({ id: assistanceId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
await new permission().PermissionOrgUserUpdate(
req,
"SYS_REGISTRY_EMP",
record.profileEmployeeId,
);
const before = structuredClone(record);
// const before_null = null;
const history = new ProfileAssistanceHistory();
Object.assign(record, body);
Object.assign(history, { ...record, id: undefined });
history.profileAssistanceId = assistanceId;
record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub;
history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([
this.profileAssistanceRepo.save(record, { data: req }),
setLogDataDiff(req, { before, after: record }),
this.profileAssistanceHistoryRepo.save(history, { data: req }),
// setLogDataDiff(req, { before: before_null, after: history }),
]);
return new HttpSuccess();
}
@Delete("{assistanceId}")
public async deleteProfileAssistance(
@Path() assistanceId: string,
@Request() req: RequestWithUser,
) {
const _record = await this.profileAssistanceRepo.findOneBy({ id: assistanceId });
if (_record) {
await new permission().PermissionOrgUserDelete(
req,
"SYS_REGISTRY_EMP",
_record.profileEmployeeId,
);
}
await this.profileAssistanceHistoryRepo.delete({
profileAssistanceId: assistanceId,
});
const result = await this.profileAssistanceRepo.delete({ id: assistanceId });
if (result.affected == undefined || result.affected <= 0) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess();
}
}

View file

@ -0,0 +1,198 @@
import {
Body,
Controller,
Delete,
Get,
Patch,
Path,
Post,
Request,
Route,
Security,
Tags,
} from "tsoa";
import { AppDataSource } from "../database/data-source";
import {
CreateProfileAssistanceEmployee,
ProfileAssistance,
UpdateProfileAssistance,
} from "../entities/ProfileAssistance";
import { ProfileAssistanceHistory } from "../entities/ProfileAssistanceHistory";
import { RequestWithUser } from "../middlewares/user";
import HttpError from "../interfaces/http-error";
import HttpStatus from "../interfaces/http-status";
import HttpSuccess from "../interfaces/http-success";
import { ProfileEmployee } from "../entities/ProfileEmployee";
import permission from "../interfaces/permission";
import { setLogDataDiff } from "../interfaces/utils";
@Route("api/v1/org/profile-temp/assistance")
@Tags("ProfileAssistanceEmployee")
@Security("bearerAuth")
export class ProfileAssistanceEmployeeTempController extends Controller {
private profileEmployeeRepo = AppDataSource.getRepository(ProfileEmployee);
private profileAssistanceRepo = AppDataSource.getRepository(ProfileAssistance);
private profileAssistanceHistoryRepo = AppDataSource.getRepository(ProfileAssistanceHistory);
@Get("user")
public async detailProfileAssistanceUser(@Request() request: { user: Record<string, any> }) {
const profile = await this.profileEmployeeRepo.findOneBy({ keycloak: request.user.sub });
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
const getProfileAssistanceId = await this.profileAssistanceRepo.find({
where: { profileEmployeeId: profile.id },
order: { createdAt: "ASC" },
});
if (!getProfileAssistanceId) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess(getProfileAssistanceId);
}
@Get("{profileEmployeeId}")
public async detailProfileAssistance(
@Path() profileEmployeeId: string,
@Request() req: RequestWithUser,
) {
let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_TEMP");
if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const getProfileAssistanceId = await this.profileAssistanceRepo.find({
where: { profileEmployeeId: profileEmployeeId },
order: { createdAt: "ASC" },
});
if (!getProfileAssistanceId) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess(getProfileAssistanceId);
}
@Get("admin/history/{assistanceId}")
public async getProfileAdminAssistanceHistory(
@Path() assistanceId: string,
@Request() req: RequestWithUser,
) {
const _record = await this.profileAssistanceRepo.findOneBy({ id: assistanceId });
if (_record) {
let _workflow = await new permission().Workflow(req, assistanceId, "SYS_REGISTRY_TEMP");
if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
}
const record = await this.profileAssistanceHistoryRepo.find({
where: { profileAssistanceId: assistanceId },
order: { createdAt: "DESC" },
});
if (!record) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess(record);
}
@Get("history/{assistanceId}")
public async getProfileAssistanceHistory(@Path() assistanceId: string) {
const record = await this.profileAssistanceHistoryRepo.find({
where: { profileAssistanceId: assistanceId },
order: { createdAt: "DESC" },
});
if (!record) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess(record);
}
@Post()
public async newProfileAssistance(
@Request() req: RequestWithUser,
@Body() body: CreateProfileAssistanceEmployee,
) {
if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId");
}
const profile = await this.profileEmployeeRepo.findOneBy({ id: body.profileEmployeeId });
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");
const before = null;
const data = new ProfileAssistance();
const meta = {
createdUserId: req.user.sub,
createdFullName: req.user.name,
lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
};
Object.assign(data, { ...body, ...meta });
const history = new ProfileAssistanceHistory();
Object.assign(history, { ...data, id: undefined });
await this.profileAssistanceRepo.save(data, { data: req });
setLogDataDiff(req, { before, after: data });
history.profileAssistanceId = data.id;
await this.profileAssistanceHistoryRepo.save(history, { data: req });
//setLogDataDiff(req, { before, after: history });
return new HttpSuccess();
}
@Patch("{assistanceId}")
public async editProfileAssistance(
@Body() body: UpdateProfileAssistance,
@Request() req: RequestWithUser,
@Path() assistanceId: string,
) {
const record = await this.profileAssistanceRepo.findOneBy({ id: assistanceId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");
const before = structuredClone(record);
// const before_null = null;
const history = new ProfileAssistanceHistory();
Object.assign(record, body);
Object.assign(history, { ...record, id: undefined });
history.profileAssistanceId = assistanceId;
record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub;
history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([
this.profileAssistanceRepo.save(record, { data: req }),
setLogDataDiff(req, { before, after: record }),
this.profileAssistanceHistoryRepo.save(history, { data: req }),
// setLogDataDiff(req, { before: before_null, after: history }),
]);
return new HttpSuccess();
}
@Delete("{assistanceId}")
public async deleteProfileAssistance(
@Path() assistanceId: string,
@Request() req: RequestWithUser,
) {
const _record = await this.profileAssistanceRepo.findOneBy({ id: assistanceId });
if (_record) {
await new permission().PermissionDelete(req, "SYS_REGISTRY_TEMP");
}
await this.profileAssistanceHistoryRepo.delete({
profileAssistanceId: assistanceId,
});
const result = await this.profileAssistanceRepo.delete({ id: assistanceId });
if (result.affected == undefined || result.affected <= 0) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess();
}
}