แก้ วันที่ update

This commit is contained in:
kittapath 2024-08-30 18:02:34 +07:00
parent 6d36c9b05f
commit 218886b3f4
83 changed files with 1671 additions and 3483 deletions

View file

@ -68,6 +68,8 @@ export class AuthRoleAttrController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -101,7 +103,9 @@ export class AuthRoleAttrController extends Controller {
body.authSysId = body.authSysId?.toUpperCase(); body.authSysId = body.authSysId?.toUpperCase();
Object.assign(record, body); Object.assign(record, body);
record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
await Promise.all([this.authRoleAttrRepo.save(record)]); await Promise.all([this.authRoleAttrRepo.save(record)]);

View file

@ -71,6 +71,8 @@ export class AuthRoleController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -100,6 +102,7 @@ export class AuthRoleController extends Controller {
posMaster.lastUpdateUserId = req.user.sub; posMaster.lastUpdateUserId = req.user.sub;
posMaster.lastUpdateFullName = req.user.name; posMaster.lastUpdateFullName = req.user.name;
posMaster.lastUpdatedAt = new Date();
posMaster.authRoleId = body.authRoleId; posMaster.authRoleId = body.authRoleId;
await this.posMasterRepository.save(posMaster); await this.posMasterRepository.save(posMaster);
@ -142,6 +145,7 @@ export class AuthRoleController extends Controller {
posMaster.lastUpdateUserId = req.user.sub; posMaster.lastUpdateUserId = req.user.sub;
posMaster.lastUpdateFullName = req.user.name; posMaster.lastUpdateFullName = req.user.name;
posMaster.lastUpdatedAt = new Date();
posMaster.authRoleId = body.authRoleId; posMaster.authRoleId = body.authRoleId;
await this.employeePosMasterRepository.save(posMaster); await this.employeePosMasterRepository.save(posMaster);
return new HttpSuccess(); return new HttpSuccess();
@ -184,6 +188,8 @@ export class AuthRoleController extends Controller {
roleName: body.roleName, roleName: body.roleName,
roleDescription: body.roleDescription, roleDescription: body.roleDescription,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}); });
} }
const roleAttrData = await this.authRoleAttrRepo.find({ const roleAttrData = await this.authRoleAttrRepo.find({
@ -207,7 +213,9 @@ export class AuthRoleController extends Controller {
// createdUserId: req.user.sub, // createdUserId: req.user.sub,
// createdFullName: req.user.name, // createdFullName: req.user.name,
// lastUpdateUserId: req.user.sub, // lastUpdateUserId: req.user.sub,
// lastUpdateFullName: req.user.name, // lastUpdateFullName: req.user.name,
// createdAt: new Date(),
// lastUpdatedAt: new Date(),
// }); // });
// return newAttr; // return newAttr;
// }); // });
@ -228,6 +236,8 @@ export class AuthRoleController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}); });
return newAttr; return newAttr;
}); });

View file

@ -71,6 +71,8 @@ export class AuthSysController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -92,7 +94,9 @@ export class AuthSysController extends Controller {
body.id = body.id?.toUpperCase(); body.id = body.id?.toUpperCase();
Object.assign(record, body); Object.assign(record, body);
record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
await Promise.all([this.authSysRepo.save(record)]); await Promise.all([this.authSysRepo.save(record)]);

View file

@ -53,8 +53,10 @@ export class BloodGroupController extends Controller {
const bloodGroup = Object.assign(new BloodGroup(), requestBody); const bloodGroup = Object.assign(new BloodGroup(), requestBody);
bloodGroup.createdUserId = request.user.sub; bloodGroup.createdUserId = request.user.sub;
bloodGroup.createdFullName = request.user.name; bloodGroup.createdFullName = request.user.name;
bloodGroup.createdAt = new Date();
bloodGroup.lastUpdateUserId = request.user.sub; bloodGroup.lastUpdateUserId = request.user.sub;
bloodGroup.lastUpdateFullName = request.user.name; bloodGroup.lastUpdateFullName = request.user.name;
bloodGroup.lastUpdatedAt = new Date();
await this.bloodGroupRepository.save(bloodGroup); await this.bloodGroupRepository.save(bloodGroup);
return new HttpSuccess(); return new HttpSuccess();
} }
@ -88,6 +90,7 @@ export class BloodGroupController extends Controller {
bloodGroup.lastUpdateUserId = request.user.sub; bloodGroup.lastUpdateUserId = request.user.sub;
bloodGroup.lastUpdateFullName = request.user.name; bloodGroup.lastUpdateFullName = request.user.name;
bloodGroup.lastUpdatedAt = new Date();
this.bloodGroupRepository.merge(bloodGroup, requestBody); this.bloodGroupRepository.merge(bloodGroup, requestBody);
await this.bloodGroupRepository.save(bloodGroup); await this.bloodGroupRepository.save(bloodGroup);
return new HttpSuccess(); return new HttpSuccess();

View file

@ -77,12 +77,14 @@ export class ChangePositionController extends Controller {
const changePosition = new ChangePosition(); const changePosition = new ChangePosition();
Object.assign(changePosition, body); Object.assign(changePosition, body);
(changePosition.date = new Date()), changePosition.date = new Date();
(changePosition.status = "WAITTING"), changePosition.status = "WAITTING";
(changePosition.createdUserId = request.user.sub); changePosition.createdUserId = request.user.sub;
changePosition.createdFullName = request.user.name; changePosition.createdFullName = request.user.name;
changePosition.createdAt = new Date();
changePosition.lastUpdateUserId = request.user.sub; changePosition.lastUpdateUserId = request.user.sub;
changePosition.lastUpdateFullName = request.user.name; changePosition.lastUpdateFullName = request.user.name;
changePosition.lastUpdatedAt = new Date();
await this.changePositionRepository.save(changePosition); await this.changePositionRepository.save(changePosition);
return new HttpSuccess(); return new HttpSuccess();
} }
@ -143,6 +145,7 @@ export class ChangePositionController extends Controller {
Object.assign(changePosition, body); Object.assign(changePosition, body);
changePosition.lastUpdateUserId = request.user.sub; changePosition.lastUpdateUserId = request.user.sub;
changePosition.lastUpdateFullName = request.user.name; changePosition.lastUpdateFullName = request.user.name;
changePosition.lastUpdatedAt = new Date();
await this.changePositionRepository.save(changePosition); await this.changePositionRepository.save(changePosition);
return new HttpSuccess(); return new HttpSuccess();
} }
@ -236,12 +239,14 @@ export class ChangePositionController extends Controller {
let positionOld = data.positionOld ? `${data.positionOld}` : ""; let positionOld = data.positionOld ? `${data.positionOld}` : "";
let rootOld = data.rootOld ? (data.positionOld ? `/${data.rootOld}` : `${data.rootOld}`) : ""; let rootOld = data.rootOld ? (data.positionOld ? `/${data.rootOld}` : `${data.rootOld}`) : "";
profiles.changePositionId = changePositionId; profiles.changePositionId = changePositionId;
(profiles.organizationPositionOld = `${positionOld}${rootOld}`), profiles.organizationPositionOld = `${positionOld}${rootOld}`;
(profiles.status = "WAITTING"), profiles.status = "WAITTING";
(profiles.createdUserId = request.user.sub); profiles.createdUserId = request.user.sub;
profiles.createdFullName = request.user.name; profiles.createdFullName = request.user.name;
profiles.createdAt = new Date();
profiles.lastUpdateUserId = request.user.sub; profiles.lastUpdateUserId = request.user.sub;
profiles.lastUpdateFullName = request.user.name; profiles.lastUpdateFullName = request.user.name;
profiles.lastUpdatedAt = new Date();
profileChangePositions.push(profiles); profileChangePositions.push(profiles);
} }
await this.profileChangePositionRepository.save(profileChangePositions); await this.profileChangePositionRepository.save(profileChangePositions);
@ -391,6 +396,7 @@ export class ChangePositionController extends Controller {
profileChangePos.lastUpdateUserId = request.user.sub; profileChangePos.lastUpdateUserId = request.user.sub;
profileChangePos.lastUpdateFullName = request.user.name; profileChangePos.lastUpdateFullName = request.user.name;
profileChangePos.lastUpdatedAt = new Date();
profileChangePos.educationOld = body.educationOld; profileChangePos.educationOld = body.educationOld;
profileChangePos.posMasterNoOld = body.posMasterNoOld; profileChangePos.posMasterNoOld = body.posMasterNoOld;
profileChangePos.positionTypeOld = body.positionTypeOld; profileChangePos.positionTypeOld = body.positionTypeOld;
@ -512,6 +518,7 @@ export class ChangePositionController extends Controller {
profileChangePos.lastUpdateUserId = request.user.sub; profileChangePos.lastUpdateUserId = request.user.sub;
profileChangePos.lastUpdateFullName = request.user.name; profileChangePos.lastUpdateFullName = request.user.name;
profileChangePos.lastUpdatedAt = new Date();
profileChangePos.node = body.node; profileChangePos.node = body.node;
profileChangePos.nodeId = body.nodeId; profileChangePos.nodeId = body.nodeId;
profileChangePos.orgRevisionId = body.orgRevisionId; profileChangePos.orgRevisionId = body.orgRevisionId;
@ -546,11 +553,13 @@ export class ChangePositionController extends Controller {
item.status = "REPORT"; item.status = "REPORT";
item.lastUpdateUserId = request.user.sub; item.lastUpdateUserId = request.user.sub;
item.lastUpdateFullName = request.user.name; item.lastUpdateFullName = request.user.name;
item.lastUpdatedAt = new Date();
if (item.profileChangePosition) { if (item.profileChangePosition) {
for (const profile of item.profileChangePosition) { for (const profile of item.profileChangePosition) {
profile.status = "REPORT"; profile.status = "REPORT";
profile.lastUpdateUserId = request.user.sub; profile.lastUpdateUserId = request.user.sub;
profile.lastUpdateFullName = request.user.name; profile.lastUpdateFullName = request.user.name;
profile.lastUpdatedAt = new Date();
await this.profileChangePositionRepository.save(profile); await this.profileChangePositionRepository.save(profile);
} }
} }

View file

@ -103,8 +103,10 @@ export class DistrictController extends Controller {
_district.createdUserId = request.user.sub; _district.createdUserId = request.user.sub;
_district.createdFullName = request.user.name; _district.createdFullName = request.user.name;
_district.createdAt = new Date();
_district.lastUpdateUserId = request.user.sub; _district.lastUpdateUserId = request.user.sub;
_district.lastUpdateFullName = request.user.name; _district.lastUpdateFullName = request.user.name;
_district.lastUpdatedAt = new Date();
await this.districtRepository.save(_district); await this.districtRepository.save(_district);
return new HttpSuccess(); return new HttpSuccess();
} }
@ -144,6 +146,7 @@ export class DistrictController extends Controller {
_district.lastUpdateUserId = request.user.sub; _district.lastUpdateUserId = request.user.sub;
_district.lastUpdateFullName = request.user.name; _district.lastUpdateFullName = request.user.name;
_district.lastUpdatedAt = new Date();
this.districtRepository.merge(_district, requestBody); this.districtRepository.merge(_district, requestBody);
await this.districtRepository.save(_district); await this.districtRepository.save(_district);
return new HttpSuccess(); return new HttpSuccess();

View file

@ -53,8 +53,10 @@ export class EducationLevelController extends Controller {
const educationLevel = Object.assign(new EducationLevel(), requestBody); const educationLevel = Object.assign(new EducationLevel(), requestBody);
educationLevel.createdUserId = request.user.sub; educationLevel.createdUserId = request.user.sub;
educationLevel.createdFullName = request.user.name; educationLevel.createdFullName = request.user.name;
educationLevel.createdAt = new Date();
educationLevel.lastUpdateUserId = request.user.sub; educationLevel.lastUpdateUserId = request.user.sub;
educationLevel.lastUpdateFullName = request.user.name; educationLevel.lastUpdateFullName = request.user.name;
educationLevel.lastUpdatedAt = new Date();
await this.educationLevelRepository.save(educationLevel); await this.educationLevelRepository.save(educationLevel);
return new HttpSuccess(); return new HttpSuccess();
} }
@ -88,6 +90,7 @@ export class EducationLevelController extends Controller {
educationLevel.lastUpdateUserId = request.user.sub; educationLevel.lastUpdateUserId = request.user.sub;
educationLevel.lastUpdateFullName = request.user.name; educationLevel.lastUpdateFullName = request.user.name;
educationLevel.lastUpdatedAt = new Date();
this.educationLevelRepository.merge(educationLevel, requestBody); this.educationLevelRepository.merge(educationLevel, requestBody);
await this.educationLevelRepository.save(educationLevel); await this.educationLevelRepository.save(educationLevel);
return new HttpSuccess(); return new HttpSuccess();

View file

@ -107,8 +107,10 @@ export class EmployeePositionController extends Controller {
empPosDict.createdUserId = request.user.sub; empPosDict.createdUserId = request.user.sub;
empPosDict.createdFullName = request.user.name; empPosDict.createdFullName = request.user.name;
empPosDict.createdAt = new Date();
empPosDict.lastUpdateUserId = request.user.sub; empPosDict.lastUpdateUserId = request.user.sub;
empPosDict.lastUpdateFullName = request.user.name; empPosDict.lastUpdateFullName = request.user.name;
empPosDict.lastUpdatedAt = new Date();
await this.employeePosDictRepository.save(empPosDict); await this.employeePosDictRepository.save(empPosDict);
return new HttpSuccess(empPosDict.id); return new HttpSuccess(empPosDict.id);
} }
@ -162,6 +164,7 @@ export class EmployeePositionController extends Controller {
empPosDict.lastUpdateUserId = request.user.sub; empPosDict.lastUpdateUserId = request.user.sub;
empPosDict.lastUpdateFullName = request.user.name; empPosDict.lastUpdateFullName = request.user.name;
empPosDict.lastUpdatedAt = new Date();
this.employeePosDictRepository.merge(empPosDict, requestBody); this.employeePosDictRepository.merge(empPosDict, requestBody);
await this.employeePosDictRepository.save(empPosDict); await this.employeePosDictRepository.save(empPosDict);
return new HttpSuccess(empPosDict.id); return new HttpSuccess(empPosDict.id);
@ -582,8 +585,10 @@ export class EmployeePositionController extends Controller {
posMaster.createdUserId = request.user.sub; posMaster.createdUserId = request.user.sub;
posMaster.createdFullName = request.user.name; posMaster.createdFullName = request.user.name;
posMaster.createdAt = new Date();
posMaster.lastUpdateUserId = request.user.sub; posMaster.lastUpdateUserId = request.user.sub;
posMaster.lastUpdateFullName = request.user.name; posMaster.lastUpdateFullName = request.user.name;
posMaster.lastUpdatedAt = new Date();
await this.employeePosMasterRepository.save(posMaster); await this.employeePosMasterRepository.save(posMaster);
await Promise.all( await Promise.all(
requestBody.positions.map(async (x: any) => { requestBody.positions.map(async (x: any) => {
@ -595,8 +600,10 @@ export class EmployeePositionController extends Controller {
position.posMasterId = posMaster.id; position.posMasterId = posMaster.id;
position.createdUserId = request.user.sub; position.createdUserId = request.user.sub;
position.createdFullName = request.user.name; position.createdFullName = request.user.name;
position.createdAt = new Date();
position.lastUpdateUserId = request.user.sub; position.lastUpdateUserId = request.user.sub;
position.lastUpdateFullName = request.user.name; position.lastUpdateFullName = request.user.name;
position.lastUpdatedAt = new Date();
await this.employeePositionRepository.save(position); await this.employeePositionRepository.save(position);
}), }),
); );
@ -787,8 +794,10 @@ export class EmployeePositionController extends Controller {
posMaster.createdUserId = request.user.sub; //สงสัยว่าทำให้ bug แก้ไขไม่ได้ posMaster.createdUserId = request.user.sub; //สงสัยว่าทำให้ bug แก้ไขไม่ได้
posMaster.createdFullName = request.user.name; posMaster.createdFullName = request.user.name;
posMaster.createdAt = new Date();
posMaster.lastUpdateUserId = request.user.sub; posMaster.lastUpdateUserId = request.user.sub;
posMaster.lastUpdateFullName = request.user.name; posMaster.lastUpdateFullName = request.user.name;
posMaster.lastUpdatedAt = new Date();
await this.employeePosMasterRepository.save(posMaster); await this.employeePosMasterRepository.save(posMaster);
await this.employeePositionRepository.delete({ posMasterId: posMaster.id }); await this.employeePositionRepository.delete({ posMasterId: posMaster.id });
@ -802,8 +811,10 @@ export class EmployeePositionController extends Controller {
position.posMasterId = posMaster.id; position.posMasterId = posMaster.id;
position.createdUserId = request.user.sub; position.createdUserId = request.user.sub;
position.createdFullName = request.user.name; position.createdFullName = request.user.name;
position.createdAt = new Date();
position.lastUpdateUserId = request.user.sub; position.lastUpdateUserId = request.user.sub;
position.lastUpdateFullName = request.user.name; position.lastUpdateFullName = request.user.name;
position.lastUpdatedAt = new Date();
await this.employeePositionRepository.save(position); await this.employeePositionRepository.save(position);
}), }),
); );
@ -1186,7 +1197,10 @@ export class EmployeePositionController extends Controller {
* *
*/ */
@Post("sort") @Post("sort")
async SortEmp(@Body() requestBody: { id: string; type: number; sortId: string[] }, @Request() request: RequestWithUser) { async SortEmp(
@Body() requestBody: { id: string; type: number; sortId: string[] },
@Request() request: RequestWithUser,
) {
await new permission().PermissionUpdate(request, "SYS_ORG_EMP"); await new permission().PermissionUpdate(request, "SYS_ORG_EMP");
switch (requestBody.type) { switch (requestBody.type) {
case 0: { case 0: {
@ -1614,8 +1628,10 @@ export class EmployeePositionController extends Controller {
posMaster.posMasterOrder = maxPosMasterOrder += 1; posMaster.posMasterOrder = maxPosMasterOrder += 1;
posMaster.createdUserId = request.user.sub; posMaster.createdUserId = request.user.sub;
posMaster.createdFullName = request.user.name; posMaster.createdFullName = request.user.name;
posMaster.createdAt = new Date();
posMaster.lastUpdateUserId = request.user.sub; posMaster.lastUpdateUserId = request.user.sub;
posMaster.lastUpdateFullName = request.user.name; posMaster.lastUpdateFullName = request.user.name;
posMaster.lastUpdatedAt = new Date();
await this.employeePosMasterRepository.save(posMaster); await this.employeePosMasterRepository.save(posMaster);
} }
}), }),
@ -2078,7 +2094,7 @@ export class EmployeePositionController extends Controller {
@Post("profile") @Post("profile")
async createEmpHolder( async createEmpHolder(
@Body() requestBody: { posMaster: string; position: string; profileId: string; isSit: boolean }, @Body() requestBody: { posMaster: string; position: string; profileId: string; isSit: boolean },
@Request() request: RequestWithUser @Request() request: RequestWithUser,
) { ) {
await new permission().PermissionCreate(request, "SYS_ORG_EMP"); await new permission().PermissionCreate(request, "SYS_ORG_EMP");
const dataMaster = await this.employeePosMasterRepository.findOne({ const dataMaster = await this.employeePosMasterRepository.findOne({
@ -2144,7 +2160,10 @@ export class EmployeePositionController extends Controller {
* *
*/ */
@Post("dna") @Post("dna")
async dnaEmp(@Body() requestBody: { draftPositionId: string; publishPositionId: string }, @Request() request: RequestWithUser) { async dnaEmp(
@Body() requestBody: { draftPositionId: string; publishPositionId: string },
@Request() request: RequestWithUser,
) {
await new permission().PermissionDelete(request, "SYS_ORG_EMP"); await new permission().PermissionDelete(request, "SYS_ORG_EMP");
const findDraft = await this.orgRevisionRepository.findOne({ const findDraft = await this.orgRevisionRepository.findOne({
where: { where: {

View file

@ -3443,6 +3443,20 @@ export class OrganizationController extends Controller {
"orgChild1s.orgChild2s.orgChild3s", "orgChild1s.orgChild2s.orgChild3s",
"orgChild1s.orgChild2s.orgChild3s.orgChild4s", "orgChild1s.orgChild2s.orgChild3s.orgChild4s",
], ],
order: {
orgChild1s: {
orgChild1Order: "ASC",
orgChild2s: {
orgChild2Order: "ASC",
orgChild3s: {
orgChild3Order: "ASC",
orgChild4s: {
orgChild4Order: "ASC",
},
},
},
},
},
}); });
return new HttpSuccess(data); return new HttpSuccess(data);
} }

View file

@ -874,6 +874,8 @@ export class OrganizationDotnetController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });

View file

@ -2,7 +2,6 @@ import {
Body, Body,
Controller, Controller,
Delete, Delete,
Example,
Get, Get,
Patch, Patch,
Path, Path,
@ -41,6 +40,7 @@ export class ProfileAbilityController extends Controller {
} }
const getProfileAbilityId = await this.profileAbilityRepo.find({ const getProfileAbilityId = await this.profileAbilityRepo.find({
where: { profileId: profile.id }, where: { profileId: profile.id },
order: { createdAt: "ASC" },
}); });
if (!getProfileAbilityId) { if (!getProfileAbilityId) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -49,31 +49,12 @@ export class ProfileAbilityController extends Controller {
} }
@Get("{profileId}") @Get("{profileId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "ad7d0955-7bcd-4ed0-911c-2edceba12579",
createdAt: "2024-03-12T21:37:35.037Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T21:37:35.037Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "test bar",
lastUpdateFullName: "test bar",
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
remark: "ต้องส่งให้ทันก่อนวันที่ 15 มีนาคม",
detail: "-",
reference: "-",
dateStart: "2024-03-13T04:36:06.000Z",
dateEnd: "2024-03-13T04:36:06.000Z",
field: "ความมั่นคง",
},
],
})
public async detailProfileAbility(@Path() profileId: string, @Request() req: RequestWithUser) { public async detailProfileAbility(@Path() profileId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
const getProfileAbilityId = await this.profileAbilityRepo.findBy({ profileId }); const getProfileAbilityId = await this.profileAbilityRepo.find({
where: { profileId: profileId },
order: { createdAt: "ASC" },
});
if (!getProfileAbilityId) { if (!getProfileAbilityId) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
} }
@ -81,44 +62,6 @@ export class ProfileAbilityController extends Controller {
} }
@Get("history/{abilityId}") @Get("history/{abilityId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "1c92cd8a-e176-48af-ac00-c018fb4c9895",
createdAt: "2024-03-12T21:38:56.342Z",
createdUserId: "00000000-0000-0000-0000-000000000000",
lastUpdatedAt: "2024-03-12T21:38:56.342Z",
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
createdFullName: "string",
lastUpdateFullName: "test bar",
remark: "ต้องส่งให้ทันก่อนวันที่ 15 มีนาคม",
detail: "ด่วน",
reference: "-",
dateStart: "2024-03-13T04:36:06.000Z",
dateEnd: "2024-03-13T04:36:06.000Z",
field: "ความมั่นคง",
profileAbilityId: "ad7d0955-7bcd-4ed0-911c-2edceba12579",
},
{
id: "2fb95768-cb62-40a3-9540-5a561d640959",
createdAt: "2024-03-12T21:39:06.094Z",
createdUserId: "00000000-0000-0000-0000-000000000000",
lastUpdatedAt: "2024-03-12T21:39:06.094Z",
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
createdFullName: "string",
lastUpdateFullName: "test bar",
remark: "ต้องส่งให้ทันก่อนวันที่ 15 มีนาคม",
detail: "ด่วนมากสุด",
reference: "-",
dateStart: "2024-03-13T04:36:06.000Z",
dateEnd: "2024-03-13T04:36:06.000Z",
field: "ความมั่นคง",
profileAbilityId: "ad7d0955-7bcd-4ed0-911c-2edceba12579",
},
],
})
public async getProfileAbilityHistory( public async getProfileAbilityHistory(
@Path() abilityId: string, @Path() abilityId: string,
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@ -130,8 +73,8 @@ export class ProfileAbilityController extends Controller {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
} }
const record = await this.profileAbilityHistoryRepo.find({ const record = await this.profileAbilityHistoryRepo.find({
relations: ["histories"],
where: { profileAbilityId: abilityId }, where: { profileAbilityId: abilityId },
order: { createdAt: "DESC" },
}); });
if (!record) { if (!record) {
@ -161,6 +104,8 @@ export class ProfileAbilityController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -187,15 +132,18 @@ export class ProfileAbilityController extends Controller {
const history = new ProfileAbilityHistory(); const history = new ProfileAbilityHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileAbilityId = abilityId; history.profileAbilityId = abilityId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.profileAbilityRepo.save(record), this.profileAbilityRepo.save(record),

View file

@ -2,7 +2,6 @@ import {
Body, Body,
Controller, Controller,
Delete, Delete,
Example,
Get, Get,
Patch, Patch,
Path, Path,
@ -13,9 +12,7 @@ import {
Tags, Tags,
} from "tsoa"; } from "tsoa";
import { AppDataSource } from "../database/data-source"; import { AppDataSource } from "../database/data-source";
import { Profile } from "../entities/Profile";
import { import {
CreateProfileAbility,
CreateProfileAbilityEmployee, CreateProfileAbilityEmployee,
ProfileAbility, ProfileAbility,
UpdateProfileAbility, UpdateProfileAbility,
@ -43,6 +40,7 @@ export class ProfileAbilityEmployeeController extends Controller {
} }
const getProfileAbilityId = await this.profileAbilityRepo.find({ const getProfileAbilityId = await this.profileAbilityRepo.find({
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
order: { createdAt: "ASC" },
}); });
if (!getProfileAbilityId) { if (!getProfileAbilityId) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -51,31 +49,15 @@ export class ProfileAbilityEmployeeController extends Controller {
} }
@Get("{profileEmployeeId}") @Get("{profileEmployeeId}")
@Example({ public async detailProfileAbility(
status: 200, @Path() profileEmployeeId: string,
message: "สำเร็จ", @Request() req: RequestWithUser,
result: [ ) {
{
id: "ad7d0955-7bcd-4ed0-911c-2edceba12579",
createdAt: "2024-03-12T21:37:35.037Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T21:37:35.037Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "test bar",
lastUpdateFullName: "test bar",
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
remark: "ต้องส่งให้ทันก่อนวันที่ 15 มีนาคม",
detail: "-",
reference: "-",
dateStart: "2024-03-13T04:36:06.000Z",
dateEnd: "2024-03-13T04:36:06.000Z",
field: "ความมั่นคง",
},
],
})
public async detailProfileAbility(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
const getProfileAbilityId = await this.profileAbilityRepo.findBy({ profileEmployeeId }); const getProfileAbilityId = await this.profileAbilityRepo.find({
where: { profileEmployeeId: profileEmployeeId },
order: { createdAt: "ASC" },
});
if (!getProfileAbilityId) { if (!getProfileAbilityId) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
} }
@ -83,45 +65,10 @@ export class ProfileAbilityEmployeeController extends Controller {
} }
@Get("history/{abilityId}") @Get("history/{abilityId}")
@Example({ public async getProfileAbilityHistory(
status: 200, @Path() abilityId: string,
message: "สำเร็จ", @Request() req: RequestWithUser,
result: [ ) {
{
id: "1c92cd8a-e176-48af-ac00-c018fb4c9895",
createdAt: "2024-03-12T21:38:56.342Z",
createdUserId: "00000000-0000-0000-0000-000000000000",
lastUpdatedAt: "2024-03-12T21:38:56.342Z",
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
createdFullName: "string",
lastUpdateFullName: "test bar",
remark: "ต้องส่งให้ทันก่อนวันที่ 15 มีนาคม",
detail: "ด่วน",
reference: "-",
dateStart: "2024-03-13T04:36:06.000Z",
dateEnd: "2024-03-13T04:36:06.000Z",
field: "ความมั่นคง",
profileAbilityId: "ad7d0955-7bcd-4ed0-911c-2edceba12579",
},
{
id: "2fb95768-cb62-40a3-9540-5a561d640959",
createdAt: "2024-03-12T21:39:06.094Z",
createdUserId: "00000000-0000-0000-0000-000000000000",
lastUpdatedAt: "2024-03-12T21:39:06.094Z",
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
createdFullName: "string",
lastUpdateFullName: "test bar",
remark: "ต้องส่งให้ทันก่อนวันที่ 15 มีนาคม",
detail: "ด่วนมากสุด",
reference: "-",
dateStart: "2024-03-13T04:36:06.000Z",
dateEnd: "2024-03-13T04:36:06.000Z",
field: "ความมั่นคง",
profileAbilityId: "ad7d0955-7bcd-4ed0-911c-2edceba12579",
},
],
})
public async getProfileAbilityHistory(@Path() abilityId: string, @Request() req: RequestWithUser) {
const _record = await this.profileAbilityRepo.findOneBy({ id: abilityId }); const _record = await this.profileAbilityRepo.findOneBy({ id: abilityId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserGet( await new permission().PermissionOrgUserGet(
@ -130,8 +77,9 @@ export class ProfileAbilityEmployeeController extends Controller {
_record.profileEmployeeId, _record.profileEmployeeId,
); );
} }
const record = await this.profileAbilityHistoryRepo.findBy({ const record = await this.profileAbilityHistoryRepo.find({
profileAbilityId: abilityId, where: { profileAbilityId: abilityId },
order: { createdAt: "DESC" },
}); });
if (!record) { if (!record) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -160,6 +108,8 @@ export class ProfileAbilityEmployeeController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -181,20 +131,27 @@ export class ProfileAbilityEmployeeController extends Controller {
) { ) {
const record = await this.profileAbilityRepo.findOneBy({ id: abilityId }); const record = await this.profileAbilityRepo.findOneBy({ id: abilityId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId); await new permission().PermissionOrgUserUpdate(
req,
"SYS_REGISTRY_EMP",
record.profileEmployeeId,
);
const history = new ProfileAbilityHistory(); const history = new ProfileAbilityHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileAbilityId = abilityId; history.profileAbilityId = abilityId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.profileAbilityRepo.save(record), this.profileAbilityRepo.save(record),
@ -206,14 +163,14 @@ export class ProfileAbilityEmployeeController extends Controller {
@Delete("{abilityId}") @Delete("{abilityId}")
public async deleteProfileAbility(@Path() abilityId: string, @Request() req: RequestWithUser) { public async deleteProfileAbility(@Path() abilityId: string, @Request() req: RequestWithUser) {
const _record = await this.profileAbilityRepo.findOneBy({ id: abilityId }); const _record = await this.profileAbilityRepo.findOneBy({ id: abilityId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserDelete( await new permission().PermissionOrgUserDelete(
req, req,
"SYS_REGISTRY_EMP", "SYS_REGISTRY_EMP",
_record.profileEmployeeId, _record.profileEmployeeId,
); );
} }
await this.profileAbilityHistoryRepo.delete({ await this.profileAbilityHistoryRepo.delete({
profileAbilityId: abilityId, profileAbilityId: abilityId,
}); });

View file

@ -2,7 +2,6 @@ import {
Body, Body,
Controller, Controller,
Delete, Delete,
Example,
Get, Get,
Patch, Patch,
Path, Path,
@ -13,9 +12,7 @@ import {
Tags, Tags,
} from "tsoa"; } from "tsoa";
import { AppDataSource } from "../database/data-source"; import { AppDataSource } from "../database/data-source";
import { Profile } from "../entities/Profile";
import { import {
CreateProfileAbility,
CreateProfileAbilityEmployee, CreateProfileAbilityEmployee,
ProfileAbility, ProfileAbility,
UpdateProfileAbility, UpdateProfileAbility,
@ -43,6 +40,7 @@ export class ProfileAbilityEmployeeTempController extends Controller {
} }
const getProfileAbilityId = await this.profileAbilityRepo.find({ const getProfileAbilityId = await this.profileAbilityRepo.find({
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
order: { createdAt: "ASC" },
}); });
if (!getProfileAbilityId) { if (!getProfileAbilityId) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -51,31 +49,15 @@ export class ProfileAbilityEmployeeTempController extends Controller {
} }
@Get("{profileEmployeeId}") @Get("{profileEmployeeId}")
@Example({ public async detailProfileAbility(
status: 200, @Path() profileEmployeeId: string,
message: "สำเร็จ", @Request() req: RequestWithUser,
result: [ ) {
{
id: "ad7d0955-7bcd-4ed0-911c-2edceba12579",
createdAt: "2024-03-12T21:37:35.037Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T21:37:35.037Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "test bar",
lastUpdateFullName: "test bar",
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
remark: "ต้องส่งให้ทันก่อนวันที่ 15 มีนาคม",
detail: "-",
reference: "-",
dateStart: "2024-03-13T04:36:06.000Z",
dateEnd: "2024-03-13T04:36:06.000Z",
field: "ความมั่นคง",
},
],
})
public async detailProfileAbility(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const getProfileAbilityId = await this.profileAbilityRepo.findBy({ profileEmployeeId }); const getProfileAbilityId = await this.profileAbilityRepo.find({
where: { profileEmployeeId: profileEmployeeId },
order: { createdAt: "ASC" },
});
if (!getProfileAbilityId) { if (!getProfileAbilityId) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
} }
@ -83,52 +65,17 @@ export class ProfileAbilityEmployeeTempController extends Controller {
} }
@Get("history/{abilityId}") @Get("history/{abilityId}")
@Example({ public async getProfileAbilityHistory(
status: 200, @Path() abilityId: string,
message: "สำเร็จ", @Request() req: RequestWithUser,
result: [ ) {
{
id: "1c92cd8a-e176-48af-ac00-c018fb4c9895",
createdAt: "2024-03-12T21:38:56.342Z",
createdUserId: "00000000-0000-0000-0000-000000000000",
lastUpdatedAt: "2024-03-12T21:38:56.342Z",
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
createdFullName: "string",
lastUpdateFullName: "test bar",
remark: "ต้องส่งให้ทันก่อนวันที่ 15 มีนาคม",
detail: "ด่วน",
reference: "-",
dateStart: "2024-03-13T04:36:06.000Z",
dateEnd: "2024-03-13T04:36:06.000Z",
field: "ความมั่นคง",
profileAbilityId: "ad7d0955-7bcd-4ed0-911c-2edceba12579",
},
{
id: "2fb95768-cb62-40a3-9540-5a561d640959",
createdAt: "2024-03-12T21:39:06.094Z",
createdUserId: "00000000-0000-0000-0000-000000000000",
lastUpdatedAt: "2024-03-12T21:39:06.094Z",
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
createdFullName: "string",
lastUpdateFullName: "test bar",
remark: "ต้องส่งให้ทันก่อนวันที่ 15 มีนาคม",
detail: "ด่วนมากสุด",
reference: "-",
dateStart: "2024-03-13T04:36:06.000Z",
dateEnd: "2024-03-13T04:36:06.000Z",
field: "ความมั่นคง",
profileAbilityId: "ad7d0955-7bcd-4ed0-911c-2edceba12579",
},
],
})
public async getProfileAbilityHistory(@Path() abilityId: string, @Request() req: RequestWithUser) {
const _record = await this.profileAbilityRepo.findOneBy({ id: abilityId }); const _record = await this.profileAbilityRepo.findOneBy({ id: abilityId });
if (_record) { if (_record) {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
} }
const record = await this.profileAbilityHistoryRepo.find({
const record = await this.profileAbilityHistoryRepo.findBy({ where: { profileAbilityId: abilityId },
profileAbilityId: abilityId, order: { createdAt: "DESC" },
}); });
if (!record) { if (!record) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -157,6 +104,8 @@ export class ProfileAbilityEmployeeTempController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -178,20 +127,23 @@ export class ProfileAbilityEmployeeTempController extends Controller {
) { ) {
const record = await this.profileAbilityRepo.findOneBy({ id: abilityId }); const record = await this.profileAbilityRepo.findOneBy({ id: abilityId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP") await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");
const history = new ProfileAbilityHistory(); const history = new ProfileAbilityHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileAbilityId = abilityId; history.profileAbilityId = abilityId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.profileAbilityRepo.save(record), this.profileAbilityRepo.save(record),

View file

@ -1,21 +1,4 @@
import { import { Controller, Route, Security, Tags, Body, Path, Request, Get, Patch } from "tsoa";
Controller,
Post,
Put,
Delete,
Route,
Security,
Tags,
Body,
Path,
Request,
SuccessResponse,
Response,
Get,
Query,
Patch,
Example,
} from "tsoa";
import HttpSuccess from "../interfaces/http-success"; import HttpSuccess from "../interfaces/http-success";
import HttpError from "../interfaces/http-error"; import HttpError from "../interfaces/http-error";
@ -23,9 +6,6 @@ import HttpStatus from "../interfaces/http-status";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import { Profile, ProfileAddressHistory, UpdateProfileAddress } from "../entities/Profile"; import { Profile, ProfileAddressHistory, UpdateProfileAddress } from "../entities/Profile";
import { AppDataSource } from "../database/data-source"; import { AppDataSource } from "../database/data-source";
import { Province } from "../entities/Province";
import { District } from "../entities/District";
import { SubDistrict } from "../entities/SubDistrict";
import permission from "../interfaces/permission"; import permission from "../interfaces/permission";
@Route("api/v1/org/profile/address") @Route("api/v1/org/profile/address")
@Tags("ProfileAddress") @Tags("ProfileAddress")
@ -54,7 +34,9 @@ export class ProfileAddressController extends Controller {
"currentDistrictId", "currentDistrictId",
"currentSubDistrictId", "currentSubDistrictId",
"currentZipCode", "currentZipCode",
"createdAt",
], ],
order: { createdAt: "ASC" },
}); });
if (!getProfileAddress) { if (!getProfileAddress) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -84,6 +66,7 @@ export class ProfileAddressController extends Controller {
"currentDistrictId", "currentDistrictId",
"currentSubDistrictId", "currentSubDistrictId",
"currentZipCode", "currentZipCode",
"createdAt",
], ],
}); });
if (!getProfileAddress) { if (!getProfileAddress) {
@ -105,28 +88,7 @@ export class ProfileAddressController extends Controller {
} }
const record = await this.profileAddressHistoryRepo.find({ const record = await this.profileAddressHistoryRepo.find({
where: { profileId: profile.id }, where: { profileId: profile.id },
relations: { order: { createdAt: "DESC" },
registrationProvince: true,
registrationDistrict: true,
registrationSubDistrict: true,
currentProvince: true,
currentDistrict: true,
currentSubDistrict: true,
},
select: [
"registrationAddress",
"registrationProvinceId",
"registrationDistrictId",
"registrationSubDistrictId",
"registrationZipCode",
"currentAddress",
"currentProvinceId",
"currentDistrictId",
"currentSubDistrictId",
"currentZipCode",
"lastUpdateFullName",
"lastUpdatedAt",
],
}); });
if (!record) { if (!record) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -140,32 +102,14 @@ export class ProfileAddressController extends Controller {
* *
*/ */
@Get("history/{profileId}") @Get("history/{profileId}")
public async getProfileAddressHistory(@Path() profileId: string, @Request() req: RequestWithUser) { public async getProfileAddressHistory(
@Path() profileId: string,
@Request() req: RequestWithUser,
) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
const record = await this.profileAddressHistoryRepo.find({ const record = await this.profileAddressHistoryRepo.find({
where: { profileId: profileId }, where: { profileId: profileId },
relations: { order: { createdAt: "DESC" },
registrationProvince: true,
registrationDistrict: true,
registrationSubDistrict: true,
currentProvince: true,
currentDistrict: true,
currentSubDistrict: true,
},
select: [
"registrationAddress",
"registrationProvinceId",
"registrationDistrictId",
"registrationSubDistrictId",
"registrationZipCode",
"currentAddress",
"currentProvinceId",
"currentDistrictId",
"currentSubDistrictId",
"currentZipCode",
"lastUpdateFullName",
"lastUpdatedAt",
],
}); });
if (!record) { if (!record) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -191,15 +135,18 @@ export class ProfileAddressController extends Controller {
const history = new ProfileAddressHistory(); const history = new ProfileAddressHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileId = profileId; history.profileId = profileId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.profileRepo.save(record), this.profileRepo.save(record),

View file

@ -1,31 +1,11 @@
import { import { Controller, Route, Security, Tags, Body, Path, Request, Get, Patch } from "tsoa";
Controller,
Post,
Put,
Delete,
Route,
Security,
Tags,
Body,
Path,
Request,
SuccessResponse,
Response,
Get,
Query,
Patch,
Example,
} from "tsoa";
import HttpSuccess from "../interfaces/http-success"; import HttpSuccess from "../interfaces/http-success";
import HttpError from "../interfaces/http-error"; import HttpError from "../interfaces/http-error";
import HttpStatus from "../interfaces/http-status"; import HttpStatus from "../interfaces/http-status";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import { Profile, ProfileAddressHistory, UpdateProfileAddress } from "../entities/Profile"; import { ProfileAddressHistory } from "../entities/Profile";
import { AppDataSource } from "../database/data-source"; import { AppDataSource } from "../database/data-source";
import { Province } from "../entities/Province";
import { District } from "../entities/District";
import { SubDistrict } from "../entities/SubDistrict";
import { ProfileEmployee, UpdateProfileAddressEmployee } from "../entities/ProfileEmployee"; import { ProfileEmployee, UpdateProfileAddressEmployee } from "../entities/ProfileEmployee";
import permission from "../interfaces/permission"; import permission from "../interfaces/permission";
@Route("api/v1/org/profile-employee/address") @Route("api/v1/org/profile-employee/address")
@ -55,7 +35,9 @@ export class ProfileAddressEmployeeController extends Controller {
"currentDistrictId", "currentDistrictId",
"currentSubDistrictId", "currentSubDistrictId",
"currentZipCode", "currentZipCode",
"createdAt",
], ],
order: { createdAt: "ASC" },
}); });
if (!getProfileAddress) { if (!getProfileAddress) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -69,7 +51,10 @@ export class ProfileAddressEmployeeController extends Controller {
* *
*/ */
@Get("{profileEmployeeId}") @Get("{profileEmployeeId}")
public async detailProfileAddress(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { public async detailProfileAddress(
@Path() profileEmployeeId: string,
@Request() req: RequestWithUser,
) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
const getProfileAddress = await this.profileEmployeeRepo.findOne({ const getProfileAddress = await this.profileEmployeeRepo.findOne({
where: { id: profileEmployeeId }, where: { id: profileEmployeeId },
@ -85,6 +70,7 @@ export class ProfileAddressEmployeeController extends Controller {
"currentDistrictId", "currentDistrictId",
"currentSubDistrictId", "currentSubDistrictId",
"currentZipCode", "currentZipCode",
"createdAt",
], ],
}); });
if (!getProfileAddress) { if (!getProfileAddress) {
@ -106,28 +92,7 @@ export class ProfileAddressEmployeeController extends Controller {
} }
const record = await this.profileAddressHistoryRepo.find({ const record = await this.profileAddressHistoryRepo.find({
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
relations: { order: { createdAt: "DESC" },
registrationProvince: true,
registrationDistrict: true,
registrationSubDistrict: true,
currentProvince: true,
currentDistrict: true,
currentSubDistrict: true,
},
select: [
"registrationAddress",
"registrationProvinceId",
"registrationDistrictId",
"registrationSubDistrictId",
"registrationZipCode",
"currentAddress",
"currentProvinceId",
"currentDistrictId",
"currentSubDistrictId",
"currentZipCode",
"lastUpdateFullName",
"lastUpdatedAt",
],
}); });
if (!record) { if (!record) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -141,32 +106,14 @@ export class ProfileAddressEmployeeController extends Controller {
* *
*/ */
@Get("history/{profileId}") @Get("history/{profileId}")
public async getProfileAddressHistory(@Path() profileId: string, @Request() req: RequestWithUser) { public async getProfileAddressHistory(
@Path() profileId: string,
@Request() req: RequestWithUser,
) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId);
const record = await this.profileAddressHistoryRepo.find({ const record = await this.profileAddressHistoryRepo.find({
where: { profileEmployeeId: profileId }, where: { profileEmployeeId: profileId },
relations: { order: { createdAt: "DESC" },
registrationProvince: true,
registrationDistrict: true,
registrationSubDistrict: true,
currentProvince: true,
currentDistrict: true,
currentSubDistrict: true,
},
select: [
"registrationAddress",
"registrationProvinceId",
"registrationDistrictId",
"registrationSubDistrictId",
"registrationZipCode",
"currentAddress",
"currentProvinceId",
"currentDistrictId",
"currentSubDistrictId",
"currentZipCode",
"lastUpdateFullName",
"lastUpdatedAt",
],
}); });
if (!record) { if (!record) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -192,15 +139,18 @@ export class ProfileAddressEmployeeController extends Controller {
const history = new ProfileAddressHistory(); const history = new ProfileAddressHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileEmployeeId = profileId; history.profileEmployeeId = profileId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.profileEmployeeRepo.save(record), this.profileEmployeeRepo.save(record),

View file

@ -1,31 +1,11 @@
import { import { Controller, Route, Security, Tags, Body, Path, Request, Get, Patch } from "tsoa";
Controller,
Post,
Put,
Delete,
Route,
Security,
Tags,
Body,
Path,
Request,
SuccessResponse,
Response,
Get,
Query,
Patch,
Example,
} from "tsoa";
import HttpSuccess from "../interfaces/http-success"; import HttpSuccess from "../interfaces/http-success";
import HttpError from "../interfaces/http-error"; import HttpError from "../interfaces/http-error";
import HttpStatus from "../interfaces/http-status"; import HttpStatus from "../interfaces/http-status";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import { Profile, ProfileAddressHistory, UpdateProfileAddress } from "../entities/Profile"; import { ProfileAddressHistory } from "../entities/Profile";
import { AppDataSource } from "../database/data-source"; import { AppDataSource } from "../database/data-source";
import { Province } from "../entities/Province";
import { District } from "../entities/District";
import { SubDistrict } from "../entities/SubDistrict";
import { ProfileEmployee, UpdateProfileAddressEmployee } from "../entities/ProfileEmployee"; import { ProfileEmployee, UpdateProfileAddressEmployee } from "../entities/ProfileEmployee";
import permission from "../interfaces/permission"; import permission from "../interfaces/permission";
@Route("api/v1/org/profile-temp/address") @Route("api/v1/org/profile-temp/address")
@ -55,7 +35,9 @@ export class ProfileAddressEmployeeTempController extends Controller {
"currentDistrictId", "currentDistrictId",
"currentSubDistrictId", "currentSubDistrictId",
"currentZipCode", "currentZipCode",
"createdAt",
], ],
order: { createdAt: "ASC" },
}); });
if (!getProfileAddress) { if (!getProfileAddress) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -88,6 +70,7 @@ export class ProfileAddressEmployeeTempController extends Controller {
"currentDistrictId", "currentDistrictId",
"currentSubDistrictId", "currentSubDistrictId",
"currentZipCode", "currentZipCode",
"createdAt",
], ],
}); });
if (!getProfileAddress) { if (!getProfileAddress) {
@ -109,28 +92,7 @@ export class ProfileAddressEmployeeTempController extends Controller {
} }
const record = await this.profileAddressHistoryRepo.find({ const record = await this.profileAddressHistoryRepo.find({
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
relations: { order: { createdAt: "DESC" },
registrationProvince: true,
registrationDistrict: true,
registrationSubDistrict: true,
currentProvince: true,
currentDistrict: true,
currentSubDistrict: true,
},
select: [
"registrationAddress",
"registrationProvinceId",
"registrationDistrictId",
"registrationSubDistrictId",
"registrationZipCode",
"currentAddress",
"currentProvinceId",
"currentDistrictId",
"currentSubDistrictId",
"currentZipCode",
"lastUpdateFullName",
"lastUpdatedAt",
],
}); });
if (!record) { if (!record) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -151,28 +113,7 @@ export class ProfileAddressEmployeeTempController extends Controller {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const record = await this.profileAddressHistoryRepo.find({ const record = await this.profileAddressHistoryRepo.find({
where: { profileEmployeeId: profileId }, where: { profileEmployeeId: profileId },
relations: { order: { createdAt: "DESC" },
registrationProvince: true,
registrationDistrict: true,
registrationSubDistrict: true,
currentProvince: true,
currentDistrict: true,
currentSubDistrict: true,
},
select: [
"registrationAddress",
"registrationProvinceId",
"registrationDistrictId",
"registrationSubDistrictId",
"registrationZipCode",
"currentAddress",
"currentProvinceId",
"currentDistrictId",
"currentSubDistrictId",
"currentZipCode",
"lastUpdateFullName",
"lastUpdatedAt",
],
}); });
if (!record) { if (!record) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -198,15 +139,18 @@ export class ProfileAddressEmployeeTempController extends Controller {
const history = new ProfileAddressHistory(); const history = new ProfileAddressHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileEmployeeId = profileId; history.profileEmployeeId = profileId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.profileEmployeeRepo.save(record), this.profileEmployeeRepo.save(record),

View file

@ -1,7 +1,6 @@
import { import {
Controller, Controller,
Post, Post,
Put,
Delete, Delete,
Route, Route,
Security, Security,
@ -9,12 +8,8 @@ import {
Body, Body,
Path, Path,
Request, Request,
SuccessResponse,
Response,
Get, Get,
Query,
Patch, Patch,
Example,
} from "tsoa"; } from "tsoa";
import HttpError from "../interfaces/http-error"; import HttpError from "../interfaces/http-error";
import HttpStatus from "../interfaces/http-status"; import HttpStatus from "../interfaces/http-status";
@ -46,6 +41,7 @@ export class ProfileAssessmentsController extends Controller {
} }
const getProfileAssessments = await this.profileAssessmentsRepository.find({ const getProfileAssessments = await this.profileAssessmentsRepository.find({
where: { profileId: profile.id }, where: { profileId: profile.id },
order: { createdAt: "ASC" },
}); });
if (!getProfileAssessments) { if (!getProfileAssessments) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -54,36 +50,15 @@ export class ProfileAssessmentsController extends Controller {
} }
@Get("{profileId}") @Get("{profileId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "f723bf42-a61c-4af4-ba8b-0e4ad0a89a80",
createdAt: "2024-03-12T20:56:45.986Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T20:56:45.986Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "test bar",
lastUpdateFullName: "test bar",
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
name: "สาวิตรี ศรีสมัย",
date: "2024-03-13T03:55:42.000Z",
point1: 0,
point1Total: 0,
point2: 0,
point2Total: 0,
pointSum: 0,
pointSumTotal: 0,
},
],
})
public async detailProfileAssessments( public async detailProfileAssessments(
@Path() profileId: string, @Path() profileId: string,
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
) { ) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
const getProfileAssessments = await this.profileAssessmentsRepository.findBy({ profileId }); const getProfileAssessments = await this.profileAssessmentsRepository.find({
where: { profileId: profileId },
order: { createdAt: "ASC" },
});
if (!getProfileAssessments) { if (!getProfileAssessments) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
} }
@ -91,67 +66,25 @@ export class ProfileAssessmentsController extends Controller {
} }
@Get("history/{assessmentId}") @Get("history/{assessmentId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "47b3e370-be05-4469-a34f-e4a04747f54e",
createdAt: "2024-03-12T20:59:39.774Z",
createdUserId: "00000000-0000-0000-0000-000000000000",
lastUpdatedAt: "2024-03-12T20:59:39.774Z",
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
createdFullName: "string",
lastUpdateFullName: "test bar",
name: "สาวิตรี ศรีสมัย",
date: "2024-03-13T03:55:42.000Z",
point1: 0,
point1Total: 0,
point2: 100,
point2Total: 100,
pointSum: 100,
pointSumTotal: 100,
profileAssessmentId: "f723bf42-a61c-4af4-ba8b-0e4ad0a89a80",
},
{
id: "ecff89b1-9bef-49a9-83f5-8be3cecb8ca7",
createdAt: "2024-03-12T20:58:19.450Z",
createdUserId: "00000000-0000-0000-0000-000000000000",
lastUpdatedAt: "2024-03-12T20:58:19.450Z",
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
createdFullName: "string",
lastUpdateFullName: "test bar",
name: "สาวิตรี ศรีสมัย",
date: "2024-03-13T03:55:42.000Z",
point1: 50,
point1Total: 50,
point2: 100,
point2Total: 100,
pointSum: 150,
pointSumTotal: 150,
profileAssessmentId: "f723bf42-a61c-4af4-ba8b-0e4ad0a89a80",
},
],
})
public async getProfileAssessmentsHistory( public async getProfileAssessmentsHistory(
@Path() assessmentId: string, @Path() assessmentId: string,
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
) { ) {
const record = await this.profileAssessmentsHistoryRepository.findBy({ const _record = await this.profileAssessmentsRepository.findOneBy({
profileAssessmentId: assessmentId, id: assessmentId,
});
if (_record)
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
const record = await this.profileAssessmentsHistoryRepository.find({
where: {
profileAssessmentId: assessmentId,
},
order: { createdAt: "DESC" },
}); });
if (!record) { if (!record) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
} }
const _record = await this.profileAssessmentsRepository.findOne({
where: {
id: assessmentId,
},
});
if (_record) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
}
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@ -176,6 +109,8 @@ export class ProfileAssessmentsController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
const history = new ProfileAssessmentHistory(); const history = new ProfileAssessmentHistory();
@ -201,15 +136,18 @@ export class ProfileAssessmentsController extends Controller {
const history = new ProfileAssessmentHistory(); const history = new ProfileAssessmentHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileAssessmentId = assessmentId; history.profileAssessmentId = assessmentId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.profileAssessmentsRepository.save(record), this.profileAssessmentsRepository.save(record),

View file

@ -1,7 +1,6 @@
import { import {
Controller, Controller,
Post, Post,
Put,
Delete, Delete,
Route, Route,
Security, Security,
@ -9,12 +8,8 @@ import {
Body, Body,
Path, Path,
Request, Request,
SuccessResponse,
Response,
Get, Get,
Query,
Patch, Patch,
Example,
} from "tsoa"; } from "tsoa";
import HttpError from "../interfaces/http-error"; import HttpError from "../interfaces/http-error";
import HttpStatus from "../interfaces/http-status"; import HttpStatus from "../interfaces/http-status";
@ -46,6 +41,7 @@ export class ProfileAssessmentsEmployeeController extends Controller {
} }
const getProfileAssessments = await this.profileAssessmentsRepository.find({ const getProfileAssessments = await this.profileAssessmentsRepository.find({
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
order: { createdAt: "ASC" },
}); });
if (!getProfileAssessments) { if (!getProfileAssessments) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -54,34 +50,16 @@ export class ProfileAssessmentsEmployeeController extends Controller {
} }
@Get("{profileEmployeeId}") @Get("{profileEmployeeId}")
@Example({ public async detailProfileAssessments(
status: 200, @Path() profileEmployeeId: string,
message: "สำเร็จ", @Request() req: RequestWithUser,
result: [ ) {
{
id: "f723bf42-a61c-4af4-ba8b-0e4ad0a89a80",
createdAt: "2024-03-12T20:56:45.986Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T20:56:45.986Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "test bar",
lastUpdateFullName: "test bar",
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
name: "สาวิตรี ศรีสมัย",
date: "2024-03-13T03:55:42.000Z",
point1: 0,
point1Total: 0,
point2: 0,
point2Total: 0,
pointSum: 0,
pointSumTotal: 0,
},
],
})
public async detailProfileAssessments(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
const getProfileAssessments = await this.profileAssessmentsRepository.findBy({ const getProfileAssessments = await this.profileAssessmentsRepository.find({
profileEmployeeId, where: {
profileEmployeeId: profileEmployeeId,
},
order: { createdAt: "ASC" },
}); });
if (!getProfileAssessments) { if (!getProfileAssessments) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -90,55 +68,19 @@ export class ProfileAssessmentsEmployeeController extends Controller {
} }
@Get("history/{assessmentId}") @Get("history/{assessmentId}")
@Example({ public async getProfileAssessmentsHistory(
status: 200, @Path() assessmentId: string,
message: "สำเร็จ", @Request() req: RequestWithUser,
result: [ ) {
{
id: "47b3e370-be05-4469-a34f-e4a04747f54e",
createdAt: "2024-03-12T20:59:39.774Z",
createdUserId: "00000000-0000-0000-0000-000000000000",
lastUpdatedAt: "2024-03-12T20:59:39.774Z",
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
createdFullName: "string",
lastUpdateFullName: "test bar",
name: "สาวิตรี ศรีสมัย",
date: "2024-03-13T03:55:42.000Z",
point1: 0,
point1Total: 0,
point2: 100,
point2Total: 100,
pointSum: 100,
pointSumTotal: 100,
profileAssessmentId: "f723bf42-a61c-4af4-ba8b-0e4ad0a89a80",
},
{
id: "ecff89b1-9bef-49a9-83f5-8be3cecb8ca7",
createdAt: "2024-03-12T20:58:19.450Z",
createdUserId: "00000000-0000-0000-0000-000000000000",
lastUpdatedAt: "2024-03-12T20:58:19.450Z",
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
createdFullName: "string",
lastUpdateFullName: "test bar",
name: "สาวิตรี ศรีสมัย",
date: "2024-03-13T03:55:42.000Z",
point1: 50,
point1Total: 50,
point2: 100,
point2Total: 100,
pointSum: 150,
pointSumTotal: 150,
profileAssessmentId: "f723bf42-a61c-4af4-ba8b-0e4ad0a89a80",
},
],
})
public async getProfileAssessmentsHistory(@Path() assessmentId: string, @Request() req: RequestWithUser) {
const _record = await this.profileAssessmentsRepository.findOneBy({ id: assessmentId }); const _record = await this.profileAssessmentsRepository.findOneBy({ id: assessmentId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileId);
} }
const record = await this.profileAssessmentsHistoryRepository.findBy({ const record = await this.profileAssessmentsHistoryRepository.find({
profileAssessmentId: assessmentId, where: {
profileAssessmentId: assessmentId,
},
order: { createdAt: "DESC" },
}); });
if (!record) { if (!record) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -168,6 +110,8 @@ export class ProfileAssessmentsEmployeeController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
const history = new ProfileAssessmentHistory(); const history = new ProfileAssessmentHistory();
@ -188,20 +132,27 @@ export class ProfileAssessmentsEmployeeController extends Controller {
) { ) {
const record = await this.profileAssessmentsRepository.findOneBy({ id: assessmentId }); const record = await this.profileAssessmentsRepository.findOneBy({ id: assessmentId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId); await new permission().PermissionOrgUserUpdate(
req,
"SYS_REGISTRY_EMP",
record.profileEmployeeId,
);
const history = new ProfileAssessmentHistory(); const history = new ProfileAssessmentHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileAssessmentId = assessmentId; history.profileAssessmentId = assessmentId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.profileAssessmentsRepository.save(record), this.profileAssessmentsRepository.save(record),
@ -218,7 +169,11 @@ export class ProfileAssessmentsEmployeeController extends Controller {
) { ) {
const _record = await this.profileAssessmentsRepository.findOneBy({ id: assessmentId }); const _record = await this.profileAssessmentsRepository.findOneBy({ id: assessmentId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); await new permission().PermissionOrgUserDelete(
req,
"SYS_REGISTRY_EMP",
_record.profileEmployeeId,
);
} }
await this.profileAssessmentsHistoryRepository.delete({ await this.profileAssessmentsHistoryRepository.delete({
profileAssessmentId: assessmentId, profileAssessmentId: assessmentId,

View file

@ -1,7 +1,6 @@
import { import {
Controller, Controller,
Post, Post,
Put,
Delete, Delete,
Route, Route,
Security, Security,
@ -9,12 +8,8 @@ import {
Body, Body,
Path, Path,
Request, Request,
SuccessResponse,
Response,
Get, Get,
Query,
Patch, Patch,
Example,
} from "tsoa"; } from "tsoa";
import HttpError from "../interfaces/http-error"; import HttpError from "../interfaces/http-error";
import HttpStatus from "../interfaces/http-status"; import HttpStatus from "../interfaces/http-status";
@ -46,6 +41,7 @@ export class ProfileAssessmentsEmployeeTempController extends Controller {
} }
const getProfileAssessments = await this.profileAssessmentsRepository.find({ const getProfileAssessments = await this.profileAssessmentsRepository.find({
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
order: { createdAt: "ASC" },
}); });
if (!getProfileAssessments) { if (!getProfileAssessments) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -54,34 +50,16 @@ export class ProfileAssessmentsEmployeeTempController extends Controller {
} }
@Get("{profileEmployeeId}") @Get("{profileEmployeeId}")
@Example({ public async detailProfileAssessments(
status: 200, @Path() profileEmployeeId: string,
message: "สำเร็จ", @Request() req: RequestWithUser,
result: [ ) {
{
id: "f723bf42-a61c-4af4-ba8b-0e4ad0a89a80",
createdAt: "2024-03-12T20:56:45.986Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T20:56:45.986Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "test bar",
lastUpdateFullName: "test bar",
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
name: "สาวิตรี ศรีสมัย",
date: "2024-03-13T03:55:42.000Z",
point1: 0,
point1Total: 0,
point2: 0,
point2Total: 0,
pointSum: 0,
pointSumTotal: 0,
},
],
})
public async detailProfileAssessments(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const getProfileAssessments = await this.profileAssessmentsRepository.findBy({ const getProfileAssessments = await this.profileAssessmentsRepository.find({
profileEmployeeId, where: {
profileEmployeeId: profileEmployeeId,
},
order: { createdAt: "ASC" },
}); });
if (!getProfileAssessments) { if (!getProfileAssessments) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -90,52 +68,16 @@ export class ProfileAssessmentsEmployeeTempController extends Controller {
} }
@Get("history/{assessmentId}") @Get("history/{assessmentId}")
@Example({ public async getProfileAssessmentsHistory(
status: 200, @Path() assessmentId: string,
message: "สำเร็จ", @Request() req: RequestWithUser,
result: [ ) {
{
id: "47b3e370-be05-4469-a34f-e4a04747f54e",
createdAt: "2024-03-12T20:59:39.774Z",
createdUserId: "00000000-0000-0000-0000-000000000000",
lastUpdatedAt: "2024-03-12T20:59:39.774Z",
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
createdFullName: "string",
lastUpdateFullName: "test bar",
name: "สาวิตรี ศรีสมัย",
date: "2024-03-13T03:55:42.000Z",
point1: 0,
point1Total: 0,
point2: 100,
point2Total: 100,
pointSum: 100,
pointSumTotal: 100,
profileAssessmentId: "f723bf42-a61c-4af4-ba8b-0e4ad0a89a80",
},
{
id: "ecff89b1-9bef-49a9-83f5-8be3cecb8ca7",
createdAt: "2024-03-12T20:58:19.450Z",
createdUserId: "00000000-0000-0000-0000-000000000000",
lastUpdatedAt: "2024-03-12T20:58:19.450Z",
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
createdFullName: "string",
lastUpdateFullName: "test bar",
name: "สาวิตรี ศรีสมัย",
date: "2024-03-13T03:55:42.000Z",
point1: 50,
point1Total: 50,
point2: 100,
point2Total: 100,
pointSum: 150,
pointSumTotal: 150,
profileAssessmentId: "f723bf42-a61c-4af4-ba8b-0e4ad0a89a80",
},
],
})
public async getProfileAssessmentsHistory(@Path() assessmentId: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const record = await this.profileAssessmentsHistoryRepository.findBy({ const record = await this.profileAssessmentsHistoryRepository.find({
profileAssessmentId: assessmentId, where: {
profileAssessmentId: assessmentId,
},
order: { createdAt: "DESC" },
}); });
if (!record) { if (!record) {
@ -166,6 +108,8 @@ export class ProfileAssessmentsEmployeeTempController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
const history = new ProfileAssessmentHistory(); const history = new ProfileAssessmentHistory();
@ -191,15 +135,18 @@ export class ProfileAssessmentsEmployeeTempController extends Controller {
const history = new ProfileAssessmentHistory(); const history = new ProfileAssessmentHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileAssessmentId = assessmentId; history.profileAssessmentId = assessmentId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.profileAssessmentsRepository.save(record), this.profileAssessmentsRepository.save(record),

View file

@ -19,6 +19,7 @@ export class ProfileAvatarController extends Controller {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
const lists = await this.avatarRepository.find({ const lists = await this.avatarRepository.find({
where: { profileId: profileId }, where: { profileId: profileId },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@ -27,7 +28,6 @@ export class ProfileAvatarController extends Controller {
async getProfile(@Path() id: string, @Request() req: RequestWithUser) { async getProfile(@Path() id: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", id); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", id);
const profile = await this.profileRepository.findOne({ const profile = await this.profileRepository.findOne({
select: ["id", "avatar", "avatarName"],
where: { id }, where: { id },
}); });
@ -39,7 +39,6 @@ export class ProfileAvatarController extends Controller {
@Get("profileId-admin/{id}") @Get("profileId-admin/{id}")
async getProfileAdmin(@Path() id: string) { async getProfileAdmin(@Path() id: string) {
const profile = await this.profileRepository.findOne({ const profile = await this.profileRepository.findOne({
select: ["id", "avatar", "avatarName"],
where: { id }, where: { id },
}); });
@ -49,7 +48,11 @@ export class ProfileAvatarController extends Controller {
} }
@Get("select/{profileId}/{id}") @Get("select/{profileId}/{id}")
public async selectAvatar(@Path() profileId: string, @Path() id: string, @Request() req: RequestWithUser) { public async selectAvatar(
@Path() profileId: string,
@Path() id: string,
@Request() req: RequestWithUser,
) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
const result = await this.avatarRepository.findOneBy({ id: id }); const result = await this.avatarRepository.findOneBy({ id: id });
if (!result) { if (!result) {
@ -94,6 +97,8 @@ export class ProfileAvatarController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -129,11 +134,14 @@ export class ProfileAvatarController extends Controller {
} }
@Delete("{avatarId}") @Delete("{avatarId}")
public async deleteAvatar(@Path() avatarId: string, @Request() req: RequestWithUser) public async deleteAvatar(@Path() avatarId: string, @Request() req: RequestWithUser) {
{
const _record = await this.avatarRepository.findOneBy({ id: avatarId }); const _record = await this.avatarRepository.findOneBy({ id: avatarId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId); await new permission().PermissionOrgUserDelete(
req,
"SYS_REGISTRY_OFFICER",
_record.profileId,
);
} }
const result = await this.avatarRepository.delete({ id: avatarId }); const result = await this.avatarRepository.delete({ id: avatarId });

View file

@ -22,6 +22,7 @@ export class ProfileAvatarEmployeeController extends Controller {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
const lists = await this.avatarRepository.find({ const lists = await this.avatarRepository.find({
where: { profileEmployeeId }, where: { profileEmployeeId },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@ -30,7 +31,6 @@ export class ProfileAvatarEmployeeController extends Controller {
async getProfile(@Path() id: string, @Request() req: RequestWithUser) { async getProfile(@Path() id: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", id); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", id);
const profile = await this.profileRepository.findOne({ const profile = await this.profileRepository.findOne({
select: ["id", "avatar", "avatarName"],
where: { id }, where: { id },
}); });
@ -42,7 +42,6 @@ export class ProfileAvatarEmployeeController extends Controller {
@Get("profileEmployeeId-admin/{id}") @Get("profileEmployeeId-admin/{id}")
async getProfileAdmin(@Path() id: string) { async getProfileAdmin(@Path() id: string) {
const profile = await this.profileRepository.findOne({ const profile = await this.profileRepository.findOne({
select: ["id", "avatar", "avatarName"],
where: { id }, where: { id },
}); });
@ -103,6 +102,8 @@ export class ProfileAvatarEmployeeController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -141,7 +142,11 @@ export class ProfileAvatarEmployeeController extends Controller {
public async deleteAvatarEmployee(@Path() avatarId: string, @Request() req: RequestWithUser) { public async deleteAvatarEmployee(@Path() avatarId: string, @Request() req: RequestWithUser) {
const _record = await this.avatarRepository.findOneBy({ id: avatarId }); const _record = await this.avatarRepository.findOneBy({ id: avatarId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); await new permission().PermissionOrgUserDelete(
req,
"SYS_REGISTRY_EMP",
_record.profileEmployeeId,
);
} }
const result = await this.avatarRepository.delete({ id: avatarId }); const result = await this.avatarRepository.delete({ id: avatarId });

View file

@ -22,6 +22,7 @@ export class ProfileAvatarEmployeeTempController extends Controller {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const lists = await this.avatarRepository.find({ const lists = await this.avatarRepository.find({
where: { profileEmployeeId }, where: { profileEmployeeId },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@ -30,7 +31,6 @@ export class ProfileAvatarEmployeeTempController extends Controller {
async getProfile(@Path() id: string, @Request() req: RequestWithUser) { async getProfile(@Path() id: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const profile = await this.profileRepository.findOne({ const profile = await this.profileRepository.findOne({
select: ["id", "avatar", "avatarName"],
where: { id }, where: { id },
}); });
@ -42,7 +42,6 @@ export class ProfileAvatarEmployeeTempController extends Controller {
@Get("profileEmployeeId-admin/{id}") @Get("profileEmployeeId-admin/{id}")
async getProfileAdmin(@Path() id: string) { async getProfileAdmin(@Path() id: string) {
const profile = await this.profileRepository.findOne({ const profile = await this.profileRepository.findOne({
select: ["id", "avatar", "avatarName"],
where: { id }, where: { id },
}); });
@ -57,7 +56,7 @@ export class ProfileAvatarEmployeeTempController extends Controller {
@Path() id: string, @Path() id: string,
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
) { ) {
// await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); //ไม่แน่ใจTEMPปิดไว้ก่อน await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const result = await this.avatarRepository.findOneBy({ id: id }); const result = await this.avatarRepository.findOneBy({ id: id });
if (!result) { if (!result) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -104,6 +103,8 @@ export class ProfileAvatarEmployeeTempController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });

View file

@ -2,7 +2,6 @@ import {
Body, Body,
Controller, Controller,
Delete, Delete,
Example,
Get, Get,
Patch, Patch,
Path, Path,
@ -41,85 +40,34 @@ export class ProfileCertificateController extends Controller {
} }
const record = await this.certificateRepo.find({ const record = await this.certificateRepo.find({
where: { profileId: profile.id }, where: { profileId: profile.id },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@Get("{profileId}") @Get("{profileId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "e1ef9c3d-079a-40d8-8332-664c3e9a5a70",
createdAt: "2024-03-12T03:02:27.532Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T03:02:27.532Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
expireDate: "2024-03-12T10:01:48.000Z",
issueDate: "2024-03-12T10:01:48.000Z",
certificateNo: "string",
certificateType: "string",
issuer: "string",
},
],
})
public async getCertificate(@Path() profileId: string, @Request() req: RequestWithUser) { public async getCertificate(@Path() profileId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
const record = await this.certificateRepo.findBy({ profileId }); const record = await this.certificateRepo.find({
where: { profileId: profileId },
order: { createdAt: "ASC" },
});
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@Get("history/{certificateId}") @Get("history/{certificateId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "c0ecf986-b290-44ca-b45e-f4448cdd34dd",
createdAt: "2024-03-12T03:03:30.169Z",
createdUserId: "00000000-0000-0000-0000-000000000000",
lastUpdatedAt: "2024-03-12T03:03:30.169Z",
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
createdFullName: "string",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
expireDate: "2024-03-12T10:03:05.000Z",
issueDate: "2024-03-12T10:03:05.000Z",
certificateNo: "no",
certificateType: "type",
issuer: "issuer",
profileCertificateId: "e1ef9c3d-079a-40d8-8332-664c3e9a5a70",
},
{
id: "dc4c2800-5fc5-4ec3-b19a-c4a27beac35f",
createdAt: "2024-03-12T03:02:27.583Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T03:02:27.583Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
expireDate: "2024-03-12T10:01:48.000Z",
issueDate: "2024-03-12T10:01:48.000Z",
certificateNo: "string",
certificateType: "string",
issuer: "string",
profileCertificateId: "e1ef9c3d-079a-40d8-8332-664c3e9a5a70",
},
],
})
public async certificateHistory(@Path() certificateId: string, @Request() req: RequestWithUser) { public async certificateHistory(@Path() certificateId: string, @Request() req: RequestWithUser) {
const _record = await this.certificateRepo.findOneBy({ id: certificateId }); const _record = await this.certificateRepo.findOneBy({ id: certificateId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
} }
const record = await this.certificateHistoryRepo.findBy({ const record = await this.certificateHistoryRepo.find({
profileCertificateId: certificateId, where: {
profileCertificateId: certificateId,
},
order: { createdAt: "DESC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@Post() @Post()
@ -145,6 +93,8 @@ export class ProfileCertificateController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -171,15 +121,18 @@ export class ProfileCertificateController extends Controller {
const history = new ProfileCertificateHistory(); const history = new ProfileCertificateHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileCertificateId = certificateId; history.profileCertificateId = certificateId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.certificateRepo.save(record), this.certificateRepo.save(record),
@ -191,10 +144,14 @@ export class ProfileCertificateController extends Controller {
@Delete("{certificateId}") @Delete("{certificateId}")
public async deleteCertificate(@Path() certificateId: string, @Request() req: RequestWithUser) { public async deleteCertificate(@Path() certificateId: string, @Request() req: RequestWithUser) {
const _record = await this.certificateRepo.findOneBy({ id: certificateId }); const _record = await this.certificateRepo.findOneBy({ id: certificateId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId); await new permission().PermissionOrgUserDelete(
} req,
"SYS_REGISTRY_OFFICER",
_record.profileId,
);
}
await this.certificateHistoryRepo.delete({ await this.certificateHistoryRepo.delete({
profileCertificateId: certificateId, profileCertificateId: certificateId,
}); });

View file

@ -2,7 +2,6 @@ import {
Body, Body,
Controller, Controller,
Delete, Delete,
Example,
Get, Get,
Patch, Patch,
Path, Path,
@ -41,82 +40,36 @@ export class ProfileCertificateEmployeeController extends Controller {
} }
const record = await this.certificateRepo.find({ const record = await this.certificateRepo.find({
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@Get("{profileEmployeeId}") @Get("{profileEmployeeId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "e1ef9c3d-079a-40d8-8332-664c3e9a5a70",
createdAt: "2024-03-12T03:02:27.532Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T03:02:27.532Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
expireDate: "2024-03-12T10:01:48.000Z",
issueDate: "2024-03-12T10:01:48.000Z",
certificateNo: "string",
certificateType: "string",
issuer: "string",
},
],
})
public async getCertificate(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { public async getCertificate(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
const record = await this.certificateRepo.findBy({ profileEmployeeId }); const record = await this.certificateRepo.find({
where: { profileEmployeeId: profileEmployeeId },
order: { createdAt: "ASC" },
});
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@Get("history/{certificateId}") @Get("history/{certificateId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "c0ecf986-b290-44ca-b45e-f4448cdd34dd",
createdAt: "2024-03-12T03:03:30.169Z",
createdUserId: "00000000-0000-0000-0000-000000000000",
lastUpdatedAt: "2024-03-12T03:03:30.169Z",
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
createdFullName: "string",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
expireDate: "2024-03-12T10:03:05.000Z",
issueDate: "2024-03-12T10:03:05.000Z",
certificateNo: "no",
certificateType: "type",
issuer: "issuer",
profileCertificateId: "e1ef9c3d-079a-40d8-8332-664c3e9a5a70",
},
{
id: "dc4c2800-5fc5-4ec3-b19a-c4a27beac35f",
createdAt: "2024-03-12T03:02:27.583Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T03:02:27.583Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
expireDate: "2024-03-12T10:01:48.000Z",
issueDate: "2024-03-12T10:01:48.000Z",
certificateNo: "string",
certificateType: "string",
issuer: "string",
profileCertificateId: "e1ef9c3d-079a-40d8-8332-664c3e9a5a70",
},
],
})
public async certificateHistory(@Path() certificateId: string, @Request() req: RequestWithUser) { public async certificateHistory(@Path() certificateId: string, @Request() req: RequestWithUser) {
const _record = await this.certificateRepo.findOneBy({ id: certificateId }); const _record = await this.certificateRepo.findOneBy({ id: certificateId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); await new permission().PermissionOrgUserGet(
} req,
const record = await this.certificateHistoryRepo.findBy({ "SYS_REGISTRY_EMP",
profileCertificateId: certificateId, _record.profileEmployeeId,
);
}
const record = await this.certificateHistoryRepo.find({
where: {
profileCertificateId: certificateId,
},
order: { createdAt: "DESC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@ -143,6 +96,8 @@ export class ProfileCertificateEmployeeController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -164,20 +119,27 @@ export class ProfileCertificateEmployeeController extends Controller {
) { ) {
const record = await this.certificateRepo.findOneBy({ id: certificateId }); const record = await this.certificateRepo.findOneBy({ id: certificateId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId); await new permission().PermissionOrgUserUpdate(
req,
"SYS_REGISTRY_EMP",
record.profileEmployeeId,
);
const history = new ProfileCertificateHistory(); const history = new ProfileCertificateHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileCertificateId = certificateId; history.profileCertificateId = certificateId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.certificateRepo.save(record), this.certificateRepo.save(record),
@ -191,8 +153,12 @@ export class ProfileCertificateEmployeeController extends Controller {
public async deleteCertificate(@Path() certificateId: string, @Request() req: RequestWithUser) { public async deleteCertificate(@Path() certificateId: string, @Request() req: RequestWithUser) {
const _record = await this.certificateRepo.findOneBy({ id: certificateId }); const _record = await this.certificateRepo.findOneBy({ id: certificateId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); await new permission().PermissionOrgUserDelete(
} req,
"SYS_REGISTRY_EMP",
_record.profileEmployeeId,
);
}
await this.certificateHistoryRepo.delete({ await this.certificateHistoryRepo.delete({
profileCertificateId: certificateId, profileCertificateId: certificateId,
}); });

View file

@ -2,7 +2,6 @@ import {
Body, Body,
Controller, Controller,
Delete, Delete,
Example,
Get, Get,
Patch, Patch,
Path, Path,
@ -41,79 +40,29 @@ export class ProfileCertificateEmployeeTempController extends Controller {
} }
const record = await this.certificateRepo.find({ const record = await this.certificateRepo.find({
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@Get("{profileEmployeeId}") @Get("{profileEmployeeId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "e1ef9c3d-079a-40d8-8332-664c3e9a5a70",
createdAt: "2024-03-12T03:02:27.532Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T03:02:27.532Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
expireDate: "2024-03-12T10:01:48.000Z",
issueDate: "2024-03-12T10:01:48.000Z",
certificateNo: "string",
certificateType: "string",
issuer: "string",
},
],
})
public async getCertificate(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { public async getCertificate(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const record = await this.certificateRepo.findBy({ profileEmployeeId }); const record = await this.certificateRepo.find({
where: { profileEmployeeId },
order: { createdAt: "ASC" },
});
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@Get("history/{certificateId}") @Get("history/{certificateId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "c0ecf986-b290-44ca-b45e-f4448cdd34dd",
createdAt: "2024-03-12T03:03:30.169Z",
createdUserId: "00000000-0000-0000-0000-000000000000",
lastUpdatedAt: "2024-03-12T03:03:30.169Z",
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
createdFullName: "string",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
expireDate: "2024-03-12T10:03:05.000Z",
issueDate: "2024-03-12T10:03:05.000Z",
certificateNo: "no",
certificateType: "type",
issuer: "issuer",
profileCertificateId: "e1ef9c3d-079a-40d8-8332-664c3e9a5a70",
},
{
id: "dc4c2800-5fc5-4ec3-b19a-c4a27beac35f",
createdAt: "2024-03-12T03:02:27.583Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T03:02:27.583Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
expireDate: "2024-03-12T10:01:48.000Z",
issueDate: "2024-03-12T10:01:48.000Z",
certificateNo: "string",
certificateType: "string",
issuer: "string",
profileCertificateId: "e1ef9c3d-079a-40d8-8332-664c3e9a5a70",
},
],
})
public async certificateHistory(@Path() certificateId: string, @Request() req: RequestWithUser) { public async certificateHistory(@Path() certificateId: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const record = await this.certificateHistoryRepo.findBy({ const record = await this.certificateHistoryRepo.find({
profileCertificateId: certificateId, where: {
profileCertificateId: certificateId,
},
order: { createdAt: "DESC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@ -141,6 +90,8 @@ export class ProfileCertificateEmployeeTempController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -168,15 +119,18 @@ export class ProfileCertificateEmployeeTempController extends Controller {
const history = new ProfileCertificateHistory(); const history = new ProfileCertificateHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileCertificateId = certificateId; history.profileCertificateId = certificateId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.certificateRepo.save(record), this.certificateRepo.save(record),

View file

@ -2,7 +2,6 @@ import {
Body, Body,
Controller, Controller,
Delete, Delete,
Example,
Get, Get,
Patch, Patch,
Path, Path,
@ -24,7 +23,6 @@ import {
ProfileChangeName, ProfileChangeName,
UpdateProfileChangeName, UpdateProfileChangeName,
} from "../entities/ProfileChangeName"; } from "../entities/ProfileChangeName";
import CallAPI from "../interfaces/call-api";
import { updateName } from "../keycloak"; import { updateName } from "../keycloak";
import permission from "../interfaces/permission"; import permission from "../interfaces/permission";
@Route("api/v1/org/profile/changeName") @Route("api/v1/org/profile/changeName")
@ -43,61 +41,22 @@ export class ProfileChangeNameController extends Controller {
} }
const lists = await this.changeNameRepository.find({ const lists = await this.changeNameRepository.find({
where: { profileId: profile.id }, where: { profileId: profile.id },
select: ["id", "prefix", "firstName", "lastName", "status"],
order: { createdAt: "ASC" }, order: { createdAt: "ASC" },
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@Get("{profileId}") @Get("{profileId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
prefix: "string",
firstName: "string",
lastName: "string",
status: "string",
},
],
})
public async getChangeName(@Path() profileId: string, @Request() req: RequestWithUser) { public async getChangeName(@Path() profileId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
const lists = await this.changeNameRepository.find({ const lists = await this.changeNameRepository.find({
where: { profileId: profileId }, where: { profileId: profileId },
select: ["id", "prefix", "firstName", "lastName", "status"],
order: { createdAt: "ASC" }, order: { createdAt: "ASC" },
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@Get("history/{changeNameId}") @Get("history/{changeNameId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
prefix: "string",
firstName: "string",
lastName: "string",
status: "string",
createdFullName: "string",
createdAt: "string",
},
{
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
prefix: "string",
firstName: "string",
lastName: "string",
status: "string",
createdFullName: "string",
createdAt: "string",
},
],
})
public async changeNameHistory(@Path() changeNameId: string, @Request() req: RequestWithUser) { public async changeNameHistory(@Path() changeNameId: string, @Request() req: RequestWithUser) {
const _record = await this.changeNameRepository.findOneBy({ id: changeNameId }); const _record = await this.changeNameRepository.findOneBy({ id: changeNameId });
if (_record) { if (_record) {
@ -105,15 +64,6 @@ export class ProfileChangeNameController extends Controller {
} }
const record = await this.changeNameHistoryRepository.find({ const record = await this.changeNameHistoryRepository.find({
where: { profileChangeNameId: changeNameId }, where: { profileChangeNameId: changeNameId },
select: [
"id",
"prefix",
"firstName",
"lastName",
"status",
"lastUpdateFullName",
"lastUpdatedAt",
],
order: { createdAt: "DESC" }, order: { createdAt: "DESC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
@ -141,6 +91,8 @@ export class ProfileChangeNameController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -179,15 +131,18 @@ export class ProfileChangeNameController extends Controller {
const history = new ProfileChangeNameHistory(); const history = new ProfileChangeNameHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileChangeNameId = changeNameId; history.profileChangeNameId = changeNameId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.changeNameRepository.save(record), this.changeNameRepository.save(record),
@ -228,7 +183,11 @@ export class ProfileChangeNameController extends Controller {
public async deleteTraning(@Path() changeNameId: string, @Request() req: RequestWithUser) { public async deleteTraning(@Path() changeNameId: string, @Request() req: RequestWithUser) {
const _record = await this.changeNameRepository.findOneBy({ id: changeNameId }); const _record = await this.changeNameRepository.findOneBy({ id: changeNameId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId); await new permission().PermissionOrgUserDelete(
req,
"SYS_REGISTRY_OFFICER",
_record.profileId,
);
} }
await this.changeNameHistoryRepository.delete({ await this.changeNameHistoryRepository.delete({
profileChangeNameId: changeNameId, profileChangeNameId: changeNameId,

View file

@ -2,7 +2,6 @@ import {
Body, Body,
Controller, Controller,
Delete, Delete,
Example,
Get, Get,
Patch, Patch,
Path, Path,
@ -18,9 +17,7 @@ import HttpStatus from "../interfaces/http-status";
import HttpError from "../interfaces/http-error"; import HttpError from "../interfaces/http-error";
import { ProfileChangeNameHistory } from "../entities/ProfileChangeNameHistory"; import { ProfileChangeNameHistory } from "../entities/ProfileChangeNameHistory";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import { Profile } from "../entities/Profile";
import { import {
CreateProfileChangeName,
CreateProfileChangeNameEmployee, CreateProfileChangeNameEmployee,
ProfileChangeName, ProfileChangeName,
UpdateProfileChangeName, UpdateProfileChangeName,
@ -44,78 +41,33 @@ export class ProfileChangeNameEmployeeController extends Controller {
} }
const lists = await this.changeNameRepository.find({ const lists = await this.changeNameRepository.find({
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
select: ["id", "prefix", "firstName", "lastName", "status"],
order: { createdAt: "ASC" }, order: { createdAt: "ASC" },
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@Get("{profileEmployeeId}") @Get("{profileEmployeeId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
prefix: "string",
firstName: "string",
lastName: "string",
status: "string",
},
],
})
public async getChangeName(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { public async getChangeName(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
const lists = await this.changeNameRepository.find({ const lists = await this.changeNameRepository.find({
where: { profileEmployeeId: profileEmployeeId }, where: { profileEmployeeId: profileEmployeeId },
select: ["id", "prefix", "firstName", "lastName", "status"],
order: { createdAt: "ASC" }, order: { createdAt: "ASC" },
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@Get("history/{changeNameId}") @Get("history/{changeNameId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
prefix: "string",
firstName: "string",
lastName: "string",
status: "string",
createdFullName: "string",
createdAt: "string",
},
{
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
prefix: "string",
firstName: "string",
lastName: "string",
status: "string",
createdFullName: "string",
createdAt: "string",
},
],
})
public async changeNameHistory(@Path() changeNameId: string, @Request() req: RequestWithUser) { public async changeNameHistory(@Path() changeNameId: string, @Request() req: RequestWithUser) {
const _record = await this.changeNameRepository.findOneBy({ id: changeNameId }); const _record = await this.changeNameRepository.findOneBy({ id: changeNameId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId, await new permission().PermissionOrgUserGet(
); req,
} "SYS_REGISTRY_EMP",
_record.profileEmployeeId,
);
}
const record = await this.changeNameHistoryRepository.find({ const record = await this.changeNameHistoryRepository.find({
where: { profileChangeNameId: changeNameId }, where: { profileChangeNameId: changeNameId },
select: [
"id",
"prefix",
"firstName",
"lastName",
"status",
"lastUpdateFullName",
"lastUpdatedAt",
],
order: { createdAt: "DESC" }, order: { createdAt: "DESC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
@ -143,6 +95,8 @@ export class ProfileChangeNameEmployeeController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -176,20 +130,27 @@ export class ProfileChangeNameEmployeeController extends Controller {
) { ) {
const record = await this.changeNameRepository.findOneBy({ id: changeNameId }); const record = await this.changeNameRepository.findOneBy({ id: changeNameId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId); await new permission().PermissionOrgUserUpdate(
req,
"SYS_REGISTRY_EMP",
record.profileEmployeeId,
);
const history = new ProfileChangeNameHistory(); const history = new ProfileChangeNameHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileChangeNameId = changeNameId; history.profileChangeNameId = changeNameId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.changeNameRepository.save(record), this.changeNameRepository.save(record),
@ -220,10 +181,14 @@ export class ProfileChangeNameEmployeeController extends Controller {
@Delete("{changeNameId}") @Delete("{changeNameId}")
public async deleteTraning(@Path() changeNameId: string, @Request() req: RequestWithUser) { public async deleteTraning(@Path() changeNameId: string, @Request() req: RequestWithUser) {
const _record = await this.changeNameRepository.findOneBy({ id: changeNameId }); const _record = await this.changeNameRepository.findOneBy({ id: changeNameId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); await new permission().PermissionOrgUserDelete(
} req,
"SYS_REGISTRY_EMP",
_record.profileEmployeeId,
);
}
await this.changeNameHistoryRepository.delete({ await this.changeNameHistoryRepository.delete({
profileChangeNameId: changeNameId, profileChangeNameId: changeNameId,
}); });

View file

@ -2,7 +2,6 @@ import {
Body, Body,
Controller, Controller,
Delete, Delete,
Example,
Get, Get,
Patch, Patch,
Path, Path,
@ -18,9 +17,7 @@ import HttpStatus from "../interfaces/http-status";
import HttpError from "../interfaces/http-error"; import HttpError from "../interfaces/http-error";
import { ProfileChangeNameHistory } from "../entities/ProfileChangeNameHistory"; import { ProfileChangeNameHistory } from "../entities/ProfileChangeNameHistory";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import { Profile } from "../entities/Profile";
import { import {
CreateProfileChangeName,
CreateProfileChangeNameEmployee, CreateProfileChangeNameEmployee,
ProfileChangeName, ProfileChangeName,
UpdateProfileChangeName, UpdateProfileChangeName,
@ -44,74 +41,26 @@ export class ProfileChangeNameEmployeeTempController extends Controller {
} }
const lists = await this.changeNameRepository.find({ const lists = await this.changeNameRepository.find({
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
select: ["id", "prefix", "firstName", "lastName", "status"],
order: { createdAt: "ASC" }, order: { createdAt: "ASC" },
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@Get("{profileEmployeeId}") @Get("{profileEmployeeId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
prefix: "string",
firstName: "string",
lastName: "string",
status: "string",
},
],
})
public async getChangeName(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { public async getChangeName(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const lists = await this.changeNameRepository.find({ const lists = await this.changeNameRepository.find({
where: { profileEmployeeId: profileEmployeeId }, where: { profileEmployeeId: profileEmployeeId },
select: ["id", "prefix", "firstName", "lastName", "status"],
order: { createdAt: "ASC" }, order: { createdAt: "ASC" },
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@Get("history/{changeNameId}") @Get("history/{changeNameId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
prefix: "string",
firstName: "string",
lastName: "string",
status: "string",
createdFullName: "string",
createdAt: "string",
},
{
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
prefix: "string",
firstName: "string",
lastName: "string",
status: "string",
createdFullName: "string",
createdAt: "string",
},
],
})
public async changeNameHistory(@Path() changeNameId: string, @Request() req: RequestWithUser) { public async changeNameHistory(@Path() changeNameId: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const record = await this.changeNameHistoryRepository.find({ const record = await this.changeNameHistoryRepository.find({
where: { profileChangeNameId: changeNameId }, where: { profileChangeNameId: changeNameId },
select: [
"id",
"prefix",
"firstName",
"lastName",
"status",
"lastUpdateFullName",
"lastUpdatedAt",
],
order: { createdAt: "DESC" }, order: { createdAt: "DESC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
@ -140,6 +89,8 @@ export class ProfileChangeNameEmployeeTempController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -179,15 +130,18 @@ export class ProfileChangeNameEmployeeTempController extends Controller {
const history = new ProfileChangeNameHistory(); const history = new ProfileChangeNameHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileChangeNameId = changeNameId; history.profileChangeNameId = changeNameId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.changeNameRepository.save(record), this.changeNameRepository.save(record),

View file

@ -2,7 +2,6 @@ import {
Body, Body,
Controller, Controller,
Delete, Delete,
Example,
Get, Get,
Patch, Patch,
Path, Path,
@ -42,6 +41,7 @@ export class ProfileChildrenController extends Controller {
} }
const lists = await this.childrenRepository.find({ const lists = await this.childrenRepository.find({
where: { profileId: profile.id }, where: { profileId: profile.id },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@ -51,6 +51,7 @@ export class ProfileChildrenController extends Controller {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
const lists = await this.childrenRepository.find({ const lists = await this.childrenRepository.find({
where: { profileId: profileId }, where: { profileId: profileId },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@ -82,6 +83,8 @@ export class ProfileChildrenController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -109,16 +112,19 @@ export class ProfileChildrenController extends Controller {
const history = new ProfileChildrenHistory(); const history = new ProfileChildrenHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
record.childrenCitizenId = Extension.CheckCitizen(String(record.childrenCitizenId)); record.childrenCitizenId = Extension.CheckCitizen(String(record.childrenCitizenId));
history.profileChildrenId = record.id; history.profileChildrenId = record.id;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.childrenRepository.save(record), this.childrenRepository.save(record),
this.childrenHistoryRepository.save(history), this.childrenHistoryRepository.save(history),
@ -131,7 +137,11 @@ export class ProfileChildrenController extends Controller {
public async deleteTraning(@Path() childrenId: string, @Request() req: RequestWithUser) { public async deleteTraning(@Path() childrenId: string, @Request() req: RequestWithUser) {
const _record = await this.childrenRepository.findOneBy({ id: childrenId }); const _record = await this.childrenRepository.findOneBy({ id: childrenId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId); await new permission().PermissionOrgUserDelete(
req,
"SYS_REGISTRY_OFFICER",
_record.profileId,
);
} }
await this.childrenHistoryRepository.delete({ await this.childrenHistoryRepository.delete({
profileChildrenId: childrenId, profileChildrenId: childrenId,

View file

@ -2,7 +2,6 @@ import {
Body, Body,
Controller, Controller,
Delete, Delete,
Example,
Get, Get,
Patch, Patch,
Path, Path,
@ -18,9 +17,7 @@ import HttpStatus from "../interfaces/http-status";
import HttpError from "../interfaces/http-error"; import HttpError from "../interfaces/http-error";
import { ProfileChildrenHistory } from "../entities/ProfileChildrenHistory"; import { ProfileChildrenHistory } from "../entities/ProfileChildrenHistory";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import { Profile } from "../entities/Profile";
import { import {
CreateProfileChildren,
CreateProfileChildrenEmployee, CreateProfileChildrenEmployee,
ProfileChildren, ProfileChildren,
UpdateProfileChildren, UpdateProfileChildren,
@ -44,6 +41,7 @@ export class ProfileChildrenEmployeeController extends Controller {
} }
const lists = await this.childrenRepository.find({ const lists = await this.childrenRepository.find({
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@ -53,17 +51,21 @@ export class ProfileChildrenEmployeeController extends Controller {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
const lists = await this.childrenRepository.find({ const lists = await this.childrenRepository.find({
where: { profileEmployeeId: profileEmployeeId }, where: { profileEmployeeId: profileEmployeeId },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@Get("history/{childrenId}") @Get("history/{childrenId}")
public async childrenHistory(@Path() childrenId: string, @Request() req: RequestWithUser) { public async childrenHistory(@Path() childrenId: string, @Request() req: RequestWithUser) {
const _record = await this.childrenRepository.findOneBy({ id: childrenId }); const _record = await this.childrenRepository.findOneBy({ id: childrenId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId, await new permission().PermissionOrgUserGet(
); req,
} "SYS_REGISTRY_EMP",
_record.profileEmployeeId,
);
}
const record = await this.childrenHistoryRepository.find({ const record = await this.childrenHistoryRepository.find({
where: { profileChildrenId: childrenId }, where: { profileChildrenId: childrenId },
order: { createdAt: "DESC" }, order: { createdAt: "DESC" },
@ -89,6 +91,8 @@ export class ProfileChildrenEmployeeController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -112,20 +116,27 @@ export class ProfileChildrenEmployeeController extends Controller {
) { ) {
const record = await this.childrenRepository.findOneBy({ id: childrenId }); const record = await this.childrenRepository.findOneBy({ id: childrenId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId); await new permission().PermissionOrgUserUpdate(
req,
"SYS_REGISTRY_EMP",
record.profileEmployeeId,
);
const history = new ProfileChildrenHistory(); const history = new ProfileChildrenHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
record.childrenCitizenId = Extension.CheckCitizen(String(record.childrenCitizenId)); record.childrenCitizenId = Extension.CheckCitizen(String(record.childrenCitizenId));
history.profileChildrenId = record.id; history.profileChildrenId = record.id;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.childrenRepository.save(record), this.childrenRepository.save(record),
@ -139,7 +150,11 @@ export class ProfileChildrenEmployeeController extends Controller {
public async deleteTraning(@Path() childrenId: string, @Request() req: RequestWithUser) { public async deleteTraning(@Path() childrenId: string, @Request() req: RequestWithUser) {
const _record = await this.childrenRepository.findOneBy({ id: childrenId }); const _record = await this.childrenRepository.findOneBy({ id: childrenId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); await new permission().PermissionOrgUserDelete(
req,
"SYS_REGISTRY_EMP",
_record.profileEmployeeId,
);
} }
await this.childrenHistoryRepository.delete({ await this.childrenHistoryRepository.delete({
profileChildrenId: childrenId, profileChildrenId: childrenId,

View file

@ -2,7 +2,6 @@ import {
Body, Body,
Controller, Controller,
Delete, Delete,
Example,
Get, Get,
Patch, Patch,
Path, Path,
@ -18,9 +17,7 @@ import HttpStatus from "../interfaces/http-status";
import HttpError from "../interfaces/http-error"; import HttpError from "../interfaces/http-error";
import { ProfileChildrenHistory } from "../entities/ProfileChildrenHistory"; import { ProfileChildrenHistory } from "../entities/ProfileChildrenHistory";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import { Profile } from "../entities/Profile";
import { import {
CreateProfileChildren,
CreateProfileChildrenEmployee, CreateProfileChildrenEmployee,
ProfileChildren, ProfileChildren,
UpdateProfileChildren, UpdateProfileChildren,
@ -44,6 +41,7 @@ export class ProfileChildrenEmployeeTempController extends Controller {
} }
const lists = await this.childrenRepository.find({ const lists = await this.childrenRepository.find({
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@ -53,6 +51,7 @@ export class ProfileChildrenEmployeeTempController extends Controller {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const lists = await this.childrenRepository.find({ const lists = await this.childrenRepository.find({
where: { profileEmployeeId: profileEmployeeId }, where: { profileEmployeeId: profileEmployeeId },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@ -86,6 +85,8 @@ export class ProfileChildrenEmployeeTempController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -112,16 +113,19 @@ export class ProfileChildrenEmployeeTempController extends Controller {
const history = new ProfileChildrenHistory(); const history = new ProfileChildrenHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
record.childrenCitizenId = Extension.CheckCitizen(String(record.childrenCitizenId)); record.childrenCitizenId = Extension.CheckCitizen(String(record.childrenCitizenId));
history.profileChildrenId = record.id; history.profileChildrenId = record.id;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.childrenRepository.save(record), this.childrenRepository.save(record),

View file

@ -1419,6 +1419,8 @@ export class ProfileController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}); });
await Promise.all([this.salaryRepository.save(profileSalary)]); await Promise.all([this.salaryRepository.save(profileSalary)]);
} }
@ -1498,6 +1500,8 @@ export class ProfileController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}); });
await Promise.all([this.profileRepo.save(_profile), this.salaryRepository.save(profileSalary)]); await Promise.all([this.profileRepo.save(_profile), this.salaryRepository.save(profileSalary)]);
@ -1576,6 +1580,8 @@ export class ProfileController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}); });
await Promise.all([this.profileRepo.save(_profile), this.salaryRepository.save(profileSalary)]); await Promise.all([this.profileRepo.save(_profile), this.salaryRepository.save(profileSalary)]);
@ -1654,6 +1660,8 @@ export class ProfileController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}); });
// //เพิ่มวินัย // //เพิ่มวินัย
// const profileDiscipline: ProfileDiscipline = Object.assign(new ProfileDiscipline(), { // const profileDiscipline: ProfileDiscipline = Object.assign(new ProfileDiscipline(), {
@ -1663,7 +1671,9 @@ export class ProfileController extends Controller {
// createdUserId: req.user.sub, // createdUserId: req.user.sub,
// createdFullName: req.user.name, // createdFullName: req.user.name,
// lastUpdateUserId: req.user.sub, // lastUpdateUserId: req.user.sub,
// lastUpdateFullName: req.user.name, // lastUpdateFullName: req.user.name,
// createdAt: new Date(),
// lastUpdatedAt: new Date(),
// }); // });
await Promise.all([ await Promise.all([
this.profileRepo.save(_profile), this.profileRepo.save(_profile),
@ -1746,6 +1756,8 @@ export class ProfileController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}); });
await Promise.all([this.profileRepo.save(_profile), this.salaryRepository.save(profileSalary)]); await Promise.all([this.profileRepo.save(_profile), this.salaryRepository.save(profileSalary)]);
@ -1824,6 +1836,8 @@ export class ProfileController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}); });
await Promise.all([this.profileRepo.save(_profile), this.salaryRepository.save(profileSalary)]); await Promise.all([this.profileRepo.save(_profile), this.salaryRepository.save(profileSalary)]);
@ -1895,6 +1909,8 @@ export class ProfileController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}); });
await Promise.all([this.salaryRepository.save(profileSalary)]); await Promise.all([this.salaryRepository.save(profileSalary)]);
@ -1966,6 +1982,8 @@ export class ProfileController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}); });
await Promise.all([this.salaryRepository.save(profileSalary)]); await Promise.all([this.salaryRepository.save(profileSalary)]);
@ -2037,6 +2055,8 @@ export class ProfileController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}); });
await Promise.all([this.salaryRepository.save(profileSalary)]); await Promise.all([this.salaryRepository.save(profileSalary)]);
@ -2108,6 +2128,8 @@ export class ProfileController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}); });
await Promise.all([this.salaryRepository.save(profileSalary)]); await Promise.all([this.salaryRepository.save(profileSalary)]);
@ -2179,6 +2201,8 @@ export class ProfileController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}); });
await Promise.all([this.salaryRepository.save(profileSalary)]); await Promise.all([this.salaryRepository.save(profileSalary)]);
@ -2250,7 +2274,9 @@ export class ProfileController extends Controller {
// createdUserId: req.user.sub, // createdUserId: req.user.sub,
// createdFullName: req.user.name, // createdFullName: req.user.name,
// lastUpdateUserId: req.user.sub, // lastUpdateUserId: req.user.sub,
// lastUpdateFullName: req.user.name, // lastUpdateFullName: req.user.name,
// createdAt: new Date(),
// lastUpdatedAt: new Date(),
// }); // });
await Promise.all([this.profileRepo.save(profile)]); await Promise.all([this.profileRepo.save(profile)]);

View file

@ -2,7 +2,6 @@ import {
Body, Body,
Controller, Controller,
Delete, Delete,
Example,
Get, Get,
Patch, Patch,
Path, Path,
@ -41,53 +40,22 @@ export class ProfileDevelopmentController extends Controller {
} }
const lists = await this.developmentRepository.find({ const lists = await this.developmentRepository.find({
where: { profileId: profile.id }, where: { profileId: profile.id },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@Get("{profileId}") @Get("{profileId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
isActive: true,
date: "2024-03-12T10:09:47.000Z",
reference: "string",
detail: "string",
refCommandNo: "string",
refCommandDate: "2024-03-12T10:09:47.000Z",
},
],
})
public async getDevelopment(@Path() profileId: string, @Request() req: RequestWithUser) { public async getDevelopment(@Path() profileId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
const lists = await this.developmentRepository.find({ const lists = await this.developmentRepository.find({
where: { profileId: profileId }, where: { profileId: profileId },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@Get("history/{developmentId}") @Get("history/{developmentId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
isActive: true,
date: "2024-03-12T10:09:47.000Z",
detail: "string",
},
{
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
isActive: true,
date: "2024-03-12T10:09:47.000Z",
detail: "string",
},
],
})
public async developmentHistory(@Path() developmentId: string, @Request() req: RequestWithUser) { public async developmentHistory(@Path() developmentId: string, @Request() req: RequestWithUser) {
const _record = await this.developmentRepository.findOneBy({ id: developmentId }); const _record = await this.developmentRepository.findOneBy({ id: developmentId });
if (_record) { if (_record) {
@ -122,6 +90,8 @@ export class ProfileDevelopmentController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -150,15 +120,18 @@ export class ProfileDevelopmentController extends Controller {
const history = new ProfileDevelopmentHistory(); const history = new ProfileDevelopmentHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileDevelopmentId = developmentId; history.profileDevelopmentId = developmentId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.developmentRepository.save(record), this.developmentRepository.save(record),

View file

@ -2,7 +2,6 @@ import {
Body, Body,
Controller, Controller,
Delete, Delete,
Example,
Get, Get,
Patch, Patch,
Path, Path,
@ -41,6 +40,7 @@ export class ProfileDevelopmentEmployeeController extends Controller {
} }
const lists = await this.developmentRepository.find({ const lists = await this.developmentRepository.find({
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@ -50,6 +50,7 @@ export class ProfileDevelopmentEmployeeController extends Controller {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId);
const lists = await this.developmentRepository.find({ const lists = await this.developmentRepository.find({
where: { profileEmployeeId: profileId }, where: { profileEmployeeId: profileId },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@ -93,6 +94,8 @@ export class ProfileDevelopmentEmployeeController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -125,15 +128,18 @@ export class ProfileDevelopmentEmployeeController extends Controller {
const history = new ProfileDevelopmentHistory(); const history = new ProfileDevelopmentHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileDevelopmentId = developmentId; history.profileDevelopmentId = developmentId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.developmentRepository.save(record), this.developmentRepository.save(record),

View file

@ -2,7 +2,6 @@ import {
Body, Body,
Controller, Controller,
Delete, Delete,
Example,
Get, Get,
Patch, Patch,
Path, Path,
@ -41,6 +40,7 @@ export class ProfileDevelopmentEmployeeTempController extends Controller {
} }
const lists = await this.developmentRepository.find({ const lists = await this.developmentRepository.find({
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@ -50,6 +50,7 @@ export class ProfileDevelopmentEmployeeTempController extends Controller {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const lists = await this.developmentRepository.find({ const lists = await this.developmentRepository.find({
where: { profileEmployeeId: profileId }, where: { profileEmployeeId: profileId },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@ -87,6 +88,8 @@ export class ProfileDevelopmentEmployeeTempController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -116,15 +119,18 @@ export class ProfileDevelopmentEmployeeTempController extends Controller {
const history = new ProfileDevelopmentHistory(); const history = new ProfileDevelopmentHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileDevelopmentId = developmentId; history.profileDevelopmentId = developmentId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.developmentRepository.save(record), this.developmentRepository.save(record),

View file

@ -2,7 +2,6 @@ import {
Body, Body,
Controller, Controller,
Delete, Delete,
Example,
Get, Get,
Patch, Patch,
Path, Path,
@ -41,17 +40,7 @@ export class ProfileDisciplineController extends Controller {
} }
const lists = await this.disciplineRepository.find({ const lists = await this.disciplineRepository.find({
where: { profileId: profile.id }, where: { profileId: profile.id },
select: [ order: { createdAt: "ASC" },
"id",
"date",
"level",
"detail",
"unStigma",
"refCommandNo",
"refCommandDate",
"lastUpdateFullName",
"lastUpdatedAt",
],
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@ -61,17 +50,7 @@ export class ProfileDisciplineController extends Controller {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
const lists = await this.disciplineRepository.find({ const lists = await this.disciplineRepository.find({
where: { profileId: profileId }, where: { profileId: profileId },
select: [ order: { createdAt: "ASC" },
"id",
"date",
"level",
"detail",
"unStigma",
"refCommandNo",
"refCommandDate",
"lastUpdateFullName",
"lastUpdatedAt",
],
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@ -81,46 +60,12 @@ export class ProfileDisciplineController extends Controller {
await new permission().PermissionGet(req, "SYS_SALARY_OFFICER"); await new permission().PermissionGet(req, "SYS_SALARY_OFFICER");
const lists = await this.disciplineRepository.find({ const lists = await this.disciplineRepository.find({
where: { profileId: profileId }, where: { profileId: profileId },
select: [ order: { createdAt: "ASC" },
"id",
"date",
"level",
"detail",
"unStigma",
"refCommandNo",
"refCommandDate",
"lastUpdateFullName",
"lastUpdatedAt",
],
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@Get("history/{disciplineId}") @Get("history/{disciplineId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
date: "2024-03-12T10:09:47.000Z",
level: "string",
detail: "string",
unStigma: "string",
refCommandNo: "string",
refCommandDate: "2024-03-12T10:09:47.000Z",
},
{
id: "ba0e2f82-014e-46c6-8b82-a7c28eb5325f",
date: "2024-03-12T10:09:47.000Z",
level: "string",
detail: "string",
unStigma: "string",
refCommandNo: "string",
refCommandDate: "2024-03-12T10:09:47.000Z",
},
],
})
public async disciplineHistory(@Path() disciplineId: string, @Request() req: RequestWithUser) { public async disciplineHistory(@Path() disciplineId: string, @Request() req: RequestWithUser) {
const _record = await this.disciplineRepository.findOneBy({ id: disciplineId }); const _record = await this.disciplineRepository.findOneBy({ id: disciplineId });
if (_record) { if (_record) {
@ -128,17 +73,6 @@ export class ProfileDisciplineController extends Controller {
} }
const record = await this.disciplineHistoryRepository.find({ const record = await this.disciplineHistoryRepository.find({
where: { profileDisciplineId: disciplineId }, where: { profileDisciplineId: disciplineId },
select: [
"id",
"date",
"level",
"detail",
"unStigma",
"refCommandNo",
"refCommandDate",
"lastUpdateFullName",
"lastUpdatedAt",
],
order: { createdAt: "DESC" }, order: { createdAt: "DESC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
@ -167,6 +101,8 @@ export class ProfileDisciplineController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -193,15 +129,18 @@ export class ProfileDisciplineController extends Controller {
const history = new ProfileDisciplineHistory(); const history = new ProfileDisciplineHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileDisciplineId = disciplineId; history.profileDisciplineId = disciplineId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.disciplineRepository.save(record), this.disciplineRepository.save(record),
@ -215,7 +154,11 @@ export class ProfileDisciplineController extends Controller {
public async deleteDiscipline(@Path() disciplineId: string, @Request() req: RequestWithUser) { public async deleteDiscipline(@Path() disciplineId: string, @Request() req: RequestWithUser) {
const _record = await this.disciplineRepository.findOneBy({ id: disciplineId }); const _record = await this.disciplineRepository.findOneBy({ id: disciplineId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId); await new permission().PermissionOrgUserDelete(
req,
"SYS_REGISTRY_OFFICER",
_record.profileId,
);
} }
await this.disciplineHistoryRepository.delete({ await this.disciplineHistoryRepository.delete({
profileDisciplineId: disciplineId, profileDisciplineId: disciplineId,

View file

@ -2,7 +2,6 @@ import {
Body, Body,
Controller, Controller,
Delete, Delete,
Example,
Get, Get,
Patch, Patch,
Path, Path,
@ -41,52 +40,17 @@ export class ProfileDisciplineEmployeeController extends Controller {
} }
const lists = await this.disciplineRepository.find({ const lists = await this.disciplineRepository.find({
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
select: [ order: { createdAt: "ASC" },
"id",
"date",
"level",
"detail",
"unStigma",
"refCommandNo",
"refCommandDate",
"lastUpdateFullName",
"lastUpdatedAt",
],
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@Get("{profileId}") @Get("{profileId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
date: "2024-03-12T10:09:47.000Z",
level: "string",
detail: "string",
unStigma: "string",
refCommandNo: "string",
refCommandDate: "2024-03-12T10:09:47.000Z",
},
],
})
public async getDiscipline(@Path() profileId: string, @Request() req: RequestWithUser) { public async getDiscipline(@Path() profileId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId);
const lists = await this.disciplineRepository.find({ const lists = await this.disciplineRepository.find({
where: { profileEmployeeId: profileId }, where: { profileEmployeeId: profileId },
select: [ order: { createdAt: "ASC" },
"id",
"date",
"level",
"detail",
"unStigma",
"refCommandNo",
"refCommandDate",
"lastUpdateFullName",
"lastUpdatedAt",
],
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@ -96,17 +60,7 @@ export class ProfileDisciplineEmployeeController extends Controller {
await new permission().PermissionGet(req, "SYS_WAGE"); await new permission().PermissionGet(req, "SYS_WAGE");
const lists = await this.disciplineRepository.find({ const lists = await this.disciplineRepository.find({
where: { profileEmployeeId: profileId }, where: { profileEmployeeId: profileId },
select: [ order: { createdAt: "ASC" },
"id",
"date",
"level",
"detail",
"unStigma",
"refCommandNo",
"refCommandDate",
"lastUpdateFullName",
"lastUpdatedAt",
],
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@ -115,21 +69,14 @@ export class ProfileDisciplineEmployeeController extends Controller {
public async disciplineHistory(@Path() disciplineId: string, @Request() req: RequestWithUser) { public async disciplineHistory(@Path() disciplineId: string, @Request() req: RequestWithUser) {
const _record = await this.disciplineRepository.findOneBy({ id: disciplineId }); const _record = await this.disciplineRepository.findOneBy({ id: disciplineId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); await new permission().PermissionOrgUserGet(
req,
"SYS_REGISTRY_EMP",
_record.profileEmployeeId,
);
} }
const record = await this.disciplineHistoryRepository.find({ const record = await this.disciplineHistoryRepository.find({
where: { profileDisciplineId: disciplineId }, where: { profileDisciplineId: disciplineId },
select: [
"id",
"date",
"level",
"detail",
"unStigma",
"refCommandNo",
"refCommandDate",
"lastUpdateFullName",
"lastUpdatedAt",
],
order: { createdAt: "DESC" }, order: { createdAt: "DESC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
@ -157,6 +104,8 @@ export class ProfileDisciplineEmployeeController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -178,20 +127,27 @@ export class ProfileDisciplineEmployeeController extends Controller {
) { ) {
const record = await this.disciplineRepository.findOneBy({ id: disciplineId }); const record = await this.disciplineRepository.findOneBy({ id: disciplineId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId) await new permission().PermissionOrgUserUpdate(
req,
"SYS_REGISTRY_EMP",
record.profileEmployeeId,
);
const history = new ProfileDisciplineHistory(); const history = new ProfileDisciplineHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileDisciplineId = disciplineId; history.profileDisciplineId = disciplineId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.disciplineRepository.save(record), this.disciplineRepository.save(record),
@ -205,7 +161,11 @@ export class ProfileDisciplineEmployeeController extends Controller {
public async deleteDiscipline(@Path() disciplineId: string, @Request() req: RequestWithUser) { public async deleteDiscipline(@Path() disciplineId: string, @Request() req: RequestWithUser) {
const _record = await this.disciplineRepository.findOneBy({ id: disciplineId }); const _record = await this.disciplineRepository.findOneBy({ id: disciplineId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); await new permission().PermissionOrgUserDelete(
req,
"SYS_REGISTRY_EMP",
_record.profileEmployeeId,
);
} }
await this.disciplineHistoryRepository.delete({ await this.disciplineHistoryRepository.delete({
profileDisciplineId: disciplineId, profileDisciplineId: disciplineId,

View file

@ -2,7 +2,6 @@ import {
Body, Body,
Controller, Controller,
Delete, Delete,
Example,
Get, Get,
Patch, Patch,
Path, Path,
@ -41,52 +40,17 @@ export class ProfileDisciplineEmployeeTempController extends Controller {
} }
const lists = await this.disciplineRepository.find({ const lists = await this.disciplineRepository.find({
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
select: [ order: { createdAt: "ASC" },
"id",
"date",
"level",
"detail",
"unStigma",
"refCommandNo",
"refCommandDate",
"lastUpdateFullName",
"lastUpdatedAt",
],
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@Get("{profileId}") @Get("{profileId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
date: "2024-03-12T10:09:47.000Z",
level: "string",
detail: "string",
unStigma: "string",
refCommandNo: "string",
refCommandDate: "2024-03-12T10:09:47.000Z",
},
],
})
public async getDiscipline(@Path() profileId: string, @Request() req: RequestWithUser) { public async getDiscipline(@Path() profileId: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const lists = await this.disciplineRepository.find({ const lists = await this.disciplineRepository.find({
where: { profileEmployeeId: profileId }, where: { profileEmployeeId: profileId },
select: [ order: { createdAt: "ASC" },
"id",
"date",
"level",
"detail",
"unStigma",
"refCommandNo",
"refCommandDate",
"lastUpdateFullName",
"lastUpdatedAt",
],
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@ -96,17 +60,7 @@ export class ProfileDisciplineEmployeeTempController extends Controller {
await new permission().PermissionGet(req, "SYS_WAGE"); await new permission().PermissionGet(req, "SYS_WAGE");
const lists = await this.disciplineRepository.find({ const lists = await this.disciplineRepository.find({
where: { profileEmployeeId: profileId }, where: { profileEmployeeId: profileId },
select: [ order: { createdAt: "ASC" },
"id",
"date",
"level",
"detail",
"unStigma",
"refCommandNo",
"refCommandDate",
"lastUpdateFullName",
"lastUpdatedAt",
],
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@ -116,17 +70,6 @@ export class ProfileDisciplineEmployeeTempController extends Controller {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const record = await this.disciplineHistoryRepository.find({ const record = await this.disciplineHistoryRepository.find({
where: { profileDisciplineId: disciplineId }, where: { profileDisciplineId: disciplineId },
select: [
"id",
"date",
"level",
"detail",
"unStigma",
"refCommandNo",
"refCommandDate",
"lastUpdateFullName",
"lastUpdatedAt",
],
order: { createdAt: "DESC" }, order: { createdAt: "DESC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
@ -155,6 +98,8 @@ export class ProfileDisciplineEmployeeTempController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -182,15 +127,18 @@ export class ProfileDisciplineEmployeeTempController extends Controller {
const history = new ProfileDisciplineHistory(); const history = new ProfileDisciplineHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileDisciplineId = disciplineId; history.profileDisciplineId = disciplineId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.disciplineRepository.save(record), this.disciplineRepository.save(record),

View file

@ -2,7 +2,6 @@ import {
Body, Body,
Controller, Controller,
Delete, Delete,
Example,
Get, Get,
Patch, Patch,
Path, Path,
@ -37,77 +36,22 @@ export class ProfileDutyController extends Controller {
} }
const lists = await this.dutyRepository.find({ const lists = await this.dutyRepository.find({
where: { profileId: profile.id }, where: { profileId: profile.id },
select: [ order: { createdAt: "ASC" },
"id",
"dateStart",
"dateEnd",
"reference",
"detail",
"refCommandNo",
"refCommandDate",
],
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@Get("{profileId}") @Get("{profileId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
dateStart: "2024-03-12T10:09:47.000Z",
dateEnd: "string",
reference: "string",
detail: "string",
refCommandNo: "string",
refCommandDate: "2024-03-12T10:09:47.000Z",
},
],
})
public async getDuty(@Path() profileId: string, @Request() req: RequestWithUser) { public async getDuty(@Path() profileId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
const lists = await this.dutyRepository.find({ const lists = await this.dutyRepository.find({
where: { profileId: profileId }, where: { profileId: profileId },
select: [ order: { createdAt: "ASC" },
"id",
"dateStart",
"dateEnd",
"reference",
"detail",
"refCommandNo",
"refCommandDate",
],
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@Get("history/{dutyId}") @Get("history/{dutyId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
dateStart: "2024-03-12T10:09:47.000Z",
dateEnd: "string",
reference: "string",
detail: "string",
refCommandNo: "string",
refCommandDate: "2024-03-12T10:09:47.000Z",
},
{
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
dateStart: "2024-03-12T10:09:47.000Z",
dateEnd: "string",
reference: "string",
detail: "string",
refCommandNo: "string",
refCommandDate: "2024-03-12T10:09:47.000Z",
},
],
})
public async dutyHistory(@Path() dutyId: string, @Request() req: RequestWithUser) { public async dutyHistory(@Path() dutyId: string, @Request() req: RequestWithUser) {
const _record = await this.dutyRepository.findOneBy({ id: dutyId }); const _record = await this.dutyRepository.findOneBy({ id: dutyId });
if (_record) { if (_record) {
@ -115,17 +59,6 @@ export class ProfileDutyController extends Controller {
} }
const record = await this.dutyHistoryRepository.find({ const record = await this.dutyHistoryRepository.find({
where: { profileDutyId: dutyId }, where: { profileDutyId: dutyId },
select: [
"id",
"dateStart",
"dateEnd",
"reference",
"detail",
"refCommandNo",
"refCommandDate",
"lastUpdateFullName",
"lastUpdatedAt",
],
order: { createdAt: "DESC" }, order: { createdAt: "DESC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
@ -150,6 +83,8 @@ export class ProfileDutyController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -176,15 +111,18 @@ export class ProfileDutyController extends Controller {
const history = new ProfileDutyHistory(); const history = new ProfileDutyHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileDutyId = dutyId; history.profileDutyId = dutyId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([this.dutyRepository.save(record), this.dutyHistoryRepository.save(history)]); await Promise.all([this.dutyRepository.save(record), this.dutyHistoryRepository.save(history)]);

View file

@ -2,7 +2,6 @@ import {
Body, Body,
Controller, Controller,
Delete, Delete,
Example,
Get, Get,
Patch, Patch,
Path, Path,
@ -37,15 +36,7 @@ export class ProfileDutyEmployeeController extends Controller {
} }
const lists = await this.dutyRepository.find({ const lists = await this.dutyRepository.find({
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
select: [ order: { createdAt: "ASC" },
"id",
"dateStart",
"dateEnd",
"reference",
"detail",
"refCommandNo",
"refCommandDate",
],
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@ -55,15 +46,7 @@ export class ProfileDutyEmployeeController extends Controller {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId);
const lists = await this.dutyRepository.find({ const lists = await this.dutyRepository.find({
where: { profileEmployeeId: profileId }, where: { profileEmployeeId: profileId },
select: [ order: { createdAt: "ASC" },
"id",
"dateStart",
"dateEnd",
"reference",
"detail",
"refCommandNo",
"refCommandDate",
],
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@ -72,21 +55,14 @@ export class ProfileDutyEmployeeController extends Controller {
public async dutyHistory(@Path() dutyId: string, @Request() req: RequestWithUser) { public async dutyHistory(@Path() dutyId: string, @Request() req: RequestWithUser) {
const _record = await this.dutyRepository.findOneBy({ id: dutyId }); const _record = await this.dutyRepository.findOneBy({ id: dutyId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); await new permission().PermissionOrgUserGet(
req,
"SYS_REGISTRY_EMP",
_record.profileEmployeeId,
);
} }
const record = await this.dutyHistoryRepository.find({ const record = await this.dutyHistoryRepository.find({
where: { profileDutyId: dutyId }, where: { profileDutyId: dutyId },
select: [
"id",
"dateStart",
"dateEnd",
"reference",
"detail",
"refCommandNo",
"refCommandDate",
"lastUpdateFullName",
"lastUpdatedAt",
],
order: { createdAt: "DESC" }, order: { createdAt: "DESC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
@ -111,6 +87,8 @@ export class ProfileDutyEmployeeController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -132,20 +110,27 @@ export class ProfileDutyEmployeeController extends Controller {
) { ) {
const record = await this.dutyRepository.findOneBy({ id: dutyId }); const record = await this.dutyRepository.findOneBy({ id: dutyId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId) await new permission().PermissionOrgUserUpdate(
req,
"SYS_REGISTRY_EMP",
record.profileEmployeeId,
);
const history = new ProfileDutyHistory(); const history = new ProfileDutyHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileDutyId = dutyId; history.profileDutyId = dutyId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([this.dutyRepository.save(record), this.dutyHistoryRepository.save(history)]); await Promise.all([this.dutyRepository.save(record), this.dutyHistoryRepository.save(history)]);
@ -156,7 +141,11 @@ export class ProfileDutyEmployeeController extends Controller {
public async deleteDuty(@Path() dutyId: string, @Request() req: RequestWithUser) { public async deleteDuty(@Path() dutyId: string, @Request() req: RequestWithUser) {
const _record = await this.dutyRepository.findOneBy({ id: dutyId }); const _record = await this.dutyRepository.findOneBy({ id: dutyId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); await new permission().PermissionOrgUserDelete(
req,
"SYS_REGISTRY_EMP",
_record.profileEmployeeId,
);
} }
await this.dutyHistoryRepository.delete({ await this.dutyHistoryRepository.delete({
profileDutyId: dutyId, profileDutyId: dutyId,

View file

@ -2,7 +2,6 @@ import {
Body, Body,
Controller, Controller,
Delete, Delete,
Example,
Get, Get,
Patch, Patch,
Path, Path,
@ -37,15 +36,7 @@ export class ProfileDutyEmployeeTempController extends Controller {
} }
const lists = await this.dutyRepository.find({ const lists = await this.dutyRepository.find({
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
select: [ order: { createdAt: "ASC" },
"id",
"dateStart",
"dateEnd",
"reference",
"detail",
"refCommandNo",
"refCommandDate",
],
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@ -55,15 +46,7 @@ export class ProfileDutyEmployeeTempController extends Controller {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const lists = await this.dutyRepository.find({ const lists = await this.dutyRepository.find({
where: { profileEmployeeId: profileId }, where: { profileEmployeeId: profileId },
select: [ order: { createdAt: "ASC" },
"id",
"dateStart",
"dateEnd",
"reference",
"detail",
"refCommandNo",
"refCommandDate",
],
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@ -73,17 +56,6 @@ export class ProfileDutyEmployeeTempController extends Controller {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const record = await this.dutyHistoryRepository.find({ const record = await this.dutyHistoryRepository.find({
where: { profileDutyId: dutyId }, where: { profileDutyId: dutyId },
select: [
"id",
"dateStart",
"dateEnd",
"reference",
"detail",
"refCommandNo",
"refCommandDate",
"lastUpdateFullName",
"lastUpdatedAt",
],
order: { createdAt: "DESC" }, order: { createdAt: "DESC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
@ -109,6 +81,8 @@ export class ProfileDutyEmployeeTempController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -136,15 +110,18 @@ export class ProfileDutyEmployeeTempController extends Controller {
const history = new ProfileDutyHistory(); const history = new ProfileDutyHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileDutyId = dutyId; history.profileDutyId = dutyId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([this.dutyRepository.save(record), this.dutyHistoryRepository.save(history)]); await Promise.all([this.dutyRepository.save(record), this.dutyHistoryRepository.save(history)]);

View file

@ -19,7 +19,7 @@ import { AppDataSource } from "../database/data-source";
import { Profile } from "../entities/Profile"; import { Profile } from "../entities/Profile";
import { CreateProfileEdit, EditProfileEdit, ProfileEdit } from "../entities/ProfileEdit"; import { CreateProfileEdit, EditProfileEdit, ProfileEdit } from "../entities/ProfileEdit";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import { IsNull, Not, Brackets } from "typeorm"; import { Brackets } from "typeorm";
@Route("api/v1/org/profile/edit") @Route("api/v1/org/profile/edit")
@Tags("ProfileEdit") @Tags("ProfileEdit")
@ -52,22 +52,14 @@ export class ProfileEditController extends Controller {
}) })
.andWhere( .andWhere(
new Brackets((qb) => { new Brackets((qb) => {
qb.where( qb.where(keyword != "" && keyword != null ? "ProfileEdit.topic LIKE :keyword" : "1=1", {
keyword != "" && keyword != null keyword: `%${keyword}%`,
? "ProfileEdit.topic LIKE :keyword" }).orWhere(
: "1=1", keyword != "" && keyword != null ? "ProfileEdit.detail LIKE :keyword" : "1=1",
{ {
keyword: `%${keyword}%`, keyword: `%${keyword}%`,
}, },
) );
.orWhere(
keyword != "" && keyword != null
? "ProfileEdit.detail LIKE :keyword"
: "1=1",
{
keyword: `%${keyword}%`,
},
)
}), }),
) )
.orderBy("ProfileEdit.createdAt", "ASC") .orderBy("ProfileEdit.createdAt", "ASC")
@ -114,22 +106,14 @@ export class ProfileEditController extends Controller {
}) })
.andWhere( .andWhere(
new Brackets((qb) => { new Brackets((qb) => {
qb.where( qb.where(keyword != "" && keyword != null ? "ProfileEdit.topic LIKE :keyword" : "1=1", {
keyword != "" && keyword != null keyword: `%${keyword}%`,
? "ProfileEdit.topic LIKE :keyword" }).orWhere(
: "1=1", keyword != "" && keyword != null ? "ProfileEdit.detail LIKE :keyword" : "1=1",
{ {
keyword: `%${keyword}%`, keyword: `%${keyword}%`,
}, },
) );
.orWhere(
keyword != "" && keyword != null
? "ProfileEdit.detail LIKE :keyword"
: "1=1",
{
keyword: `%${keyword}%`,
},
)
}), }),
) )
.orderBy("ProfileEdit.createdAt", "ASC") .orderBy("ProfileEdit.createdAt", "ASC")
@ -209,6 +193,8 @@ export class ProfileEditController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -226,7 +212,7 @@ export class ProfileEditController extends Controller {
) { ) {
// const record = await this.profileEditRepo.findOneBy({ id: editId }); // const record = await this.profileEditRepo.findOneBy({ id: editId });
const record = await this.profileEditRepo.findOne({ const record = await this.profileEditRepo.findOne({
where: { id: editId } where: { id: editId },
}); });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");

View file

@ -23,7 +23,7 @@ import {
} from "../entities/ProfileEdit"; } from "../entities/ProfileEdit";
import { ProfileEmployee } from "../entities/ProfileEmployee"; import { ProfileEmployee } from "../entities/ProfileEmployee";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import { IsNull, Not, Brackets } from "typeorm"; import { Brackets } from "typeorm";
@Route("api/v1/org/profile-employee/edit") @Route("api/v1/org/profile-employee/edit")
@Tags("ProfileEmployeeEdit") @Tags("ProfileEmployeeEdit")
@ -203,6 +203,8 @@ export class ProfileEditEmployeeController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
data.status = "PENDING"; data.status = "PENDING";

View file

@ -1,7 +1,6 @@
import { import {
Controller, Controller,
Post, Post,
Put,
Delete, Delete,
Route, Route,
Security, Security,
@ -9,12 +8,8 @@ import {
Body, Body,
Path, Path,
Request, Request,
SuccessResponse,
Response,
Get, Get,
Query,
Patch, Patch,
Example,
} from "tsoa"; } from "tsoa";
import HttpSuccess from "../interfaces/http-success"; import HttpSuccess from "../interfaces/http-success";
@ -47,6 +42,7 @@ export class ProfileEducationsController extends Controller {
} }
const getProfileEducation = await this.profileEducationRepo.find({ const getProfileEducation = await this.profileEducationRepo.find({
where: { profileId: profile.id }, where: { profileId: profile.id },
order: { createdAt: "ASC" },
}); });
if (!getProfileEducation) { if (!getProfileEducation) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -55,45 +51,12 @@ export class ProfileEducationsController extends Controller {
} }
@Get("{profileId}") @Get("{profileId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "f6c693b4-1a9b-4fbe-95c5-ed4da50d35b6",
createdAt: "2024-03-12T20:26:42.621Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T20:33:09.000Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "test bar",
lastUpdateFullName: "test bar",
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
isActive: true,
country: "string",
degree: "ปวส",
duration: "-",
durationYear: 0,
field: "ชางเทคนิค ชั้นสูง",
finishDate: "2024-03-13T03:23:31.000Z",
fundName: "-",
gpa: "3.64",
institute: "เทคโนเชียงใหม่",
other: "string",
startDate: "2024-03-13T03:23:31.000Z",
endDate: "2024-03-13T03:23:31.000Z",
educationLevel: "ปวส",
educationLevelId: "string",
positionPath: "string",
positionPathId: "string",
note: "string",
isDate: true,
isEducation: true,
},
],
})
public async detailProfileEducation(@Path() profileId: string, @Request() req: RequestWithUser) { public async detailProfileEducation(@Path() profileId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
const getProfileEducation = await this.profileEducationRepo.findBy({ profileId }); const getProfileEducation = await this.profileEducationRepo.find({
where: { profileId: profileId },
order: { createdAt: "ASC" },
});
if (!getProfileEducation) { if (!getProfileEducation) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
} }
@ -101,79 +64,19 @@ export class ProfileEducationsController extends Controller {
} }
@Get("history/{educationId}") @Get("history/{educationId}")
@Example({ public async getProfileEducationHistory(
status: 200, @Path() educationId: string,
message: "สำเร็จ", @Request() req: RequestWithUser,
result: [ ) {
{ const _record = await this.profileEducationRepo.findOneBy({ id: educationId });
id: "294aa117-6ce7-4c23-b5bd-fe1f12932c4a", if (_record) {
createdAt: "2024-03-12T20:29:45.251Z", await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
createdUserId: "00000000-0000-0000-0000-000000000000", }
lastUpdatedAt: "2024-03-12T20:29:45.251Z", const record = await this.profileEducationHistoryRepo.find({
lastUpdateUserId: "00000000-0000-0000-0000-000000000000", where: {
createdFullName: "string", profileEducationId: educationId,
lastUpdateFullName: "test bar",
isActive: true,
country: "string",
degree: "ปวส",
duration: "-",
durationYear: 0,
field: "ชางเทคนิค",
finishDate: "2024-03-13T03:23:31.000Z",
fundName: "-",
gpa: "3.64",
institute: "เทคโนเชียงใหม่",
other: "string",
startDate: "2024-03-13T03:23:31.000Z",
endDate: "2024-03-13T03:23:31.000Z",
educationLevel: "ปวส",
educationLevelId: "string",
positionPath: "string",
positionPathId: "string",
note: "string",
isDate: true,
isEducation: true,
profileEducationId: "f6c693b4-1a9b-4fbe-95c5-ed4da50d35b6",
}, },
{ order: { createdAt: "DESC" },
id: "2f00bd59-be3e-46d8-92a2-c4700baabf12",
createdAt: "2024-03-12T20:33:09.128Z",
createdUserId: "00000000-0000-0000-0000-000000000000",
lastUpdatedAt: "2024-03-12T20:33:09.128Z",
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
createdFullName: "string",
lastUpdateFullName: "test bar",
isActive: true,
country: "string",
degree: "ปวส",
duration: "-",
durationYear: 0,
field: "ชางเทคนิค ชั้นสูง",
finishDate: "2024-03-13T03:23:31.000Z",
fundName: "-",
gpa: "3.64",
institute: "เทคโนเชียงใหม่",
other: "string",
startDate: "2024-03-13T03:23:31.000Z",
endDate: "2024-03-13T03:23:31.000Z",
educationLevel: "ปวส",
educationLevelId: "string",
positionPath: "string",
positionPathId: "string",
note: "string",
isDate: true,
isEducation: true,
profileEducationId: "f6c693b4-1a9b-4fbe-95c5-ed4da50d35b6",
},
],
})
public async getProfileEducationHistory(@Path() educationId: string, @Request() req: RequestWithUser) {
const _record = await this.profileEducationRepo.findOneBy({ id: educationId });
if (_record) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
}
const record = await this.profileEducationHistoryRepo.findBy({
profileEducationId: educationId,
}); });
if (!record) { if (!record) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -202,6 +105,8 @@ export class ProfileEducationsController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -228,15 +133,18 @@ export class ProfileEducationsController extends Controller {
const history = new ProfileEducationHistory(); const history = new ProfileEducationHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileEducationId = educationId; history.profileEducationId = educationId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.profileEducationRepo.save(record), this.profileEducationRepo.save(record),

View file

@ -1,7 +1,6 @@
import { import {
Controller, Controller,
Post, Post,
Put,
Delete, Delete,
Route, Route,
Security, Security,
@ -9,24 +8,18 @@ import {
Body, Body,
Path, Path,
Request, Request,
SuccessResponse,
Response,
Get, Get,
Query,
Patch, Patch,
Example,
} from "tsoa"; } from "tsoa";
import HttpSuccess from "../interfaces/http-success"; import HttpSuccess from "../interfaces/http-success";
import HttpError from "../interfaces/http-error"; import HttpError from "../interfaces/http-error";
import HttpStatus from "../interfaces/http-status"; import HttpStatus from "../interfaces/http-status";
import { import {
ProfileEducation, ProfileEducation,
CreateProfileEducation,
UpdateProfileEducation, UpdateProfileEducation,
CreateProfileEducationEmployee, CreateProfileEducationEmployee,
} from "../entities/ProfileEducation"; } from "../entities/ProfileEducation";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import { Profile } from "../entities/Profile";
import { ProfileEducationHistory } from "../entities/ProfileEducationHistory"; import { ProfileEducationHistory } from "../entities/ProfileEducationHistory";
import { AppDataSource } from "../database/data-source"; import { AppDataSource } from "../database/data-source";
import { ProfileEmployee } from "../entities/ProfileEmployee"; import { ProfileEmployee } from "../entities/ProfileEmployee";
@ -47,6 +40,7 @@ export class ProfileEducationsEmployeeController extends Controller {
} }
const getProfileEducation = await this.profileEducationRepo.find({ const getProfileEducation = await this.profileEducationRepo.find({
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
order: { createdAt: "ASC" },
}); });
if (!getProfileEducation) { if (!getProfileEducation) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -55,46 +49,14 @@ export class ProfileEducationsEmployeeController extends Controller {
} }
@Get("{profileEmployeeId}") @Get("{profileEmployeeId}")
@Example({ public async detailProfileEducation(
status: 200, @Path() profileEmployeeId: string,
message: "สำเร็จ", @Request() req: RequestWithUser,
result: [ ) {
{
id: "f6c693b4-1a9b-4fbe-95c5-ed4da50d35b6",
createdAt: "2024-03-12T20:26:42.621Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T20:33:09.000Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "test bar",
lastUpdateFullName: "test bar",
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
isActive: true,
country: "string",
degree: "ปวส",
duration: "-",
durationYear: 0,
field: "ชางเทคนิค ชั้นสูง",
finishDate: "2024-03-13T03:23:31.000Z",
fundName: "-",
gpa: "3.64",
institute: "เทคโนเชียงใหม่",
other: "string",
startDate: "2024-03-13T03:23:31.000Z",
endDate: "2024-03-13T03:23:31.000Z",
educationLevel: "ปวส",
educationLevelId: "string",
positionPath: "string",
positionPathId: "string",
note: "string",
isDate: true,
isEducation: true,
},
],
})
public async detailProfileEducation(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
const getProfileEducation = await this.profileEducationRepo.find({ const getProfileEducation = await this.profileEducationRepo.find({
where: { profileEmployeeId: profileEmployeeId }, where: { profileEmployeeId: profileEmployeeId },
order: { createdAt: "ASC" },
}); });
if (!getProfileEducation) { if (!getProfileEducation) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -103,80 +65,24 @@ export class ProfileEducationsEmployeeController extends Controller {
} }
@Get("history/{educationId}") @Get("history/{educationId}")
@Example({ public async getProfileEducationHistory(
status: 200, @Path() educationId: string,
message: "สำเร็จ", @Request() req: RequestWithUser,
result: [ ) {
{
id: "294aa117-6ce7-4c23-b5bd-fe1f12932c4a",
createdAt: "2024-03-12T20:29:45.251Z",
createdUserId: "00000000-0000-0000-0000-000000000000",
lastUpdatedAt: "2024-03-12T20:29:45.251Z",
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
createdFullName: "string",
lastUpdateFullName: "test bar",
isActive: true,
country: "string",
degree: "ปวส",
duration: "-",
durationYear: 0,
field: "ชางเทคนิค",
finishDate: "2024-03-13T03:23:31.000Z",
fundName: "-",
gpa: "3.64",
institute: "เทคโนเชียงใหม่",
other: "string",
startDate: "2024-03-13T03:23:31.000Z",
endDate: "2024-03-13T03:23:31.000Z",
educationLevel: "ปวส",
educationLevelId: "string",
positionPath: "string",
positionPathId: "string",
note: "string",
isDate: true,
isEducation: true,
profileEducationId: "f6c693b4-1a9b-4fbe-95c5-ed4da50d35b6",
},
{
id: "2f00bd59-be3e-46d8-92a2-c4700baabf12",
createdAt: "2024-03-12T20:33:09.128Z",
createdUserId: "00000000-0000-0000-0000-000000000000",
lastUpdatedAt: "2024-03-12T20:33:09.128Z",
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
createdFullName: "string",
lastUpdateFullName: "test bar",
isActive: true,
country: "string",
degree: "ปวส",
duration: "-",
durationYear: 0,
field: "ชางเทคนิค ชั้นสูง",
finishDate: "2024-03-13T03:23:31.000Z",
fundName: "-",
gpa: "3.64",
institute: "เทคโนเชียงใหม่",
other: "string",
startDate: "2024-03-13T03:23:31.000Z",
endDate: "2024-03-13T03:23:31.000Z",
educationLevel: "ปวส",
educationLevelId: "string",
positionPath: "string",
positionPathId: "string",
note: "string",
isDate: true,
isEducation: true,
profileEducationId: "f6c693b4-1a9b-4fbe-95c5-ed4da50d35b6",
},
],
})
public async getProfileEducationHistory(@Path() educationId: string, @Request() req: RequestWithUser) {
const _record = await this.profileEducationRepo.findOneBy({ id: educationId }); const _record = await this.profileEducationRepo.findOneBy({ id: educationId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); await new permission().PermissionOrgUserGet(
req,
"SYS_REGISTRY_EMP",
_record.profileEmployeeId,
);
} }
const record = await this.profileEducationHistoryRepo.findBy({ const record = await this.profileEducationHistoryRepo.find({
profileEducationId: educationId, where: {
profileEducationId: educationId,
},
order: { createdAt: "DESC" },
}); });
if (!record) { if (!record) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -205,6 +111,8 @@ export class ProfileEducationsEmployeeController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -226,20 +134,27 @@ export class ProfileEducationsEmployeeController extends Controller {
) { ) {
const record = await this.profileEducationRepo.findOneBy({ id: educationId }); const record = await this.profileEducationRepo.findOneBy({ id: educationId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId); await new permission().PermissionOrgUserUpdate(
req,
"SYS_REGISTRY_EMP",
record.profileEmployeeId,
);
const history = new ProfileEducationHistory(); const history = new ProfileEducationHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileEducationId = educationId; history.profileEducationId = educationId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.profileEducationRepo.save(record), this.profileEducationRepo.save(record),
@ -256,7 +171,11 @@ export class ProfileEducationsEmployeeController extends Controller {
) { ) {
const _record = await this.profileEducationRepo.findOneBy({ id: educationId }); const _record = await this.profileEducationRepo.findOneBy({ id: educationId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); await new permission().PermissionOrgUserDelete(
req,
"SYS_REGISTRY_EMP",
_record.profileEmployeeId,
);
} }
await this.profileEducationHistoryRepo.delete({ await this.profileEducationHistoryRepo.delete({

View file

@ -1,7 +1,6 @@
import { import {
Controller, Controller,
Post, Post,
Put,
Delete, Delete,
Route, Route,
Security, Security,
@ -9,24 +8,18 @@ import {
Body, Body,
Path, Path,
Request, Request,
SuccessResponse,
Response,
Get, Get,
Query,
Patch, Patch,
Example,
} from "tsoa"; } from "tsoa";
import HttpSuccess from "../interfaces/http-success"; import HttpSuccess from "../interfaces/http-success";
import HttpError from "../interfaces/http-error"; import HttpError from "../interfaces/http-error";
import HttpStatus from "../interfaces/http-status"; import HttpStatus from "../interfaces/http-status";
import { import {
ProfileEducation, ProfileEducation,
CreateProfileEducation,
UpdateProfileEducation, UpdateProfileEducation,
CreateProfileEducationEmployee, CreateProfileEducationEmployee,
} from "../entities/ProfileEducation"; } from "../entities/ProfileEducation";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import { Profile } from "../entities/Profile";
import { ProfileEducationHistory } from "../entities/ProfileEducationHistory"; import { ProfileEducationHistory } from "../entities/ProfileEducationHistory";
import { AppDataSource } from "../database/data-source"; import { AppDataSource } from "../database/data-source";
import { ProfileEmployee } from "../entities/ProfileEmployee"; import { ProfileEmployee } from "../entities/ProfileEmployee";
@ -47,6 +40,7 @@ export class ProfileEducationsEmployeeTempController extends Controller {
} }
const getProfileEducation = await this.profileEducationRepo.find({ const getProfileEducation = await this.profileEducationRepo.find({
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
order: { createdAt: "ASC" },
}); });
if (!getProfileEducation) { if (!getProfileEducation) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -55,46 +49,14 @@ export class ProfileEducationsEmployeeTempController extends Controller {
} }
@Get("{profileEmployeeId}") @Get("{profileEmployeeId}")
@Example({ public async detailProfileEducation(
status: 200, @Path() profileEmployeeId: string,
message: "สำเร็จ", @Request() req: RequestWithUser,
result: [ ) {
{
id: "f6c693b4-1a9b-4fbe-95c5-ed4da50d35b6",
createdAt: "2024-03-12T20:26:42.621Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T20:33:09.000Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "test bar",
lastUpdateFullName: "test bar",
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
isActive: true,
country: "string",
degree: "ปวส",
duration: "-",
durationYear: 0,
field: "ชางเทคนิค ชั้นสูง",
finishDate: "2024-03-13T03:23:31.000Z",
fundName: "-",
gpa: "3.64",
institute: "เทคโนเชียงใหม่",
other: "string",
startDate: "2024-03-13T03:23:31.000Z",
endDate: "2024-03-13T03:23:31.000Z",
educationLevel: "ปวส",
educationLevelId: "string",
positionPath: "string",
positionPathId: "string",
note: "string",
isDate: true,
isEducation: true,
},
],
})
public async detailProfileEducation(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const getProfileEducation = await this.profileEducationRepo.find({ const getProfileEducation = await this.profileEducationRepo.find({
where: { profileEmployeeId: profileEmployeeId }, where: { profileEmployeeId: profileEmployeeId },
order: { createdAt: "ASC" },
}); });
if (!getProfileEducation) { if (!getProfileEducation) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -103,76 +65,16 @@ export class ProfileEducationsEmployeeTempController extends Controller {
} }
@Get("history/{educationId}") @Get("history/{educationId}")
@Example({ public async getProfileEducationHistory(
status: 200, @Path() educationId: string,
message: "สำเร็จ", @Request() req: RequestWithUser,
result: [ ) {
{
id: "294aa117-6ce7-4c23-b5bd-fe1f12932c4a",
createdAt: "2024-03-12T20:29:45.251Z",
createdUserId: "00000000-0000-0000-0000-000000000000",
lastUpdatedAt: "2024-03-12T20:29:45.251Z",
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
createdFullName: "string",
lastUpdateFullName: "test bar",
isActive: true,
country: "string",
degree: "ปวส",
duration: "-",
durationYear: 0,
field: "ชางเทคนิค",
finishDate: "2024-03-13T03:23:31.000Z",
fundName: "-",
gpa: "3.64",
institute: "เทคโนเชียงใหม่",
other: "string",
startDate: "2024-03-13T03:23:31.000Z",
endDate: "2024-03-13T03:23:31.000Z",
educationLevel: "ปวส",
educationLevelId: "string",
positionPath: "string",
positionPathId: "string",
note: "string",
isDate: true,
isEducation: true,
profileEducationId: "f6c693b4-1a9b-4fbe-95c5-ed4da50d35b6",
},
{
id: "2f00bd59-be3e-46d8-92a2-c4700baabf12",
createdAt: "2024-03-12T20:33:09.128Z",
createdUserId: "00000000-0000-0000-0000-000000000000",
lastUpdatedAt: "2024-03-12T20:33:09.128Z",
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
createdFullName: "string",
lastUpdateFullName: "test bar",
isActive: true,
country: "string",
degree: "ปวส",
duration: "-",
durationYear: 0,
field: "ชางเทคนิค ชั้นสูง",
finishDate: "2024-03-13T03:23:31.000Z",
fundName: "-",
gpa: "3.64",
institute: "เทคโนเชียงใหม่",
other: "string",
startDate: "2024-03-13T03:23:31.000Z",
endDate: "2024-03-13T03:23:31.000Z",
educationLevel: "ปวส",
educationLevelId: "string",
positionPath: "string",
positionPathId: "string",
note: "string",
isDate: true,
isEducation: true,
profileEducationId: "f6c693b4-1a9b-4fbe-95c5-ed4da50d35b6",
},
],
})
public async getProfileEducationHistory(@Path() educationId: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const record = await this.profileEducationHistoryRepo.findBy({ const record = await this.profileEducationHistoryRepo.find({
profileEducationId: educationId, where: {
profileEducationId: educationId,
},
order: { createdAt: "DESC" },
}); });
if (!record) { if (!record) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -201,6 +103,8 @@ export class ProfileEducationsEmployeeTempController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -227,15 +131,18 @@ export class ProfileEducationsEmployeeTempController extends Controller {
const history = new ProfileEducationHistory(); const history = new ProfileEducationHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileEducationId = educationId; history.profileEducationId = educationId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.profileEducationRepo.save(record), this.profileEducationRepo.save(record),

View file

@ -666,6 +666,9 @@ export class ProfileEmployeeController extends Controller {
await this.profileHistoryRepo.save( await this.profileHistoryRepo.save(
Object.assign(new ProfileEmployeeHistory(), { Object.assign(new ProfileEmployeeHistory(), {
...record, ...record,
lastUpdateUserId: request.user.sub,
lastUpdateFullName: request.user.name,
lastUpdatedAt: new Date(),
profileEmployeeId: id, profileEmployeeId: id,
id: undefined, id: undefined,
}), }),
@ -2923,11 +2926,15 @@ export class ProfileEmployeeController extends Controller {
if (!profileEmp) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้"); if (!profileEmp) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้");
const history = new ProfileEmployeeInformationHistory(); const history = new ProfileEmployeeInformationHistory();
Object.assign(history, { ...profileEmp, id: undefined });
Object.assign(profileEmp, body); Object.assign(profileEmp, body);
Object.assign(history, { ...profileEmp, id: undefined });
history.profileEmployeeId = profileEmployeeId; history.profileEmployeeId = profileEmployeeId;
history.lastUpdateFullName = request.user.name; history.lastUpdateFullName = request.user.name;
history.lastUpdateUserId = request.user.sub; history.lastUpdateUserId = request.user.sub;
history.lastUpdatedAt = new Date();
history.createdUserId = request.user.sub;
history.createdFullName = request.user.name;
history.createdAt = new Date();
profileEmp.lastUpdateUserId = request.user.sub; profileEmp.lastUpdateUserId = request.user.sub;
profileEmp.lastUpdateFullName = request.user.name; profileEmp.lastUpdateFullName = request.user.name;
@ -3103,24 +3110,26 @@ export class ProfileEmployeeController extends Controller {
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
await new permission().PermissionOrgUserUpdate(request, "SYS_REGISTRY_EMP", profile.id); await new permission().PermissionOrgUserUpdate(request, "SYS_REGISTRY_EMP", profile.id);
const employment = new ProfileEmployeeEmployment(); const data = new ProfileEmployeeEmployment();
// const history = new ProfileEmployeeEmploymentHistory();
Object.assign(employment, body); const meta = {
employment.profileEmployeeId = profileEmployeeId; createdUserId: request.user.sub,
employment.createdUserId = request.user.sub; createdFullName: request.user.name,
employment.createdFullName = request.user.name; lastUpdateUserId: request.user.sub,
employment.lastUpdateUserId = request.user.sub; lastUpdateFullName: request.user.name,
employment.lastUpdateFullName = request.user.name; createdAt: new Date(),
await this.employmentRepository.save(employment); lastUpdatedAt: new Date(),
// if (employment) { profileEmployeeId: profileEmployeeId,
// Object.assign(history, { ...employment, id: undefined }); };
// history.profileEmployeeEmploymentId = employment.id;
// history.createdUserId = request.user.sub; Object.assign(data, { ...body, ...meta });
// history.createdFullName = request.user.name; const history = new ProfileEmployeeEmploymentHistory();
// history.lastUpdateFullName = request.user.name; Object.assign(history, { ...data, id: undefined });
// history.lastUpdateUserId = request.user.sub;
// await this.employmentHistoryRepository.save(history); await this.employmentRepository.save(data);
// } history.profileEmployeeEmploymentId = data.id;
await this.employmentHistoryRepository.save(history);
return new HttpSuccess(); return new HttpSuccess();
} }
@ -3176,14 +3185,16 @@ export class ProfileEmployeeController extends Controller {
); );
const history = new ProfileEmployeeEmploymentHistory(); const history = new ProfileEmployeeEmploymentHistory();
Object.assign(history, { ...employment, id: undefined });
Object.assign(employment, body); Object.assign(employment, body);
Object.assign(history, { ...employment, id: undefined });
employment.lastUpdateUserId = request.user.sub; employment.lastUpdateUserId = request.user.sub;
employment.lastUpdateFullName = request.user.name; employment.lastUpdateFullName = request.user.name;
history.profileEmployeeEmploymentId = id; history.profileEmployeeEmploymentId = id;
history.lastUpdateFullName = request.user.name;
history.lastUpdateUserId = request.user.sub; history.lastUpdateUserId = request.user.sub;
history.lastUpdateFullName = request.user.name;
history.createdUserId = request.user.sub;
history.createdFullName = request.user.name;
await Promise.all([ await Promise.all([
this.employmentRepository.save(employment), this.employmentRepository.save(employment),
@ -3210,6 +3221,7 @@ export class ProfileEmployeeController extends Controller {
statusTemp: "REPORT", statusTemp: "REPORT",
lastUpdateUserId: request.user.sub, lastUpdateUserId: request.user.sub,
lastUpdateFullName: request.user.name, lastUpdateFullName: request.user.name,
lastUpdatedAt: new Date(),
}; };
}), }),
); );

View file

@ -3171,6 +3171,7 @@ export class ProfileEmployeeTempController extends Controller {
statusTemp: "REPORT", statusTemp: "REPORT",
lastUpdateUserId: request.user.sub, lastUpdateUserId: request.user.sub,
lastUpdateFullName: request.user.name, lastUpdateFullName: request.user.name,
lastUpdatedAt: new Date(),
}; };
}), }),
); );

View file

@ -1,7 +1,6 @@
import { import {
Body, Body,
Controller, Controller,
Delete,
Example, Example,
Get, Get,
Patch, Patch,
@ -41,18 +40,6 @@ export class ProfileFamilyCoupleController extends Controller {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
const familyCouple = await this.ProfileFamilyCouple.findOne({ const familyCouple = await this.ProfileFamilyCouple.findOne({
select: [
"id",
"couplePrefix",
"coupleFirstName",
"coupleLastName",
"coupleLastNameOld",
"coupleCareer",
"coupleCitizenId",
"coupleLive",
"relationship",
"profileId",
],
where: { profileId: profile.id }, where: { profileId: profile.id },
order: { lastUpdatedAt: "DESC" }, order: { lastUpdatedAt: "DESC" },
}); });
@ -61,22 +48,6 @@ export class ProfileFamilyCoupleController extends Controller {
} }
@Get("{profileId}") @Get("{profileId}")
@Example({
status: 200,
message: "สำเร็จ",
result: {
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
couplePrefix: "string",
coupleFirstName: "string",
coupleLastName: "string",
coupleLastNameOld: "string",
coupleCareer: "string",
coupleCitizenId: "string",
coupleLive: true,
relationship: "string",
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
},
})
public async getFamilyCouple(@Path() profileId: string, @Request() req: RequestWithUser) { public async getFamilyCouple(@Path() profileId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
@ -87,18 +58,6 @@ export class ProfileFamilyCoupleController extends Controller {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
const familyCouple = await this.ProfileFamilyCouple.findOne({ const familyCouple = await this.ProfileFamilyCouple.findOne({
select: [
"id",
"couplePrefix",
"coupleFirstName",
"coupleLastName",
"coupleLastNameOld",
"coupleCareer",
"coupleCitizenId",
"coupleLive",
"relationship",
"profileId",
],
where: { profileId }, where: { profileId },
order: { lastUpdatedAt: "DESC" }, order: { lastUpdatedAt: "DESC" },
}); });
@ -152,31 +111,6 @@ export class ProfileFamilyCoupleController extends Controller {
} }
@Get("history/{profileId}") @Get("history/{profileId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
createdAt: "2024-03-19T11:00:29.769Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-19T11:00:29.769Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
couplePrefix: "string",
coupleFirstName: "string",
coupleLastName: "string",
coupleLastNameOld: "string",
coupleCareer: "string",
coupleCitizenId: "string",
coupleLive: true,
relationship: "string",
profileFamilyCoupleId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
},
],
})
public async familyCoupleHistory(@Path() profileId: string, @Request() req: RequestWithUser) { public async familyCoupleHistory(@Path() profileId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
@ -236,6 +170,8 @@ export class ProfileFamilyCoupleController extends Controller {
familyCouple.createdFullName = req.user.name; familyCouple.createdFullName = req.user.name;
familyCouple.lastUpdateUserId = req.user.sub; familyCouple.lastUpdateUserId = req.user.sub;
familyCouple.lastUpdateFullName = req.user.name; familyCouple.lastUpdateFullName = req.user.name;
familyCouple.createdAt = new Date();
familyCouple.lastUpdatedAt = new Date();
profile.relationship = familyCouple.relationship; //update profileEmployee.relationship profile.relationship = familyCouple.relationship; //update profileEmployee.relationship
const history = new ProfileFamilyCoupleHistory(); const history = new ProfileFamilyCoupleHistory();
@ -267,10 +203,13 @@ export class ProfileFamilyCoupleController extends Controller {
history.profileFamilyCoupleId = familyCouple.id; history.profileFamilyCoupleId = familyCouple.id;
familyCouple.lastUpdateUserId = req.user.sub; familyCouple.lastUpdateUserId = req.user.sub;
familyCouple.lastUpdateFullName = req.user.name; familyCouple.lastUpdateFullName = req.user.name;
familyCouple.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.ProfileFamilyCouple.save(familyCouple), this.ProfileFamilyCouple.save(familyCouple),

View file

@ -1,7 +1,6 @@
import { import {
Body, Body,
Controller, Controller,
Delete,
Example, Example,
Get, Get,
Patch, Patch,
@ -41,18 +40,6 @@ export class ProfileFamilyCoupleEmployeeController extends Controller {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
const familyCouple = await this.ProfileFamilyCouple.findOne({ const familyCouple = await this.ProfileFamilyCouple.findOne({
select: [
"id",
"couplePrefix",
"coupleFirstName",
"coupleLastName",
"coupleLastNameOld",
"coupleCareer",
"coupleCitizenId",
"coupleLive",
"relationship",
"profileId",
],
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
order: { lastUpdatedAt: "DESC" }, order: { lastUpdatedAt: "DESC" },
}); });
@ -61,22 +48,6 @@ export class ProfileFamilyCoupleEmployeeController extends Controller {
} }
@Get("{profileEmployeeId}") @Get("{profileEmployeeId}")
@Example({
status: 200,
message: "สำเร็จ",
result: {
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
couplePrefix: "string",
coupleFirstName: "string",
coupleLastName: "string",
coupleLastNameOld: "string",
coupleCareer: "string",
coupleCitizenId: "string",
coupleLive: true,
relationship: "string",
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
},
})
public async getFamilyCouple(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { public async getFamilyCouple(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
where: { id: profileEmployeeId }, where: { id: profileEmployeeId },
@ -87,18 +58,6 @@ export class ProfileFamilyCoupleEmployeeController extends Controller {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profile.id); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profile.id);
const familyCouple = await this.ProfileFamilyCouple.findOne({ const familyCouple = await this.ProfileFamilyCouple.findOne({
select: [
"id",
"couplePrefix",
"coupleFirstName",
"coupleLastName",
"coupleLastNameOld",
"coupleCareer",
"coupleCitizenId",
"coupleLive",
"relationship",
"profileEmployeeId",
],
where: { profileEmployeeId }, where: { profileEmployeeId },
order: { lastUpdatedAt: "DESC" }, order: { lastUpdatedAt: "DESC" },
}); });
@ -152,32 +111,10 @@ export class ProfileFamilyCoupleEmployeeController extends Controller {
} }
@Get("history/{profileEmployeeId}") @Get("history/{profileEmployeeId}")
@Example({ public async familyCoupleHistory(
status: 200, @Path() profileEmployeeId: string,
message: "สำเร็จ", @Request() req: RequestWithUser,
result: [ ) {
{
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
createdAt: "2024-03-19T11:00:29.769Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-19T11:00:29.769Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
couplePrefix: "string",
coupleFirstName: "string",
coupleLastName: "string",
coupleLastNameOld: "string",
coupleCareer: "string",
coupleCitizenId: "string",
coupleLive: true,
relationship: "string",
profileFamilyCoupleId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
},
],
})
public async familyCoupleHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
where: { id: profileEmployeeId }, where: { id: profileEmployeeId },
}); });
@ -237,6 +174,8 @@ export class ProfileFamilyCoupleEmployeeController extends Controller {
familyCouple.createdFullName = req.user.name; familyCouple.createdFullName = req.user.name;
familyCouple.lastUpdateUserId = req.user.sub; familyCouple.lastUpdateUserId = req.user.sub;
familyCouple.lastUpdateFullName = req.user.name; familyCouple.lastUpdateFullName = req.user.name;
familyCouple.createdAt = new Date();
familyCouple.lastUpdatedAt = new Date();
profile.relationship = familyCouple.relationship; //update profileEmployee.relationship profile.relationship = familyCouple.relationship; //update profileEmployee.relationship
const history = new ProfileFamilyCoupleHistory(); const history = new ProfileFamilyCoupleHistory();
@ -256,7 +195,7 @@ export class ProfileFamilyCoupleEmployeeController extends Controller {
@Body() body: UpdateProfileFamilyCouple, @Body() body: UpdateProfileFamilyCouple,
@Path() profileEmployeeId: string, @Path() profileEmployeeId: string,
) { ) {
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profileEmployeeId) await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profileEmployeeId);
const familyCouple = await this.ProfileFamilyCouple.findOneBy({ const familyCouple = await this.ProfileFamilyCouple.findOneBy({
profileEmployeeId: profileEmployeeId, profileEmployeeId: profileEmployeeId,
}); });
@ -270,10 +209,13 @@ export class ProfileFamilyCoupleEmployeeController extends Controller {
history.profileFamilyCoupleId = familyCouple.id; history.profileFamilyCoupleId = familyCouple.id;
familyCouple.lastUpdateUserId = req.user.sub; familyCouple.lastUpdateUserId = req.user.sub;
familyCouple.lastUpdateFullName = req.user.name; familyCouple.lastUpdateFullName = req.user.name;
familyCouple.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.ProfileFamilyCouple.save(familyCouple), this.ProfileFamilyCouple.save(familyCouple),

View file

@ -1,7 +1,6 @@
import { import {
Body, Body,
Controller, Controller,
Delete,
Example, Example,
Get, Get,
Patch, Patch,
@ -41,18 +40,6 @@ export class ProfileFamilyCoupleEmployeeTempController extends Controller {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
const familyCouple = await this.ProfileFamilyCouple.findOne({ const familyCouple = await this.ProfileFamilyCouple.findOne({
select: [
"id",
"couplePrefix",
"coupleFirstName",
"coupleLastName",
"coupleLastNameOld",
"coupleCareer",
"coupleCitizenId",
"coupleLive",
"relationship",
"profileId",
],
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
order: { lastUpdatedAt: "DESC" }, order: { lastUpdatedAt: "DESC" },
}); });
@ -61,22 +48,6 @@ export class ProfileFamilyCoupleEmployeeTempController extends Controller {
} }
@Get("{profileEmployeeId}") @Get("{profileEmployeeId}")
@Example({
status: 200,
message: "สำเร็จ",
result: {
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
couplePrefix: "string",
coupleFirstName: "string",
coupleLastName: "string",
coupleLastNameOld: "string",
coupleCareer: "string",
coupleCitizenId: "string",
coupleLive: true,
relationship: "string",
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
},
})
public async getFamilyCouple(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { public async getFamilyCouple(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
@ -87,18 +58,6 @@ export class ProfileFamilyCoupleEmployeeTempController extends Controller {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
const familyCouple = await this.ProfileFamilyCouple.findOne({ const familyCouple = await this.ProfileFamilyCouple.findOne({
select: [
"id",
"couplePrefix",
"coupleFirstName",
"coupleLastName",
"coupleLastNameOld",
"coupleCareer",
"coupleCitizenId",
"coupleLive",
"relationship",
"profileEmployeeId",
],
where: { profileEmployeeId }, where: { profileEmployeeId },
order: { lastUpdatedAt: "DESC" }, order: { lastUpdatedAt: "DESC" },
}); });
@ -153,32 +112,10 @@ export class ProfileFamilyCoupleEmployeeTempController extends Controller {
} }
@Get("history/{profileEmployeeId}") @Get("history/{profileEmployeeId}")
@Example({ public async familyCoupleHistory(
status: 200, @Path() profileEmployeeId: string,
message: "สำเร็จ", @Request() req: RequestWithUser,
result: [ ) {
{
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
createdAt: "2024-03-19T11:00:29.769Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-19T11:00:29.769Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
couplePrefix: "string",
coupleFirstName: "string",
coupleLastName: "string",
coupleLastNameOld: "string",
coupleCareer: "string",
coupleCitizenId: "string",
coupleLive: true,
relationship: "string",
profileFamilyCoupleId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
},
],
})
public async familyCoupleHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
where: { id: profileEmployeeId }, where: { id: profileEmployeeId },
@ -237,6 +174,8 @@ export class ProfileFamilyCoupleEmployeeTempController extends Controller {
familyCouple.createdFullName = req.user.name; familyCouple.createdFullName = req.user.name;
familyCouple.lastUpdateUserId = req.user.sub; familyCouple.lastUpdateUserId = req.user.sub;
familyCouple.lastUpdateFullName = req.user.name; familyCouple.lastUpdateFullName = req.user.name;
familyCouple.createdAt = new Date();
familyCouple.lastUpdatedAt = new Date();
await this.ProfileFamilyCouple.save(familyCouple); await this.ProfileFamilyCouple.save(familyCouple);
profile.relationship = familyCouple.relationship; //update profileEmployee.relationship profile.relationship = familyCouple.relationship; //update profileEmployee.relationship
@ -271,10 +210,13 @@ export class ProfileFamilyCoupleEmployeeTempController extends Controller {
history.profileFamilyCoupleId = familyCouple.id; history.profileFamilyCoupleId = familyCouple.id;
familyCouple.lastUpdateUserId = req.user.sub; familyCouple.lastUpdateUserId = req.user.sub;
familyCouple.lastUpdateFullName = req.user.name; familyCouple.lastUpdateFullName = req.user.name;
familyCouple.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.ProfileFamilyCouple.save(familyCouple), this.ProfileFamilyCouple.save(familyCouple),

View file

@ -1,7 +1,6 @@
import { import {
Body, Body,
Controller, Controller,
Delete,
Example, Example,
Get, Get,
Patch, Patch,
@ -41,16 +40,6 @@ export class ProfileFamilyFatherController extends Controller {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
const familyFather = await this.ProfileFamilyFather.findOne({ const familyFather = await this.ProfileFamilyFather.findOne({
select: [
"id",
"fatherPrefix",
"fatherFirstName",
"fatherLastName",
"fatherCareer",
"fatherCitizenId",
"fatherLive",
"profileId",
],
where: { profileId: profile.id }, where: { profileId: profile.id },
order: { lastUpdatedAt: "DESC" }, order: { lastUpdatedAt: "DESC" },
}); });
@ -59,20 +48,6 @@ export class ProfileFamilyFatherController extends Controller {
} }
@Get("{profileId}") @Get("{profileId}")
@Example({
status: 200,
message: "สำเร็จ",
result: {
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
fatherPrefix: "string",
fatherFirstName: "string",
fatherLastName: "string",
fatherCareer: "string",
fatherCitizenId: "string",
fatherLive: true,
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
},
})
public async getFamilyFather(@Path() profileId: string, @Request() req: RequestWithUser) { public async getFamilyFather(@Path() profileId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
@ -83,16 +58,6 @@ export class ProfileFamilyFatherController extends Controller {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
const familyFather = await this.ProfileFamilyFather.findOne({ const familyFather = await this.ProfileFamilyFather.findOne({
select: [
"id",
"fatherPrefix",
"fatherFirstName",
"fatherLastName",
"fatherCareer",
"fatherCitizenId",
"fatherLive",
"profileId",
],
where: { profileId }, where: { profileId },
order: { lastUpdatedAt: "DESC" }, order: { lastUpdatedAt: "DESC" },
}); });
@ -142,29 +107,6 @@ export class ProfileFamilyFatherController extends Controller {
} }
@Get("history/{profileId}") @Get("history/{profileId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
createdAt: "2024-03-19T11:00:29.769Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-19T11:00:29.769Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
fatherPrefix: "string",
fatherFirstName: "string",
fatherLastName: "string",
fatherCareer: "string",
fatherCitizenId: "string",
fatherLive: true,
profileFamilyFatherId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
},
],
})
public async familyFatherHistory(@Path() profileId: string, @Request() req: RequestWithUser) { public async familyFatherHistory(@Path() profileId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
@ -222,6 +164,8 @@ export class ProfileFamilyFatherController extends Controller {
familyFather.createdFullName = req.user.name; familyFather.createdFullName = req.user.name;
familyFather.lastUpdateUserId = req.user.sub; familyFather.lastUpdateUserId = req.user.sub;
familyFather.lastUpdateFullName = req.user.name; familyFather.lastUpdateFullName = req.user.name;
familyFather.createdAt = new Date();
familyFather.lastUpdatedAt = new Date();
const history = new ProfileFamilyFatherHistory(); const history = new ProfileFamilyFatherHistory();
Object.assign(history, { ...familyFather, id: undefined }); Object.assign(history, { ...familyFather, id: undefined });
@ -251,10 +195,13 @@ export class ProfileFamilyFatherController extends Controller {
history.profileFamilyFatherId = familyFather.id; //profileFamilyFatherId history.profileFamilyFatherId = familyFather.id; //profileFamilyFatherId
familyFather.lastUpdateUserId = req.user.sub; familyFather.lastUpdateUserId = req.user.sub;
familyFather.lastUpdateFullName = req.user.name; familyFather.lastUpdateFullName = req.user.name;
familyFather.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.ProfileFamilyFather.save(familyFather), this.ProfileFamilyFather.save(familyFather),

View file

@ -1,7 +1,6 @@
import { import {
Body, Body,
Controller, Controller,
Delete,
Example, Example,
Get, Get,
Patch, Patch,
@ -41,16 +40,6 @@ export class ProfileFamilyFatherEmployeeController extends Controller {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
const familyFather = await this.ProfileFamilyFather.findOne({ const familyFather = await this.ProfileFamilyFather.findOne({
select: [
"id",
"fatherPrefix",
"fatherFirstName",
"fatherLastName",
"fatherCareer",
"fatherCitizenId",
"fatherLive",
"profileId",
],
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
order: { lastUpdatedAt: "DESC" }, order: { lastUpdatedAt: "DESC" },
}); });
@ -59,20 +48,6 @@ export class ProfileFamilyFatherEmployeeController extends Controller {
} }
@Get("{profileEmployeeId}") @Get("{profileEmployeeId}")
@Example({
status: 200,
message: "สำเร็จ",
result: {
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
fatherPrefix: "string",
fatherFirstName: "string",
fatherLastName: "string",
fatherCareer: "string",
fatherCitizenId: "string",
fatherLive: true,
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
},
})
public async getFamilyFather(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { public async getFamilyFather(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
@ -82,16 +57,6 @@ export class ProfileFamilyFatherEmployeeController extends Controller {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
const familyFather = await this.ProfileFamilyFather.findOne({ const familyFather = await this.ProfileFamilyFather.findOne({
select: [
"id",
"fatherPrefix",
"fatherFirstName",
"fatherLastName",
"fatherCareer",
"fatherCitizenId",
"fatherLive",
"profileEmployeeId",
],
where: { profileEmployeeId }, where: { profileEmployeeId },
order: { lastUpdatedAt: "DESC" }, order: { lastUpdatedAt: "DESC" },
}); });
@ -141,30 +106,10 @@ export class ProfileFamilyFatherEmployeeController extends Controller {
} }
@Get("history/{profileEmployeeId}") @Get("history/{profileEmployeeId}")
@Example({ public async familyFatherHistory(
status: 200, @Path() profileEmployeeId: string,
message: "สำเร็จ", @Request() req: RequestWithUser,
result: [ ) {
{
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
createdAt: "2024-03-19T11:00:29.769Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-19T11:00:29.769Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
fatherPrefix: "string",
fatherFirstName: "string",
fatherLastName: "string",
fatherCareer: "string",
fatherCitizenId: "string",
fatherLive: true,
profileFamilyFatherId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
},
],
})
public async familyFatherHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
where: { id: profileEmployeeId }, where: { id: profileEmployeeId },
@ -221,6 +166,8 @@ export class ProfileFamilyFatherEmployeeController extends Controller {
familyFather.createdFullName = req.user.name; familyFather.createdFullName = req.user.name;
familyFather.lastUpdateUserId = req.user.sub; familyFather.lastUpdateUserId = req.user.sub;
familyFather.lastUpdateFullName = req.user.name; familyFather.lastUpdateFullName = req.user.name;
familyFather.createdAt = new Date();
familyFather.lastUpdatedAt = new Date();
const history = new ProfileFamilyFatherHistory(); const history = new ProfileFamilyFatherHistory();
Object.assign(history, { ...familyFather, id: undefined }); Object.assign(history, { ...familyFather, id: undefined });
@ -252,10 +199,13 @@ export class ProfileFamilyFatherEmployeeController extends Controller {
history.profileFamilyFatherId = familyFather.id; history.profileFamilyFatherId = familyFather.id;
familyFather.lastUpdateUserId = req.user.sub; familyFather.lastUpdateUserId = req.user.sub;
familyFather.lastUpdateFullName = req.user.name; familyFather.lastUpdateFullName = req.user.name;
familyFather.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.ProfileFamilyFather.save(familyFather), this.ProfileFamilyFather.save(familyFather),

View file

@ -1,7 +1,6 @@
import { import {
Body, Body,
Controller, Controller,
Delete,
Example, Example,
Get, Get,
Patch, Patch,
@ -41,16 +40,6 @@ export class ProfileFamilyFatherEmployeeTempController extends Controller {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
const familyFather = await this.ProfileFamilyFather.findOne({ const familyFather = await this.ProfileFamilyFather.findOne({
select: [
"id",
"fatherPrefix",
"fatherFirstName",
"fatherLastName",
"fatherCareer",
"fatherCitizenId",
"fatherLive",
"profileId",
],
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
order: { lastUpdatedAt: "DESC" }, order: { lastUpdatedAt: "DESC" },
}); });
@ -59,20 +48,6 @@ export class ProfileFamilyFatherEmployeeTempController extends Controller {
} }
@Get("{profileEmployeeId}") @Get("{profileEmployeeId}")
@Example({
status: 200,
message: "สำเร็จ",
result: {
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
fatherPrefix: "string",
fatherFirstName: "string",
fatherLastName: "string",
fatherCareer: "string",
fatherCitizenId: "string",
fatherLive: true,
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
},
})
public async getFamilyFather(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { public async getFamilyFather(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
@ -83,16 +58,6 @@ export class ProfileFamilyFatherEmployeeTempController extends Controller {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
const familyFather = await this.ProfileFamilyFather.findOne({ const familyFather = await this.ProfileFamilyFather.findOne({
select: [
"id",
"fatherPrefix",
"fatherFirstName",
"fatherLastName",
"fatherCareer",
"fatherCitizenId",
"fatherLive",
"profileEmployeeId",
],
where: { profileEmployeeId }, where: { profileEmployeeId },
order: { lastUpdatedAt: "DESC" }, order: { lastUpdatedAt: "DESC" },
}); });
@ -142,30 +107,10 @@ export class ProfileFamilyFatherEmployeeTempController extends Controller {
} }
@Get("history/{profileEmployeeId}") @Get("history/{profileEmployeeId}")
@Example({ public async familyFatherHistory(
status: 200, @Path() profileEmployeeId: string,
message: "สำเร็จ", @Request() req: RequestWithUser,
result: [ ) {
{
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
createdAt: "2024-03-19T11:00:29.769Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-19T11:00:29.769Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
fatherPrefix: "string",
fatherFirstName: "string",
fatherLastName: "string",
fatherCareer: "string",
fatherCitizenId: "string",
fatherLive: true,
profileFamilyFatherId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
},
],
})
public async familyFatherHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
where: { id: profileEmployeeId }, where: { id: profileEmployeeId },
@ -222,6 +167,8 @@ export class ProfileFamilyFatherEmployeeTempController extends Controller {
familyFather.createdFullName = req.user.name; familyFather.createdFullName = req.user.name;
familyFather.lastUpdateUserId = req.user.sub; familyFather.lastUpdateUserId = req.user.sub;
familyFather.lastUpdateFullName = req.user.name; familyFather.lastUpdateFullName = req.user.name;
familyFather.createdAt = new Date();
familyFather.lastUpdatedAt = new Date();
const history = new ProfileFamilyFatherHistory(); const history = new ProfileFamilyFatherHistory();
Object.assign(history, { ...familyFather, id: undefined }); Object.assign(history, { ...familyFather, id: undefined });
@ -253,10 +200,13 @@ export class ProfileFamilyFatherEmployeeTempController extends Controller {
history.profileFamilyFatherId = familyFather.id; history.profileFamilyFatherId = familyFather.id;
familyFather.lastUpdateUserId = req.user.sub; familyFather.lastUpdateUserId = req.user.sub;
familyFather.lastUpdateFullName = req.user.name; familyFather.lastUpdateFullName = req.user.name;
familyFather.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.ProfileFamilyFather.save(familyFather), this.ProfileFamilyFather.save(familyFather),

View file

@ -1,7 +1,6 @@
import { import {
Body, Body,
Controller, Controller,
Delete,
Example, Example,
Get, Get,
Patch, Patch,
@ -41,16 +40,6 @@ export class ProfileFamilyMotherController extends Controller {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
const familyMother = await this.ProfileFamilyMother.findOne({ const familyMother = await this.ProfileFamilyMother.findOne({
select: [
"id",
"motherPrefix",
"motherFirstName",
"motherLastName",
"motherCareer",
"motherCitizenId",
"motherLive",
"profileId",
],
where: { profileId: profile.id }, where: { profileId: profile.id },
order: { lastUpdatedAt: "DESC" }, order: { lastUpdatedAt: "DESC" },
}); });
@ -59,20 +48,6 @@ export class ProfileFamilyMotherController extends Controller {
} }
@Get("{profileId}") @Get("{profileId}")
@Example({
status: 200,
message: "สำเร็จ",
result: {
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
motherPrefix: "string",
motherFirstName: "string",
motherLastName: "string",
motherCareer: "string",
motherCitizenId: "string",
motherLive: true,
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
},
})
public async getFamilyMother(@Path() profileId: string, @Request() req: RequestWithUser) { public async getFamilyMother(@Path() profileId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
@ -83,16 +58,6 @@ export class ProfileFamilyMotherController extends Controller {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
const familyMother = await this.ProfileFamilyMother.findOne({ const familyMother = await this.ProfileFamilyMother.findOne({
select: [
"id",
"motherPrefix",
"motherFirstName",
"motherLastName",
"motherCareer",
"motherCitizenId",
"motherLive",
"profileId",
],
where: { profileId }, where: { profileId },
order: { lastUpdatedAt: "DESC" }, order: { lastUpdatedAt: "DESC" },
}); });
@ -142,29 +107,6 @@ export class ProfileFamilyMotherController extends Controller {
} }
@Get("history/{profileId}") @Get("history/{profileId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
createdAt: "2024-03-19T11:00:29.769Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-19T11:00:29.769Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
motherPrefix: "string",
motherFirstName: "string",
motherLastName: "string",
motherCareer: "string",
motherCitizenId: "string",
motherLive: true,
profileFamilyMotherId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
},
],
})
public async familyMotherHistory(@Path() profileId: string, @Request() req: RequestWithUser) { public async familyMotherHistory(@Path() profileId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
@ -221,6 +163,8 @@ export class ProfileFamilyMotherController extends Controller {
familyMother.createdFullName = req.user.name; familyMother.createdFullName = req.user.name;
familyMother.lastUpdateUserId = req.user.sub; familyMother.lastUpdateUserId = req.user.sub;
familyMother.lastUpdateFullName = req.user.name; familyMother.lastUpdateFullName = req.user.name;
familyMother.createdAt = new Date();
familyMother.lastUpdatedAt = new Date();
const history = new ProfileFamilyMotherHistory(); const history = new ProfileFamilyMotherHistory();
Object.assign(history, { ...familyMother, id: undefined }); Object.assign(history, { ...familyMother, id: undefined });
@ -250,10 +194,13 @@ export class ProfileFamilyMotherController extends Controller {
history.profileFamilyMotherId = familyMother.id; history.profileFamilyMotherId = familyMother.id;
familyMother.lastUpdateUserId = req.user.sub; familyMother.lastUpdateUserId = req.user.sub;
familyMother.lastUpdateFullName = req.user.name; familyMother.lastUpdateFullName = req.user.name;
familyMother.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.ProfileFamilyMother.save(familyMother), this.ProfileFamilyMother.save(familyMother),

View file

@ -1,7 +1,6 @@
import { import {
Body, Body,
Controller, Controller,
Delete,
Example, Example,
Get, Get,
Patch, Patch,
@ -41,16 +40,6 @@ export class ProfileFamilyMotherEmployeeController extends Controller {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
const familyMother = await this.ProfileFamilyMother.findOne({ const familyMother = await this.ProfileFamilyMother.findOne({
select: [
"id",
"motherPrefix",
"motherFirstName",
"motherLastName",
"motherCareer",
"motherCitizenId",
"motherLive",
"profileId",
],
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
order: { lastUpdatedAt: "DESC" }, order: { lastUpdatedAt: "DESC" },
}); });
@ -59,20 +48,6 @@ export class ProfileFamilyMotherEmployeeController extends Controller {
} }
@Get("{profileEmployeeId}") @Get("{profileEmployeeId}")
@Example({
status: 200,
message: "สำเร็จ",
result: {
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
motherPrefix: "string",
motherFirstName: "string",
motherLastName: "string",
motherCareer: "string",
motherCitizenId: "string",
motherLive: true,
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
},
})
public async getFamilyMother(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { public async getFamilyMother(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
@ -83,16 +58,6 @@ export class ProfileFamilyMotherEmployeeController extends Controller {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
const familyMother = await this.ProfileFamilyMother.findOne({ const familyMother = await this.ProfileFamilyMother.findOne({
select: [
"id",
"motherPrefix",
"motherFirstName",
"motherLastName",
"motherCareer",
"motherCitizenId",
"motherLive",
"profileEmployeeId",
],
where: { profileEmployeeId }, where: { profileEmployeeId },
order: { lastUpdatedAt: "DESC" }, order: { lastUpdatedAt: "DESC" },
}); });
@ -142,30 +107,10 @@ export class ProfileFamilyMotherEmployeeController extends Controller {
} }
@Get("history/{profileEmployeeId}") @Get("history/{profileEmployeeId}")
@Example({ public async familyMotherHistory(
status: 200, @Path() profileEmployeeId: string,
message: "สำเร็จ", @Request() req: RequestWithUser,
result: [ ) {
{
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
createdAt: "2024-03-19T11:00:29.769Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-19T11:00:29.769Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
motherPrefix: "string",
motherFirstName: "string",
motherLastName: "string",
motherCareer: "string",
motherCitizenId: "string",
motherLive: true,
profileFamilyMotherId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
},
],
})
public async familyMotherHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
where: { id: profileEmployeeId }, where: { id: profileEmployeeId },
@ -221,6 +166,8 @@ export class ProfileFamilyMotherEmployeeController extends Controller {
familyMother.createdFullName = req.user.name; familyMother.createdFullName = req.user.name;
familyMother.lastUpdateUserId = req.user.sub; familyMother.lastUpdateUserId = req.user.sub;
familyMother.lastUpdateFullName = req.user.name; familyMother.lastUpdateFullName = req.user.name;
familyMother.createdAt = new Date();
familyMother.lastUpdatedAt = new Date();
const history = new ProfileFamilyMotherHistory(); const history = new ProfileFamilyMotherHistory();
Object.assign(history, { ...familyMother, id: undefined }); Object.assign(history, { ...familyMother, id: undefined });
@ -252,10 +199,13 @@ export class ProfileFamilyMotherEmployeeController extends Controller {
history.profileFamilyMotherId = familyMother.id; history.profileFamilyMotherId = familyMother.id;
familyMother.lastUpdateUserId = req.user.sub; familyMother.lastUpdateUserId = req.user.sub;
familyMother.lastUpdateFullName = req.user.name; familyMother.lastUpdateFullName = req.user.name;
familyMother.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.ProfileFamilyMother.save(familyMother), this.ProfileFamilyMother.save(familyMother),

View file

@ -1,7 +1,6 @@
import { import {
Body, Body,
Controller, Controller,
Delete,
Example, Example,
Get, Get,
Patch, Patch,
@ -41,16 +40,6 @@ export class ProfileFamilyMotherEmployeeTempController extends Controller {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
const familyMother = await this.ProfileFamilyMother.findOne({ const familyMother = await this.ProfileFamilyMother.findOne({
select: [
"id",
"motherPrefix",
"motherFirstName",
"motherLastName",
"motherCareer",
"motherCitizenId",
"motherLive",
"profileId",
],
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
order: { lastUpdatedAt: "DESC" }, order: { lastUpdatedAt: "DESC" },
}); });
@ -59,20 +48,6 @@ export class ProfileFamilyMotherEmployeeTempController extends Controller {
} }
@Get("{profileEmployeeId}") @Get("{profileEmployeeId}")
@Example({
status: 200,
message: "สำเร็จ",
result: {
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
motherPrefix: "string",
motherFirstName: "string",
motherLastName: "string",
motherCareer: "string",
motherCitizenId: "string",
motherLive: true,
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
},
})
public async getFamilyMother(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { public async getFamilyMother(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
@ -83,16 +58,6 @@ export class ProfileFamilyMotherEmployeeTempController extends Controller {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
const familyMother = await this.ProfileFamilyMother.findOne({ const familyMother = await this.ProfileFamilyMother.findOne({
select: [
"id",
"motherPrefix",
"motherFirstName",
"motherLastName",
"motherCareer",
"motherCitizenId",
"motherLive",
"profileEmployeeId",
],
where: { profileEmployeeId }, where: { profileEmployeeId },
order: { lastUpdatedAt: "DESC" }, order: { lastUpdatedAt: "DESC" },
}); });
@ -142,30 +107,10 @@ export class ProfileFamilyMotherEmployeeTempController extends Controller {
} }
@Get("history/{profileEmployeeId}") @Get("history/{profileEmployeeId}")
@Example({ public async familyMotherHistory(
status: 200, @Path() profileEmployeeId: string,
message: "สำเร็จ", @Request() req: RequestWithUser,
result: [ ) {
{
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
createdAt: "2024-03-19T11:00:29.769Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-19T11:00:29.769Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
motherPrefix: "string",
motherFirstName: "string",
motherLastName: "string",
motherCareer: "string",
motherCitizenId: "string",
motherLive: true,
profileFamilyMotherId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
},
],
})
public async familyMotherHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
where: { id: profileEmployeeId }, where: { id: profileEmployeeId },
@ -222,6 +167,8 @@ export class ProfileFamilyMotherEmployeeTempController extends Controller {
familyMother.createdFullName = req.user.name; familyMother.createdFullName = req.user.name;
familyMother.lastUpdateUserId = req.user.sub; familyMother.lastUpdateUserId = req.user.sub;
familyMother.lastUpdateFullName = req.user.name; familyMother.lastUpdateFullName = req.user.name;
familyMother.createdAt = new Date();
familyMother.lastUpdatedAt = new Date();
const history = new ProfileFamilyMotherHistory(); const history = new ProfileFamilyMotherHistory();
Object.assign(history, { ...familyMother, id: undefined }); Object.assign(history, { ...familyMother, id: undefined });
@ -253,10 +200,13 @@ export class ProfileFamilyMotherEmployeeTempController extends Controller {
history.profileFamilyMotherId = familyMother.id; history.profileFamilyMotherId = familyMother.id;
familyMother.lastUpdateUserId = req.user.sub; familyMother.lastUpdateUserId = req.user.sub;
familyMother.lastUpdateFullName = req.user.name; familyMother.lastUpdateFullName = req.user.name;
familyMother.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.ProfileFamilyMother.save(familyMother), this.ProfileFamilyMother.save(familyMother),

View file

@ -389,15 +389,18 @@ export class ProfileGovernmentHistoryController extends Controller {
const history = new ProfileGovernment(); const history = new ProfileGovernment();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileId = profileId; history.profileId = profileId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([this.profileRepo.save(record), this.govRepo.save(history)]); await Promise.all([this.profileRepo.save(record), this.govRepo.save(history)]);

View file

@ -343,7 +343,7 @@ export class ProfileGovernmentEmployeeController extends Controller {
@Get("history/{profileEmployeeId}") @Get("history/{profileEmployeeId}")
@Example({}) @Example({})
public async govHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { public async govHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId) await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
const record = await this.govRepo.find({ const record = await this.govRepo.find({
order: { lastUpdatedAt: "DESC" }, order: { lastUpdatedAt: "DESC" },
where: { profileEmployeeId: profileEmployeeId }, where: { profileEmployeeId: profileEmployeeId },
@ -362,7 +362,7 @@ export class ProfileGovernmentEmployeeController extends Controller {
@Body() body: UpdateProfileGovernment, @Body() body: UpdateProfileGovernment,
@Path() profileEmployeeId: string, @Path() profileEmployeeId: string,
) { ) {
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profileEmployeeId) await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profileEmployeeId);
const record = await this.profileEmployeeRepo.findOne({ const record = await this.profileEmployeeRepo.findOne({
where: { id: profileEmployeeId }, where: { id: profileEmployeeId },
}); });
@ -371,15 +371,18 @@ export class ProfileGovernmentEmployeeController extends Controller {
const history = new ProfileGovernment(); const history = new ProfileGovernment();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileEmployeeId = profileEmployeeId; history.profileEmployeeId = profileEmployeeId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([this.profileEmployeeRepo.save(record), this.govRepo.save(history)]); await Promise.all([this.profileEmployeeRepo.save(record), this.govRepo.save(history)]);
return new HttpSuccess(); return new HttpSuccess();

View file

@ -372,15 +372,18 @@ export class ProfileGovernmentEmployeeTempController extends Controller {
const history = new ProfileGovernment(); const history = new ProfileGovernment();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileEmployeeId = profileEmployeeId; history.profileEmployeeId = profileEmployeeId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([this.profileEmployeeRepo.save(record), this.govRepo.save(history)]); await Promise.all([this.profileEmployeeRepo.save(record), this.govRepo.save(history)]);
return new HttpSuccess(); return new HttpSuccess();

View file

@ -2,7 +2,6 @@ import {
Body, Body,
Controller, Controller,
Delete, Delete,
Example,
Get, Get,
Patch, Patch,
Path, Path,
@ -37,36 +36,18 @@ export class ProfileHonorController extends Controller {
} }
const record = await this.honorRepo.find({ const record = await this.honorRepo.find({
where: { profileId: profile.id }, where: { profileId: profile.id },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@Get("{profileId}") @Get("{profileId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
createdAt: "2024-03-12T03:10:05.594Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T03:10:05.594Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
detail: "string",
issueDate: "2024-03-12T10:09:47.000Z",
issuer: "string",
refCommandDate: "2024-03-12T10:09:47.000Z",
refCommandNo: "string",
isDate: true,
},
],
})
public async getHonor(@Path() profileId: string, @Request() req: RequestWithUser) { public async getHonor(@Path() profileId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
const record = await this.honorRepo.findBy({ profileId }); const record = await this.honorRepo.find({
where: { profileId: profileId },
order: { createdAt: "ASC" },
});
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@ -87,56 +68,22 @@ export class ProfileHonorController extends Controller {
profileId: profile.id, profileId: profile.id,
}, },
}, },
order: { createdAt: "DESC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@Get("history/{honorId}") @Get("history/{honorId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "3bedb365-4a41-4df5-8f47-b6e143221d2c",
createdAt: "2024-03-12T03:11:01.395Z",
createdUserId: "00000000-0000-0000-0000-000000000000",
lastUpdatedAt: "2024-03-12T03:11:01.395Z",
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
createdFullName: "string",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
detail: "detail",
issueDate: "2024-03-12T10:10:31.000Z",
issuer: "issuer",
refCommandDate: "2024-03-12T10:10:31.000Z",
refCommandNo: "refCommandNo",
isDate: true,
profileHonorId: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
},
{
id: "ba0e2f82-014e-46c6-8b82-a7c28eb5325f",
createdAt: "2024-03-12T03:10:05.657Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T03:10:05.657Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
detail: "string",
issueDate: "2024-03-12T10:09:47.000Z",
issuer: "string",
refCommandDate: "2024-03-12T10:09:47.000Z",
refCommandNo: "string",
isDate: true,
profileHonorId: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
},
],
})
public async honorHistory(@Path() honorId: string, @Request() req: RequestWithUser) { public async honorHistory(@Path() honorId: string, @Request() req: RequestWithUser) {
const _record = await this.honorRepo.findOneBy({ id: honorId }); const _record = await this.honorRepo.findOneBy({ id: honorId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
} }
const record = await this.honorHistoryRepo.findBy({ const record = await this.honorHistoryRepo.find({
profileHonorId: honorId, where: {
profileHonorId: honorId,
},
order: { createdAt: "DESC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@ -161,6 +108,8 @@ export class ProfileHonorController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -187,15 +136,18 @@ export class ProfileHonorController extends Controller {
const history = new ProfileHonorHistory(); const history = new ProfileHonorHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileHonorId = honorId; history.profileHonorId = honorId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([this.honorRepo.save(record), this.honorHistoryRepo.save(history)]); await Promise.all([this.honorRepo.save(record), this.honorHistoryRepo.save(history)]);

View file

@ -2,7 +2,6 @@ import {
Body, Body,
Controller, Controller,
Delete, Delete,
Example,
Get, Get,
Patch, Patch,
Path, Path,
@ -41,36 +40,18 @@ export class ProfileHonorEmployeeController extends Controller {
} }
const record = await this.honorRepo.find({ const record = await this.honorRepo.find({
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@Get("{profileEmployeeId}") @Get("{profileEmployeeId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
createdAt: "2024-03-12T03:10:05.594Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T03:10:05.594Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
detail: "string",
issueDate: "2024-03-12T10:09:47.000Z",
issuer: "string",
refCommandDate: "2024-03-12T10:09:47.000Z",
refCommandNo: "string",
isDate: true,
},
],
})
public async getHonor(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { public async getHonor(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
const record = await this.honorRepo.findBy({ profileEmployeeId }); const record = await this.honorRepo.find({
where: { profileEmployeeId: profileEmployeeId },
order: { createdAt: "ASC" },
});
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@ -91,57 +72,27 @@ export class ProfileHonorEmployeeController extends Controller {
profileEmployeeId: profile.id, profileEmployeeId: profile.id,
}, },
}, },
order: { createdAt: "DESC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@Get("history/{honorId}") @Get("history/{honorId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "3bedb365-4a41-4df5-8f47-b6e143221d2c",
createdAt: "2024-03-12T03:11:01.395Z",
createdUserId: "00000000-0000-0000-0000-000000000000",
lastUpdatedAt: "2024-03-12T03:11:01.395Z",
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
createdFullName: "string",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
detail: "detail",
issueDate: "2024-03-12T10:10:31.000Z",
issuer: "issuer",
refCommandDate: "2024-03-12T10:10:31.000Z",
refCommandNo: "refCommandNo",
isDate: true,
profileHonorId: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
},
{
id: "ba0e2f82-014e-46c6-8b82-a7c28eb5325f",
createdAt: "2024-03-12T03:10:05.657Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T03:10:05.657Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
detail: "string",
issueDate: "2024-03-12T10:09:47.000Z",
issuer: "string",
refCommandDate: "2024-03-12T10:09:47.000Z",
refCommandNo: "string",
isDate: true,
profileHonorId: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
},
],
})
public async honorHistory(@Path() honorId: string, @Request() req: RequestWithUser) { public async honorHistory(@Path() honorId: string, @Request() req: RequestWithUser) {
const _record = await this.honorRepo.findOneBy({ id: honorId }); const _record = await this.honorRepo.findOneBy({ id: honorId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); await new permission().PermissionOrgUserGet(
req,
"SYS_REGISTRY_EMP",
_record.profileEmployeeId,
);
} }
const record = await this.honorHistoryRepo.findBy({ const record = await this.honorHistoryRepo.find({
profileHonorId: honorId, where: {
profileHonorId: honorId,
},
order: { createdAt: "DESC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@ -165,6 +116,8 @@ export class ProfileHonorEmployeeController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -186,20 +139,27 @@ export class ProfileHonorEmployeeController extends Controller {
) { ) {
const record = await this.honorRepo.findOneBy({ id: honorId }); const record = await this.honorRepo.findOneBy({ id: honorId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId) await new permission().PermissionOrgUserUpdate(
req,
"SYS_REGISTRY_EMP",
record.profileEmployeeId,
);
const history = new ProfileHonorHistory(); const history = new ProfileHonorHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileHonorId = honorId; history.profileHonorId = honorId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([this.honorRepo.save(record), this.honorHistoryRepo.save(history)]); await Promise.all([this.honorRepo.save(record), this.honorHistoryRepo.save(history)]);
@ -210,7 +170,11 @@ export class ProfileHonorEmployeeController extends Controller {
public async deleteTraning(@Path() honorId: string, @Request() req: RequestWithUser) { public async deleteTraning(@Path() honorId: string, @Request() req: RequestWithUser) {
const _record = await this.honorRepo.findOneBy({ id: honorId }); const _record = await this.honorRepo.findOneBy({ id: honorId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); await new permission().PermissionOrgUserDelete(
req,
"SYS_REGISTRY_EMP",
_record.profileEmployeeId,
);
} }
await this.honorHistoryRepo.delete({ await this.honorHistoryRepo.delete({

View file

@ -2,7 +2,6 @@ import {
Body, Body,
Controller, Controller,
Delete, Delete,
Example,
Get, Get,
Patch, Patch,
Path, Path,
@ -41,36 +40,18 @@ export class ProfileHonorEmployeeTempController extends Controller {
} }
const record = await this.honorRepo.find({ const record = await this.honorRepo.find({
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@Get("{profileEmployeeId}") @Get("{profileEmployeeId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
createdAt: "2024-03-12T03:10:05.594Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T03:10:05.594Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
detail: "string",
issueDate: "2024-03-12T10:09:47.000Z",
issuer: "string",
refCommandDate: "2024-03-12T10:09:47.000Z",
refCommandNo: "string",
isDate: true,
},
],
})
public async getHonor(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { public async getHonor(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const record = await this.honorRepo.findBy({ profileEmployeeId }); const record = await this.honorRepo.find({
where: { profileEmployeeId: profileEmployeeId },
order: { createdAt: "ASC" },
});
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@ -91,53 +72,19 @@ export class ProfileHonorEmployeeTempController extends Controller {
profileEmployeeId: profile.id, profileEmployeeId: profile.id,
}, },
}, },
order: { createdAt: "DESC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@Get("history/{honorId}") @Get("history/{honorId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "3bedb365-4a41-4df5-8f47-b6e143221d2c",
createdAt: "2024-03-12T03:11:01.395Z",
createdUserId: "00000000-0000-0000-0000-000000000000",
lastUpdatedAt: "2024-03-12T03:11:01.395Z",
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
createdFullName: "string",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
detail: "detail",
issueDate: "2024-03-12T10:10:31.000Z",
issuer: "issuer",
refCommandDate: "2024-03-12T10:10:31.000Z",
refCommandNo: "refCommandNo",
isDate: true,
profileHonorId: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
},
{
id: "ba0e2f82-014e-46c6-8b82-a7c28eb5325f",
createdAt: "2024-03-12T03:10:05.657Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T03:10:05.657Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
detail: "string",
issueDate: "2024-03-12T10:09:47.000Z",
issuer: "string",
refCommandDate: "2024-03-12T10:09:47.000Z",
refCommandNo: "string",
isDate: true,
profileHonorId: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
},
],
})
public async honorHistory(@Path() honorId: string, @Request() req: RequestWithUser) { public async honorHistory(@Path() honorId: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const record = await this.honorHistoryRepo.findBy({ const record = await this.honorHistoryRepo.find({
profileHonorId: honorId, where: {
profileHonorId: honorId,
},
order: { createdAt: "DESC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@ -162,6 +109,8 @@ export class ProfileHonorEmployeeTempController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -189,15 +138,18 @@ export class ProfileHonorEmployeeTempController extends Controller {
const history = new ProfileHonorHistory(); const history = new ProfileHonorHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileHonorId = honorId; history.profileHonorId = honorId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([this.honorRepo.save(record), this.honorHistoryRepo.save(history)]); await Promise.all([this.honorRepo.save(record), this.honorHistoryRepo.save(history)]);

View file

@ -2,7 +2,6 @@ import {
Body, Body,
Controller, Controller,
Delete, Delete,
Example,
Get, Get,
Patch, Patch,
Path, Path,
@ -48,41 +47,12 @@ export class ProfileInsigniaController extends Controller {
}, },
}, },
where: { profileId: profile.id }, where: { profileId: profile.id },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@Get("{profileId}") @Get("{profileId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "c9d4dd52-25f5-491a-852d-28bfe00d66cb",
createdAt: "2024-03-12T03:05:09.393Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T03:05:09.393Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
year: 0,
no: "string",
volume: "string",
section: "string",
page: "string",
receiveDate: "2024-03-12T10:05:02.000Z",
insigniaId: "string",
insigniaType: "string",
dateAnnounce: "2024-03-12T10:05:02.000Z",
issue: "string",
volumeNo: "string",
refCommandDate: "2024-03-12T10:05:02.000Z",
refCommandNo: "string",
note: "string",
},
],
})
public async getInsignia(@Path() profileId: string, @Request() req: RequestWithUser) { public async getInsignia(@Path() profileId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
const record = await this.insigniaRepo.find({ const record = await this.insigniaRepo.find({
@ -92,70 +62,17 @@ export class ProfileInsigniaController extends Controller {
}, },
}, },
where: { profileId }, where: { profileId },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@Get("history/{InsigniaId}") @Get("history/{InsigniaId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "c363d13c-88bd-4954-adf5-70d3f5ca9c30",
createdAt: "2024-03-12T03:06:31.062Z",
createdUserId: "00000000-0000-0000-0000-000000000000",
lastUpdatedAt: "2024-03-12T03:06:31.062Z",
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
createdFullName: "string",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
year: 0,
no: "no",
volume: "volume",
section: "section",
page: "page",
receiveDate: "2024-03-12T10:05:44.000Z",
insigniaId: "insigniaId",
insigniaType: "insigniaType",
dateAnnounce: "2024-03-12T10:05:44.000Z",
issue: "string",
volumeNo: "volumeNo",
refCommandDate: "2024-03-12T10:05:44.000Z",
refCommandNo: "refCommandNo",
note: "string",
profileInsigniaId: "c9d4dd52-25f5-491a-852d-28bfe00d66cb",
},
{
id: "c9d4dd52-25f5-491a-852d-28bfe00d66cb",
createdAt: "2024-03-12T03:05:09.393Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T03:09:04.905Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
year: 0,
no: "string",
volume: "string",
section: "string",
page: "string",
receiveDate: "2024-03-12T10:05:02.000Z",
insigniaId: "string",
insigniaType: "string",
dateAnnounce: "2024-03-12T10:05:02.000Z",
issue: "string",
volumeNo: "string",
refCommandDate: "2024-03-12T10:05:02.000Z",
refCommandNo: "string",
note: "string",
profileInsigniaId: "c9d4dd52-25f5-491a-852d-28bfe00d66cb",
},
],
})
public async getInsigniaHistory(@Path() InsigniaId: string, @Request() req: RequestWithUser) { public async getInsigniaHistory(@Path() InsigniaId: string, @Request() req: RequestWithUser) {
const _record = await this.insigniaRepo.findOneBy({ id: InsigniaId }); const _record = await this.insigniaRepo.findOneBy({ id: InsigniaId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
} }
const record = await this.insigniaHistoryRepo.find({ const record = await this.insigniaHistoryRepo.find({
relations: { relations: {
insignia: { insignia: {
@ -165,6 +82,7 @@ export class ProfileInsigniaController extends Controller {
where: { where: {
profileInsigniaId: InsigniaId, profileInsigniaId: InsigniaId,
}, },
order: { createdAt: "DESC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@ -195,6 +113,8 @@ export class ProfileInsigniaController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -228,15 +148,18 @@ export class ProfileInsigniaController extends Controller {
const history = new ProfileInsigniaHistory(); const history = new ProfileInsigniaHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileInsigniaId = insigniaId; history.profileInsigniaId = insigniaId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([this.insigniaRepo.save(record), this.insigniaHistoryRepo.save(history)]); await Promise.all([this.insigniaRepo.save(record), this.insigniaHistoryRepo.save(history)]);
@ -247,7 +170,11 @@ export class ProfileInsigniaController extends Controller {
public async deleteInsignia(@Path() insigniaId: string, @Request() req: RequestWithUser) { public async deleteInsignia(@Path() insigniaId: string, @Request() req: RequestWithUser) {
const _record = await this.insigniaRepo.findOneBy({ id: insigniaId }); const _record = await this.insigniaRepo.findOneBy({ id: insigniaId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId); await new permission().PermissionOrgUserDelete(
req,
"SYS_REGISTRY_OFFICER",
_record.profileId,
);
} }
await this.insigniaHistoryRepo.delete({ await this.insigniaHistoryRepo.delete({
profileInsigniaId: insigniaId, profileInsigniaId: insigniaId,
@ -291,6 +218,8 @@ export class ProfileInsigniaController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });

View file

@ -2,7 +2,6 @@ import {
Body, Body,
Controller, Controller,
Delete, Delete,
Example,
Get, Get,
Patch, Patch,
Path, Path,
@ -48,41 +47,12 @@ export class ProfileInsigniaEmployeeController extends Controller {
}, },
}, },
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@Get("{profileEmployeeId}") @Get("{profileEmployeeId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "c9d4dd52-25f5-491a-852d-28bfe00d66cb",
createdAt: "2024-03-12T03:05:09.393Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T03:05:09.393Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
year: 0,
no: "string",
volume: "string",
section: "string",
page: "string",
receiveDate: "2024-03-12T10:05:02.000Z",
insigniaId: "string",
insigniaType: "string",
dateAnnounce: "2024-03-12T10:05:02.000Z",
issue: "string",
volumeNo: "string",
refCommandDate: "2024-03-12T10:05:02.000Z",
refCommandNo: "string",
note: "string",
},
],
})
public async getInsignia(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { public async getInsignia(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
const record = await this.insigniaRepo.find({ const record = await this.insigniaRepo.find({
@ -92,69 +62,20 @@ export class ProfileInsigniaEmployeeController extends Controller {
}, },
}, },
where: { profileEmployeeId }, where: { profileEmployeeId },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@Get("history/{InsigniaId}") @Get("history/{InsigniaId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "c363d13c-88bd-4954-adf5-70d3f5ca9c30",
createdAt: "2024-03-12T03:06:31.062Z",
createdUserId: "00000000-0000-0000-0000-000000000000",
lastUpdatedAt: "2024-03-12T03:06:31.062Z",
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
createdFullName: "string",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
year: 0,
no: "no",
volume: "volume",
section: "section",
page: "page",
receiveDate: "2024-03-12T10:05:44.000Z",
insigniaId: "insigniaId",
insigniaType: "insigniaType",
dateAnnounce: "2024-03-12T10:05:44.000Z",
issue: "string",
volumeNo: "volumeNo",
refCommandDate: "2024-03-12T10:05:44.000Z",
refCommandNo: "refCommandNo",
note: "string",
profileInsigniaId: "c9d4dd52-25f5-491a-852d-28bfe00d66cb",
},
{
id: "c9d4dd52-25f5-491a-852d-28bfe00d66cb",
createdAt: "2024-03-12T03:05:09.393Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T03:09:04.905Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
year: 0,
no: "string",
volume: "string",
section: "string",
page: "string",
receiveDate: "2024-03-12T10:05:02.000Z",
insigniaId: "string",
insigniaType: "string",
dateAnnounce: "2024-03-12T10:05:02.000Z",
issue: "string",
volumeNo: "string",
refCommandDate: "2024-03-12T10:05:02.000Z",
refCommandNo: "string",
note: "string",
profileInsigniaId: "c9d4dd52-25f5-491a-852d-28bfe00d66cb",
},
],
})
public async getInsigniaHistory(@Path() InsigniaId: string, @Request() req: RequestWithUser) { public async getInsigniaHistory(@Path() InsigniaId: string, @Request() req: RequestWithUser) {
const _record = await this.insigniaRepo.findOneBy({ id: InsigniaId }); const _record = await this.insigniaRepo.findOneBy({ id: InsigniaId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); await new permission().PermissionOrgUserGet(
req,
"SYS_REGISTRY_EMP",
_record.profileEmployeeId,
);
} }
const record = await this.insigniaHistoryRepo.find({ const record = await this.insigniaHistoryRepo.find({
relations: { relations: {
@ -165,6 +86,7 @@ export class ProfileInsigniaEmployeeController extends Controller {
where: { where: {
profileInsigniaId: InsigniaId, profileInsigniaId: InsigniaId,
}, },
order: { createdAt: "DESC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@ -182,7 +104,7 @@ export class ProfileInsigniaEmployeeController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profile.id) await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profile.id);
const insignia = await this.insigniaMetaRepo.findOne({ const insignia = await this.insigniaMetaRepo.findOne({
where: { id: body.insigniaId }, where: { id: body.insigniaId },
@ -198,6 +120,8 @@ export class ProfileInsigniaEmployeeController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -219,7 +143,11 @@ export class ProfileInsigniaEmployeeController extends Controller {
) { ) {
const record = await this.insigniaRepo.findOneBy({ id: insigniaId }); const record = await this.insigniaRepo.findOneBy({ id: insigniaId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId) await new permission().PermissionOrgUserUpdate(
req,
"SYS_REGISTRY_EMP",
record.profileEmployeeId,
);
const insignia = await this.insigniaMetaRepo.findOne({ const insignia = await this.insigniaMetaRepo.findOne({
where: { id: body.insigniaId }, where: { id: body.insigniaId },
@ -231,15 +159,18 @@ export class ProfileInsigniaEmployeeController extends Controller {
const history = new ProfileInsigniaHistory(); const history = new ProfileInsigniaHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileInsigniaId = insigniaId; history.profileInsigniaId = insigniaId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([this.insigniaRepo.save(record), this.insigniaHistoryRepo.save(history)]); await Promise.all([this.insigniaRepo.save(record), this.insigniaHistoryRepo.save(history)]);
@ -250,7 +181,11 @@ export class ProfileInsigniaEmployeeController extends Controller {
public async deleteInsignia(@Path() insigniaId: string, @Request() req: RequestWithUser) { public async deleteInsignia(@Path() insigniaId: string, @Request() req: RequestWithUser) {
const _record = await this.insigniaRepo.findOneBy({ id: insigniaId }); const _record = await this.insigniaRepo.findOneBy({ id: insigniaId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); await new permission().PermissionOrgUserDelete(
req,
"SYS_REGISTRY_EMP",
_record.profileEmployeeId,
);
} }
await this.insigniaHistoryRepo.delete({ await this.insigniaHistoryRepo.delete({

View file

@ -2,7 +2,6 @@ import {
Body, Body,
Controller, Controller,
Delete, Delete,
Example,
Get, Get,
Patch, Patch,
Path, Path,
@ -48,41 +47,12 @@ export class ProfileInsigniaEmployeeTempController extends Controller {
}, },
}, },
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@Get("{profileEmployeeId}") @Get("{profileEmployeeId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "c9d4dd52-25f5-491a-852d-28bfe00d66cb",
createdAt: "2024-03-12T03:05:09.393Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T03:05:09.393Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
year: 0,
no: "string",
volume: "string",
section: "string",
page: "string",
receiveDate: "2024-03-12T10:05:02.000Z",
insigniaId: "string",
insigniaType: "string",
dateAnnounce: "2024-03-12T10:05:02.000Z",
issue: "string",
volumeNo: "string",
refCommandDate: "2024-03-12T10:05:02.000Z",
refCommandNo: "string",
note: "string",
},
],
})
public async getInsignia(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { public async getInsignia(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const record = await this.insigniaRepo.find({ const record = await this.insigniaRepo.find({
@ -92,65 +62,12 @@ export class ProfileInsigniaEmployeeTempController extends Controller {
}, },
}, },
where: { profileEmployeeId }, where: { profileEmployeeId },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@Get("history/{InsigniaId}") @Get("history/{InsigniaId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "c363d13c-88bd-4954-adf5-70d3f5ca9c30",
createdAt: "2024-03-12T03:06:31.062Z",
createdUserId: "00000000-0000-0000-0000-000000000000",
lastUpdatedAt: "2024-03-12T03:06:31.062Z",
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
createdFullName: "string",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
year: 0,
no: "no",
volume: "volume",
section: "section",
page: "page",
receiveDate: "2024-03-12T10:05:44.000Z",
insigniaId: "insigniaId",
insigniaType: "insigniaType",
dateAnnounce: "2024-03-12T10:05:44.000Z",
issue: "string",
volumeNo: "volumeNo",
refCommandDate: "2024-03-12T10:05:44.000Z",
refCommandNo: "refCommandNo",
note: "string",
profileInsigniaId: "c9d4dd52-25f5-491a-852d-28bfe00d66cb",
},
{
id: "c9d4dd52-25f5-491a-852d-28bfe00d66cb",
createdAt: "2024-03-12T03:05:09.393Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T03:09:04.905Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
year: 0,
no: "string",
volume: "string",
section: "string",
page: "string",
receiveDate: "2024-03-12T10:05:02.000Z",
insigniaId: "string",
insigniaType: "string",
dateAnnounce: "2024-03-12T10:05:02.000Z",
issue: "string",
volumeNo: "string",
refCommandDate: "2024-03-12T10:05:02.000Z",
refCommandNo: "string",
note: "string",
profileInsigniaId: "c9d4dd52-25f5-491a-852d-28bfe00d66cb",
},
],
})
public async getInsigniaHistory(@Path() InsigniaId: string, @Request() req: RequestWithUser) { public async getInsigniaHistory(@Path() InsigniaId: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const record = await this.insigniaHistoryRepo.find({ const record = await this.insigniaHistoryRepo.find({
@ -162,6 +79,7 @@ export class ProfileInsigniaEmployeeTempController extends Controller {
where: { where: {
profileInsigniaId: InsigniaId, profileInsigniaId: InsigniaId,
}, },
order: { createdAt: "DESC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@ -196,6 +114,8 @@ export class ProfileInsigniaEmployeeTempController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -230,15 +150,18 @@ export class ProfileInsigniaEmployeeTempController extends Controller {
const history = new ProfileInsigniaHistory(); const history = new ProfileInsigniaHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileInsigniaId = insigniaId; history.profileInsigniaId = insigniaId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([this.insigniaRepo.save(record), this.insigniaHistoryRepo.save(history)]); await Promise.all([this.insigniaRepo.save(record), this.insigniaHistoryRepo.save(history)]);

View file

@ -2,7 +2,6 @@ import {
Body, Body,
Controller, Controller,
Delete, Delete,
Example,
Get, Get,
Patch, Patch,
Path, Path,
@ -25,7 +24,6 @@ import HttpError from "../interfaces/http-error";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import { Profile } from "../entities/Profile"; import { Profile } from "../entities/Profile";
import { LeaveType } from "../entities/LeaveType"; import { LeaveType } from "../entities/LeaveType";
import { Brackets } from "typeorm";
import permission from "../interfaces/permission"; import permission from "../interfaces/permission";
@Route("api/v1/org/profile/leave") @Route("api/v1/org/profile/leave")
@Tags("ProfileLeave") @Tags("ProfileLeave")
@ -121,50 +119,18 @@ export class ProfileLeaveController extends Controller {
const record = await this.leaveRepo.find({ const record = await this.leaveRepo.find({
relations: { leaveType: true }, relations: { leaveType: true },
where: { profileId: profile.id }, where: { profileId: profile.id },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@Get("{profileId}") @Get("{profileId}")
@Example({
status: 200,
message: "สำเร็จ",
result: {
id: "adbb08a6-d2f4-41b0-a9c1-49e883ca96bc",
createdAt: "2024-03-20T23:35:45.230Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-20T23:40:06.000Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
leaveTypeId: "8dc5e672-b416-4323-b086-06dde8c4353c",
dateLeaveStart: "2024-03-21T06:39:46.000Z",
dateLeaveEnd: "2024-03-21T06:39:46.000Z",
leaveDays: 0,
leaveCount: null,
totalLeave: 0,
status: "string",
reason: "string",
leaveType: {
id: "8dc5e672-b416-4323-b086-06dde8c4353c",
createdAt: "2024-02-04T21:28:40.536Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-02-04T21:28:40.536Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
name: "ลาป่วย",
code: "CM-002",
limit: 1,
},
},
})
public async getLeave(@Path() profileId: string, @Request() req: RequestWithUser) { public async getLeave(@Path() profileId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
const record = await this.leaveRepo.find({ const record = await this.leaveRepo.find({
relations: { leaveType: true }, relations: { leaveType: true },
where: { profileId }, where: { profileId },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@ -175,87 +141,21 @@ export class ProfileLeaveController extends Controller {
const record = await this.leaveRepo.find({ const record = await this.leaveRepo.find({
relations: { leaveType: true }, relations: { leaveType: true },
where: { profileId }, where: { profileId },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@Get("history/{leaveId}") @Get("history/{leaveId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "7eed2e72-d71c-4b3b-a90b-e1b7abdaa838",
createdAt: "2024-03-20T23:35:45.230Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-20T23:40:06.000Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
leaveTypeId: "8dc5e672-b416-4323-b086-06dde8c4353c",
dateLeaveStart: "2024-03-21T06:39:46.000Z",
dateLeaveEnd: "2024-03-21T06:39:46.000Z",
leaveDays: 0,
leaveCount: null,
totalLeave: 0,
status: "string",
reason: "string",
leaveType: {
id: "8dc5e672-b416-4323-b086-06dde8c4353c",
createdAt: "2024-02-04T21:28:40.536Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-02-04T21:28:40.536Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
name: "ลาป่วย",
code: "CM-002",
limit: 1,
},
profileLeaveId: "adbb08a6-d2f4-41b0-a9c1-49e883ca96bc",
},
{
id: "b1b9c291-9c96-4cbb-9309-6ff5a2a6e0e8",
createdAt: "2024-03-20T23:35:45.230Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-20T23:35:45.230Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
leaveTypeId: "7dc4e314-b456-4323-b086-06dde8c4353c",
dateLeaveStart: "2024-03-21T06:34:49.000Z",
dateLeaveEnd: "2024-03-21T06:34:49.000Z",
leaveDays: 2,
leaveCount: null,
totalLeave: 200,
status: "ไม่ผ่าน",
reason: "ติดงานสำคัญ",
leaveType: {
id: "7dc4e314-b456-4323-b086-06dde8c4353c",
createdAt: "2024-02-04T21:28:40.536Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-02-04T21:28:40.536Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
name: "ลาพักร้อน",
code: "CM-001",
limit: 356,
},
profileLeaveId: "adbb08a6-d2f4-41b0-a9c1-49e883ca96bc",
},
],
})
public async leaveHistory(@Path() leaveId: string, @Request() req: RequestWithUser) { public async leaveHistory(@Path() leaveId: string, @Request() req: RequestWithUser) {
const _record = await this.leaveRepo.findOneBy({ id: leaveId }); const _record = await this.leaveRepo.findOneBy({ id: leaveId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
} }
const record = await this.leaveHistoryRepo.find({ const record = await this.leaveHistoryRepo.find({
relations: { leaveType: true }, relations: { leaveType: true },
where: { profileLeaveId: leaveId }, where: { profileLeaveId: leaveId },
order: { createdAt: "DESC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@ -286,6 +186,8 @@ export class ProfileLeaveController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -319,15 +221,18 @@ export class ProfileLeaveController extends Controller {
const history = new ProfileLeaveHistory(); const history = new ProfileLeaveHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileLeaveId = leaveId; history.profileLeaveId = leaveId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([this.leaveRepo.save(record), this.leaveHistoryRepo.save(history)]); await Promise.all([this.leaveRepo.save(record), this.leaveHistoryRepo.save(history)]);
@ -338,7 +243,11 @@ export class ProfileLeaveController extends Controller {
public async deleteLeave(@Path() leaveId: string, @Request() req: RequestWithUser) { public async deleteLeave(@Path() leaveId: string, @Request() req: RequestWithUser) {
const _record = await this.leaveRepo.findOneBy({ id: leaveId }); const _record = await this.leaveRepo.findOneBy({ id: leaveId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId); await new permission().PermissionOrgUserDelete(
req,
"SYS_REGISTRY_OFFICER",
_record.profileId,
);
} }
await this.leaveHistoryRepo.delete({ await this.leaveHistoryRepo.delete({
profileLeaveId: leaveId, profileLeaveId: leaveId,
@ -378,6 +287,8 @@ export class ProfileLeaveController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });

View file

@ -2,7 +2,6 @@ import {
Body, Body,
Controller, Controller,
Delete, Delete,
Example,
Get, Get,
Patch, Patch,
Path, Path,
@ -44,6 +43,7 @@ export class ProfileLeaveEmployeeController extends Controller {
const record = await this.leaveRepo.find({ const record = await this.leaveRepo.find({
relations: { leaveType: true }, relations: { leaveType: true },
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@ -54,6 +54,7 @@ export class ProfileLeaveEmployeeController extends Controller {
const record = await this.leaveRepo.find({ const record = await this.leaveRepo.find({
relations: { leaveType: true }, relations: { leaveType: true },
where: { profileEmployeeId: profileId }, where: { profileEmployeeId: profileId },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@ -64,6 +65,7 @@ export class ProfileLeaveEmployeeController extends Controller {
const record = await this.leaveRepo.find({ const record = await this.leaveRepo.find({
relations: { leaveType: true }, relations: { leaveType: true },
where: { profileEmployeeId: profileId }, where: { profileEmployeeId: profileId },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@ -72,18 +74,22 @@ export class ProfileLeaveEmployeeController extends Controller {
public async leaveHistory(@Path() leaveId: string, @Request() req: RequestWithUser) { public async leaveHistory(@Path() leaveId: string, @Request() req: RequestWithUser) {
const _record = await this.leaveRepo.findOneBy({ id: leaveId }); const _record = await this.leaveRepo.findOneBy({ id: leaveId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); await new permission().PermissionOrgUserGet(
req,
"SYS_REGISTRY_EMP",
_record.profileEmployeeId,
);
} }
const record = await this.leaveHistoryRepo.find({ const record = await this.leaveHistoryRepo.find({
relations: { leaveType: true }, relations: { leaveType: true },
where: { profileLeaveId: leaveId }, where: { profileLeaveId: leaveId },
order: { createdAt: "DESC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@Post() @Post()
public async newLeave(@Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeLeave) { public async newLeave(@Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeLeave) {
if (!body.profileEmployeeId) { if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
} }
@ -108,6 +114,8 @@ export class ProfileLeaveEmployeeController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -129,7 +137,11 @@ export class ProfileLeaveEmployeeController extends Controller {
) { ) {
const record = await this.leaveRepo.findOneBy({ id: leaveId }); const record = await this.leaveRepo.findOneBy({ id: leaveId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId) await new permission().PermissionOrgUserUpdate(
req,
"SYS_REGISTRY_EMP",
record.profileEmployeeId,
);
const leaveType = await this.leaveTypeRepository.findOne({ const leaveType = await this.leaveTypeRepository.findOne({
where: { id: body.leaveTypeId }, where: { id: body.leaveTypeId },
@ -141,15 +153,18 @@ export class ProfileLeaveEmployeeController extends Controller {
const history = new ProfileLeaveHistory(); const history = new ProfileLeaveHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileLeaveId = leaveId; history.profileLeaveId = leaveId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([this.leaveRepo.save(record), this.leaveHistoryRepo.save(history)]); await Promise.all([this.leaveRepo.save(record), this.leaveHistoryRepo.save(history)]);
@ -160,7 +175,11 @@ export class ProfileLeaveEmployeeController extends Controller {
public async deleteLeave(@Path() leaveId: string, @Request() req: RequestWithUser) { public async deleteLeave(@Path() leaveId: string, @Request() req: RequestWithUser) {
const _record = await this.leaveRepo.findOneBy({ id: leaveId }); const _record = await this.leaveRepo.findOneBy({ id: leaveId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); await new permission().PermissionOrgUserDelete(
req,
"SYS_REGISTRY_EMP",
_record.profileEmployeeId,
);
} }
await this.leaveHistoryRepo.delete({ await this.leaveHistoryRepo.delete({

View file

@ -2,7 +2,6 @@ import {
Body, Body,
Controller, Controller,
Delete, Delete,
Example,
Get, Get,
Patch, Patch,
Path, Path,
@ -44,6 +43,7 @@ export class ProfileLeaveEmployeeTempController extends Controller {
const record = await this.leaveRepo.find({ const record = await this.leaveRepo.find({
relations: { leaveType: true }, relations: { leaveType: true },
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@ -54,6 +54,7 @@ export class ProfileLeaveEmployeeTempController extends Controller {
const record = await this.leaveRepo.find({ const record = await this.leaveRepo.find({
relations: { leaveType: true }, relations: { leaveType: true },
where: { profileEmployeeId: profileId }, where: { profileEmployeeId: profileId },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@ -64,6 +65,7 @@ export class ProfileLeaveEmployeeTempController extends Controller {
const record = await this.leaveRepo.find({ const record = await this.leaveRepo.find({
relations: { leaveType: true }, relations: { leaveType: true },
where: { profileEmployeeId: profileId }, where: { profileEmployeeId: profileId },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@ -74,6 +76,7 @@ export class ProfileLeaveEmployeeTempController extends Controller {
const record = await this.leaveHistoryRepo.find({ const record = await this.leaveHistoryRepo.find({
relations: { leaveType: true }, relations: { leaveType: true },
where: { profileLeaveId: leaveId }, where: { profileLeaveId: leaveId },
order: { createdAt: "DESC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@ -104,6 +107,8 @@ export class ProfileLeaveEmployeeTempController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -138,15 +143,18 @@ export class ProfileLeaveEmployeeTempController extends Controller {
const history = new ProfileLeaveHistory(); const history = new ProfileLeaveHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileLeaveId = leaveId; history.profileLeaveId = leaveId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([this.leaveRepo.save(record), this.leaveHistoryRepo.save(history)]); await Promise.all([this.leaveRepo.save(record), this.leaveHistoryRepo.save(history)]);

View file

@ -2,7 +2,6 @@ import {
Body, Body,
Controller, Controller,
Delete, Delete,
Example,
Get, Get,
Patch, Patch,
Path, Path,
@ -37,61 +36,27 @@ export class ProfileNopaidController extends Controller {
} }
const lists = await this.nopaidRepository.find({ const lists = await this.nopaidRepository.find({
where: { profileId: profile.id }, where: { profileId: profile.id },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@Get("{profileId}") @Get("{profileId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
date: "2024-03-12T10:09:47.000Z",
reference: "string",
detail: "string",
refCommandNo: "string",
refCommandDate: "2024-03-12T10:09:47.000Z",
},
],
})
public async getNopaid(@Path() profileId: string, @Request() req: RequestWithUser) { public async getNopaid(@Path() profileId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
const lists = await this.nopaidRepository.find({ const lists = await this.nopaidRepository.find({
where: { profileId }, where: { profileId },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@Get("history/{nopaidId}") @Get("history/{nopaidId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
date: "2024-03-12T10:09:47.000Z",
reference: "string",
detail: "string",
refCommandNo: "string",
refCommandDate: "2024-03-12T10:09:47.000Z",
},
{
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
date: "2024-03-12T10:09:47.000Z",
reference: "string",
detail: "string",
refCommandNo: "string",
refCommandDate: "2024-03-12T10:09:47.000Z",
},
],
})
public async nopaidHistory(@Path() nopaidId: string, @Request() req: RequestWithUser) { public async nopaidHistory(@Path() nopaidId: string, @Request() req: RequestWithUser) {
const _record = await this.nopaidRepository.findOneBy({ id: nopaidId }); const _record = await this.nopaidRepository.findOneBy({ id: nopaidId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
}; }
const record = await this.nopaidHistoryRepository.find({ const record = await this.nopaidHistoryRepository.find({
where: { profileNopaidId: nopaidId }, where: { profileNopaidId: nopaidId },
order: { createdAt: "DESC" }, order: { createdAt: "DESC" },
@ -118,6 +83,8 @@ export class ProfileNopaidController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -144,15 +111,18 @@ export class ProfileNopaidController extends Controller {
const history = new ProfileNopaidHistory(); const history = new ProfileNopaidHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileNopaidId = nopaidId; history.profileNopaidId = nopaidId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.nopaidRepository.save(record), this.nopaidRepository.save(record),
@ -166,7 +136,11 @@ export class ProfileNopaidController extends Controller {
public async deleteNopaid(@Path() nopaidId: string, @Request() req: RequestWithUser) { public async deleteNopaid(@Path() nopaidId: string, @Request() req: RequestWithUser) {
const _record = await this.nopaidRepository.findOneBy({ id: nopaidId }); const _record = await this.nopaidRepository.findOneBy({ id: nopaidId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId); await new permission().PermissionOrgUserDelete(
req,
"SYS_REGISTRY_OFFICER",
_record.profileId,
);
} }
await this.nopaidHistoryRepository.delete({ await this.nopaidHistoryRepository.delete({
profileNopaidId: nopaidId, profileNopaidId: nopaidId,

View file

@ -2,7 +2,6 @@ import {
Body, Body,
Controller, Controller,
Delete, Delete,
Example,
Get, Get,
Patch, Patch,
Path, Path,
@ -41,20 +40,24 @@ export class ProfileNopaidEmployeeController extends Controller {
} }
const lists = await this.nopaidRepository.find({ const lists = await this.nopaidRepository.find({
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@Get("{profileId}") @Get("{profileId}")
public async getNopaid(@Path() profileId: string) { public async getNopaid(@Path() profileId: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const lists = await this.nopaidRepository.find({ const lists = await this.nopaidRepository.find({
where: { profileEmployeeId: profileId }, where: { profileEmployeeId: profileId },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@Get("history/{nopaidId}") @Get("history/{nopaidId}")
public async nopaidHistory(@Path() nopaidId: string) { public async nopaidHistory(@Path() nopaidId: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const record = await this.nopaidHistoryRepository.find({ const record = await this.nopaidHistoryRepository.find({
where: { profileNopaidId: nopaidId }, where: { profileNopaidId: nopaidId },
order: { createdAt: "DESC" }, order: { createdAt: "DESC" },
@ -67,7 +70,6 @@ export class ProfileNopaidEmployeeController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Body() body: CreateProfileEmployeeNopaid, @Body() body: CreateProfileEmployeeNopaid,
) { ) {
if (!body.profileEmployeeId) { if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
} }
@ -85,6 +87,8 @@ export class ProfileNopaidEmployeeController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -106,20 +110,27 @@ export class ProfileNopaidEmployeeController extends Controller {
) { ) {
const record = await this.nopaidRepository.findOneBy({ id: nopaidId }); const record = await this.nopaidRepository.findOneBy({ id: nopaidId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId) await new permission().PermissionOrgUserUpdate(
req,
"SYS_REGISTRY_EMP",
record.profileEmployeeId,
);
const history = new ProfileNopaidHistory(); const history = new ProfileNopaidHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileNopaidId = nopaidId; history.profileNopaidId = nopaidId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.nopaidRepository.save(record), this.nopaidRepository.save(record),
@ -133,7 +144,11 @@ export class ProfileNopaidEmployeeController extends Controller {
public async deleteNopaid(@Path() nopaidId: string, @Request() req: RequestWithUser) { public async deleteNopaid(@Path() nopaidId: string, @Request() req: RequestWithUser) {
const _record = await this.nopaidRepository.findOneBy({ id: nopaidId }); const _record = await this.nopaidRepository.findOneBy({ id: nopaidId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); await new permission().PermissionOrgUserDelete(
req,
"SYS_REGISTRY_EMP",
_record.profileEmployeeId,
);
} }
await this.nopaidHistoryRepository.delete({ await this.nopaidHistoryRepository.delete({

View file

@ -2,7 +2,6 @@ import {
Body, Body,
Controller, Controller,
Delete, Delete,
Example,
Get, Get,
Patch, Patch,
Path, Path,
@ -41,6 +40,7 @@ export class ProfileNopaidEmployeeTempController extends Controller {
} }
const lists = await this.nopaidRepository.find({ const lists = await this.nopaidRepository.find({
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@ -50,6 +50,7 @@ export class ProfileNopaidEmployeeTempController extends Controller {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const lists = await this.nopaidRepository.find({ const lists = await this.nopaidRepository.find({
where: { profileEmployeeId: profileId }, where: { profileEmployeeId: profileId },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@ -87,6 +88,8 @@ export class ProfileNopaidEmployeeTempController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -114,15 +117,18 @@ export class ProfileNopaidEmployeeTempController extends Controller {
const history = new ProfileNopaidHistory(); const history = new ProfileNopaidHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileNopaidId = nopaidId; history.profileNopaidId = nopaidId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.nopaidRepository.save(record), this.nopaidRepository.save(record),

View file

@ -37,53 +37,22 @@ export class ProfileOtherController extends Controller {
} }
const lists = await this.otherRepository.find({ const lists = await this.otherRepository.find({
where: { profileId: profile.id }, where: { profileId: profile.id },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@Get("{profileId}") @Get("{profileId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
isActive: true,
date: "2024-03-12T10:09:47.000Z",
reference: "string",
detail: "string",
refCommandNo: "string",
refCommandDate: "2024-03-12T10:09:47.000Z",
},
],
})
public async getOther(@Path() profileId: string, @Request() req: RequestWithUser) { public async getOther(@Path() profileId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
const lists = await this.otherRepository.find({ const lists = await this.otherRepository.find({
where: { profileId: profileId }, where: { profileId: profileId },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@Get("history/{otherId}") @Get("history/{otherId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
isActive: true,
date: "2024-03-12T10:09:47.000Z",
detail: "string",
},
{
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
isActive: true,
date: "2024-03-12T10:09:47.000Z",
detail: "string",
},
],
})
public async otherHistory(@Path() otherId: string, @Request() req: RequestWithUser) { public async otherHistory(@Path() otherId: string, @Request() req: RequestWithUser) {
const _record = await this.otherRepository.findOneBy({ id: otherId }); const _record = await this.otherRepository.findOneBy({ id: otherId });
if (_record) { if (_record) {
@ -115,6 +84,8 @@ export class ProfileOtherController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -141,15 +112,18 @@ export class ProfileOtherController extends Controller {
const history = new ProfileOtherHistory(); const history = new ProfileOtherHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileOtherId = otherId; history.profileOtherId = otherId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.otherRepository.save(record), this.otherRepository.save(record),
@ -161,10 +135,14 @@ export class ProfileOtherController extends Controller {
@Delete("{otherId}") @Delete("{otherId}")
public async deleteOther(@Path() otherId: string, @Request() req: RequestWithUser) { public async deleteOther(@Path() otherId: string, @Request() req: RequestWithUser) {
const _record = await this.otherRepository.findOneBy({ id: otherId }); const _record = await this.otherRepository.findOneBy({ id: otherId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId); await new permission().PermissionOrgUserDelete(
} req,
"SYS_REGISTRY_OFFICER",
_record.profileId,
);
}
await this.otherHistoryRepository.delete({ await this.otherHistoryRepository.delete({
profileOtherId: otherId, profileOtherId: otherId,
}); });

View file

@ -2,7 +2,6 @@ import {
Body, Body,
Controller, Controller,
Delete, Delete,
Example,
Get, Get,
Patch, Patch,
Path, Path,
@ -41,6 +40,7 @@ export class ProfileOtherEmployeeController extends Controller {
} }
const lists = await this.otherRepository.find({ const lists = await this.otherRepository.find({
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@ -50,6 +50,7 @@ export class ProfileOtherEmployeeController extends Controller {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId);
const lists = await this.otherRepository.find({ const lists = await this.otherRepository.find({
where: { profileEmployeeId: profileId }, where: { profileEmployeeId: profileId },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@ -58,7 +59,11 @@ export class ProfileOtherEmployeeController extends Controller {
public async otherHistory(@Path() otherId: string, @Request() req: RequestWithUser) { public async otherHistory(@Path() otherId: string, @Request() req: RequestWithUser) {
const _record = await this.otherRepository.findOneBy({ id: otherId }); const _record = await this.otherRepository.findOneBy({ id: otherId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); await new permission().PermissionOrgUserGet(
req,
"SYS_REGISTRY_EMP",
_record.profileEmployeeId,
);
} }
const record = await this.otherHistoryRepository.find({ const record = await this.otherHistoryRepository.find({
where: { profileOtherId: otherId }, where: { profileOtherId: otherId },
@ -86,6 +91,8 @@ export class ProfileOtherEmployeeController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -105,23 +112,29 @@ export class ProfileOtherEmployeeController extends Controller {
@Body() body: UpdateProfileOther, @Body() body: UpdateProfileOther,
@Path() otherId: string, @Path() otherId: string,
) { ) {
const record = await this.otherRepository.findOneBy({ id: otherId }); const record = await this.otherRepository.findOneBy({ id: otherId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId) await new permission().PermissionOrgUserUpdate(
req,
"SYS_REGISTRY_EMP",
record.profileEmployeeId,
);
const history = new ProfileOtherHistory(); const history = new ProfileOtherHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileOtherId = otherId; history.profileOtherId = otherId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.otherRepository.save(record), this.otherRepository.save(record),
@ -135,7 +148,11 @@ export class ProfileOtherEmployeeController extends Controller {
public async deleteOther(@Path() otherId: string, @Request() req: RequestWithUser) { public async deleteOther(@Path() otherId: string, @Request() req: RequestWithUser) {
const _record = await this.otherRepository.findOneBy({ id: otherId }); const _record = await this.otherRepository.findOneBy({ id: otherId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); await new permission().PermissionOrgUserDelete(
req,
"SYS_REGISTRY_EMP",
_record.profileEmployeeId,
);
} }
await this.otherHistoryRepository.delete({ await this.otherHistoryRepository.delete({

View file

@ -41,6 +41,7 @@ export class ProfileOtherEmployeeTempController extends Controller {
} }
const lists = await this.otherRepository.find({ const lists = await this.otherRepository.find({
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@ -50,6 +51,7 @@ export class ProfileOtherEmployeeTempController extends Controller {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const lists = await this.otherRepository.find({ const lists = await this.otherRepository.find({
where: { profileEmployeeId: profileId }, where: { profileEmployeeId: profileId },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(lists); return new HttpSuccess(lists);
} }
@ -84,6 +86,8 @@ export class ProfileOtherEmployeeTempController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -111,15 +115,18 @@ export class ProfileOtherEmployeeTempController extends Controller {
const history = new ProfileOtherHistory(); const history = new ProfileOtherHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileOtherId = otherId; history.profileOtherId = otherId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([ await Promise.all([
this.otherRepository.save(record), this.otherRepository.save(record),

View file

@ -44,34 +44,6 @@ export class ProfileSalaryController extends Controller {
} }
@Get("{profileId}") @Get("{profileId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "3cf02fb7-2f0c-471b-b641-51d557375c0a",
createdAt: "2024-03-12T02:55:56.915Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T02:55:56.915Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
isActive: true,
startDate: "2024-03-12T09:55:23.000Z",
endDate: "2024-03-12T09:55:23.000Z",
numberOrder: "string",
topic: "string",
place: "string",
dateOrder: "2024-03-12T09:55:23.000Z",
department: "string",
duration: "string",
name: "string",
yearly: 0,
isDate: true,
},
],
})
public async getSalary(@Path() profileId: string, @Request() req: RequestWithUser) { public async getSalary(@Path() profileId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
const record = await this.salaryRepo.find({ const record = await this.salaryRepo.find({
@ -92,63 +64,16 @@ export class ProfileSalaryController extends Controller {
} }
@Get("history/{salaryId}") @Get("history/{salaryId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "6d4e9dbe-8697-4546-9651-0a1c3ea0a82d",
createdAt: "2024-03-12T02:55:56.971Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T02:55:56.971Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
isActive: true,
startDate: "2024-03-12T09:55:23.000Z",
endDate: "2024-03-12T09:55:23.000Z",
numberOrder: "string",
topic: "string",
place: "string",
dateOrder: "2024-03-12T09:55:23.000Z",
department: "string",
duration: "string",
name: "string",
yearly: 0,
isDate: true,
profileSalaryId: "3cf02fb7-2f0c-471b-b641-51d557375c0a",
},
{
id: "a251c176-3dac-4d09-9813-38c8db1127e3",
createdAt: "2024-03-12T02:58:17.917Z",
createdUserId: "00000000-0000-0000-0000-000000000000",
lastUpdatedAt: "2024-03-12T02:58:17.917Z",
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
createdFullName: "string",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
isActive: true,
startDate: "2024-03-12T09:57:44.000Z",
endDate: "2024-03-12T09:57:44.000Z",
numberOrder: "string",
topic: "topic",
place: "place",
dateOrder: "2024-03-12T09:57:44.000Z",
department: "department",
duration: "string",
name: "name",
yearly: 0,
isDate: true,
profileSalaryId: "3cf02fb7-2f0c-471b-b641-51d557375c0a",
},
],
})
public async salaryHistory(@Path() salaryId: string, @Request() req: RequestWithUser) { public async salaryHistory(@Path() salaryId: string, @Request() req: RequestWithUser) {
const _record = await this.salaryRepo.findOneBy({ id: salaryId }); const _record = await this.salaryRepo.findOneBy({ id: salaryId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
} }
const record = await this.salaryHistoryRepo.findBy({ const record = await this.salaryHistoryRepo.find({
profileSalaryId: salaryId, where: {
profileSalaryId: salaryId,
},
order: { createdAt: "DESC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@ -178,6 +103,8 @@ export class ProfileSalaryController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -204,15 +131,18 @@ export class ProfileSalaryController extends Controller {
const history = new ProfileSalaryHistory(); const history = new ProfileSalaryHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileSalaryId = salaryId; history.profileSalaryId = salaryId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([this.salaryRepo.save(record), this.salaryHistoryRepo.save(history)]); await Promise.all([this.salaryRepo.save(record), this.salaryHistoryRepo.save(history)]);
@ -223,7 +153,11 @@ export class ProfileSalaryController extends Controller {
public async deleteSalary(@Path() salaryId: string, @Request() req: RequestWithUser) { public async deleteSalary(@Path() salaryId: string, @Request() req: RequestWithUser) {
const _record = await this.salaryRepo.findOneBy({ id: salaryId }); const _record = await this.salaryRepo.findOneBy({ id: salaryId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId); await new permission().PermissionOrgUserDelete(
req,
"SYS_REGISTRY_OFFICER",
_record.profileId,
);
} }
await this.salaryHistoryRepo.delete({ await this.salaryHistoryRepo.delete({
profileSalaryId: salaryId, profileSalaryId: salaryId,
@ -239,7 +173,11 @@ export class ProfileSalaryController extends Controller {
} }
@Get("swap/{direction}/{salaryId}") @Get("swap/{direction}/{salaryId}")
public async swapSalary(@Path() direction: string, salaryId: string, @Request() req: RequestWithUser) { public async swapSalary(
@Path() direction: string,
salaryId: string,
@Request() req: RequestWithUser,
) {
const source_item = await this.salaryRepo.findOne({ where: { id: salaryId } }); const source_item = await this.salaryRepo.findOne({ where: { id: salaryId } });
// if (source_item) { // if (source_item) {
// await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", source_item.profileId);//ไม่แน่ใจOFFปิดไว้ก่อน // await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", source_item.profileId);//ไม่แน่ใจOFFปิดไว้ก่อน

View file

@ -2,7 +2,6 @@ import {
Body, Body,
Controller, Controller,
Delete, Delete,
Example,
Get, Get,
Patch, Patch,
Path, Path,
@ -49,10 +48,7 @@ export class ProfileSalaryEmployeeController extends Controller {
@Get("{profileId}") @Get("{profileId}")
public async getSalaryEmployee(@Path() profileId: string, @Request() req: RequestWithUser) { public async getSalaryEmployee(@Path() profileId: string, @Request() req: RequestWithUser) {
// const _record = await this.salaryRepo.findOneBy({ id: profileId }); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId);
// if (_record) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId);
// }
const record = await this.salaryRepo.find({ const record = await this.salaryRepo.find({
where: { profileEmployeeId: profileId }, where: { profileEmployeeId: profileId },
order: { order: "ASC" }, order: { order: "ASC" },
@ -63,10 +59,6 @@ export class ProfileSalaryEmployeeController extends Controller {
@Get("admin/{profileId}") @Get("admin/{profileId}")
public async getSalaryEmployeeAdmin(@Path() profileId: string, @Request() req: RequestWithUser) { public async getSalaryEmployeeAdmin(@Path() profileId: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_WAGE"); await new permission().PermissionGet(req, "SYS_WAGE");
// const _record = await this.salaryRepo.findOneBy({ id: profileId });
// if (_record) {
// await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId);
// }
const record = await this.salaryRepo.find({ const record = await this.salaryRepo.find({
where: { profileEmployeeId: profileId }, where: { profileEmployeeId: profileId },
order: { order: "ASC" }, order: { order: "ASC" },
@ -78,10 +70,17 @@ export class ProfileSalaryEmployeeController extends Controller {
public async salaryHistory(@Path() salaryId: string, @Request() req: RequestWithUser) { public async salaryHistory(@Path() salaryId: string, @Request() req: RequestWithUser) {
const _record = await this.salaryRepo.findOneBy({ id: salaryId }); const _record = await this.salaryRepo.findOneBy({ id: salaryId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); await new permission().PermissionOrgUserGet(
req,
"SYS_REGISTRY_EMP",
_record.profileEmployeeId,
);
} }
const record = await this.salaryHistoryRepo.findBy({ const record = await this.salaryHistoryRepo.find({
profileSalaryId: salaryId, where: {
profileSalaryId: salaryId,
},
order: { createdAt: "DESC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@ -114,6 +113,8 @@ export class ProfileSalaryEmployeeController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -133,23 +134,29 @@ export class ProfileSalaryEmployeeController extends Controller {
@Body() body: UpdateProfileSalaryEmployee, @Body() body: UpdateProfileSalaryEmployee,
@Path() salaryId: string, @Path() salaryId: string,
) { ) {
const record = await this.salaryRepo.findOneBy({ id: salaryId }); const record = await this.salaryRepo.findOneBy({ id: salaryId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId) await new permission().PermissionOrgUserUpdate(
req,
"SYS_REGISTRY_EMP",
record.profileEmployeeId,
);
const history = new ProfileSalaryHistory(); const history = new ProfileSalaryHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileSalaryId = salaryId; history.profileSalaryId = salaryId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([this.salaryRepo.save(record), this.salaryHistoryRepo.save(history)]); await Promise.all([this.salaryRepo.save(record), this.salaryHistoryRepo.save(history)]);
@ -160,7 +167,11 @@ export class ProfileSalaryEmployeeController extends Controller {
public async deleteSalaryEmployee(@Path() salaryId: string, @Request() req: RequestWithUser) { public async deleteSalaryEmployee(@Path() salaryId: string, @Request() req: RequestWithUser) {
const _record = await this.salaryRepo.findOneBy({ id: salaryId }); const _record = await this.salaryRepo.findOneBy({ id: salaryId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); await new permission().PermissionOrgUserDelete(
req,
"SYS_REGISTRY_EMP",
_record.profileEmployeeId,
);
} }
await this.salaryHistoryRepo.delete({ await this.salaryHistoryRepo.delete({
@ -177,10 +188,18 @@ export class ProfileSalaryEmployeeController extends Controller {
} }
@Get("swap/{direction}/{salaryId}") @Get("swap/{direction}/{salaryId}")
public async swapSalaryEmployee(@Path() direction: string, salaryId: string, @Request() req: RequestWithUser) { public async swapSalaryEmployee(
const _record = await this.salaryRepo.findOneBy({ id: salaryId }); @Path() direction: string,
salaryId: string,
@Request() req: RequestWithUser,
) {
const _record = await this.salaryRepo.findOneBy({ id: salaryId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); await new permission().PermissionOrgUserGet(
req,
"SYS_REGISTRY_EMP",
_record.profileEmployeeId,
);
} }
const source_item = await this.salaryRepo.findOne({ where: { id: salaryId } }); const source_item = await this.salaryRepo.findOne({ where: { id: salaryId } });
if (source_item == null) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (source_item == null) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");

View file

@ -2,7 +2,6 @@ import {
Body, Body,
Controller, Controller,
Delete, Delete,
Example,
Get, Get,
Patch, Patch,
Path, Path,
@ -70,8 +69,11 @@ export class ProfileSalaryEmployeeTempController extends Controller {
@Get("history/{salaryId}") @Get("history/{salaryId}")
public async salaryHistory(@Path() salaryId: string, @Request() req: RequestWithUser) { public async salaryHistory(@Path() salaryId: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const record = await this.salaryHistoryRepo.findBy({ const record = await this.salaryHistoryRepo.find({
profileSalaryId: salaryId, where: {
profileSalaryId: salaryId,
},
order: { createdAt: "DESC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@ -105,6 +107,8 @@ export class ProfileSalaryEmployeeTempController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -132,15 +136,18 @@ export class ProfileSalaryEmployeeTempController extends Controller {
const history = new ProfileSalaryHistory(); const history = new ProfileSalaryHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileSalaryId = salaryId; history.profileSalaryId = salaryId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([this.salaryRepo.save(record), this.salaryHistoryRepo.save(history)]); await Promise.all([this.salaryRepo.save(record), this.salaryHistoryRepo.save(history)]);

View file

@ -2,7 +2,6 @@ import {
Body, Body,
Controller, Controller,
Delete, Delete,
Example,
Get, Get,
Patch, Patch,
Path, Path,
@ -41,103 +40,32 @@ export class ProfileTrainingController extends Controller {
} }
const record = await this.trainingRepo.find({ const record = await this.trainingRepo.find({
where: { profileId: profile.id }, where: { profileId: profile.id },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@Get("{profileId}") @Get("{profileId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "3cf02fb7-2f0c-471b-b641-51d557375c0a",
createdAt: "2024-03-12T02:55:56.915Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T02:55:56.915Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
isActive: true,
startDate: "2024-03-12T09:55:23.000Z",
endDate: "2024-03-12T09:55:23.000Z",
numberOrder: "string",
topic: "string",
place: "string",
dateOrder: "2024-03-12T09:55:23.000Z",
department: "string",
duration: "string",
name: "string",
yearly: 0,
isDate: true,
},
],
})
public async getTraining(@Path() profileId: string, @Request() req: RequestWithUser) { public async getTraining(@Path() profileId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
const record = await this.trainingRepo.findBy({ profileId }); const record = await this.trainingRepo.find({
where: { profileId },
order: { createdAt: "ASC" },
});
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@Get("history/{trainingId}") @Get("history/{trainingId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "6d4e9dbe-8697-4546-9651-0a1c3ea0a82d",
createdAt: "2024-03-12T02:55:56.971Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T02:55:56.971Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
isActive: true,
startDate: "2024-03-12T09:55:23.000Z",
endDate: "2024-03-12T09:55:23.000Z",
numberOrder: "string",
topic: "string",
place: "string",
dateOrder: "2024-03-12T09:55:23.000Z",
department: "string",
duration: "string",
name: "string",
yearly: 0,
isDate: true,
profileTrainingId: "3cf02fb7-2f0c-471b-b641-51d557375c0a",
},
{
id: "a251c176-3dac-4d09-9813-38c8db1127e3",
createdAt: "2024-03-12T02:58:17.917Z",
createdUserId: "00000000-0000-0000-0000-000000000000",
lastUpdatedAt: "2024-03-12T02:58:17.917Z",
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
createdFullName: "string",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
isActive: true,
startDate: "2024-03-12T09:57:44.000Z",
endDate: "2024-03-12T09:57:44.000Z",
numberOrder: "string",
topic: "topic",
place: "place",
dateOrder: "2024-03-12T09:57:44.000Z",
department: "department",
duration: "string",
name: "name",
yearly: 0,
isDate: true,
profileTrainingId: "3cf02fb7-2f0c-471b-b641-51d557375c0a",
},
],
})
public async trainingHistory(@Path() trainingId: string, @Request() req: RequestWithUser) { public async trainingHistory(@Path() trainingId: string, @Request() req: RequestWithUser) {
const _record = await this.trainingRepo.findOneBy({ id: trainingId }); const _record = await this.trainingRepo.findOneBy({ id: trainingId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
} }
const record = await this.trainingHistoryRepo.findBy({ const record = await this.trainingHistoryRepo.find({
profileTrainingId: trainingId, where: {
profileTrainingId: trainingId,
},
order: { createdAt: "DESC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@ -161,6 +89,8 @@ export class ProfileTrainingController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -187,15 +117,18 @@ export class ProfileTrainingController extends Controller {
const history = new ProfileTrainingHistory(); const history = new ProfileTrainingHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileTrainingId = trainingId; history.profileTrainingId = trainingId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([this.trainingRepo.save(record), this.trainingHistoryRepo.save(history)]); await Promise.all([this.trainingRepo.save(record), this.trainingHistoryRepo.save(history)]);
@ -206,7 +139,11 @@ export class ProfileTrainingController extends Controller {
public async deleteTraining(@Path() trainingId: string, @Request() req: RequestWithUser) { public async deleteTraining(@Path() trainingId: string, @Request() req: RequestWithUser) {
const _record = await this.trainingRepo.findOneBy({ id: trainingId }); const _record = await this.trainingRepo.findOneBy({ id: trainingId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId); await new permission().PermissionOrgUserDelete(
req,
"SYS_REGISTRY_OFFICER",
_record.profileId,
);
} }
await this.trainingHistoryRepo.delete({ await this.trainingHistoryRepo.delete({
profileTrainingId: trainingId, profileTrainingId: trainingId,

View file

@ -41,104 +41,37 @@ export class ProfileTrainingEmployeeController extends Controller {
} }
const record = await this.trainingRepo.find({ const record = await this.trainingRepo.find({
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@Get("{profileEmployeeId}") @Get("{profileEmployeeId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "3cf02fb7-2f0c-471b-b641-51d557375c0a",
createdAt: "2024-03-12T02:55:56.915Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T02:55:56.915Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
isActive: true,
startDate: "2024-03-12T09:55:23.000Z",
endDate: "2024-03-12T09:55:23.000Z",
numberOrder: "string",
topic: "string",
place: "string",
dateOrder: "2024-03-12T09:55:23.000Z",
department: "string",
duration: "string",
name: "string",
yearly: 0,
isDate: true,
},
],
})
public async getTraining(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { public async getTraining(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
const record = await this.trainingRepo.findBy({ profileEmployeeId }); const record = await this.trainingRepo.find({
where: { profileEmployeeId },
order: { createdAt: "ASC" },
});
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@Get("history/{trainingId}") @Get("history/{trainingId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "6d4e9dbe-8697-4546-9651-0a1c3ea0a82d",
createdAt: "2024-03-12T02:55:56.971Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T02:55:56.971Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
isActive: true,
startDate: "2024-03-12T09:55:23.000Z",
endDate: "2024-03-12T09:55:23.000Z",
numberOrder: "string",
topic: "string",
place: "string",
dateOrder: "2024-03-12T09:55:23.000Z",
department: "string",
duration: "string",
name: "string",
yearly: 0,
isDate: true,
profileTrainingId: "3cf02fb7-2f0c-471b-b641-51d557375c0a",
},
{
id: "a251c176-3dac-4d09-9813-38c8db1127e3",
createdAt: "2024-03-12T02:58:17.917Z",
createdUserId: "00000000-0000-0000-0000-000000000000",
lastUpdatedAt: "2024-03-12T02:58:17.917Z",
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
createdFullName: "string",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
isActive: true,
startDate: "2024-03-12T09:57:44.000Z",
endDate: "2024-03-12T09:57:44.000Z",
numberOrder: "string",
topic: "topic",
place: "place",
dateOrder: "2024-03-12T09:57:44.000Z",
department: "department",
duration: "string",
name: "name",
yearly: 0,
isDate: true,
profileTrainingId: "3cf02fb7-2f0c-471b-b641-51d557375c0a",
},
],
})
public async trainingHistory(@Path() trainingId: string, @Request() req: RequestWithUser) { public async trainingHistory(@Path() trainingId: string, @Request() req: RequestWithUser) {
const _record = await this.trainingRepo.findOneBy({ id: trainingId }); const _record = await this.trainingRepo.findOneBy({ id: trainingId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); await new permission().PermissionOrgUserGet(
req,
"SYS_REGISTRY_EMP",
_record.profileEmployeeId,
);
} }
const record = await this.trainingHistoryRepo.findBy({ const record = await this.trainingHistoryRepo.find({
profileTrainingId: trainingId, where: {
profileTrainingId: trainingId,
},
order: { createdAt: "DESC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@ -158,7 +91,6 @@ export class ProfileTrainingEmployeeController extends Controller {
} }
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profile.id); await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profile.id);
const data = new ProfileTraining(); const data = new ProfileTraining();
const meta = { const meta = {
@ -166,6 +98,8 @@ export class ProfileTrainingEmployeeController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -187,20 +121,27 @@ export class ProfileTrainingEmployeeController extends Controller {
) { ) {
const record = await this.trainingRepo.findOneBy({ id: trainingId }); const record = await this.trainingRepo.findOneBy({ id: trainingId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId) await new permission().PermissionOrgUserUpdate(
req,
"SYS_REGISTRY_EMP",
record.profileEmployeeId,
);
const history = new ProfileTrainingHistory(); const history = new ProfileTrainingHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileTrainingId = trainingId; history.profileTrainingId = trainingId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([this.trainingRepo.save(record), this.trainingHistoryRepo.save(history)]); await Promise.all([this.trainingRepo.save(record), this.trainingHistoryRepo.save(history)]);
@ -211,7 +152,11 @@ export class ProfileTrainingEmployeeController extends Controller {
public async deleteTraining(@Path() trainingId: string, @Request() req: RequestWithUser) { public async deleteTraining(@Path() trainingId: string, @Request() req: RequestWithUser) {
const _record = await this.trainingRepo.findOneBy({ id: trainingId }); const _record = await this.trainingRepo.findOneBy({ id: trainingId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); await new permission().PermissionOrgUserDelete(
req,
"SYS_REGISTRY_EMP",
_record.profileEmployeeId,
);
} }
await this.trainingHistoryRepo.delete({ await this.trainingHistoryRepo.delete({

View file

@ -41,100 +41,29 @@ export class ProfileTrainingEmployeeTempController extends Controller {
} }
const record = await this.trainingRepo.find({ const record = await this.trainingRepo.find({
where: { profileEmployeeId: profile.id }, where: { profileEmployeeId: profile.id },
order: { createdAt: "ASC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@Get("{profileEmployeeId}") @Get("{profileEmployeeId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "3cf02fb7-2f0c-471b-b641-51d557375c0a",
createdAt: "2024-03-12T02:55:56.915Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T02:55:56.915Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
isActive: true,
startDate: "2024-03-12T09:55:23.000Z",
endDate: "2024-03-12T09:55:23.000Z",
numberOrder: "string",
topic: "string",
place: "string",
dateOrder: "2024-03-12T09:55:23.000Z",
department: "string",
duration: "string",
name: "string",
yearly: 0,
isDate: true,
},
],
})
public async getTraining(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { public async getTraining(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const record = await this.trainingRepo.findBy({ profileEmployeeId }); const record = await this.trainingRepo.find({
where: { profileEmployeeId },
order: { createdAt: "ASC" },
});
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@Get("history/{trainingId}") @Get("history/{trainingId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "6d4e9dbe-8697-4546-9651-0a1c3ea0a82d",
createdAt: "2024-03-12T02:55:56.971Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T02:55:56.971Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
isActive: true,
startDate: "2024-03-12T09:55:23.000Z",
endDate: "2024-03-12T09:55:23.000Z",
numberOrder: "string",
topic: "string",
place: "string",
dateOrder: "2024-03-12T09:55:23.000Z",
department: "string",
duration: "string",
name: "string",
yearly: 0,
isDate: true,
profileTrainingId: "3cf02fb7-2f0c-471b-b641-51d557375c0a",
},
{
id: "a251c176-3dac-4d09-9813-38c8db1127e3",
createdAt: "2024-03-12T02:58:17.917Z",
createdUserId: "00000000-0000-0000-0000-000000000000",
lastUpdatedAt: "2024-03-12T02:58:17.917Z",
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
createdFullName: "string",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
isActive: true,
startDate: "2024-03-12T09:57:44.000Z",
endDate: "2024-03-12T09:57:44.000Z",
numberOrder: "string",
topic: "topic",
place: "place",
dateOrder: "2024-03-12T09:57:44.000Z",
department: "department",
duration: "string",
name: "name",
yearly: 0,
isDate: true,
profileTrainingId: "3cf02fb7-2f0c-471b-b641-51d557375c0a",
},
],
})
public async trainingHistory(@Path() trainingId: string, @Request() req: RequestWithUser) { public async trainingHistory(@Path() trainingId: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const record = await this.trainingHistoryRepo.findBy({ const record = await this.trainingHistoryRepo.find({
profileTrainingId: trainingId, where: {
profileTrainingId: trainingId,
},
order: { createdAt: "DESC" },
}); });
return new HttpSuccess(record); return new HttpSuccess(record);
} }
@ -162,6 +91,8 @@ export class ProfileTrainingEmployeeTempController extends Controller {
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name, lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
}; };
Object.assign(data, { ...body, ...meta }); Object.assign(data, { ...body, ...meta });
@ -189,15 +120,18 @@ export class ProfileTrainingEmployeeTempController extends Controller {
const history = new ProfileTrainingHistory(); const history = new ProfileTrainingHistory();
Object.assign(record, body); Object.assign(record, body);
Object.assign(history, body); Object.assign(history, { ...body, id: undefined });
history.profileTrainingId = trainingId; history.profileTrainingId = trainingId;
record.lastUpdateUserId = req.user.sub; record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub; history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub; history.createdUserId = req.user.sub;
history.createdFullName = req.user.name; history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([this.trainingRepo.save(record), this.trainingHistoryRepo.save(history)]); await Promise.all([this.trainingRepo.save(record), this.trainingHistoryRepo.save(history)]);

View file

@ -1,14 +1,14 @@
import { import {
Entity, Entity,
PrimaryGeneratedColumn, PrimaryGeneratedColumn,
Column, Column,
CreateDateColumn, CreateDateColumn,
UpdateDateColumn, UpdateDateColumn,
} from "typeorm"; } from "typeorm";
@Entity() @Entity()
export class EntityBase { export class EntityBase {
@PrimaryGeneratedColumn("uuid") @PrimaryGeneratedColumn("uuid")
id!: string; id!: string;
@CreateDateColumn({ comment: "สร้างข้อมูลเมื่อ" }) @CreateDateColumn({ comment: "สร้างข้อมูลเมื่อ" })
@ -36,6 +36,4 @@ import {
@Column({ comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด", length: 200, default: "string" }) @Column({ comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด", length: 200, default: "string" })
lastUpdateFullName!: String; lastUpdateFullName!: String;
}
}

View file

@ -0,0 +1,386 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateBaseDate1725011784785 implements MigrationInterface {
name = 'UpdateBaseDate1725011784785'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DROP INDEX \`FK_4913ef1466f9f35c1429e213d4b\` ON \`developmentProject\``);
await queryRunner.query(`DROP INDEX \`FK_8e3f2e86427befeff4283ae80f0\` ON \`developmentProject\``);
await queryRunner.query(`CREATE TABLE \`subDistrictImport\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`PROVINCE_CODE\` varchar(255) NULL, \`AMPHUR_CODE\` varchar(255) NULL, \`DISTRICT_CODE\` varchar(255) NULL, \`DISTRICT_NAME\` varchar(255) NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`CREATE TABLE \`provinceImport\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`PROVINCE_CODE\` varchar(255) NULL, \`PROVINCE_NAME\` varchar(255) NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`CREATE TABLE \`HR_POSITION_OFFICER\` (\`CIT\` text NULL, \`id\` int NOT NULL AUTO_INCREMENT, \`MP_POS_DATE\` text NULL, \`SALARY\` text NULL, \`MP_COMMAND_NUM\` text NULL, \`POS_NUM_NAME\` text NULL, \`POS_NUM_CODE\` text NULL, \`FLAG_TO_NAME\` text NULL, \`WORK_LINE_NAME\` text NULL, \`SPECIALIST_NAME\` text NULL, \`ADMIN_NAME\` text NULL, \`REMARK\` text NULL, \`ORDER_MOVE_POSITION\` text NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`CREATE TABLE \`HR_PERSONAL_OFFICER_FAMILY\` (\`CIT\` text NULL, \`id\` int NOT NULL AUTO_INCREMENT, \`FATHER_RANK_NAME\` text NULL, \`FATHER_FNAME\` text NULL, \`FATHER_LNAME\` text NULL, \`MOTHER_RANK_NAME\` text NULL, \`MOTHER_FNAME\` text NULL, \`MOTHER_LNAME\` text NULL, \`SPOUSE_RANK_NAME\` text NULL, \`SPOUSE_FNAME\` text NULL, \`SPOUSE_LNAME\` text NULL, \`SPOUSE_ID\` text NULL, \`MARRIAGE_STATE\` text NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`CREATE TABLE \`HR_PERSONAL_EMP_ADDRESS\` (\`CIT\` text NULL, \`id\` int NOT NULL AUTO_INCREMENT, \`PROVINCE_CODE\` text NULL, \`AMPHUR_CODE\` text NULL, \`DISTRICT_CODE\` text NULL, \`CONTACT_PROVINCE_CODE\` text NULL, \`CONTACT_AMPHUR_CODE\` text NULL, \`CONTACT_DISTRICT_CODE\` text NULL, \`H_NUMBER\` text NULL, \`ZIPCODE\` text NULL, \`CONTACT_H_NUMBER\` text NULL, \`CONTACT_ZIPCODE\` text NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`CREATE TABLE \`HR_PERSONAL_OFFICER_ADDRESS\` (\`CIT\` text NULL, \`id\` int NOT NULL AUTO_INCREMENT, \`PROVINCE_CODE\` text NULL, \`AMPHUR_CODE\` text NULL, \`DISTRICT_CODE\` text NULL, \`CONTACT_PROVINCE_CODE\` text NULL, \`CONTACT_AMPHUR_CODE\` text NULL, \`CONTACT_DISTRICT_CODE\` text NULL, \`H_NUMBER\` text NULL, \`ZIPCODE\` text NULL, \`CONTACT_H_NUMBER\` text NULL, \`CONTACT_ZIPCODE\` text NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`CREATE TABLE \`HR_PERSONAL_EMP_FAMILY\` (\`CIT\` text NULL, \`id\` int NOT NULL AUTO_INCREMENT, \`FATHER_RANK_NAME\` text NULL, \`FATHER_FNAME\` text NULL, \`FATHER_LNAME\` text NULL, \`MOTHER_RANK_NAME\` text NULL, \`MOTHER_FNAME\` text NULL, \`MOTHER_LNAME\` text NULL, \`SPOUSE_RANK_NAME\` text NULL, \`SPOUSE_FNAME\` text NULL, \`SPOUSE_LNAME\` text NULL, \`SPOUSE_ID\` text NULL, \`MARRIAGE_STATE\` text NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`CREATE TABLE \`HR_EDUCATION_EMP\` (\`CIT\` text NULL, \`id\` int NOT NULL AUTO_INCREMENT, \`EDUCATION_CODE\` text NULL, \`START_EDUCATION_YEAR\` text NULL, \`EDUCATION_YEAR\` text NULL, \`INSTITUE\` text NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`CREATE TABLE \`HR_EDUCATION\` (\`CIT\` text NULL, \`id\` int NOT NULL AUTO_INCREMENT, \`EDUCATION_CODE\` text NULL, \`START_EDUCATION_YEAR\` text NULL, \`EDUCATION_YEAR\` text NULL, \`INSTITUE\` text NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`CREATE TABLE \`educationMis\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`EDUCATION_CODE\` varchar(255) NULL, \`EDUCATION_NAME\` varchar(255) NULL, \`EDUCATION_ABB_NAME\` varchar(255) NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`CREATE TABLE \`amphurImport\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`PROVINCE_CODE\` varchar(255) NULL, \`AMPHUR_CODE\` varchar(255) NULL, \`AMPHUR_NAME\` varchar(255) NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`ALTER TABLE \`entity_base\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`entity_base\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`province\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`province\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`district\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`district\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`subDistrict\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`subDistrict\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`relationship\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`relationship\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`rank\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`rank\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`religion\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`religion\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`orgChild4\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`orgChild4\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`orgChild3\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`orgChild3\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`orgChild2\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`orgChild2\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`orgChild1\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`orgChild1\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`orgRoot\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`orgRoot\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileSalaryHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileSalaryHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileSalary\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileSalary\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileCertificateHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileCertificateHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileCertificate\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileCertificate\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`insigniaType\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`insigniaType\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`insignia\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`insignia\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileInsigniaHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileInsigniaHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileInsignia\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileInsignia\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileHonorHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileHonorHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileHonor\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileHonor\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileAssessmentHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileAssessmentHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileAssessment\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileAssessment\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`leaveType\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`leaveType\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileLeave\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileLeave\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileLeaveHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileLeaveHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileDutyHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileDutyHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileDuty\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileDuty\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileNopaidHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileNopaidHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileNopaid\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileNopaid\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileDisciplineHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileDisciplineHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileDiscipline\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileDiscipline\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileChangeNameHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileChangeNameHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileChangeName\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileChangeName\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileFamilyHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileFamilyHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileEducationHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileEducationHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileEducation\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileEducation\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileAbilityHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileAbilityHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileAbility\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileAbility\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileOtherHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileOtherHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileOther\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileOther\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileAvatar\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileAvatar\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileGovernment\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileGovernment\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileFamilyFatherHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileFamilyFatherHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileFamilyFather\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileFamilyFather\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileFamilyMotherHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileFamilyMotherHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileFamilyMother\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileFamilyMother\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileFamilyCouple\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileFamilyCouple\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileChildrenHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileChildrenHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileChildren\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileChildren\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileEmployeeInformationHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileEmployeeInformationHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileEmployeeEmploymentHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileEmployeeEmploymentHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileEmployeeEmployment\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileEmployeeEmployment\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileEdit\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileEdit\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileDevelopmentHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileDevelopmentHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileDevelopment\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileDevelopment\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileEmployee\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileEmployee\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`employeePosLevel\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`employeePosLevel\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`employeePosDict\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`employeePosDict\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`employeePosType\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`employeePosType\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`employeePosition\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`employeePosition\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`authRoleAttr\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`authRoleAttr\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`authRole\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`authRole\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`employeePosMaster\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`employeePosMaster\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`orgRevision\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`orgRevision\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`posExecutive\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`posExecutive\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`posDict\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`posDict\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`posType\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`posType\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`posLevel\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`posLevel\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`position\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`position\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`posMasterAct\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`posMasterAct\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`posMaster\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`posMaster\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profile\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profile\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileAddressHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileAddressHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileTraining\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileTraining\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileTrainingHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileTrainingHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`changePosition\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`changePosition\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileChangePosition\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`profileChangePosition\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`prefixe\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`prefixe\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`gender\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`gender\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`educationLevel\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`educationLevel\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`developmentProject\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`developmentProject\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`bloodGroup\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`);
await queryRunner.query(`ALTER TABLE \`bloodGroup\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`bloodGroup\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`bloodGroup\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`developmentProject\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`developmentProject\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`educationLevel\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`educationLevel\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`gender\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`gender\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`prefixe\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`prefixe\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileChangePosition\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileChangePosition\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`changePosition\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`changePosition\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileTrainingHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileTrainingHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileTraining\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileTraining\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileAddressHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileAddressHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profile\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profile\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`posMaster\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`posMaster\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`posMasterAct\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`posMasterAct\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`position\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`position\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`posLevel\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`posLevel\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`posType\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`posType\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`posDict\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`posDict\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`posExecutive\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`posExecutive\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`orgRevision\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`orgRevision\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`employeePosMaster\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`employeePosMaster\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`authRole\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`authRole\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`authRoleAttr\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`authRoleAttr\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`employeePosition\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`employeePosition\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`employeePosType\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`employeePosType\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`employeePosDict\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`employeePosDict\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`employeePosLevel\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`employeePosLevel\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileEmployee\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileEmployee\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileDevelopment\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileDevelopment\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileDevelopmentHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileDevelopmentHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileEdit\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileEdit\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileEmployeeEmployment\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileEmployeeEmployment\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileEmployeeEmploymentHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileEmployeeEmploymentHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileEmployeeInformationHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileEmployeeInformationHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileChildren\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileChildren\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileChildrenHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileChildrenHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileFamilyCouple\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileFamilyCouple\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileFamilyMother\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileFamilyMother\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileFamilyMotherHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileFamilyMotherHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileFamilyFather\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileFamilyFather\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileFamilyFatherHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileFamilyFatherHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileGovernment\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileGovernment\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileAvatar\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileAvatar\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileOther\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileOther\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileOtherHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileOtherHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileAbility\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileAbility\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileAbilityHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileAbilityHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileEducation\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileEducation\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileEducationHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileEducationHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileFamilyHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileFamilyHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileChangeName\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileChangeName\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileChangeNameHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileChangeNameHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileDiscipline\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileDiscipline\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileDisciplineHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileDisciplineHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileNopaid\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileNopaid\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileNopaidHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileNopaidHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileDuty\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileDuty\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileDutyHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileDutyHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileLeaveHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileLeaveHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileLeave\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileLeave\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`leaveType\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`leaveType\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileAssessment\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileAssessment\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileAssessmentHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileAssessmentHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileHonor\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileHonor\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileHonorHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileHonorHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileInsignia\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileInsignia\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileInsigniaHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileInsigniaHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`insignia\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`insignia\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`insigniaType\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`insigniaType\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileCertificate\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileCertificate\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileCertificateHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileCertificateHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileSalary\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileSalary\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileSalaryHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`profileSalaryHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`orgRoot\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`orgRoot\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`orgChild1\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`orgChild1\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`orgChild2\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`orgChild2\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`orgChild3\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`orgChild3\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`orgChild4\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`orgChild4\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`religion\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`religion\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`rank\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`rank\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`relationship\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`relationship\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`subDistrict\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`subDistrict\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`district\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`district\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`province\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`province\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`entity_base\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`ALTER TABLE \`entity_base\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`);
await queryRunner.query(`DROP TABLE \`amphurImport\``);
await queryRunner.query(`DROP TABLE \`educationMis\``);
await queryRunner.query(`DROP TABLE \`HR_EDUCATION\``);
await queryRunner.query(`DROP TABLE \`HR_EDUCATION_EMP\``);
await queryRunner.query(`DROP TABLE \`HR_PERSONAL_EMP_FAMILY\``);
await queryRunner.query(`DROP TABLE \`HR_PERSONAL_OFFICER_ADDRESS\``);
await queryRunner.query(`DROP TABLE \`HR_PERSONAL_EMP_ADDRESS\``);
await queryRunner.query(`DROP TABLE \`HR_PERSONAL_OFFICER_FAMILY\``);
await queryRunner.query(`DROP TABLE \`HR_POSITION_OFFICER\``);
await queryRunner.query(`DROP TABLE \`provinceImport\``);
await queryRunner.query(`DROP TABLE \`subDistrictImport\``);
await queryRunner.query(`CREATE INDEX \`FK_8e3f2e86427befeff4283ae80f0\` ON \`developmentProject\` (\`profileDevelopmentHistoryId\`)`);
await queryRunner.query(`CREATE INDEX \`FK_4913ef1466f9f35c1429e213d4b\` ON \`developmentProject\` (\`profileDevelopmentId\`)`);
}
}