Merge branch 'develop' into adiDev
# Conflicts: # src/controllers/ProfileAssessmentsController.ts # src/controllers/ProfileCertificateController.ts # src/controllers/ProfileEducationsController.ts # src/controllers/ProfileSalaryController.ts
This commit is contained in:
commit
27ef5cabef
105 changed files with 2060 additions and 3540 deletions
|
|
@ -68,6 +68,8 @@ export class AuthRoleAttrController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -101,7 +103,9 @@ export class AuthRoleAttrController extends Controller {
|
|||
body.authSysId = body.authSysId?.toUpperCase();
|
||||
|
||||
Object.assign(record, body);
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([this.authRoleAttrRepo.save(record)]);
|
||||
|
||||
|
|
|
|||
|
|
@ -71,6 +71,8 @@ export class AuthRoleController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -100,6 +102,7 @@ export class AuthRoleController extends Controller {
|
|||
|
||||
posMaster.lastUpdateUserId = req.user.sub;
|
||||
posMaster.lastUpdateFullName = req.user.name;
|
||||
posMaster.lastUpdatedAt = new Date();
|
||||
posMaster.authRoleId = body.authRoleId;
|
||||
await this.posMasterRepository.save(posMaster);
|
||||
|
||||
|
|
@ -142,6 +145,7 @@ export class AuthRoleController extends Controller {
|
|||
|
||||
posMaster.lastUpdateUserId = req.user.sub;
|
||||
posMaster.lastUpdateFullName = req.user.name;
|
||||
posMaster.lastUpdatedAt = new Date();
|
||||
posMaster.authRoleId = body.authRoleId;
|
||||
await this.employeePosMasterRepository.save(posMaster);
|
||||
return new HttpSuccess();
|
||||
|
|
@ -184,6 +188,8 @@ export class AuthRoleController extends Controller {
|
|||
roleName: body.roleName,
|
||||
roleDescription: body.roleDescription,
|
||||
lastUpdateFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdatedAt: new Date(),
|
||||
});
|
||||
}
|
||||
const roleAttrData = await this.authRoleAttrRepo.find({
|
||||
|
|
@ -207,7 +213,9 @@ export class AuthRoleController extends Controller {
|
|||
// createdUserId: req.user.sub,
|
||||
// createdFullName: req.user.name,
|
||||
// lastUpdateUserId: req.user.sub,
|
||||
// lastUpdateFullName: req.user.name,
|
||||
// lastUpdateFullName: req.user.name,
|
||||
// createdAt: new Date(),
|
||||
// lastUpdatedAt: new Date(),
|
||||
// });
|
||||
// return newAttr;
|
||||
// });
|
||||
|
|
@ -228,6 +236,8 @@ export class AuthRoleController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
});
|
||||
return newAttr;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -71,6 +71,8 @@ export class AuthSysController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -92,7 +94,9 @@ export class AuthSysController extends Controller {
|
|||
body.id = body.id?.toUpperCase();
|
||||
|
||||
Object.assign(record, body);
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([this.authSysRepo.save(record)]);
|
||||
|
||||
|
|
|
|||
|
|
@ -53,8 +53,10 @@ export class BloodGroupController extends Controller {
|
|||
const bloodGroup = Object.assign(new BloodGroup(), requestBody);
|
||||
bloodGroup.createdUserId = request.user.sub;
|
||||
bloodGroup.createdFullName = request.user.name;
|
||||
bloodGroup.createdAt = new Date();
|
||||
bloodGroup.lastUpdateUserId = request.user.sub;
|
||||
bloodGroup.lastUpdateFullName = request.user.name;
|
||||
bloodGroup.lastUpdatedAt = new Date();
|
||||
await this.bloodGroupRepository.save(bloodGroup);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
@ -88,6 +90,7 @@ export class BloodGroupController extends Controller {
|
|||
|
||||
bloodGroup.lastUpdateUserId = request.user.sub;
|
||||
bloodGroup.lastUpdateFullName = request.user.name;
|
||||
bloodGroup.lastUpdatedAt = new Date();
|
||||
this.bloodGroupRepository.merge(bloodGroup, requestBody);
|
||||
await this.bloodGroupRepository.save(bloodGroup);
|
||||
return new HttpSuccess();
|
||||
|
|
|
|||
|
|
@ -77,12 +77,14 @@ export class ChangePositionController extends Controller {
|
|||
|
||||
const changePosition = new ChangePosition();
|
||||
Object.assign(changePosition, body);
|
||||
(changePosition.date = new Date()),
|
||||
(changePosition.status = "WAITTING"),
|
||||
(changePosition.createdUserId = request.user.sub);
|
||||
changePosition.date = new Date();
|
||||
changePosition.status = "WAITTING";
|
||||
changePosition.createdUserId = request.user.sub;
|
||||
changePosition.createdFullName = request.user.name;
|
||||
changePosition.createdAt = new Date();
|
||||
changePosition.lastUpdateUserId = request.user.sub;
|
||||
changePosition.lastUpdateFullName = request.user.name;
|
||||
changePosition.lastUpdatedAt = new Date();
|
||||
await this.changePositionRepository.save(changePosition);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
@ -143,6 +145,7 @@ export class ChangePositionController extends Controller {
|
|||
Object.assign(changePosition, body);
|
||||
changePosition.lastUpdateUserId = request.user.sub;
|
||||
changePosition.lastUpdateFullName = request.user.name;
|
||||
changePosition.lastUpdatedAt = new Date();
|
||||
await this.changePositionRepository.save(changePosition);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
@ -236,12 +239,14 @@ export class ChangePositionController extends Controller {
|
|||
let positionOld = data.positionOld ? `${data.positionOld}` : "";
|
||||
let rootOld = data.rootOld ? (data.positionOld ? `/${data.rootOld}` : `${data.rootOld}`) : "";
|
||||
profiles.changePositionId = changePositionId;
|
||||
(profiles.organizationPositionOld = `${positionOld}${rootOld}`),
|
||||
(profiles.status = "WAITTING"),
|
||||
(profiles.createdUserId = request.user.sub);
|
||||
profiles.organizationPositionOld = `${positionOld}${rootOld}`;
|
||||
profiles.status = "WAITTING";
|
||||
profiles.createdUserId = request.user.sub;
|
||||
profiles.createdFullName = request.user.name;
|
||||
profiles.createdAt = new Date();
|
||||
profiles.lastUpdateUserId = request.user.sub;
|
||||
profiles.lastUpdateFullName = request.user.name;
|
||||
profiles.lastUpdatedAt = new Date();
|
||||
profileChangePositions.push(profiles);
|
||||
}
|
||||
await this.profileChangePositionRepository.save(profileChangePositions);
|
||||
|
|
@ -391,6 +396,7 @@ export class ChangePositionController extends Controller {
|
|||
|
||||
profileChangePos.lastUpdateUserId = request.user.sub;
|
||||
profileChangePos.lastUpdateFullName = request.user.name;
|
||||
profileChangePos.lastUpdatedAt = new Date();
|
||||
profileChangePos.educationOld = body.educationOld;
|
||||
profileChangePos.posMasterNoOld = body.posMasterNoOld;
|
||||
profileChangePos.positionTypeOld = body.positionTypeOld;
|
||||
|
|
@ -512,6 +518,7 @@ export class ChangePositionController extends Controller {
|
|||
|
||||
profileChangePos.lastUpdateUserId = request.user.sub;
|
||||
profileChangePos.lastUpdateFullName = request.user.name;
|
||||
profileChangePos.lastUpdatedAt = new Date();
|
||||
profileChangePos.node = body.node;
|
||||
profileChangePos.nodeId = body.nodeId;
|
||||
profileChangePos.orgRevisionId = body.orgRevisionId;
|
||||
|
|
@ -546,11 +553,13 @@ export class ChangePositionController extends Controller {
|
|||
item.status = "REPORT";
|
||||
item.lastUpdateUserId = request.user.sub;
|
||||
item.lastUpdateFullName = request.user.name;
|
||||
item.lastUpdatedAt = new Date();
|
||||
if (item.profileChangePosition) {
|
||||
for (const profile of item.profileChangePosition) {
|
||||
profile.status = "REPORT";
|
||||
profile.lastUpdateUserId = request.user.sub;
|
||||
profile.lastUpdateFullName = request.user.name;
|
||||
profile.lastUpdatedAt = new Date();
|
||||
await this.profileChangePositionRepository.save(profile);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,8 +103,10 @@ export class DistrictController extends Controller {
|
|||
|
||||
_district.createdUserId = request.user.sub;
|
||||
_district.createdFullName = request.user.name;
|
||||
_district.createdAt = new Date();
|
||||
_district.lastUpdateUserId = request.user.sub;
|
||||
_district.lastUpdateFullName = request.user.name;
|
||||
_district.lastUpdatedAt = new Date();
|
||||
await this.districtRepository.save(_district);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
@ -144,6 +146,7 @@ export class DistrictController extends Controller {
|
|||
|
||||
_district.lastUpdateUserId = request.user.sub;
|
||||
_district.lastUpdateFullName = request.user.name;
|
||||
_district.lastUpdatedAt = new Date();
|
||||
this.districtRepository.merge(_district, requestBody);
|
||||
await this.districtRepository.save(_district);
|
||||
return new HttpSuccess();
|
||||
|
|
|
|||
|
|
@ -53,8 +53,10 @@ export class EducationLevelController extends Controller {
|
|||
const educationLevel = Object.assign(new EducationLevel(), requestBody);
|
||||
educationLevel.createdUserId = request.user.sub;
|
||||
educationLevel.createdFullName = request.user.name;
|
||||
educationLevel.createdAt = new Date();
|
||||
educationLevel.lastUpdateUserId = request.user.sub;
|
||||
educationLevel.lastUpdateFullName = request.user.name;
|
||||
educationLevel.lastUpdatedAt = new Date();
|
||||
await this.educationLevelRepository.save(educationLevel);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
@ -88,6 +90,7 @@ export class EducationLevelController extends Controller {
|
|||
|
||||
educationLevel.lastUpdateUserId = request.user.sub;
|
||||
educationLevel.lastUpdateFullName = request.user.name;
|
||||
educationLevel.lastUpdatedAt = new Date();
|
||||
this.educationLevelRepository.merge(educationLevel, requestBody);
|
||||
await this.educationLevelRepository.save(educationLevel);
|
||||
return new HttpSuccess();
|
||||
|
|
|
|||
|
|
@ -80,6 +80,8 @@ export class EmployeePosLevelController extends Controller {
|
|||
EmpPosLevel.createdFullName = request.user.name;
|
||||
EmpPosLevel.lastUpdateUserId = request.user.sub;
|
||||
EmpPosLevel.lastUpdateFullName = request.user.name;
|
||||
EmpPosLevel.createdAt = new Date();
|
||||
EmpPosLevel.lastUpdatedAt = new Date();
|
||||
await this.employeePosLevelRepository.save(EmpPosLevel);
|
||||
return new HttpSuccess(EmpPosLevel.id);
|
||||
}
|
||||
|
|
@ -125,6 +127,7 @@ export class EmployeePosLevelController extends Controller {
|
|||
}
|
||||
EmpPosLevel.lastUpdateUserId = request.user.sub;
|
||||
EmpPosLevel.lastUpdateFullName = request.user.name;
|
||||
EmpPosLevel.lastUpdatedAt = new Date();
|
||||
this.employeePosLevelRepository.merge(EmpPosLevel, requestBody);
|
||||
await this.employeePosLevelRepository.save(EmpPosLevel);
|
||||
return new HttpSuccess(EmpPosLevel.id);
|
||||
|
|
@ -139,11 +142,14 @@ export class EmployeePosLevelController extends Controller {
|
|||
*/
|
||||
@Delete("{id}")
|
||||
async deleteType(@Path() id: string) {
|
||||
let result :any
|
||||
let result: any;
|
||||
try {
|
||||
result = await this.employeePosLevelRepository.delete({ id: id });
|
||||
} catch {
|
||||
throw new HttpError( HttpStatusCode.NOT_FOUND, "ไม่สามารถลบได้เนื่องจากมีการใช้งานระดับชั้นงานนี้อยู่");
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่สามารถลบได้เนื่องจากมีการใช้งานระดับชั้นงานนี้อยู่",
|
||||
);
|
||||
}
|
||||
if (result.affected == undefined || result.affected <= 0) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
|
|||
|
|
@ -76,6 +76,8 @@ export class EmployeePosTypeController extends Controller {
|
|||
EmpPosType.createdFullName = request.user.name;
|
||||
EmpPosType.lastUpdateUserId = request.user.sub;
|
||||
EmpPosType.lastUpdateFullName = request.user.name;
|
||||
EmpPosType.createdAt = new Date();
|
||||
EmpPosType.lastUpdatedAt = new Date();
|
||||
await this.employeePosTypeRepository.save(EmpPosType);
|
||||
return new HttpSuccess(EmpPosType.id);
|
||||
}
|
||||
|
|
@ -120,6 +122,7 @@ export class EmployeePosTypeController extends Controller {
|
|||
}
|
||||
EmpPosType.lastUpdateUserId = request.user.sub;
|
||||
EmpPosType.lastUpdateFullName = request.user.name;
|
||||
EmpPosType.lastUpdatedAt = new Date();
|
||||
this.employeePosTypeRepository.merge(EmpPosType, requestBody);
|
||||
await this.employeePosTypeRepository.save(EmpPosType);
|
||||
return new HttpSuccess(EmpPosType.id);
|
||||
|
|
@ -134,11 +137,14 @@ export class EmployeePosTypeController extends Controller {
|
|||
*/
|
||||
@Delete("{id}")
|
||||
async deleteType(@Path() id: string) {
|
||||
let result :any
|
||||
let result: any;
|
||||
try {
|
||||
result = await this.employeePosTypeRepository.delete({ id: id });
|
||||
} catch {
|
||||
throw new HttpError( HttpStatusCode.NOT_FOUND, "ไม่สามารถลบได้เนื่องจากมีการใช้งานระดับกลุ่มงานนี้อยู่");
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่สามารถลบได้เนื่องจากมีการใช้งานระดับกลุ่มงานนี้อยู่",
|
||||
);
|
||||
}
|
||||
if (result.affected == undefined || result.affected <= 0) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
|
|||
|
|
@ -107,8 +107,10 @@ export class EmployeePositionController extends Controller {
|
|||
|
||||
empPosDict.createdUserId = request.user.sub;
|
||||
empPosDict.createdFullName = request.user.name;
|
||||
empPosDict.createdAt = new Date();
|
||||
empPosDict.lastUpdateUserId = request.user.sub;
|
||||
empPosDict.lastUpdateFullName = request.user.name;
|
||||
empPosDict.lastUpdatedAt = new Date();
|
||||
await this.employeePosDictRepository.save(empPosDict);
|
||||
return new HttpSuccess(empPosDict.id);
|
||||
}
|
||||
|
|
@ -162,6 +164,7 @@ export class EmployeePositionController extends Controller {
|
|||
|
||||
empPosDict.lastUpdateUserId = request.user.sub;
|
||||
empPosDict.lastUpdateFullName = request.user.name;
|
||||
empPosDict.lastUpdatedAt = new Date();
|
||||
this.employeePosDictRepository.merge(empPosDict, requestBody);
|
||||
await this.employeePosDictRepository.save(empPosDict);
|
||||
return new HttpSuccess(empPosDict.id);
|
||||
|
|
@ -582,8 +585,10 @@ export class EmployeePositionController extends Controller {
|
|||
|
||||
posMaster.createdUserId = request.user.sub;
|
||||
posMaster.createdFullName = request.user.name;
|
||||
posMaster.createdAt = new Date();
|
||||
posMaster.lastUpdateUserId = request.user.sub;
|
||||
posMaster.lastUpdateFullName = request.user.name;
|
||||
posMaster.lastUpdatedAt = new Date();
|
||||
await this.employeePosMasterRepository.save(posMaster);
|
||||
await Promise.all(
|
||||
requestBody.positions.map(async (x: any) => {
|
||||
|
|
@ -595,8 +600,10 @@ export class EmployeePositionController extends Controller {
|
|||
position.posMasterId = posMaster.id;
|
||||
position.createdUserId = request.user.sub;
|
||||
position.createdFullName = request.user.name;
|
||||
position.createdAt = new Date();
|
||||
position.lastUpdateUserId = request.user.sub;
|
||||
position.lastUpdateFullName = request.user.name;
|
||||
position.lastUpdatedAt = new Date();
|
||||
await this.employeePositionRepository.save(position);
|
||||
}),
|
||||
);
|
||||
|
|
@ -787,8 +794,10 @@ export class EmployeePositionController extends Controller {
|
|||
|
||||
posMaster.createdUserId = request.user.sub; //สงสัยว่าทำให้ bug แก้ไขไม่ได้
|
||||
posMaster.createdFullName = request.user.name;
|
||||
posMaster.createdAt = new Date();
|
||||
posMaster.lastUpdateUserId = request.user.sub;
|
||||
posMaster.lastUpdateFullName = request.user.name;
|
||||
posMaster.lastUpdatedAt = new Date();
|
||||
await this.employeePosMasterRepository.save(posMaster);
|
||||
await this.employeePositionRepository.delete({ posMasterId: posMaster.id });
|
||||
|
||||
|
|
@ -802,8 +811,10 @@ export class EmployeePositionController extends Controller {
|
|||
position.posMasterId = posMaster.id;
|
||||
position.createdUserId = request.user.sub;
|
||||
position.createdFullName = request.user.name;
|
||||
position.createdAt = new Date();
|
||||
position.lastUpdateUserId = request.user.sub;
|
||||
position.lastUpdateFullName = request.user.name;
|
||||
position.lastUpdatedAt = new Date();
|
||||
await this.employeePositionRepository.save(position);
|
||||
}),
|
||||
);
|
||||
|
|
@ -1186,7 +1197,10 @@ export class EmployeePositionController extends Controller {
|
|||
*
|
||||
*/
|
||||
@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");
|
||||
switch (requestBody.type) {
|
||||
case 0: {
|
||||
|
|
@ -1614,8 +1628,10 @@ export class EmployeePositionController extends Controller {
|
|||
posMaster.posMasterOrder = maxPosMasterOrder += 1;
|
||||
posMaster.createdUserId = request.user.sub;
|
||||
posMaster.createdFullName = request.user.name;
|
||||
posMaster.createdAt = new Date();
|
||||
posMaster.lastUpdateUserId = request.user.sub;
|
||||
posMaster.lastUpdateFullName = request.user.name;
|
||||
posMaster.lastUpdatedAt = new Date();
|
||||
await this.employeePosMasterRepository.save(posMaster);
|
||||
}
|
||||
}),
|
||||
|
|
@ -2078,7 +2094,7 @@ export class EmployeePositionController extends Controller {
|
|||
@Post("profile")
|
||||
async createEmpHolder(
|
||||
@Body() requestBody: { posMaster: string; position: string; profileId: string; isSit: boolean },
|
||||
@Request() request: RequestWithUser
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionCreate(request, "SYS_ORG_EMP");
|
||||
const dataMaster = await this.employeePosMasterRepository.findOne({
|
||||
|
|
@ -2144,7 +2160,10 @@ export class EmployeePositionController extends Controller {
|
|||
*
|
||||
*/
|
||||
@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");
|
||||
const findDraft = await this.orgRevisionRepository.findOne({
|
||||
where: {
|
||||
|
|
|
|||
|
|
@ -98,6 +98,8 @@ export class GenderController extends Controller {
|
|||
_gender.createdFullName = request.user.name;
|
||||
_gender.lastUpdateUserId = request.user.sub;
|
||||
_gender.lastUpdateFullName = request.user.name;
|
||||
_gender.createdAt = new Date();
|
||||
_gender.lastUpdatedAt = new Date();
|
||||
await this.genderRepository.save(_gender);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
@ -129,6 +131,7 @@ export class GenderController extends Controller {
|
|||
|
||||
_gender.lastUpdateUserId = request.user.sub;
|
||||
_gender.lastUpdateFullName = request.user.name;
|
||||
_gender.lastUpdatedAt = new Date();
|
||||
this.genderRepository.merge(_gender, requestBody);
|
||||
await this.genderRepository.save(_gender);
|
||||
return new HttpSuccess();
|
||||
|
|
|
|||
|
|
@ -175,6 +175,8 @@ export class ImportDataController extends Controller {
|
|||
profile.createdFullName = request.user.name;
|
||||
profile.lastUpdateUserId = request.user.sub;
|
||||
profile.lastUpdateFullName = request.user.name;
|
||||
profile.createdAt = new Date();
|
||||
profile.lastUpdatedAt = new Date();
|
||||
profiles.push(profile);
|
||||
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
||||
|
||||
|
|
@ -248,6 +250,8 @@ export class ImportDataController extends Controller {
|
|||
profileEmp.createdFullName = request.user.name;
|
||||
profileEmp.lastUpdateUserId = request.user.sub;
|
||||
profileEmp.lastUpdateFullName = request.user.name;
|
||||
profileEmp.createdAt = new Date();
|
||||
profileEmp.lastUpdatedAt = new Date();
|
||||
profiles.push(profileEmp);
|
||||
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
||||
|
||||
|
|
@ -336,6 +340,8 @@ export class ImportDataController extends Controller {
|
|||
profileSalary.createdFullName = request.user.name;
|
||||
profileSalary.lastUpdateUserId = request.user.sub;
|
||||
profileSalary.lastUpdateFullName = request.user.name;
|
||||
profileSalary.createdAt = new Date();
|
||||
profileSalary.lastUpdatedAt = new Date();
|
||||
// profileSalarys.push(profileSalary);
|
||||
// await this.salaryRepository.save(profileSalary);
|
||||
// if (profileSalarys.length === BATCH_SIZE) {
|
||||
|
|
@ -428,6 +434,8 @@ export class ImportDataController extends Controller {
|
|||
profileSalary.createdFullName = request.user.name;
|
||||
profileSalary.lastUpdateUserId = request.user.sub;
|
||||
profileSalary.lastUpdateFullName = request.user.name;
|
||||
profileSalary.createdAt = new Date();
|
||||
profileSalary.lastUpdatedAt = new Date();
|
||||
// profileSalarys.push(profileSalary);
|
||||
// await this.salaryRepository.save(profileSalary);
|
||||
// if (profileSalarys.length === BATCH_SIZE) {
|
||||
|
|
@ -509,6 +517,8 @@ export class ImportDataController extends Controller {
|
|||
profileFather.createdFullName = request.user.name;
|
||||
profileFather.lastUpdateUserId = request.user.sub;
|
||||
profileFather.lastUpdateFullName = request.user.name;
|
||||
profileFather.createdAt = new Date();
|
||||
profileFather.lastUpdatedAt = new Date();
|
||||
|
||||
profileMother.profileId = _item.id;
|
||||
profileMother.motherPrefix = existingProfile.MOTHER_RANK_NAME;
|
||||
|
|
@ -518,6 +528,8 @@ export class ImportDataController extends Controller {
|
|||
profileMother.createdFullName = request.user.name;
|
||||
profileMother.lastUpdateUserId = request.user.sub;
|
||||
profileMother.lastUpdateFullName = request.user.name;
|
||||
profileMother.createdAt = new Date();
|
||||
profileMother.lastUpdatedAt = new Date();
|
||||
|
||||
profileCouple.profileId = _item.id;
|
||||
profileCouple.couplePrefix = existingProfile.SPOUSE_RANK_NAME;
|
||||
|
|
@ -539,6 +551,8 @@ export class ImportDataController extends Controller {
|
|||
profileCouple.createdFullName = request.user.name;
|
||||
profileCouple.lastUpdateUserId = request.user.sub;
|
||||
profileCouple.lastUpdateFullName = request.user.name;
|
||||
profileCouple.createdAt = new Date();
|
||||
profileCouple.lastUpdatedAt = new Date();
|
||||
|
||||
// fathers.push(profileFather);
|
||||
// mothers.push(profileMother);
|
||||
|
|
@ -633,6 +647,8 @@ export class ImportDataController extends Controller {
|
|||
profileFather.createdFullName = request.user.name;
|
||||
profileFather.lastUpdateUserId = request.user.sub;
|
||||
profileFather.lastUpdateFullName = request.user.name;
|
||||
profileFather.createdAt = new Date();
|
||||
profileFather.lastUpdatedAt = new Date();
|
||||
|
||||
profileMother.profileEmployeeId = _item.id;
|
||||
profileMother.motherPrefix = existingProfile.MOTHER_RANK_NAME;
|
||||
|
|
@ -642,6 +658,8 @@ export class ImportDataController extends Controller {
|
|||
profileMother.createdFullName = request.user.name;
|
||||
profileMother.lastUpdateUserId = request.user.sub;
|
||||
profileMother.lastUpdateFullName = request.user.name;
|
||||
profileMother.createdAt = new Date();
|
||||
profileMother.lastUpdatedAt = new Date();
|
||||
|
||||
profileCouple.profileEmployeeId = _item.id;
|
||||
profileCouple.couplePrefix = existingProfile.SPOUSE_RANK_NAME;
|
||||
|
|
@ -663,6 +681,8 @@ export class ImportDataController extends Controller {
|
|||
profileCouple.createdFullName = request.user.name;
|
||||
profileCouple.lastUpdateUserId = request.user.sub;
|
||||
profileCouple.lastUpdateFullName = request.user.name;
|
||||
profileCouple.createdAt = new Date();
|
||||
profileCouple.lastUpdatedAt = new Date();
|
||||
|
||||
// fathers.push(profileFather);
|
||||
// mothers.push(profileMother);
|
||||
|
|
@ -720,6 +740,8 @@ export class ImportDataController extends Controller {
|
|||
educationMis.createdFullName = request.user.name;
|
||||
educationMis.lastUpdateUserId = request.user.sub;
|
||||
educationMis.lastUpdateFullName = request.user.name;
|
||||
educationMis.createdAt = new Date();
|
||||
educationMis.lastUpdatedAt = new Date();
|
||||
educationMis_.push(educationMis);
|
||||
}),
|
||||
);
|
||||
|
|
@ -786,6 +808,8 @@ export class ImportDataController extends Controller {
|
|||
education.createdFullName = request.user.name;
|
||||
education.lastUpdateUserId = request.user.sub;
|
||||
education.lastUpdateFullName = request.user.name;
|
||||
education.createdAt = new Date();
|
||||
education.lastUpdatedAt = new Date();
|
||||
// await educations.push(await education);
|
||||
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
||||
await this.educationRepository.save(await education);
|
||||
|
|
@ -860,6 +884,8 @@ export class ImportDataController extends Controller {
|
|||
education.createdFullName = request.user.name;
|
||||
education.lastUpdateUserId = request.user.sub;
|
||||
education.lastUpdateFullName = request.user.name;
|
||||
education.createdAt = new Date();
|
||||
education.lastUpdatedAt = new Date();
|
||||
// educations.push(education);
|
||||
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
||||
await this.educationRepository.save(education);
|
||||
|
|
@ -898,6 +924,8 @@ export class ImportDataController extends Controller {
|
|||
prov.createdFullName = request.user.name;
|
||||
prov.lastUpdateUserId = request.user.sub;
|
||||
prov.lastUpdateFullName = request.user.name;
|
||||
prov.createdAt = new Date();
|
||||
prov.lastUpdatedAt = new Date();
|
||||
provinces_.push(prov);
|
||||
}),
|
||||
);
|
||||
|
|
@ -930,6 +958,8 @@ export class ImportDataController extends Controller {
|
|||
amh.createdFullName = request.user.name;
|
||||
amh.lastUpdateUserId = request.user.sub;
|
||||
amh.lastUpdateFullName = request.user.name;
|
||||
amh.createdAt = new Date();
|
||||
amh.lastUpdatedAt = new Date();
|
||||
amphur_.push(amh);
|
||||
}),
|
||||
);
|
||||
|
|
@ -963,6 +993,8 @@ export class ImportDataController extends Controller {
|
|||
subD.createdFullName = request.user.name;
|
||||
subD.lastUpdateUserId = request.user.sub;
|
||||
subD.lastUpdateFullName = request.user.name;
|
||||
subD.createdAt = new Date();
|
||||
subD.lastUpdatedAt = new Date();
|
||||
subDistrict_.push(subD);
|
||||
}),
|
||||
);
|
||||
|
|
@ -1112,6 +1144,8 @@ export class ImportDataController extends Controller {
|
|||
_item.createdFullName = request.user.name;
|
||||
_item.lastUpdateUserId = request.user.sub;
|
||||
_item.lastUpdateFullName = request.user.name;
|
||||
_item.createdAt = new Date();
|
||||
_item.lastUpdatedAt = new Date();
|
||||
// profileDatas.push(_item);
|
||||
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
||||
await this.profileRepo.save(_item);
|
||||
|
|
@ -1265,6 +1299,8 @@ export class ImportDataController extends Controller {
|
|||
_item.createdFullName = request.user.name;
|
||||
_item.lastUpdateUserId = request.user.sub;
|
||||
_item.lastUpdateFullName = request.user.name;
|
||||
_item.createdAt = new Date();
|
||||
_item.lastUpdatedAt = new Date();
|
||||
// profileDatas.push(_item);
|
||||
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
||||
await this.profileEmpRepo.save(_item);
|
||||
|
|
|
|||
|
|
@ -71,6 +71,8 @@ export class InsigniaController extends Controller {
|
|||
insignia.createdFullName = request.user.name;
|
||||
insignia.lastUpdateUserId = request.user.sub;
|
||||
insignia.lastUpdateFullName = request.user.name;
|
||||
insignia.createdAt = new Date();
|
||||
insignia.lastUpdatedAt = new Date();
|
||||
await this.insigniaRepository.save(insignia);
|
||||
return new HttpSuccess(insignia.id);
|
||||
}
|
||||
|
|
@ -113,6 +115,7 @@ export class InsigniaController extends Controller {
|
|||
|
||||
insignia.lastUpdateUserId = request.user.sub;
|
||||
insignia.lastUpdateFullName = request.user.name;
|
||||
insignia.lastUpdatedAt = new Date();
|
||||
this.insigniaRepository.merge(insignia, requestBody);
|
||||
await this.insigniaRepository.save(insignia);
|
||||
return new HttpSuccess(insignia.id);
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ import HttpSuccess from "../interfaces/http-success";
|
|||
import HttpStatusCode from "../interfaces/http-status";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import { Equal, ILike, In, IsNull, Like, Not, Brackets, Between } from "typeorm";
|
||||
import { InsigniaType, CreateInsigniaType, UpdateInsigniaType } from "../entities/InsigniaType";
|
||||
import { Insignia, } from "../entities/Insignia";
|
||||
import { InsigniaType, CreateInsigniaType, UpdateInsigniaType } from "../entities/InsigniaType";
|
||||
import { Insignia } from "../entities/Insignia";
|
||||
|
||||
@Route("api/v1/org/insignia/insignia-type")
|
||||
@Tags("InsigniaType")
|
||||
|
|
@ -33,10 +33,9 @@ import { Insignia, } from "../entities/Insignia";
|
|||
)
|
||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||
export class InsigniaTypeController extends Controller {
|
||||
|
||||
private insigniaTypeRepository = AppDataSource.getRepository(InsigniaType);
|
||||
private insigniaRepository = AppDataSource.getRepository(Insignia);
|
||||
|
||||
|
||||
/**
|
||||
* API เพิ่มข้อมูลลำดับชั้นเครื่องราชอิสริยาภรณ์
|
||||
*
|
||||
|
|
@ -48,7 +47,6 @@ export class InsigniaTypeController extends Controller {
|
|||
@Body() requestBody: CreateInsigniaType,
|
||||
@Request() request: { user: Record<string, any> },
|
||||
) {
|
||||
|
||||
const insigniaType = Object.assign(new InsigniaType(), requestBody);
|
||||
if (!insigniaType) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
@ -68,6 +66,8 @@ export class InsigniaTypeController extends Controller {
|
|||
insigniaType.createdFullName = request.user.name;
|
||||
insigniaType.lastUpdateUserId = request.user.sub;
|
||||
insigniaType.lastUpdateFullName = request.user.name;
|
||||
insigniaType.createdAt = new Date();
|
||||
insigniaType.lastUpdatedAt = new Date();
|
||||
await this.insigniaTypeRepository.save(insigniaType);
|
||||
return new HttpSuccess(insigniaType.id);
|
||||
}
|
||||
|
|
@ -77,7 +77,7 @@ export class InsigniaTypeController extends Controller {
|
|||
*
|
||||
* @summary แก้ไขลำดับชั้นเครื่องราชอิสริยาภรณ์ (ADMIN)
|
||||
*
|
||||
* @param {string} id Id ลำดับชั้นเครื่องราชอิสริยาภรณ์
|
||||
* @param {string} id Id ลำดับชั้นเครื่องราชอิสริยาภรณ์
|
||||
*/
|
||||
@Put("{id}")
|
||||
async UpdateInsigniaType(
|
||||
|
|
@ -104,6 +104,7 @@ export class InsigniaTypeController extends Controller {
|
|||
|
||||
insigniaType.lastUpdateUserId = request.user.sub;
|
||||
insigniaType.lastUpdateFullName = request.user.name;
|
||||
insigniaType.lastUpdatedAt = new Date();
|
||||
this.insigniaTypeRepository.merge(insigniaType, requestBody);
|
||||
await this.insigniaTypeRepository.save(insigniaType);
|
||||
return new HttpSuccess(insigniaType.id);
|
||||
|
|
@ -122,11 +123,14 @@ export class InsigniaTypeController extends Controller {
|
|||
if (!delInsigniaType) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลลำดับชั้นเครื่องราชอิสริยาภรณ์นี้");
|
||||
}
|
||||
const Insignia = await this.insigniaRepository.find({
|
||||
where: { insigniaTypeId: id }
|
||||
const Insignia = await this.insigniaRepository.find({
|
||||
where: { insigniaTypeId: id },
|
||||
});
|
||||
if (Insignia.length > 0) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถลบได้ เนื่องจากพบข้อมูลที่ตารางเครื่องราชอิสริยาภรณ์");
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่สามารถลบได้ เนื่องจากพบข้อมูลที่ตารางเครื่องราชอิสริยาภรณ์",
|
||||
);
|
||||
}
|
||||
await this.insigniaTypeRepository.remove(delInsigniaType);
|
||||
return new HttpSuccess();
|
||||
|
|
@ -143,7 +147,7 @@ export class InsigniaTypeController extends Controller {
|
|||
const insigniaType_Active = await this.insigniaTypeRepository.find({
|
||||
select: ["id", "name", "createdAt", "lastUpdatedAt", "lastUpdateFullName", "isActive"],
|
||||
where: { isActive: true },
|
||||
order: { "name": "ASC" }
|
||||
order: { name: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(insigniaType_Active);
|
||||
}
|
||||
|
|
@ -153,7 +157,7 @@ export class InsigniaTypeController extends Controller {
|
|||
*
|
||||
* @summary ORG_037 - รายละเอียดข้อมูลลำดับชั้นเครื่องราชอิสริยาภรณ์ (ADMIN) #
|
||||
*
|
||||
* @param {string} id Id ลำดับชั้นเครื่องราชอิสริยาภรณ์
|
||||
* @param {string} id Id ลำดับชั้นเครื่องราชอิสริยาภรณ์
|
||||
*/
|
||||
@Get("{id}")
|
||||
async GetInsigniaTypeById(@Path() id: string) {
|
||||
|
|
@ -163,7 +167,10 @@ export class InsigniaTypeController extends Controller {
|
|||
where: { id: id },
|
||||
});
|
||||
if (!insigniaType) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลลำดับชั้นเครื่องราชอิสริยาภรณ์ นี้");
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลลำดับชั้นเครื่องราชอิสริยาภรณ์ นี้",
|
||||
);
|
||||
}
|
||||
return new HttpSuccess(insigniaType);
|
||||
}
|
||||
|
|
@ -178,7 +185,7 @@ export class InsigniaTypeController extends Controller {
|
|||
async GetInsigniaType() {
|
||||
const insigniaTypeAll = await this.insigniaTypeRepository.find({
|
||||
select: ["id", "name", "createdAt", "lastUpdatedAt", "lastUpdateFullName", "isActive"],
|
||||
order: { "name": "ASC" }
|
||||
order: { name: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(insigniaTypeAll);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,6 +167,8 @@ export class OrgChild1Controller {
|
|||
child1.createdFullName = request.user.name;
|
||||
child1.lastUpdateUserId = request.user.sub;
|
||||
child1.lastUpdateFullName = request.user.name;
|
||||
child1.createdAt = new Date();
|
||||
child1.lastUpdatedAt = new Date();
|
||||
child1.orgRevisionId = String(rootIdExits?.orgRevisionId);
|
||||
child1.orgRootId = String(rootIdExits?.id);
|
||||
child1.orgChild1Order =
|
||||
|
|
|
|||
|
|
@ -152,6 +152,8 @@ export class OrgChild2Controller extends Controller {
|
|||
child2.createdFullName = request.user.name;
|
||||
child2.lastUpdateUserId = request.user.sub;
|
||||
child2.lastUpdateFullName = request.user.name;
|
||||
child2.createdAt = new Date();
|
||||
child2.lastUpdatedAt = new Date();
|
||||
child2.orgRootId = String(child1?.orgRootId);
|
||||
child2.orgRevisionId = String(child1?.orgRevisionId);
|
||||
child2.orgChild1Id = String(child1?.id);
|
||||
|
|
|
|||
|
|
@ -131,6 +131,8 @@ export class OrgChild3Controller {
|
|||
child3.createdFullName = request.user.name;
|
||||
child3.lastUpdateUserId = request.user.sub;
|
||||
child3.lastUpdateFullName = request.user.name;
|
||||
child3.createdAt = new Date();
|
||||
child3.lastUpdatedAt = new Date();
|
||||
child3.orgRootId = String(child2?.orgRootId);
|
||||
child3.orgChild1Id = String(child2?.orgChild1Id);
|
||||
child3.orgRevisionId = String(child2?.orgRevisionId);
|
||||
|
|
|
|||
|
|
@ -150,6 +150,8 @@ export class OrgChild4Controller extends Controller {
|
|||
child4.createdFullName = request.user.name;
|
||||
child4.lastUpdateUserId = request.user.sub;
|
||||
child4.lastUpdateFullName = request.user.name;
|
||||
child4.createdAt = new Date();
|
||||
child4.lastUpdatedAt = new Date();
|
||||
child4.orgRootId = String(child3?.orgRootId);
|
||||
child4.orgChild1Id = String(child3?.orgChild1Id);
|
||||
child4.orgChild2Id = String(child3?.orgChild2Id);
|
||||
|
|
@ -189,7 +191,7 @@ export class OrgChild4Controller extends Controller {
|
|||
requestBody: UpdateOrgChild4,
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionUpdate(request, "SYS_ORG");
|
||||
await new permission().PermissionUpdate(request, "SYS_ORG");
|
||||
const child3IdExits = await this.child3Repository.findOne({
|
||||
where: { id: requestBody.orgChild3Id },
|
||||
});
|
||||
|
|
|
|||
|
|
@ -152,6 +152,8 @@ export class OrgRootController extends Controller {
|
|||
orgRoot.createdFullName = request.user.name;
|
||||
orgRoot.lastUpdateUserId = request.user.sub;
|
||||
orgRoot.lastUpdateFullName = request.user.name;
|
||||
orgRoot.createdAt = new Date();
|
||||
orgRoot.lastUpdatedAt = new Date();
|
||||
orgRoot.orgRootOrder = order == null || order.orgRootOrder == null ? 1 : order.orgRootOrder + 1;
|
||||
await this.orgRootRepository.save(orgRoot);
|
||||
|
||||
|
|
|
|||
|
|
@ -128,6 +128,8 @@ export class OrganizationController extends Controller {
|
|||
revision.createdFullName = request.user.name;
|
||||
revision.lastUpdateUserId = request.user.sub;
|
||||
revision.lastUpdateFullName = request.user.name;
|
||||
revision.createdAt = new Date();
|
||||
revision.lastUpdatedAt = new Date();
|
||||
await this.orgRevisionRepository.save(revision);
|
||||
|
||||
if (
|
||||
|
|
@ -3443,6 +3445,20 @@ export class OrganizationController extends Controller {
|
|||
"orgChild1s.orgChild2s.orgChild3s",
|
||||
"orgChild1s.orgChild2s.orgChild3s.orgChild4s",
|
||||
],
|
||||
order: {
|
||||
orgChild1s: {
|
||||
orgChild1Order: "ASC",
|
||||
orgChild2s: {
|
||||
orgChild2Order: "ASC",
|
||||
orgChild3s: {
|
||||
orgChild3Order: "ASC",
|
||||
orgChild4s: {
|
||||
orgChild4Order: "ASC",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
return new HttpSuccess(data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -828,6 +828,7 @@ export class OrganizationDotnetController extends Controller {
|
|||
profile.dutyTimeEffectiveDate = body.effectiveDate;
|
||||
profile.lastUpdateUserId = req.user.sub;
|
||||
profile.lastUpdateFullName = req.user.name;
|
||||
profile.lastUpdatedAt = new Date();
|
||||
await this.profileRepo.save(profile);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
@ -874,6 +875,8 @@ export class OrganizationDotnetController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
|
|||
|
|
@ -79,6 +79,8 @@ export class PosExecutiveController extends Controller {
|
|||
posExecutive.createdFullName = request.user.name;
|
||||
posExecutive.lastUpdateUserId = request.user.sub;
|
||||
posExecutive.lastUpdateFullName = request.user.name;
|
||||
posExecutive.createdAt = new Date();
|
||||
posExecutive.lastUpdatedAt = new Date();
|
||||
await this.posExecutiveRepository.save(posExecutive);
|
||||
return new HttpSuccess(posExecutive.id);
|
||||
}
|
||||
|
|
@ -138,6 +140,7 @@ export class PosExecutiveController extends Controller {
|
|||
posExecutive.posExecutiveName = requestBody.posExecutiveName;
|
||||
posExecutive.lastUpdateUserId = request.user.sub;
|
||||
posExecutive.lastUpdateFullName = request.user.name;
|
||||
posExecutive.lastUpdatedAt = new Date();
|
||||
// this.posExecutiveRepository.merge(posExecutive, requestBody);
|
||||
await this.posExecutiveRepository.save(posExecutive);
|
||||
return new HttpSuccess();
|
||||
|
|
|
|||
|
|
@ -89,6 +89,8 @@ export class PosLevelController extends Controller {
|
|||
posLevel.createdFullName = request.user.name;
|
||||
posLevel.lastUpdateUserId = request.user.sub;
|
||||
posLevel.lastUpdateFullName = request.user.name;
|
||||
posLevel.createdAt = new Date();
|
||||
posLevel.lastUpdatedAt = new Date();
|
||||
await this.posLevelRepository.save(posLevel);
|
||||
return new HttpSuccess(posLevel);
|
||||
}
|
||||
|
|
@ -144,6 +146,7 @@ export class PosLevelController extends Controller {
|
|||
|
||||
posLevel.lastUpdateUserId = request.user.sub;
|
||||
posLevel.lastUpdateFullName = request.user.name;
|
||||
posLevel.lastUpdatedAt = new Date();
|
||||
this.posLevelRepository.merge(posLevel, requestBody);
|
||||
await this.posLevelRepository.save(posLevel);
|
||||
return new HttpSuccess(posLevel.id);
|
||||
|
|
@ -158,11 +161,14 @@ export class PosLevelController extends Controller {
|
|||
*/
|
||||
@Delete("{id}")
|
||||
async deleteLevel(@Path() id: string) {
|
||||
let result :any
|
||||
let result: any;
|
||||
try {
|
||||
result = await this.posLevelRepository.delete({ id: id });
|
||||
} catch {
|
||||
throw new HttpError( HttpStatusCode.NOT_FOUND, "ไม่สามารถลบได้เนื่องจากมีการใช้งานระดับตำแหน่งนี้อยู่");
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่สามารถลบได้เนื่องจากมีการใช้งานระดับตำแหน่งนี้อยู่",
|
||||
);
|
||||
}
|
||||
if (result.affected == undefined || result.affected <= 0) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
|
|||
|
|
@ -84,6 +84,8 @@ export class PosMasterActController extends Controller {
|
|||
posMasterAct.createdFullName = request.user.name;
|
||||
posMasterAct.lastUpdateUserId = request.user.sub;
|
||||
posMasterAct.lastUpdateFullName = request.user.name;
|
||||
posMasterAct.createdAt = new Date();
|
||||
posMasterAct.lastUpdatedAt = new Date();
|
||||
await this.posMasterActRepository.save(posMasterAct);
|
||||
return new HttpSuccess(posMasterAct);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,6 +68,8 @@ export class PosTypeController extends Controller {
|
|||
posType.createdFullName = request.user.name;
|
||||
posType.lastUpdateUserId = request.user.sub;
|
||||
posType.lastUpdateFullName = request.user.name;
|
||||
posType.createdAt = new Date();
|
||||
posType.lastUpdatedAt = new Date();
|
||||
await this.posTypeRepository.save(posType);
|
||||
return new HttpSuccess(posType);
|
||||
}
|
||||
|
|
@ -104,6 +106,7 @@ export class PosTypeController extends Controller {
|
|||
}
|
||||
posType.lastUpdateUserId = request.user.sub;
|
||||
posType.lastUpdateFullName = request.user.name;
|
||||
posType.lastUpdatedAt = new Date();
|
||||
this.posTypeRepository.merge(posType, requestBody);
|
||||
await this.posTypeRepository.save(posType);
|
||||
return new HttpSuccess(posType.id);
|
||||
|
|
@ -118,11 +121,14 @@ export class PosTypeController extends Controller {
|
|||
*/
|
||||
@Delete("{id}")
|
||||
async deleteType(@Path() id: string) {
|
||||
let result :any
|
||||
let result: any;
|
||||
try {
|
||||
result = await this.posTypeRepository.delete({ id: id });
|
||||
} catch {
|
||||
throw new HttpError( HttpStatusCode.NOT_FOUND, "ไม่สามารถลบได้เนื่องจากมีการใช้งานประเภทตำแหน่งนี้อยู่");
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่สามารถลบได้เนื่องจากมีการใช้งานประเภทตำแหน่งนี้อยู่",
|
||||
);
|
||||
}
|
||||
if (result.affected == undefined || result.affected <= 0) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
|
|||
|
|
@ -143,6 +143,8 @@ export class PositionController extends Controller {
|
|||
posDict.createdFullName = request.user.name;
|
||||
posDict.lastUpdateUserId = request.user.sub;
|
||||
posDict.lastUpdateFullName = request.user.name;
|
||||
posDict.createdAt = new Date();
|
||||
posDict.lastUpdatedAt = new Date();
|
||||
await this.posDictRepository.save(posDict);
|
||||
return new HttpSuccess(posDict.id);
|
||||
}
|
||||
|
|
@ -222,6 +224,8 @@ export class PositionController extends Controller {
|
|||
posExecutive.createdFullName = request.user.name;
|
||||
posExecutive.lastUpdateUserId = request.user.sub;
|
||||
posExecutive.lastUpdateFullName = request.user.name;
|
||||
posExecutive.createdAt = new Date();
|
||||
posExecutive.lastUpdatedAt = new Date();
|
||||
await this.posExecutiveRepository.save(posExecutive);
|
||||
}
|
||||
|
||||
|
|
@ -246,6 +250,8 @@ export class PositionController extends Controller {
|
|||
posDict.createdFullName = request.user.name;
|
||||
posDict.lastUpdateUserId = request.user.sub;
|
||||
posDict.lastUpdateFullName = request.user.name;
|
||||
posDict.createdAt = new Date();
|
||||
posDict.lastUpdatedAt = new Date();
|
||||
await this.posDictRepository.save(posDict);
|
||||
return new HttpSuccess(posDict.id);
|
||||
}
|
||||
|
|
@ -331,18 +337,19 @@ export class PositionController extends Controller {
|
|||
Object.assign(posDict, requestBody);
|
||||
posDict.lastUpdateUserId = request.user.sub;
|
||||
posDict.lastUpdateFullName = request.user.name;
|
||||
(posDict.posDictName = requestBody.posDictName),
|
||||
(posDict.posDictField = requestBody.posDictField),
|
||||
(posDict.posTypeId = requestBody.posTypeId),
|
||||
(posDict.posLevelId = requestBody.posLevelId),
|
||||
(posDict.posExecutiveId = requestBody.posExecutiveId ? requestBody.posExecutiveId : null),
|
||||
(posDict.posDictExecutiveField = requestBody.posDictExecutiveField
|
||||
? requestBody.posDictExecutiveField
|
||||
: ""),
|
||||
(posDict.posDictArea = requestBody.posDictArea ? requestBody.posDictArea : ""),
|
||||
(posDict.isSpecial = requestBody.isSpecial),
|
||||
// this.posDictRepository.merge(posDict, requestBody);
|
||||
await this.posDictRepository.save(posDict);
|
||||
posDict.lastUpdatedAt = new Date();
|
||||
posDict.posDictName = requestBody.posDictName;
|
||||
posDict.posDictField = requestBody.posDictField;
|
||||
posDict.posTypeId = requestBody.posTypeId;
|
||||
posDict.posLevelId = requestBody.posLevelId;
|
||||
posDict.posExecutiveId = requestBody.posExecutiveId ? requestBody.posExecutiveId : null;
|
||||
posDict.posDictExecutiveField = requestBody.posDictExecutiveField
|
||||
? requestBody.posDictExecutiveField
|
||||
: "";
|
||||
posDict.posDictArea = requestBody.posDictArea ? requestBody.posDictArea : "";
|
||||
posDict.isSpecial = requestBody.isSpecial;
|
||||
// this.posDictRepository.merge(posDict, requestBody);
|
||||
await this.posDictRepository.save(posDict);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
|
|
@ -743,6 +750,8 @@ export class PositionController extends Controller {
|
|||
posMaster.createdFullName = request.user.name;
|
||||
posMaster.lastUpdateUserId = request.user.sub;
|
||||
posMaster.lastUpdateFullName = request.user.name;
|
||||
posMaster.createdAt = new Date();
|
||||
posMaster.lastUpdatedAt = new Date();
|
||||
await this.posMasterRepository.save(posMaster);
|
||||
await Promise.all(
|
||||
requestBody.positions.map(async (x: any) => {
|
||||
|
|
@ -761,6 +770,8 @@ export class PositionController extends Controller {
|
|||
position.createdFullName = request.user.name;
|
||||
position.lastUpdateUserId = request.user.sub;
|
||||
position.lastUpdateFullName = request.user.name;
|
||||
position.createdAt = new Date();
|
||||
position.lastUpdatedAt = new Date();
|
||||
await this.positionRepository.save(position);
|
||||
}),
|
||||
);
|
||||
|
|
@ -948,6 +959,8 @@ export class PositionController extends Controller {
|
|||
posMaster.createdFullName = request.user.name;
|
||||
posMaster.lastUpdateUserId = request.user.sub;
|
||||
posMaster.lastUpdateFullName = request.user.name;
|
||||
posMaster.createdAt = new Date();
|
||||
posMaster.lastUpdatedAt = new Date();
|
||||
await this.posMasterRepository.save(posMaster);
|
||||
await this.positionRepository.delete({ posMasterId: posMaster.id });
|
||||
|
||||
|
|
@ -970,6 +983,8 @@ export class PositionController extends Controller {
|
|||
position.createdFullName = request.user.name;
|
||||
position.lastUpdateUserId = request.user.sub;
|
||||
position.lastUpdateFullName = request.user.name;
|
||||
position.createdAt = new Date();
|
||||
position.lastUpdatedAt = new Date();
|
||||
await this.positionRepository.save(position);
|
||||
}),
|
||||
);
|
||||
|
|
@ -1407,7 +1422,10 @@ export class PositionController extends Controller {
|
|||
*
|
||||
*/
|
||||
@Post("sort")
|
||||
async Sort(@Body() requestBody: { id: string; type: number; sortId: string[] }, @Request() request: RequestWithUser) {
|
||||
async Sort(
|
||||
@Body() requestBody: { id: string; type: number; sortId: string[] },
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionUpdate(request, "SYS_ORG");
|
||||
switch (requestBody.type) {
|
||||
case 0: {
|
||||
|
|
@ -2014,6 +2032,8 @@ export class PositionController extends Controller {
|
|||
posMaster.createdFullName = request.user.name;
|
||||
posMaster.lastUpdateUserId = request.user.sub;
|
||||
posMaster.lastUpdateFullName = request.user.name;
|
||||
posMaster.createdAt = new Date();
|
||||
posMaster.lastUpdatedAt = new Date();
|
||||
await this.posMasterRepository.save(posMaster);
|
||||
}
|
||||
}),
|
||||
|
|
@ -2476,7 +2496,7 @@ export class PositionController extends Controller {
|
|||
@Post("profile")
|
||||
async createHolder(
|
||||
@Body() requestBody: { posMaster: string; position: string; profileId: string; isSit: boolean },
|
||||
@Request() request: RequestWithUser
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionUpdate(request, "SYS_ORG");
|
||||
const dataMaster = await this.posMasterRepository.findOne({
|
||||
|
|
@ -2511,7 +2531,7 @@ export class PositionController extends Controller {
|
|||
*/
|
||||
@Post("profile/delete/{id}")
|
||||
async deleteHolder(@Path() id: string, @Request() request: RequestWithUser) {
|
||||
await new permission().PermissionDelete(request, "SYS_ORG");
|
||||
await new permission().PermissionDelete(request, "SYS_ORG");
|
||||
const dataMaster = await this.posMasterRepository.findOne({
|
||||
where: { id: id },
|
||||
relations: ["positions"],
|
||||
|
|
@ -2540,8 +2560,11 @@ export class PositionController extends Controller {
|
|||
*
|
||||
*/
|
||||
@Post("dna")
|
||||
async dna(@Body() requestBody: { draftPositionId: string; publishPositionId: string }, @Request() request: RequestWithUser) {
|
||||
await new permission().PermissionUpdate(request, "SYS_ORG");
|
||||
async dna(
|
||||
@Body() requestBody: { draftPositionId: string; publishPositionId: string },
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionUpdate(request, "SYS_ORG");
|
||||
const findDraft = await this.orgRevisionRepository.findOne({
|
||||
where: {
|
||||
orgRevisionIsDraft: true,
|
||||
|
|
|
|||
|
|
@ -97,6 +97,8 @@ export class PrefixController extends Controller {
|
|||
_prefix.createdFullName = request.user.name;
|
||||
_prefix.lastUpdateUserId = request.user.sub;
|
||||
_prefix.lastUpdateFullName = request.user.name;
|
||||
_prefix.createdAt = new Date();
|
||||
_prefix.lastUpdatedAt = new Date();
|
||||
await this.prefixRepository.save(_prefix);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
@ -128,6 +130,7 @@ export class PrefixController extends Controller {
|
|||
|
||||
_prefix.lastUpdateUserId = request.user.sub;
|
||||
_prefix.lastUpdateFullName = request.user.name;
|
||||
_prefix.lastUpdatedAt = new Date();
|
||||
this.prefixRepository.merge(_prefix, requestBody);
|
||||
await this.prefixRepository.save(_prefix);
|
||||
return new HttpSuccess();
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {
|
|||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
Path,
|
||||
|
|
@ -41,6 +40,7 @@ export class ProfileAbilityController extends Controller {
|
|||
}
|
||||
const getProfileAbilityId = await this.profileAbilityRepo.find({
|
||||
where: { profileId: profile.id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
if (!getProfileAbilityId) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
@ -49,31 +49,12 @@ export class ProfileAbilityController extends Controller {
|
|||
}
|
||||
|
||||
@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) {
|
||||
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) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
|
@ -81,44 +62,6 @@ export class ProfileAbilityController extends Controller {
|
|||
}
|
||||
|
||||
@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(
|
||||
@Path() abilityId: string,
|
||||
@Request() req: RequestWithUser,
|
||||
|
|
@ -130,8 +73,8 @@ export class ProfileAbilityController extends Controller {
|
|||
// await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
||||
// }
|
||||
const record = await this.profileAbilityHistoryRepo.find({
|
||||
relations: ["histories"],
|
||||
where: { profileAbilityId: abilityId },
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
|
||||
if (!record) {
|
||||
|
|
@ -161,6 +104,8 @@ export class ProfileAbilityController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -187,15 +132,18 @@ export class ProfileAbilityController extends Controller {
|
|||
const history = new ProfileAbilityHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileAbilityId = abilityId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.profileAbilityRepo.save(record),
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {
|
|||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
Path,
|
||||
|
|
@ -13,9 +12,7 @@ import {
|
|||
Tags,
|
||||
} from "tsoa";
|
||||
import { AppDataSource } from "../database/data-source";
|
||||
import { Profile } from "../entities/Profile";
|
||||
import {
|
||||
CreateProfileAbility,
|
||||
CreateProfileAbilityEmployee,
|
||||
ProfileAbility,
|
||||
UpdateProfileAbility,
|
||||
|
|
@ -43,6 +40,7 @@ export class ProfileAbilityEmployeeController extends Controller {
|
|||
}
|
||||
const getProfileAbilityId = await this.profileAbilityRepo.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
if (!getProfileAbilityId) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
@ -51,31 +49,15 @@ export class ProfileAbilityEmployeeController extends Controller {
|
|||
}
|
||||
|
||||
@Get("{profileEmployeeId}")
|
||||
@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",
|
||||
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) {
|
||||
public async detailProfileAbility(
|
||||
@Path() profileEmployeeId: string,
|
||||
@Request() req: RequestWithUser,
|
||||
) {
|
||||
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) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
|
@ -83,45 +65,10 @@ export class ProfileAbilityEmployeeController extends Controller {
|
|||
}
|
||||
|
||||
@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(@Path() abilityId: string, @Request() req: RequestWithUser) {
|
||||
public async getProfileAbilityHistory(
|
||||
@Path() abilityId: string,
|
||||
@Request() req: RequestWithUser,
|
||||
) {
|
||||
const _record = await this.profileAbilityRepo.findOneBy({ id: abilityId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserGet(
|
||||
|
|
@ -130,8 +77,9 @@ export class ProfileAbilityEmployeeController extends Controller {
|
|||
_record.profileEmployeeId,
|
||||
);
|
||||
}
|
||||
const record = await this.profileAbilityHistoryRepo.findBy({
|
||||
profileAbilityId: abilityId,
|
||||
const record = await this.profileAbilityHistoryRepo.find({
|
||||
where: { profileAbilityId: abilityId },
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
if (!record) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
@ -147,7 +95,7 @@ export class ProfileAbilityEmployeeController extends Controller {
|
|||
if (!body.profileEmployeeId) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId");
|
||||
}
|
||||
|
||||
|
||||
const profile = await this.profileEmployeeRepo.findOneBy({ id: body.profileEmployeeId });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
|
|
@ -160,6 +108,8 @@ export class ProfileAbilityEmployeeController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -181,20 +131,27 @@ export class ProfileAbilityEmployeeController extends Controller {
|
|||
) {
|
||||
const record = await this.profileAbilityRepo.findOneBy({ id: abilityId });
|
||||
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();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileAbilityId = abilityId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.profileAbilityRepo.save(record),
|
||||
|
|
@ -206,14 +163,14 @@ export class ProfileAbilityEmployeeController extends Controller {
|
|||
|
||||
@Delete("{abilityId}")
|
||||
public async deleteProfileAbility(@Path() abilityId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.profileAbilityRepo.findOneBy({ id: abilityId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserDelete(
|
||||
req,
|
||||
"SYS_REGISTRY_EMP",
|
||||
_record.profileEmployeeId,
|
||||
);
|
||||
}
|
||||
const _record = await this.profileAbilityRepo.findOneBy({ id: abilityId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserDelete(
|
||||
req,
|
||||
"SYS_REGISTRY_EMP",
|
||||
_record.profileEmployeeId,
|
||||
);
|
||||
}
|
||||
await this.profileAbilityHistoryRepo.delete({
|
||||
profileAbilityId: abilityId,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {
|
|||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
Path,
|
||||
|
|
@ -13,9 +12,7 @@ import {
|
|||
Tags,
|
||||
} from "tsoa";
|
||||
import { AppDataSource } from "../database/data-source";
|
||||
import { Profile } from "../entities/Profile";
|
||||
import {
|
||||
CreateProfileAbility,
|
||||
CreateProfileAbilityEmployee,
|
||||
ProfileAbility,
|
||||
UpdateProfileAbility,
|
||||
|
|
@ -43,6 +40,7 @@ export class ProfileAbilityEmployeeTempController extends Controller {
|
|||
}
|
||||
const getProfileAbilityId = await this.profileAbilityRepo.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
if (!getProfileAbilityId) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
@ -51,31 +49,15 @@ export class ProfileAbilityEmployeeTempController extends Controller {
|
|||
}
|
||||
|
||||
@Get("{profileEmployeeId}")
|
||||
@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",
|
||||
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) {
|
||||
public async detailProfileAbility(
|
||||
@Path() profileEmployeeId: string,
|
||||
@Request() req: RequestWithUser,
|
||||
) {
|
||||
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) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
|
@ -83,52 +65,17 @@ export class ProfileAbilityEmployeeTempController extends Controller {
|
|||
}
|
||||
|
||||
@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(@Path() abilityId: string, @Request() req: RequestWithUser) {
|
||||
public async getProfileAbilityHistory(
|
||||
@Path() abilityId: string,
|
||||
@Request() req: RequestWithUser,
|
||||
) {
|
||||
const _record = await this.profileAbilityRepo.findOneBy({ id: abilityId });
|
||||
if (_record) {
|
||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||
}
|
||||
|
||||
const record = await this.profileAbilityHistoryRepo.findBy({
|
||||
profileAbilityId: abilityId,
|
||||
const record = await this.profileAbilityHistoryRepo.find({
|
||||
where: { profileAbilityId: abilityId },
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
if (!record) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
@ -157,6 +104,8 @@ export class ProfileAbilityEmployeeTempController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -178,20 +127,23 @@ export class ProfileAbilityEmployeeTempController extends Controller {
|
|||
) {
|
||||
const record = await this.profileAbilityRepo.findOneBy({ id: abilityId });
|
||||
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();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileAbilityId = abilityId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.profileAbilityRepo.save(record),
|
||||
|
|
|
|||
|
|
@ -1,21 +1,4 @@
|
|||
import {
|
||||
Controller,
|
||||
Post,
|
||||
Put,
|
||||
Delete,
|
||||
Route,
|
||||
Security,
|
||||
Tags,
|
||||
Body,
|
||||
Path,
|
||||
Request,
|
||||
SuccessResponse,
|
||||
Response,
|
||||
Get,
|
||||
Query,
|
||||
Patch,
|
||||
Example,
|
||||
} from "tsoa";
|
||||
import { Controller, Route, Security, Tags, Body, Path, Request, Get, Patch } from "tsoa";
|
||||
|
||||
import HttpSuccess from "../interfaces/http-success";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
|
|
@ -23,9 +6,6 @@ import HttpStatus from "../interfaces/http-status";
|
|||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { Profile, ProfileAddressHistory, UpdateProfileAddress } from "../entities/Profile";
|
||||
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";
|
||||
@Route("api/v1/org/profile/address")
|
||||
@Tags("ProfileAddress")
|
||||
|
|
@ -55,6 +35,7 @@ export class ProfileAddressController extends Controller {
|
|||
"currentSubDistrictId",
|
||||
"currentZipCode",
|
||||
],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
if (!getProfileAddress) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
@ -105,33 +86,32 @@ export class ProfileAddressController extends Controller {
|
|||
}
|
||||
const record = await this.profileAddressHistoryRepo.find({
|
||||
where: { profileId: profile.id },
|
||||
relations: {
|
||||
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",
|
||||
relations: [
|
||||
"registrationProvince",
|
||||
"registrationDistrict",
|
||||
"registrationSubDistrict",
|
||||
"currentProvince",
|
||||
"currentDistrict",
|
||||
"currentSubDistrict",
|
||||
],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
if (!record) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
return new HttpSuccess(record);
|
||||
const _record = record.map((item) => ({
|
||||
id: item.id,
|
||||
currentAddress: item.currentAddress,
|
||||
registrationAddress: item.registrationAddress,
|
||||
currentZipCode: item.currentZipCode,
|
||||
registrationZipCode: item.registrationZipCode,
|
||||
currentProvince: item.currentProvince?.name ?? null,
|
||||
registrationProvince: item.registrationProvince?.name ?? null,
|
||||
currentDistrict: item.currentDistrict?.name ?? null,
|
||||
registrationDistrict: item.registrationDistrict?.name ?? null,
|
||||
currentSubDistrict: item.currentSubDistrict?.name ?? null,
|
||||
registrationSubDistrict: item.registrationSubDistrict?.name ?? null,
|
||||
lastUpdatedAt: item.lastUpdatedAt,
|
||||
lastUpdateFullName: item.lastUpdateFullName,
|
||||
}));
|
||||
return new HttpSuccess(_record);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -140,37 +120,39 @@ export class ProfileAddressController extends Controller {
|
|||
*
|
||||
*/
|
||||
@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);
|
||||
const record = await this.profileAddressHistoryRepo.find({
|
||||
where: { profileId: profileId },
|
||||
relations: {
|
||||
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",
|
||||
relations: [
|
||||
"registrationProvince",
|
||||
"registrationDistrict",
|
||||
"registrationSubDistrict",
|
||||
"currentProvince",
|
||||
"currentDistrict",
|
||||
"currentSubDistrict",
|
||||
],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
if (!record) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
return new HttpSuccess(record);
|
||||
const _record = record.map((item) => ({
|
||||
id: item.id,
|
||||
currentAddress: item.currentAddress,
|
||||
registrationAddress: item.registrationAddress,
|
||||
currentZipCode: item.currentZipCode,
|
||||
registrationZipCode: item.registrationZipCode,
|
||||
currentProvince: item.currentProvince?.name ?? null,
|
||||
registrationProvince: item.registrationProvince?.name ?? null,
|
||||
currentDistrict: item.currentDistrict?.name ?? null,
|
||||
registrationDistrict: item.registrationDistrict?.name ?? null,
|
||||
currentSubDistrict: item.currentSubDistrict?.name ?? null,
|
||||
registrationSubDistrict: item.registrationSubDistrict?.name ?? null,
|
||||
lastUpdatedAt: item.lastUpdatedAt,
|
||||
lastUpdateFullName: item.lastUpdateFullName,
|
||||
}));
|
||||
return new HttpSuccess(_record);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -191,15 +173,18 @@ export class ProfileAddressController extends Controller {
|
|||
const history = new ProfileAddressHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileId = profileId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.profileRepo.save(record),
|
||||
|
|
|
|||
|
|
@ -1,31 +1,11 @@
|
|||
import {
|
||||
Controller,
|
||||
Post,
|
||||
Put,
|
||||
Delete,
|
||||
Route,
|
||||
Security,
|
||||
Tags,
|
||||
Body,
|
||||
Path,
|
||||
Request,
|
||||
SuccessResponse,
|
||||
Response,
|
||||
Get,
|
||||
Query,
|
||||
Patch,
|
||||
Example,
|
||||
} from "tsoa";
|
||||
import { Controller, Route, Security, Tags, Body, Path, Request, Get, Patch } from "tsoa";
|
||||
|
||||
import HttpSuccess from "../interfaces/http-success";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import HttpStatus from "../interfaces/http-status";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { Profile, ProfileAddressHistory, UpdateProfileAddress } from "../entities/Profile";
|
||||
import { ProfileAddressHistory } from "../entities/Profile";
|
||||
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 permission from "../interfaces/permission";
|
||||
@Route("api/v1/org/profile-employee/address")
|
||||
|
|
@ -56,6 +36,7 @@ export class ProfileAddressEmployeeController extends Controller {
|
|||
"currentSubDistrictId",
|
||||
"currentZipCode",
|
||||
],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
if (!getProfileAddress) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
@ -69,7 +50,10 @@ export class ProfileAddressEmployeeController extends Controller {
|
|||
*
|
||||
*/
|
||||
@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);
|
||||
const getProfileAddress = await this.profileEmployeeRepo.findOne({
|
||||
where: { id: profileEmployeeId },
|
||||
|
|
@ -106,33 +90,32 @@ export class ProfileAddressEmployeeController extends Controller {
|
|||
}
|
||||
const record = await this.profileAddressHistoryRepo.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
relations: {
|
||||
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",
|
||||
relations: [
|
||||
"registrationProvince",
|
||||
"registrationDistrict",
|
||||
"registrationSubDistrict",
|
||||
"currentProvince",
|
||||
"currentDistrict",
|
||||
"currentSubDistrict",
|
||||
],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
if (!record) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
return new HttpSuccess(record);
|
||||
const _record = record.map((item) => ({
|
||||
id: item.id,
|
||||
currentAddress: item.currentAddress,
|
||||
registrationAddress: item.registrationAddress,
|
||||
currentZipCode: item.currentZipCode,
|
||||
registrationZipCode: item.registrationZipCode,
|
||||
currentProvince: item.currentProvince?.name ?? null,
|
||||
registrationProvince: item.registrationProvince?.name ?? null,
|
||||
currentDistrict: item.currentDistrict?.name ?? null,
|
||||
registrationDistrict: item.registrationDistrict?.name ?? null,
|
||||
currentSubDistrict: item.currentSubDistrict?.name ?? null,
|
||||
registrationSubDistrict: item.registrationSubDistrict?.name ?? null,
|
||||
lastUpdatedAt: item.lastUpdatedAt,
|
||||
lastUpdateFullName: item.lastUpdateFullName,
|
||||
}));
|
||||
return new HttpSuccess(_record);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -141,37 +124,39 @@ export class ProfileAddressEmployeeController extends Controller {
|
|||
*
|
||||
*/
|
||||
@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);
|
||||
const record = await this.profileAddressHistoryRepo.find({
|
||||
where: { profileEmployeeId: profileId },
|
||||
relations: {
|
||||
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",
|
||||
relations: [
|
||||
"registrationProvince",
|
||||
"registrationDistrict",
|
||||
"registrationSubDistrict",
|
||||
"currentProvince",
|
||||
"currentDistrict",
|
||||
"currentSubDistrict",
|
||||
],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
if (!record) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
return new HttpSuccess(record);
|
||||
const _record = record.map((item) => ({
|
||||
id: item.id,
|
||||
currentAddress: item.currentAddress,
|
||||
registrationAddress: item.registrationAddress,
|
||||
currentZipCode: item.currentZipCode,
|
||||
registrationZipCode: item.registrationZipCode,
|
||||
currentProvince: item.currentProvince?.name ?? null,
|
||||
registrationProvince: item.registrationProvince?.name ?? null,
|
||||
currentDistrict: item.currentDistrict?.name ?? null,
|
||||
registrationDistrict: item.registrationDistrict?.name ?? null,
|
||||
currentSubDistrict: item.currentSubDistrict?.name ?? null,
|
||||
registrationSubDistrict: item.registrationSubDistrict?.name ?? null,
|
||||
lastUpdatedAt: item.lastUpdatedAt,
|
||||
lastUpdateFullName: item.lastUpdateFullName,
|
||||
}));
|
||||
return new HttpSuccess(_record);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -188,19 +173,22 @@ export class ProfileAddressEmployeeController extends Controller {
|
|||
const record = await this.profileEmployeeRepo.findOneBy({ id: profileId });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.id);
|
||||
|
||||
|
||||
const history = new ProfileAddressHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileEmployeeId = profileId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.profileEmployeeRepo.save(record),
|
||||
|
|
|
|||
|
|
@ -1,31 +1,11 @@
|
|||
import {
|
||||
Controller,
|
||||
Post,
|
||||
Put,
|
||||
Delete,
|
||||
Route,
|
||||
Security,
|
||||
Tags,
|
||||
Body,
|
||||
Path,
|
||||
Request,
|
||||
SuccessResponse,
|
||||
Response,
|
||||
Get,
|
||||
Query,
|
||||
Patch,
|
||||
Example,
|
||||
} from "tsoa";
|
||||
import { Controller, Route, Security, Tags, Body, Path, Request, Get, Patch } from "tsoa";
|
||||
|
||||
import HttpSuccess from "../interfaces/http-success";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import HttpStatus from "../interfaces/http-status";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { Profile, ProfileAddressHistory, UpdateProfileAddress } from "../entities/Profile";
|
||||
import { ProfileAddressHistory } from "../entities/Profile";
|
||||
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 permission from "../interfaces/permission";
|
||||
@Route("api/v1/org/profile-temp/address")
|
||||
|
|
@ -56,6 +36,7 @@ export class ProfileAddressEmployeeTempController extends Controller {
|
|||
"currentSubDistrictId",
|
||||
"currentZipCode",
|
||||
],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
if (!getProfileAddress) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
@ -109,33 +90,32 @@ export class ProfileAddressEmployeeTempController extends Controller {
|
|||
}
|
||||
const record = await this.profileAddressHistoryRepo.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
relations: {
|
||||
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",
|
||||
relations: [
|
||||
"registrationProvince",
|
||||
"registrationDistrict",
|
||||
"registrationSubDistrict",
|
||||
"currentProvince",
|
||||
"currentDistrict",
|
||||
"currentSubDistrict",
|
||||
],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
if (!record) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
return new HttpSuccess(record);
|
||||
const _record = record.map((item) => ({
|
||||
id: item.id,
|
||||
currentAddress: item.currentAddress,
|
||||
registrationAddress: item.registrationAddress,
|
||||
currentZipCode: item.currentZipCode,
|
||||
registrationZipCode: item.registrationZipCode,
|
||||
currentProvince: item.currentProvince?.name ?? null,
|
||||
registrationProvince: item.registrationProvince?.name ?? null,
|
||||
currentDistrict: item.currentDistrict?.name ?? null,
|
||||
registrationDistrict: item.registrationDistrict?.name ?? null,
|
||||
currentSubDistrict: item.currentSubDistrict?.name ?? null,
|
||||
registrationSubDistrict: item.registrationSubDistrict?.name ?? null,
|
||||
lastUpdatedAt: item.lastUpdatedAt,
|
||||
lastUpdateFullName: item.lastUpdateFullName,
|
||||
}));
|
||||
return new HttpSuccess(_record);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -151,33 +131,32 @@ export class ProfileAddressEmployeeTempController extends Controller {
|
|||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||
const record = await this.profileAddressHistoryRepo.find({
|
||||
where: { profileEmployeeId: profileId },
|
||||
relations: {
|
||||
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",
|
||||
relations: [
|
||||
"registrationProvince",
|
||||
"registrationDistrict",
|
||||
"registrationSubDistrict",
|
||||
"currentProvince",
|
||||
"currentDistrict",
|
||||
"currentSubDistrict",
|
||||
],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
if (!record) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
return new HttpSuccess(record);
|
||||
const _record = record.map((item) => ({
|
||||
id: item.id,
|
||||
currentAddress: item.currentAddress,
|
||||
registrationAddress: item.registrationAddress,
|
||||
currentZipCode: item.currentZipCode,
|
||||
registrationZipCode: item.registrationZipCode,
|
||||
currentProvince: item.currentProvince?.name ?? null,
|
||||
registrationProvince: item.registrationProvince?.name ?? null,
|
||||
currentDistrict: item.currentDistrict?.name ?? null,
|
||||
registrationDistrict: item.registrationDistrict?.name ?? null,
|
||||
currentSubDistrict: item.currentSubDistrict?.name ?? null,
|
||||
registrationSubDistrict: item.registrationSubDistrict?.name ?? null,
|
||||
lastUpdatedAt: item.lastUpdatedAt,
|
||||
lastUpdateFullName: item.lastUpdateFullName,
|
||||
}));
|
||||
return new HttpSuccess(_record);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -198,15 +177,18 @@ export class ProfileAddressEmployeeTempController extends Controller {
|
|||
const history = new ProfileAddressHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileEmployeeId = profileId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.profileEmployeeRepo.save(record),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import {
|
||||
Controller,
|
||||
Post,
|
||||
Put,
|
||||
Delete,
|
||||
Route,
|
||||
Security,
|
||||
|
|
@ -9,12 +8,8 @@ import {
|
|||
Body,
|
||||
Path,
|
||||
Request,
|
||||
SuccessResponse,
|
||||
Response,
|
||||
Get,
|
||||
Query,
|
||||
Patch,
|
||||
Example,
|
||||
} from "tsoa";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import HttpStatus from "../interfaces/http-status";
|
||||
|
|
@ -46,6 +41,7 @@ export class ProfileAssessmentsController extends Controller {
|
|||
}
|
||||
const getProfileAssessments = await this.profileAssessmentsRepository.find({
|
||||
where: { profileId: profile.id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
if (!getProfileAssessments) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
@ -54,36 +50,15 @@ export class ProfileAssessmentsController extends Controller {
|
|||
}
|
||||
|
||||
@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(
|
||||
@Path() profileId: string,
|
||||
@Request() req: RequestWithUser,
|
||||
) {
|
||||
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) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
|
@ -91,54 +66,20 @@ export class ProfileAssessmentsController extends Controller {
|
|||
}
|
||||
|
||||
@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(
|
||||
@Path() assessmentId: string,
|
||||
@Request() req: RequestWithUser,
|
||||
) {
|
||||
const record = await this.profileAssessmentsHistoryRepository.findBy({
|
||||
profileAssessmentId: assessmentId,
|
||||
const _record = await this.profileAssessmentsRepository.findOneBy({
|
||||
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) {
|
||||
|
|
@ -176,6 +117,8 @@ export class ProfileAssessmentsController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
const history = new ProfileAssessmentHistory();
|
||||
|
|
@ -201,15 +144,18 @@ export class ProfileAssessmentsController extends Controller {
|
|||
const history = new ProfileAssessmentHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileAssessmentId = assessmentId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.profileAssessmentsRepository.save(record),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import {
|
||||
Controller,
|
||||
Post,
|
||||
Put,
|
||||
Delete,
|
||||
Route,
|
||||
Security,
|
||||
|
|
@ -9,12 +8,8 @@ import {
|
|||
Body,
|
||||
Path,
|
||||
Request,
|
||||
SuccessResponse,
|
||||
Response,
|
||||
Get,
|
||||
Query,
|
||||
Patch,
|
||||
Example,
|
||||
} from "tsoa";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import HttpStatus from "../interfaces/http-status";
|
||||
|
|
@ -46,6 +41,7 @@ export class ProfileAssessmentsEmployeeController extends Controller {
|
|||
}
|
||||
const getProfileAssessments = await this.profileAssessmentsRepository.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
if (!getProfileAssessments) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
@ -54,34 +50,16 @@ export class ProfileAssessmentsEmployeeController extends Controller {
|
|||
}
|
||||
|
||||
@Get("{profileEmployeeId}")
|
||||
@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",
|
||||
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) {
|
||||
public async detailProfileAssessments(
|
||||
@Path() profileEmployeeId: string,
|
||||
@Request() req: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
||||
const getProfileAssessments = await this.profileAssessmentsRepository.findBy({
|
||||
profileEmployeeId,
|
||||
const getProfileAssessments = await this.profileAssessmentsRepository.find({
|
||||
where: {
|
||||
profileEmployeeId: profileEmployeeId,
|
||||
},
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
if (!getProfileAssessments) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
@ -90,55 +68,19 @@ export class ProfileAssessmentsEmployeeController extends Controller {
|
|||
}
|
||||
|
||||
@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(@Path() assessmentId: string, @Request() req: RequestWithUser) {
|
||||
public async getProfileAssessmentsHistory(
|
||||
@Path() assessmentId: string,
|
||||
@Request() req: RequestWithUser,
|
||||
) {
|
||||
const _record = await this.profileAssessmentsRepository.findOneBy({ id: assessmentId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileId);
|
||||
}
|
||||
const record = await this.profileAssessmentsHistoryRepository.findBy({
|
||||
profileAssessmentId: assessmentId,
|
||||
const record = await this.profileAssessmentsHistoryRepository.find({
|
||||
where: {
|
||||
profileAssessmentId: assessmentId,
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
if (!record) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
@ -155,7 +97,7 @@ export class ProfileAssessmentsEmployeeController extends Controller {
|
|||
if (!body.profileEmployeeId) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId");
|
||||
}
|
||||
|
||||
|
||||
const profile = await this.profileEmployeeRepo.findOneBy({ id: body.profileEmployeeId });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
|
|
@ -168,6 +110,8 @@ export class ProfileAssessmentsEmployeeController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
const history = new ProfileAssessmentHistory();
|
||||
|
|
@ -188,20 +132,27 @@ export class ProfileAssessmentsEmployeeController extends Controller {
|
|||
) {
|
||||
const record = await this.profileAssessmentsRepository.findOneBy({ id: assessmentId });
|
||||
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();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileAssessmentId = assessmentId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.profileAssessmentsRepository.save(record),
|
||||
|
|
@ -218,7 +169,11 @@ export class ProfileAssessmentsEmployeeController extends Controller {
|
|||
) {
|
||||
const _record = await this.profileAssessmentsRepository.findOneBy({ id: assessmentId });
|
||||
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({
|
||||
profileAssessmentId: assessmentId,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import {
|
||||
Controller,
|
||||
Post,
|
||||
Put,
|
||||
Delete,
|
||||
Route,
|
||||
Security,
|
||||
|
|
@ -9,12 +8,8 @@ import {
|
|||
Body,
|
||||
Path,
|
||||
Request,
|
||||
SuccessResponse,
|
||||
Response,
|
||||
Get,
|
||||
Query,
|
||||
Patch,
|
||||
Example,
|
||||
} from "tsoa";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import HttpStatus from "../interfaces/http-status";
|
||||
|
|
@ -46,6 +41,7 @@ export class ProfileAssessmentsEmployeeTempController extends Controller {
|
|||
}
|
||||
const getProfileAssessments = await this.profileAssessmentsRepository.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
if (!getProfileAssessments) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
@ -54,34 +50,16 @@ export class ProfileAssessmentsEmployeeTempController extends Controller {
|
|||
}
|
||||
|
||||
@Get("{profileEmployeeId}")
|
||||
@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",
|
||||
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) {
|
||||
public async detailProfileAssessments(
|
||||
@Path() profileEmployeeId: string,
|
||||
@Request() req: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||
const getProfileAssessments = await this.profileAssessmentsRepository.findBy({
|
||||
profileEmployeeId,
|
||||
const getProfileAssessments = await this.profileAssessmentsRepository.find({
|
||||
where: {
|
||||
profileEmployeeId: profileEmployeeId,
|
||||
},
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
if (!getProfileAssessments) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
@ -90,52 +68,16 @@ export class ProfileAssessmentsEmployeeTempController extends Controller {
|
|||
}
|
||||
|
||||
@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(@Path() assessmentId: string, @Request() req: RequestWithUser) {
|
||||
public async getProfileAssessmentsHistory(
|
||||
@Path() assessmentId: string,
|
||||
@Request() req: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||
const record = await this.profileAssessmentsHistoryRepository.findBy({
|
||||
profileAssessmentId: assessmentId,
|
||||
const record = await this.profileAssessmentsHistoryRepository.find({
|
||||
where: {
|
||||
profileAssessmentId: assessmentId,
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
|
||||
if (!record) {
|
||||
|
|
@ -166,6 +108,8 @@ export class ProfileAssessmentsEmployeeTempController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
const history = new ProfileAssessmentHistory();
|
||||
|
|
@ -191,15 +135,18 @@ export class ProfileAssessmentsEmployeeTempController extends Controller {
|
|||
const history = new ProfileAssessmentHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileAssessmentId = assessmentId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.profileAssessmentsRepository.save(record),
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ export class ProfileAvatarController extends Controller {
|
|||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||
const lists = await this.avatarRepository.find({
|
||||
where: { profileId: profileId },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
|
@ -27,7 +28,6 @@ export class ProfileAvatarController extends Controller {
|
|||
async getProfile(@Path() id: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", id);
|
||||
const profile = await this.profileRepository.findOne({
|
||||
select: ["id", "avatar", "avatarName"],
|
||||
where: { id },
|
||||
});
|
||||
|
||||
|
|
@ -39,7 +39,6 @@ export class ProfileAvatarController extends Controller {
|
|||
@Get("profileId-admin/{id}")
|
||||
async getProfileAdmin(@Path() id: string) {
|
||||
const profile = await this.profileRepository.findOne({
|
||||
select: ["id", "avatar", "avatarName"],
|
||||
where: { id },
|
||||
});
|
||||
|
||||
|
|
@ -49,7 +48,11 @@ export class ProfileAvatarController extends Controller {
|
|||
}
|
||||
|
||||
@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);
|
||||
const result = await this.avatarRepository.findOneBy({ id: id });
|
||||
if (!result) {
|
||||
|
|
@ -81,7 +84,7 @@ export class ProfileAvatarController extends Controller {
|
|||
const profile = await this.profileRepository.findOne({
|
||||
where: { id: body.profileId },
|
||||
});
|
||||
|
||||
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
|
|
@ -94,6 +97,8 @@ export class ProfileAvatarController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -129,11 +134,14 @@ export class ProfileAvatarController extends Controller {
|
|||
}
|
||||
|
||||
@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 });
|
||||
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 });
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ export class ProfileAvatarEmployeeController extends Controller {
|
|||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
||||
const lists = await this.avatarRepository.find({
|
||||
where: { profileEmployeeId },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
|
@ -30,7 +31,6 @@ export class ProfileAvatarEmployeeController extends Controller {
|
|||
async getProfile(@Path() id: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", id);
|
||||
const profile = await this.profileRepository.findOne({
|
||||
select: ["id", "avatar", "avatarName"],
|
||||
where: { id },
|
||||
});
|
||||
|
||||
|
|
@ -42,7 +42,6 @@ export class ProfileAvatarEmployeeController extends Controller {
|
|||
@Get("profileEmployeeId-admin/{id}")
|
||||
async getProfileAdmin(@Path() id: string) {
|
||||
const profile = await this.profileRepository.findOne({
|
||||
select: ["id", "avatar", "avatarName"],
|
||||
where: { id },
|
||||
});
|
||||
|
||||
|
|
@ -103,6 +102,8 @@ export class ProfileAvatarEmployeeController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -141,7 +142,11 @@ export class ProfileAvatarEmployeeController extends Controller {
|
|||
public async deleteAvatarEmployee(@Path() avatarId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.avatarRepository.findOneBy({ id: avatarId });
|
||||
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 });
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ export class ProfileAvatarEmployeeTempController extends Controller {
|
|||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||
const lists = await this.avatarRepository.find({
|
||||
where: { profileEmployeeId },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
|
@ -30,7 +31,6 @@ export class ProfileAvatarEmployeeTempController extends Controller {
|
|||
async getProfile(@Path() id: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||
const profile = await this.profileRepository.findOne({
|
||||
select: ["id", "avatar", "avatarName"],
|
||||
where: { id },
|
||||
});
|
||||
|
||||
|
|
@ -42,7 +42,6 @@ export class ProfileAvatarEmployeeTempController extends Controller {
|
|||
@Get("profileEmployeeId-admin/{id}")
|
||||
async getProfileAdmin(@Path() id: string) {
|
||||
const profile = await this.profileRepository.findOne({
|
||||
select: ["id", "avatar", "avatarName"],
|
||||
where: { id },
|
||||
});
|
||||
|
||||
|
|
@ -57,7 +56,7 @@ export class ProfileAvatarEmployeeTempController extends Controller {
|
|||
@Path() id: string,
|
||||
@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 });
|
||||
if (!result) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
@ -104,6 +103,8 @@ export class ProfileAvatarEmployeeTempController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {
|
|||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
Path,
|
||||
|
|
@ -41,85 +40,34 @@ export class ProfileCertificateController extends Controller {
|
|||
}
|
||||
const record = await this.certificateRepo.find({
|
||||
where: { profileId: profile.id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
||||
@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) {
|
||||
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);
|
||||
}
|
||||
|
||||
@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) {
|
||||
// const _record = await this.certificateRepo.findOneBy({ id: certificateId });
|
||||
// if (_record) {
|
||||
// await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
||||
// }
|
||||
const record = await this.certificateHistoryRepo.findBy({
|
||||
profileCertificateId: certificateId,
|
||||
const record = await this.certificateHistoryRepo.find({
|
||||
where: {
|
||||
profileCertificateId: certificateId,
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
|
||||
}
|
||||
|
||||
@Post()
|
||||
|
|
@ -130,9 +78,9 @@ export class ProfileCertificateController extends Controller {
|
|||
if (!body.profileId) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
|
||||
}
|
||||
|
||||
|
||||
const profile = await this.profileRepo.findOneBy({ id: body.profileId });
|
||||
|
||||
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
|
|
@ -145,6 +93,8 @@ export class ProfileCertificateController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -167,19 +117,22 @@ export class ProfileCertificateController extends Controller {
|
|||
const record = await this.certificateRepo.findOneBy({ id: certificateId });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", record.profileId);
|
||||
|
||||
|
||||
const history = new ProfileCertificateHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileCertificateId = certificateId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.certificateRepo.save(record),
|
||||
|
|
@ -191,10 +144,14 @@ export class ProfileCertificateController extends Controller {
|
|||
|
||||
@Delete("{certificateId}")
|
||||
public async deleteCertificate(@Path() certificateId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.certificateRepo.findOneBy({ id: certificateId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
||||
}
|
||||
const _record = await this.certificateRepo.findOneBy({ id: certificateId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserDelete(
|
||||
req,
|
||||
"SYS_REGISTRY_OFFICER",
|
||||
_record.profileId,
|
||||
);
|
||||
}
|
||||
await this.certificateHistoryRepo.delete({
|
||||
profileCertificateId: certificateId,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {
|
|||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
Path,
|
||||
|
|
@ -41,82 +40,36 @@ export class ProfileCertificateEmployeeController extends Controller {
|
|||
}
|
||||
const record = await this.certificateRepo.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
||||
@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) {
|
||||
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);
|
||||
}
|
||||
|
||||
@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) {
|
||||
const _record = await this.certificateRepo.findOneBy({ id: certificateId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
|
||||
}
|
||||
const record = await this.certificateHistoryRepo.findBy({
|
||||
profileCertificateId: certificateId,
|
||||
const _record = await this.certificateRepo.findOneBy({ id: certificateId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserGet(
|
||||
req,
|
||||
"SYS_REGISTRY_EMP",
|
||||
_record.profileEmployeeId,
|
||||
);
|
||||
}
|
||||
const record = await this.certificateHistoryRepo.find({
|
||||
where: {
|
||||
profileCertificateId: certificateId,
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
|
@ -129,7 +82,7 @@ export class ProfileCertificateEmployeeController extends Controller {
|
|||
if (!body.profileEmployeeId) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId");
|
||||
}
|
||||
|
||||
|
||||
const profile = await this.profileEmployeeRepo.findOneBy({ id: body.profileEmployeeId });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
|
|
@ -143,6 +96,8 @@ export class ProfileCertificateEmployeeController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -164,20 +119,27 @@ export class ProfileCertificateEmployeeController extends Controller {
|
|||
) {
|
||||
const record = await this.certificateRepo.findOneBy({ id: certificateId });
|
||||
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();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileCertificateId = certificateId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.certificateRepo.save(record),
|
||||
|
|
@ -191,8 +153,12 @@ export class ProfileCertificateEmployeeController extends Controller {
|
|||
public async deleteCertificate(@Path() certificateId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.certificateRepo.findOneBy({ id: certificateId });
|
||||
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({
|
||||
profileCertificateId: certificateId,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {
|
|||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
Path,
|
||||
|
|
@ -41,79 +40,29 @@ export class ProfileCertificateEmployeeTempController extends Controller {
|
|||
}
|
||||
const record = await this.certificateRepo.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
||||
@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) {
|
||||
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);
|
||||
}
|
||||
|
||||
@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) {
|
||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||
const record = await this.certificateHistoryRepo.findBy({
|
||||
profileCertificateId: certificateId,
|
||||
const record = await this.certificateHistoryRepo.find({
|
||||
where: {
|
||||
profileCertificateId: certificateId,
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
|
@ -141,6 +90,8 @@ export class ProfileCertificateEmployeeTempController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -168,15 +119,18 @@ export class ProfileCertificateEmployeeTempController extends Controller {
|
|||
const history = new ProfileCertificateHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileCertificateId = certificateId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.certificateRepo.save(record),
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {
|
|||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
Path,
|
||||
|
|
@ -24,7 +23,6 @@ import {
|
|||
ProfileChangeName,
|
||||
UpdateProfileChangeName,
|
||||
} from "../entities/ProfileChangeName";
|
||||
import CallAPI from "../interfaces/call-api";
|
||||
import { updateName } from "../keycloak";
|
||||
import permission from "../interfaces/permission";
|
||||
@Route("api/v1/org/profile/changeName")
|
||||
|
|
@ -43,61 +41,22 @@ export class ProfileChangeNameController extends Controller {
|
|||
}
|
||||
const lists = await this.changeNameRepository.find({
|
||||
where: { profileId: profile.id },
|
||||
select: ["id", "prefix", "firstName", "lastName", "status"],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
||||
@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) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||
const lists = await this.changeNameRepository.find({
|
||||
where: { profileId: profileId },
|
||||
select: ["id", "prefix", "firstName", "lastName", "status"],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
||||
@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) {
|
||||
const _record = await this.changeNameRepository.findOneBy({ id: changeNameId });
|
||||
if (_record) {
|
||||
|
|
@ -105,15 +64,6 @@ export class ProfileChangeNameController extends Controller {
|
|||
}
|
||||
const record = await this.changeNameHistoryRepository.find({
|
||||
where: { profileChangeNameId: changeNameId },
|
||||
select: [
|
||||
"id",
|
||||
"prefix",
|
||||
"firstName",
|
||||
"lastName",
|
||||
"status",
|
||||
"lastUpdateFullName",
|
||||
"lastUpdatedAt",
|
||||
],
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
|
|
@ -127,13 +77,13 @@ export class ProfileChangeNameController extends Controller {
|
|||
if (!body.profileId) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
|
||||
}
|
||||
|
||||
|
||||
const profile = await this.profileRepository.findOneBy({ id: body.profileId });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id);
|
||||
|
||||
|
||||
const data = new ProfileChangeName();
|
||||
|
||||
const meta = {
|
||||
|
|
@ -141,6 +91,8 @@ export class ProfileChangeNameController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -179,15 +131,18 @@ export class ProfileChangeNameController extends Controller {
|
|||
const history = new ProfileChangeNameHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileChangeNameId = changeNameId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.changeNameRepository.save(record),
|
||||
|
|
@ -228,7 +183,11 @@ export class ProfileChangeNameController extends Controller {
|
|||
public async deleteTraning(@Path() changeNameId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.changeNameRepository.findOneBy({ id: changeNameId });
|
||||
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({
|
||||
profileChangeNameId: changeNameId,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {
|
|||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
Path,
|
||||
|
|
@ -18,9 +17,7 @@ import HttpStatus from "../interfaces/http-status";
|
|||
import HttpError from "../interfaces/http-error";
|
||||
import { ProfileChangeNameHistory } from "../entities/ProfileChangeNameHistory";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { Profile } from "../entities/Profile";
|
||||
import {
|
||||
CreateProfileChangeName,
|
||||
CreateProfileChangeNameEmployee,
|
||||
ProfileChangeName,
|
||||
UpdateProfileChangeName,
|
||||
|
|
@ -44,78 +41,33 @@ export class ProfileChangeNameEmployeeController extends Controller {
|
|||
}
|
||||
const lists = await this.changeNameRepository.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
select: ["id", "prefix", "firstName", "lastName", "status"],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
||||
@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) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
||||
const lists = await this.changeNameRepository.find({
|
||||
where: { profileEmployeeId: profileEmployeeId },
|
||||
select: ["id", "prefix", "firstName", "lastName", "status"],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
||||
@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) {
|
||||
const _record = await this.changeNameRepository.findOneBy({ id: changeNameId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId,
|
||||
);
|
||||
}
|
||||
const _record = await this.changeNameRepository.findOneBy({ id: changeNameId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserGet(
|
||||
req,
|
||||
"SYS_REGISTRY_EMP",
|
||||
_record.profileEmployeeId,
|
||||
);
|
||||
}
|
||||
const record = await this.changeNameHistoryRepository.find({
|
||||
where: { profileChangeNameId: changeNameId },
|
||||
select: [
|
||||
"id",
|
||||
"prefix",
|
||||
"firstName",
|
||||
"lastName",
|
||||
"status",
|
||||
"lastUpdateFullName",
|
||||
"lastUpdatedAt",
|
||||
],
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
|
|
@ -129,7 +81,7 @@ export class ProfileChangeNameEmployeeController extends Controller {
|
|||
if (!body.profileEmployeeId) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId");
|
||||
}
|
||||
|
||||
|
||||
const profile = await this.profileEmployeeRepo.findOneBy({ id: body.profileEmployeeId });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
|
|
@ -143,6 +95,8 @@ export class ProfileChangeNameEmployeeController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -176,20 +130,27 @@ export class ProfileChangeNameEmployeeController extends Controller {
|
|||
) {
|
||||
const record = await this.changeNameRepository.findOneBy({ id: changeNameId });
|
||||
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();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileChangeNameId = changeNameId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.changeNameRepository.save(record),
|
||||
|
|
@ -220,10 +181,14 @@ export class ProfileChangeNameEmployeeController extends Controller {
|
|||
|
||||
@Delete("{changeNameId}")
|
||||
public async deleteTraning(@Path() changeNameId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.changeNameRepository.findOneBy({ id: changeNameId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
|
||||
}
|
||||
const _record = await this.changeNameRepository.findOneBy({ id: changeNameId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserDelete(
|
||||
req,
|
||||
"SYS_REGISTRY_EMP",
|
||||
_record.profileEmployeeId,
|
||||
);
|
||||
}
|
||||
await this.changeNameHistoryRepository.delete({
|
||||
profileChangeNameId: changeNameId,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {
|
|||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
Path,
|
||||
|
|
@ -18,9 +17,7 @@ import HttpStatus from "../interfaces/http-status";
|
|||
import HttpError from "../interfaces/http-error";
|
||||
import { ProfileChangeNameHistory } from "../entities/ProfileChangeNameHistory";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { Profile } from "../entities/Profile";
|
||||
import {
|
||||
CreateProfileChangeName,
|
||||
CreateProfileChangeNameEmployee,
|
||||
ProfileChangeName,
|
||||
UpdateProfileChangeName,
|
||||
|
|
@ -44,74 +41,26 @@ export class ProfileChangeNameEmployeeTempController extends Controller {
|
|||
}
|
||||
const lists = await this.changeNameRepository.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
select: ["id", "prefix", "firstName", "lastName", "status"],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
||||
@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) {
|
||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||
const lists = await this.changeNameRepository.find({
|
||||
where: { profileEmployeeId: profileEmployeeId },
|
||||
select: ["id", "prefix", "firstName", "lastName", "status"],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
||||
@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) {
|
||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||
const record = await this.changeNameHistoryRepository.find({
|
||||
where: { profileChangeNameId: changeNameId },
|
||||
select: [
|
||||
"id",
|
||||
"prefix",
|
||||
"firstName",
|
||||
"lastName",
|
||||
"status",
|
||||
"lastUpdateFullName",
|
||||
"lastUpdatedAt",
|
||||
],
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
|
|
@ -140,6 +89,8 @@ export class ProfileChangeNameEmployeeTempController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -179,15 +130,18 @@ export class ProfileChangeNameEmployeeTempController extends Controller {
|
|||
const history = new ProfileChangeNameHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileChangeNameId = changeNameId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.changeNameRepository.save(record),
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {
|
|||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
Path,
|
||||
|
|
@ -42,6 +41,7 @@ export class ProfileChildrenController extends Controller {
|
|||
}
|
||||
const lists = await this.childrenRepository.find({
|
||||
where: { profileId: profile.id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
|
@ -51,6 +51,7 @@ export class ProfileChildrenController extends Controller {
|
|||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||
const lists = await this.childrenRepository.find({
|
||||
where: { profileId: profileId },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
|
@ -82,6 +83,8 @@ export class ProfileChildrenController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -109,16 +112,19 @@ export class ProfileChildrenController extends Controller {
|
|||
|
||||
const history = new ProfileChildrenHistory();
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
record.childrenCitizenId = Extension.CheckCitizen(String(record.childrenCitizenId));
|
||||
history.profileChildrenId = record.id;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
await Promise.all([
|
||||
this.childrenRepository.save(record),
|
||||
this.childrenHistoryRepository.save(history),
|
||||
|
|
@ -131,7 +137,11 @@ export class ProfileChildrenController extends Controller {
|
|||
public async deleteTraning(@Path() childrenId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.childrenRepository.findOneBy({ id: childrenId });
|
||||
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({
|
||||
profileChildrenId: childrenId,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {
|
|||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
Path,
|
||||
|
|
@ -18,9 +17,7 @@ import HttpStatus from "../interfaces/http-status";
|
|||
import HttpError from "../interfaces/http-error";
|
||||
import { ProfileChildrenHistory } from "../entities/ProfileChildrenHistory";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { Profile } from "../entities/Profile";
|
||||
import {
|
||||
CreateProfileChildren,
|
||||
CreateProfileChildrenEmployee,
|
||||
ProfileChildren,
|
||||
UpdateProfileChildren,
|
||||
|
|
@ -44,6 +41,7 @@ export class ProfileChildrenEmployeeController extends Controller {
|
|||
}
|
||||
const lists = await this.childrenRepository.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
|
@ -53,17 +51,21 @@ export class ProfileChildrenEmployeeController extends Controller {
|
|||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
||||
const lists = await this.childrenRepository.find({
|
||||
where: { profileEmployeeId: profileEmployeeId },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
||||
@Get("history/{childrenId}")
|
||||
public async childrenHistory(@Path() childrenId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.childrenRepository.findOneBy({ id: childrenId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId,
|
||||
);
|
||||
}
|
||||
const _record = await this.childrenRepository.findOneBy({ id: childrenId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserGet(
|
||||
req,
|
||||
"SYS_REGISTRY_EMP",
|
||||
_record.profileEmployeeId,
|
||||
);
|
||||
}
|
||||
const record = await this.childrenHistoryRepository.find({
|
||||
where: { profileChildrenId: childrenId },
|
||||
order: { createdAt: "DESC" },
|
||||
|
|
@ -89,6 +91,8 @@ export class ProfileChildrenEmployeeController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -112,20 +116,27 @@ export class ProfileChildrenEmployeeController extends Controller {
|
|||
) {
|
||||
const record = await this.childrenRepository.findOneBy({ id: childrenId });
|
||||
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();
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
record.childrenCitizenId = Extension.CheckCitizen(String(record.childrenCitizenId));
|
||||
history.profileChildrenId = record.id;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.childrenRepository.save(record),
|
||||
|
|
@ -139,7 +150,11 @@ export class ProfileChildrenEmployeeController extends Controller {
|
|||
public async deleteTraning(@Path() childrenId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.childrenRepository.findOneBy({ id: childrenId });
|
||||
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({
|
||||
profileChildrenId: childrenId,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {
|
|||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
Path,
|
||||
|
|
@ -18,9 +17,7 @@ import HttpStatus from "../interfaces/http-status";
|
|||
import HttpError from "../interfaces/http-error";
|
||||
import { ProfileChildrenHistory } from "../entities/ProfileChildrenHistory";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { Profile } from "../entities/Profile";
|
||||
import {
|
||||
CreateProfileChildren,
|
||||
CreateProfileChildrenEmployee,
|
||||
ProfileChildren,
|
||||
UpdateProfileChildren,
|
||||
|
|
@ -44,6 +41,7 @@ export class ProfileChildrenEmployeeTempController extends Controller {
|
|||
}
|
||||
const lists = await this.childrenRepository.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
|
@ -53,6 +51,7 @@ export class ProfileChildrenEmployeeTempController extends Controller {
|
|||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||
const lists = await this.childrenRepository.find({
|
||||
where: { profileEmployeeId: profileEmployeeId },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
|
@ -86,6 +85,8 @@ export class ProfileChildrenEmployeeTempController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -112,16 +113,19 @@ export class ProfileChildrenEmployeeTempController extends Controller {
|
|||
|
||||
const history = new ProfileChildrenHistory();
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
record.childrenCitizenId = Extension.CheckCitizen(String(record.childrenCitizenId));
|
||||
history.profileChildrenId = record.id;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.childrenRepository.save(record),
|
||||
|
|
|
|||
|
|
@ -1268,6 +1268,8 @@ export class ProfileController extends Controller {
|
|||
profile.createdFullName = request.user.name;
|
||||
profile.lastUpdateUserId = request.user.sub;
|
||||
profile.lastUpdateFullName = request.user.name;
|
||||
profile.createdAt = new Date();
|
||||
profile.lastUpdatedAt = new Date();
|
||||
profile.dateRetire = calculateRetireDate(profile.birthDate);
|
||||
profile.dateRetireLaw = calculateRetireLaw(profile.birthDate);
|
||||
await this.profileRepo.save(profile);
|
||||
|
|
@ -1310,6 +1312,8 @@ export class ProfileController extends Controller {
|
|||
profile.createdFullName = request.user.name;
|
||||
profile.lastUpdateUserId = request.user.sub;
|
||||
profile.lastUpdateFullName = request.user.name;
|
||||
profile.createdAt = new Date();
|
||||
profile.lastUpdatedAt = new Date();
|
||||
await this.profileRepo.save(profile);
|
||||
return new HttpSuccess(profile.id);
|
||||
}
|
||||
|
|
@ -1346,6 +1350,8 @@ export class ProfileController extends Controller {
|
|||
profile.createdFullName = request.user.name;
|
||||
profile.lastUpdateUserId = request.user.sub;
|
||||
profile.lastUpdateFullName = request.user.name;
|
||||
profile.createdAt = new Date();
|
||||
profile.lastUpdatedAt = new Date();
|
||||
await this.profileRepo.save(profile);
|
||||
return new HttpSuccess(profile.id);
|
||||
}
|
||||
|
|
@ -1386,6 +1392,7 @@ export class ProfileController extends Controller {
|
|||
profile.isProbation = false;
|
||||
profile.lastUpdateUserId = req.user.sub;
|
||||
profile.lastUpdateFullName = req.user.name;
|
||||
profile.lastUpdatedAt = new Date();
|
||||
const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), {
|
||||
profileId: body.profileId,
|
||||
date: body.date,
|
||||
|
|
@ -1419,6 +1426,8 @@ export class ProfileController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
});
|
||||
await Promise.all([this.salaryRepository.save(profileSalary)]);
|
||||
}
|
||||
|
|
@ -1468,6 +1477,7 @@ export class ProfileController extends Controller {
|
|||
_profile.dateLeave = dateLeave_;
|
||||
_profile.lastUpdateUserId = req.user.sub;
|
||||
_profile.lastUpdateFullName = req.user.name;
|
||||
_profile.lastUpdatedAt = new Date();
|
||||
const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), {
|
||||
profileId: body.profileId,
|
||||
date: body.date,
|
||||
|
|
@ -1498,6 +1508,8 @@ export class ProfileController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
});
|
||||
await Promise.all([this.profileRepo.save(_profile), this.salaryRepository.save(profileSalary)]);
|
||||
|
||||
|
|
@ -1546,6 +1558,7 @@ export class ProfileController extends Controller {
|
|||
_profile.dateLeave = dateLeave_;
|
||||
_profile.lastUpdateUserId = req.user.sub;
|
||||
_profile.lastUpdateFullName = req.user.name;
|
||||
_profile.lastUpdatedAt = new Date();
|
||||
const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), {
|
||||
profileId: body.profileId,
|
||||
date: body.date,
|
||||
|
|
@ -1576,6 +1589,8 @@ export class ProfileController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
});
|
||||
await Promise.all([this.profileRepo.save(_profile), this.salaryRepository.save(profileSalary)]);
|
||||
|
||||
|
|
@ -1624,6 +1639,7 @@ export class ProfileController extends Controller {
|
|||
_profile.dateLeave = dateLeave_;
|
||||
_profile.lastUpdateUserId = req.user.sub;
|
||||
_profile.lastUpdateFullName = req.user.name;
|
||||
_profile.lastUpdatedAt = new Date();
|
||||
const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), {
|
||||
profileId: body.profileId,
|
||||
date: body.date,
|
||||
|
|
@ -1654,6 +1670,8 @@ export class ProfileController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
});
|
||||
// //เพิ่มวินัย
|
||||
// const profileDiscipline: ProfileDiscipline = Object.assign(new ProfileDiscipline(), {
|
||||
|
|
@ -1663,7 +1681,9 @@ export class ProfileController extends Controller {
|
|||
// createdUserId: req.user.sub,
|
||||
// createdFullName: req.user.name,
|
||||
// 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),
|
||||
|
|
@ -1716,6 +1736,7 @@ export class ProfileController extends Controller {
|
|||
_profile.dateLeave = dateLeave_;
|
||||
_profile.lastUpdateUserId = req.user.sub;
|
||||
_profile.lastUpdateFullName = req.user.name;
|
||||
_profile.lastUpdatedAt = new Date();
|
||||
const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), {
|
||||
profileId: body.profileId,
|
||||
date: body.date,
|
||||
|
|
@ -1746,6 +1767,8 @@ export class ProfileController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
});
|
||||
await Promise.all([this.profileRepo.save(_profile), this.salaryRepository.save(profileSalary)]);
|
||||
|
||||
|
|
@ -1824,6 +1847,8 @@ export class ProfileController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
});
|
||||
await Promise.all([this.profileRepo.save(_profile), this.salaryRepository.save(profileSalary)]);
|
||||
|
||||
|
|
@ -1895,6 +1920,8 @@ export class ProfileController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
});
|
||||
await Promise.all([this.salaryRepository.save(profileSalary)]);
|
||||
|
||||
|
|
@ -1966,6 +1993,8 @@ export class ProfileController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
});
|
||||
await Promise.all([this.salaryRepository.save(profileSalary)]);
|
||||
|
||||
|
|
@ -2037,6 +2066,8 @@ export class ProfileController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
});
|
||||
await Promise.all([this.salaryRepository.save(profileSalary)]);
|
||||
|
||||
|
|
@ -2108,6 +2139,8 @@ export class ProfileController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
});
|
||||
await Promise.all([this.salaryRepository.save(profileSalary)]);
|
||||
|
||||
|
|
@ -2179,6 +2212,8 @@ export class ProfileController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
});
|
||||
await Promise.all([this.salaryRepository.save(profileSalary)]);
|
||||
|
||||
|
|
@ -2221,6 +2256,7 @@ export class ProfileController extends Controller {
|
|||
profile.dateLeave = null_;
|
||||
profile.lastUpdateUserId = req.user.sub;
|
||||
profile.lastUpdateFullName = req.user.name;
|
||||
profile.lastUpdatedAt = new Date();
|
||||
// const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), {
|
||||
// profileId: body.profileId,
|
||||
// date: body.date,
|
||||
|
|
@ -2250,7 +2286,9 @@ export class ProfileController extends Controller {
|
|||
// createdUserId: req.user.sub,
|
||||
// createdFullName: req.user.name,
|
||||
// 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)]);
|
||||
|
||||
|
|
@ -2350,6 +2388,12 @@ export class ProfileController extends Controller {
|
|||
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้");
|
||||
|
||||
Object.assign(record, body);
|
||||
record.lastUpdateUserId = request.user.sub;
|
||||
record.lastUpdateFullName = request.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
record.dateRetire = calculateRetireDate(record.birthDate);
|
||||
record.dateRetireLaw = calculateRetireLaw(record.birthDate);
|
||||
await this.profileHistoryRepo.save(
|
||||
Object.assign(new ProfileHistory(), {
|
||||
...record,
|
||||
|
|
@ -2357,12 +2401,6 @@ export class ProfileController extends Controller {
|
|||
id: undefined,
|
||||
}),
|
||||
);
|
||||
|
||||
Object.assign(record, body);
|
||||
record.lastUpdateUserId = request.user.sub;
|
||||
record.lastUpdateFullName = request.user.name;
|
||||
record.dateRetire = calculateRetireDate(record.birthDate);
|
||||
record.dateRetireLaw = calculateRetireLaw(record.birthDate);
|
||||
await this.profileRepo.save(record);
|
||||
|
||||
if (record != null && record.keycloak != null) {
|
||||
|
|
@ -5461,6 +5499,8 @@ export class ProfileController extends Controller {
|
|||
profile.createdFullName = request.user.name;
|
||||
profile.lastUpdateUserId = request.user.sub;
|
||||
profile.lastUpdateFullName = request.user.name;
|
||||
profile.createdAt = new Date();
|
||||
profile.lastUpdatedAt = new Date();
|
||||
// return new HttpSuccess(profile);
|
||||
await this.profileRepo.save(profile);
|
||||
return new HttpSuccess(profile.id);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {
|
|||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
Path,
|
||||
|
|
@ -41,53 +40,22 @@ export class ProfileDevelopmentController extends Controller {
|
|||
}
|
||||
const lists = await this.developmentRepository.find({
|
||||
where: { profileId: profile.id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
||||
@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) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||
const lists = await this.developmentRepository.find({
|
||||
where: { profileId: profileId },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
||||
@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) {
|
||||
const _record = await this.developmentRepository.findOneBy({ id: developmentId });
|
||||
if (_record) {
|
||||
|
|
@ -122,6 +90,8 @@ export class ProfileDevelopmentController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -150,15 +120,18 @@ export class ProfileDevelopmentController extends Controller {
|
|||
const history = new ProfileDevelopmentHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileDevelopmentId = developmentId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.developmentRepository.save(record),
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {
|
|||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
Path,
|
||||
|
|
@ -41,6 +40,7 @@ export class ProfileDevelopmentEmployeeController extends Controller {
|
|||
}
|
||||
const lists = await this.developmentRepository.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
|
@ -50,6 +50,7 @@ export class ProfileDevelopmentEmployeeController extends Controller {
|
|||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId);
|
||||
const lists = await this.developmentRepository.find({
|
||||
where: { profileEmployeeId: profileId },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
|
@ -93,6 +94,8 @@ export class ProfileDevelopmentEmployeeController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -125,15 +128,18 @@ export class ProfileDevelopmentEmployeeController extends Controller {
|
|||
const history = new ProfileDevelopmentHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileDevelopmentId = developmentId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.developmentRepository.save(record),
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {
|
|||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
Path,
|
||||
|
|
@ -41,6 +40,7 @@ export class ProfileDevelopmentEmployeeTempController extends Controller {
|
|||
}
|
||||
const lists = await this.developmentRepository.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
|
@ -50,6 +50,7 @@ export class ProfileDevelopmentEmployeeTempController extends Controller {
|
|||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||
const lists = await this.developmentRepository.find({
|
||||
where: { profileEmployeeId: profileId },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
|
@ -87,6 +88,8 @@ export class ProfileDevelopmentEmployeeTempController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -116,15 +119,18 @@ export class ProfileDevelopmentEmployeeTempController extends Controller {
|
|||
const history = new ProfileDevelopmentHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileDevelopmentId = developmentId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.developmentRepository.save(record),
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {
|
|||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
Path,
|
||||
|
|
@ -41,17 +40,7 @@ export class ProfileDisciplineController extends Controller {
|
|||
}
|
||||
const lists = await this.disciplineRepository.find({
|
||||
where: { profileId: profile.id },
|
||||
select: [
|
||||
"id",
|
||||
"date",
|
||||
"level",
|
||||
"detail",
|
||||
"unStigma",
|
||||
"refCommandNo",
|
||||
"refCommandDate",
|
||||
"lastUpdateFullName",
|
||||
"lastUpdatedAt",
|
||||
],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
|
@ -61,17 +50,7 @@ export class ProfileDisciplineController extends Controller {
|
|||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||
const lists = await this.disciplineRepository.find({
|
||||
where: { profileId: profileId },
|
||||
select: [
|
||||
"id",
|
||||
"date",
|
||||
"level",
|
||||
"detail",
|
||||
"unStigma",
|
||||
"refCommandNo",
|
||||
"refCommandDate",
|
||||
"lastUpdateFullName",
|
||||
"lastUpdatedAt",
|
||||
],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
|
@ -81,46 +60,12 @@ export class ProfileDisciplineController extends Controller {
|
|||
await new permission().PermissionGet(req, "SYS_SALARY_OFFICER");
|
||||
const lists = await this.disciplineRepository.find({
|
||||
where: { profileId: profileId },
|
||||
select: [
|
||||
"id",
|
||||
"date",
|
||||
"level",
|
||||
"detail",
|
||||
"unStigma",
|
||||
"refCommandNo",
|
||||
"refCommandDate",
|
||||
"lastUpdateFullName",
|
||||
"lastUpdatedAt",
|
||||
],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
||||
@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) {
|
||||
const _record = await this.disciplineRepository.findOneBy({ id: disciplineId });
|
||||
if (_record) {
|
||||
|
|
@ -128,17 +73,6 @@ export class ProfileDisciplineController extends Controller {
|
|||
}
|
||||
const record = await this.disciplineHistoryRepository.find({
|
||||
where: { profileDisciplineId: disciplineId },
|
||||
select: [
|
||||
"id",
|
||||
"date",
|
||||
"level",
|
||||
"detail",
|
||||
"unStigma",
|
||||
"refCommandNo",
|
||||
"refCommandDate",
|
||||
"lastUpdateFullName",
|
||||
"lastUpdatedAt",
|
||||
],
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
|
|
@ -152,9 +86,9 @@ export class ProfileDisciplineController extends Controller {
|
|||
if (!body.profileId) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
|
||||
}
|
||||
|
||||
|
||||
const profile = await this.profileRepository.findOneBy({ id: body.profileId });
|
||||
|
||||
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
|
|
@ -167,6 +101,8 @@ export class ProfileDisciplineController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -193,15 +129,18 @@ export class ProfileDisciplineController extends Controller {
|
|||
const history = new ProfileDisciplineHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileDisciplineId = disciplineId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.disciplineRepository.save(record),
|
||||
|
|
@ -215,7 +154,11 @@ export class ProfileDisciplineController extends Controller {
|
|||
public async deleteDiscipline(@Path() disciplineId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.disciplineRepository.findOneBy({ id: disciplineId });
|
||||
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({
|
||||
profileDisciplineId: disciplineId,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {
|
|||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
Path,
|
||||
|
|
@ -41,52 +40,17 @@ export class ProfileDisciplineEmployeeController extends Controller {
|
|||
}
|
||||
const lists = await this.disciplineRepository.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
select: [
|
||||
"id",
|
||||
"date",
|
||||
"level",
|
||||
"detail",
|
||||
"unStigma",
|
||||
"refCommandNo",
|
||||
"refCommandDate",
|
||||
"lastUpdateFullName",
|
||||
"lastUpdatedAt",
|
||||
],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
||||
@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) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId);
|
||||
const lists = await this.disciplineRepository.find({
|
||||
where: { profileEmployeeId: profileId },
|
||||
select: [
|
||||
"id",
|
||||
"date",
|
||||
"level",
|
||||
"detail",
|
||||
"unStigma",
|
||||
"refCommandNo",
|
||||
"refCommandDate",
|
||||
"lastUpdateFullName",
|
||||
"lastUpdatedAt",
|
||||
],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
|
@ -96,17 +60,7 @@ export class ProfileDisciplineEmployeeController extends Controller {
|
|||
await new permission().PermissionGet(req, "SYS_WAGE");
|
||||
const lists = await this.disciplineRepository.find({
|
||||
where: { profileEmployeeId: profileId },
|
||||
select: [
|
||||
"id",
|
||||
"date",
|
||||
"level",
|
||||
"detail",
|
||||
"unStigma",
|
||||
"refCommandNo",
|
||||
"refCommandDate",
|
||||
"lastUpdateFullName",
|
||||
"lastUpdatedAt",
|
||||
],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
|
@ -115,21 +69,14 @@ export class ProfileDisciplineEmployeeController extends Controller {
|
|||
public async disciplineHistory(@Path() disciplineId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.disciplineRepository.findOneBy({ id: disciplineId });
|
||||
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({
|
||||
where: { profileDisciplineId: disciplineId },
|
||||
select: [
|
||||
"id",
|
||||
"date",
|
||||
"level",
|
||||
"detail",
|
||||
"unStigma",
|
||||
"refCommandNo",
|
||||
"refCommandDate",
|
||||
"lastUpdateFullName",
|
||||
"lastUpdatedAt",
|
||||
],
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
|
|
@ -157,6 +104,8 @@ export class ProfileDisciplineEmployeeController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -178,20 +127,27 @@ export class ProfileDisciplineEmployeeController extends Controller {
|
|||
) {
|
||||
const record = await this.disciplineRepository.findOneBy({ id: disciplineId });
|
||||
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();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileDisciplineId = disciplineId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.disciplineRepository.save(record),
|
||||
|
|
@ -205,7 +161,11 @@ export class ProfileDisciplineEmployeeController extends Controller {
|
|||
public async deleteDiscipline(@Path() disciplineId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.disciplineRepository.findOneBy({ id: disciplineId });
|
||||
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({
|
||||
profileDisciplineId: disciplineId,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {
|
|||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
Path,
|
||||
|
|
@ -41,52 +40,17 @@ export class ProfileDisciplineEmployeeTempController extends Controller {
|
|||
}
|
||||
const lists = await this.disciplineRepository.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
select: [
|
||||
"id",
|
||||
"date",
|
||||
"level",
|
||||
"detail",
|
||||
"unStigma",
|
||||
"refCommandNo",
|
||||
"refCommandDate",
|
||||
"lastUpdateFullName",
|
||||
"lastUpdatedAt",
|
||||
],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
||||
@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) {
|
||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||
const lists = await this.disciplineRepository.find({
|
||||
where: { profileEmployeeId: profileId },
|
||||
select: [
|
||||
"id",
|
||||
"date",
|
||||
"level",
|
||||
"detail",
|
||||
"unStigma",
|
||||
"refCommandNo",
|
||||
"refCommandDate",
|
||||
"lastUpdateFullName",
|
||||
"lastUpdatedAt",
|
||||
],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
|
@ -96,17 +60,7 @@ export class ProfileDisciplineEmployeeTempController extends Controller {
|
|||
await new permission().PermissionGet(req, "SYS_WAGE");
|
||||
const lists = await this.disciplineRepository.find({
|
||||
where: { profileEmployeeId: profileId },
|
||||
select: [
|
||||
"id",
|
||||
"date",
|
||||
"level",
|
||||
"detail",
|
||||
"unStigma",
|
||||
"refCommandNo",
|
||||
"refCommandDate",
|
||||
"lastUpdateFullName",
|
||||
"lastUpdatedAt",
|
||||
],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
|
@ -116,17 +70,6 @@ export class ProfileDisciplineEmployeeTempController extends Controller {
|
|||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||
const record = await this.disciplineHistoryRepository.find({
|
||||
where: { profileDisciplineId: disciplineId },
|
||||
select: [
|
||||
"id",
|
||||
"date",
|
||||
"level",
|
||||
"detail",
|
||||
"unStigma",
|
||||
"refCommandNo",
|
||||
"refCommandDate",
|
||||
"lastUpdateFullName",
|
||||
"lastUpdatedAt",
|
||||
],
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
|
|
@ -155,6 +98,8 @@ export class ProfileDisciplineEmployeeTempController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -182,15 +127,18 @@ export class ProfileDisciplineEmployeeTempController extends Controller {
|
|||
const history = new ProfileDisciplineHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileDisciplineId = disciplineId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.disciplineRepository.save(record),
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {
|
|||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
Path,
|
||||
|
|
@ -37,77 +36,22 @@ export class ProfileDutyController extends Controller {
|
|||
}
|
||||
const lists = await this.dutyRepository.find({
|
||||
where: { profileId: profile.id },
|
||||
select: [
|
||||
"id",
|
||||
"dateStart",
|
||||
"dateEnd",
|
||||
"reference",
|
||||
"detail",
|
||||
"refCommandNo",
|
||||
"refCommandDate",
|
||||
],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
||||
@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) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||
const lists = await this.dutyRepository.find({
|
||||
where: { profileId: profileId },
|
||||
select: [
|
||||
"id",
|
||||
"dateStart",
|
||||
"dateEnd",
|
||||
"reference",
|
||||
"detail",
|
||||
"refCommandNo",
|
||||
"refCommandDate",
|
||||
],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
||||
@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) {
|
||||
const _record = await this.dutyRepository.findOneBy({ id: dutyId });
|
||||
if (_record) {
|
||||
|
|
@ -115,17 +59,6 @@ export class ProfileDutyController extends Controller {
|
|||
}
|
||||
const record = await this.dutyHistoryRepository.find({
|
||||
where: { profileDutyId: dutyId },
|
||||
select: [
|
||||
"id",
|
||||
"dateStart",
|
||||
"dateEnd",
|
||||
"reference",
|
||||
"detail",
|
||||
"refCommandNo",
|
||||
"refCommandDate",
|
||||
"lastUpdateFullName",
|
||||
"lastUpdatedAt",
|
||||
],
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
|
|
@ -150,6 +83,8 @@ export class ProfileDutyController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -176,15 +111,18 @@ export class ProfileDutyController extends Controller {
|
|||
const history = new ProfileDutyHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileDutyId = dutyId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([this.dutyRepository.save(record), this.dutyHistoryRepository.save(history)]);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {
|
|||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
Path,
|
||||
|
|
@ -37,15 +36,7 @@ export class ProfileDutyEmployeeController extends Controller {
|
|||
}
|
||||
const lists = await this.dutyRepository.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
select: [
|
||||
"id",
|
||||
"dateStart",
|
||||
"dateEnd",
|
||||
"reference",
|
||||
"detail",
|
||||
"refCommandNo",
|
||||
"refCommandDate",
|
||||
],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
|
@ -55,15 +46,7 @@ export class ProfileDutyEmployeeController extends Controller {
|
|||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId);
|
||||
const lists = await this.dutyRepository.find({
|
||||
where: { profileEmployeeId: profileId },
|
||||
select: [
|
||||
"id",
|
||||
"dateStart",
|
||||
"dateEnd",
|
||||
"reference",
|
||||
"detail",
|
||||
"refCommandNo",
|
||||
"refCommandDate",
|
||||
],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
|
@ -72,21 +55,14 @@ export class ProfileDutyEmployeeController extends Controller {
|
|||
public async dutyHistory(@Path() dutyId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.dutyRepository.findOneBy({ id: dutyId });
|
||||
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({
|
||||
where: { profileDutyId: dutyId },
|
||||
select: [
|
||||
"id",
|
||||
"dateStart",
|
||||
"dateEnd",
|
||||
"reference",
|
||||
"detail",
|
||||
"refCommandNo",
|
||||
"refCommandDate",
|
||||
"lastUpdateFullName",
|
||||
"lastUpdatedAt",
|
||||
],
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
|
|
@ -111,6 +87,8 @@ export class ProfileDutyEmployeeController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -132,20 +110,27 @@ export class ProfileDutyEmployeeController extends Controller {
|
|||
) {
|
||||
const record = await this.dutyRepository.findOneBy({ id: dutyId });
|
||||
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();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileDutyId = dutyId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([this.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) {
|
||||
const _record = await this.dutyRepository.findOneBy({ id: dutyId });
|
||||
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({
|
||||
profileDutyId: dutyId,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {
|
|||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
Path,
|
||||
|
|
@ -37,15 +36,7 @@ export class ProfileDutyEmployeeTempController extends Controller {
|
|||
}
|
||||
const lists = await this.dutyRepository.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
select: [
|
||||
"id",
|
||||
"dateStart",
|
||||
"dateEnd",
|
||||
"reference",
|
||||
"detail",
|
||||
"refCommandNo",
|
||||
"refCommandDate",
|
||||
],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
|
@ -55,15 +46,7 @@ export class ProfileDutyEmployeeTempController extends Controller {
|
|||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||
const lists = await this.dutyRepository.find({
|
||||
where: { profileEmployeeId: profileId },
|
||||
select: [
|
||||
"id",
|
||||
"dateStart",
|
||||
"dateEnd",
|
||||
"reference",
|
||||
"detail",
|
||||
"refCommandNo",
|
||||
"refCommandDate",
|
||||
],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
|
@ -73,17 +56,6 @@ export class ProfileDutyEmployeeTempController extends Controller {
|
|||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||
const record = await this.dutyHistoryRepository.find({
|
||||
where: { profileDutyId: dutyId },
|
||||
select: [
|
||||
"id",
|
||||
"dateStart",
|
||||
"dateEnd",
|
||||
"reference",
|
||||
"detail",
|
||||
"refCommandNo",
|
||||
"refCommandDate",
|
||||
"lastUpdateFullName",
|
||||
"lastUpdatedAt",
|
||||
],
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
|
|
@ -109,6 +81,8 @@ export class ProfileDutyEmployeeTempController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -136,15 +110,18 @@ export class ProfileDutyEmployeeTempController extends Controller {
|
|||
const history = new ProfileDutyHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileDutyId = dutyId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([this.dutyRepository.save(record), this.dutyHistoryRepository.save(history)]);
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import { AppDataSource } from "../database/data-source";
|
|||
import { Profile } from "../entities/Profile";
|
||||
import { CreateProfileEdit, EditProfileEdit, ProfileEdit } from "../entities/ProfileEdit";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { IsNull, Not, Brackets } from "typeorm";
|
||||
import { Brackets } from "typeorm";
|
||||
|
||||
@Route("api/v1/org/profile/edit")
|
||||
@Tags("ProfileEdit")
|
||||
|
|
@ -52,22 +52,14 @@ export class ProfileEditController extends Controller {
|
|||
})
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.where(
|
||||
keyword != "" && keyword != null
|
||||
? "ProfileEdit.topic LIKE :keyword"
|
||||
: "1=1",
|
||||
qb.where(keyword != "" && keyword != null ? "ProfileEdit.topic LIKE :keyword" : "1=1", {
|
||||
keyword: `%${keyword}%`,
|
||||
}).orWhere(
|
||||
keyword != "" && keyword != null ? "ProfileEdit.detail LIKE :keyword" : "1=1",
|
||||
{
|
||||
keyword: `%${keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
keyword != "" && keyword != null
|
||||
? "ProfileEdit.detail LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${keyword}%`,
|
||||
},
|
||||
)
|
||||
);
|
||||
}),
|
||||
)
|
||||
.orderBy("ProfileEdit.createdAt", "ASC")
|
||||
|
|
@ -114,22 +106,14 @@ export class ProfileEditController extends Controller {
|
|||
})
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.where(
|
||||
keyword != "" && keyword != null
|
||||
? "ProfileEdit.topic LIKE :keyword"
|
||||
: "1=1",
|
||||
qb.where(keyword != "" && keyword != null ? "ProfileEdit.topic LIKE :keyword" : "1=1", {
|
||||
keyword: `%${keyword}%`,
|
||||
}).orWhere(
|
||||
keyword != "" && keyword != null ? "ProfileEdit.detail LIKE :keyword" : "1=1",
|
||||
{
|
||||
keyword: `%${keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
keyword != "" && keyword != null
|
||||
? "ProfileEdit.detail LIKE :keyword"
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${keyword}%`,
|
||||
},
|
||||
)
|
||||
);
|
||||
}),
|
||||
)
|
||||
.orderBy("ProfileEdit.createdAt", "ASC")
|
||||
|
|
@ -209,6 +193,8 @@ export class ProfileEditController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
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.findOne({
|
||||
where: { id: editId }
|
||||
where: { id: editId },
|
||||
});
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import {
|
|||
} from "../entities/ProfileEdit";
|
||||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { IsNull, Not, Brackets } from "typeorm";
|
||||
import { Brackets } from "typeorm";
|
||||
|
||||
@Route("api/v1/org/profile-employee/edit")
|
||||
@Tags("ProfileEmployeeEdit")
|
||||
|
|
@ -203,6 +203,8 @@ export class ProfileEditEmployeeController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
data.status = "PENDING";
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import {
|
||||
Controller,
|
||||
Post,
|
||||
Put,
|
||||
Delete,
|
||||
Route,
|
||||
Security,
|
||||
|
|
@ -9,12 +8,8 @@ import {
|
|||
Body,
|
||||
Path,
|
||||
Request,
|
||||
SuccessResponse,
|
||||
Response,
|
||||
Get,
|
||||
Query,
|
||||
Patch,
|
||||
Example,
|
||||
} from "tsoa";
|
||||
|
||||
import HttpSuccess from "../interfaces/http-success";
|
||||
|
|
@ -47,6 +42,7 @@ export class ProfileEducationsController extends Controller {
|
|||
}
|
||||
const getProfileEducation = await this.profileEducationRepo.find({
|
||||
where: { profileId: profile.id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
if (!getProfileEducation) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
@ -55,45 +51,12 @@ export class ProfileEducationsController extends Controller {
|
|||
}
|
||||
|
||||
@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) {
|
||||
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) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
|
@ -101,79 +64,19 @@ export class ProfileEducationsController extends Controller {
|
|||
}
|
||||
|
||||
@Get("history/{educationId}")
|
||||
@Example({
|
||||
status: 200,
|
||||
message: "สำเร็จ",
|
||||
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",
|
||||
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.find({
|
||||
where: {
|
||||
profileEducationId: educationId,
|
||||
},
|
||||
{
|
||||
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,
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
if (!record) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
@ -189,7 +92,7 @@ export class ProfileEducationsController extends Controller {
|
|||
if (!body.profileId) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
|
||||
}
|
||||
|
||||
|
||||
const profile = await this.profileRepo.findOneBy({ id: body.profileId });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
|
|
@ -202,6 +105,8 @@ export class ProfileEducationsController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -228,15 +133,18 @@ export class ProfileEducationsController extends Controller {
|
|||
const history = new ProfileEducationHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileEducationId = educationId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.profileEducationRepo.save(record),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import {
|
||||
Controller,
|
||||
Post,
|
||||
Put,
|
||||
Delete,
|
||||
Route,
|
||||
Security,
|
||||
|
|
@ -9,24 +8,18 @@ import {
|
|||
Body,
|
||||
Path,
|
||||
Request,
|
||||
SuccessResponse,
|
||||
Response,
|
||||
Get,
|
||||
Query,
|
||||
Patch,
|
||||
Example,
|
||||
} from "tsoa";
|
||||
import HttpSuccess from "../interfaces/http-success";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import HttpStatus from "../interfaces/http-status";
|
||||
import {
|
||||
ProfileEducation,
|
||||
CreateProfileEducation,
|
||||
UpdateProfileEducation,
|
||||
CreateProfileEducationEmployee,
|
||||
} from "../entities/ProfileEducation";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { Profile } from "../entities/Profile";
|
||||
import { ProfileEducationHistory } from "../entities/ProfileEducationHistory";
|
||||
import { AppDataSource } from "../database/data-source";
|
||||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||
|
|
@ -47,6 +40,7 @@ export class ProfileEducationsEmployeeController extends Controller {
|
|||
}
|
||||
const getProfileEducation = await this.profileEducationRepo.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
if (!getProfileEducation) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
@ -55,46 +49,14 @@ export class ProfileEducationsEmployeeController extends Controller {
|
|||
}
|
||||
|
||||
@Get("{profileEmployeeId}")
|
||||
@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",
|
||||
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) {
|
||||
public async detailProfileEducation(
|
||||
@Path() profileEmployeeId: string,
|
||||
@Request() req: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
||||
const getProfileEducation = await this.profileEducationRepo.find({
|
||||
where: { profileEmployeeId: profileEmployeeId },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
if (!getProfileEducation) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
@ -103,80 +65,24 @@ export class ProfileEducationsEmployeeController extends Controller {
|
|||
}
|
||||
|
||||
@Get("history/{educationId}")
|
||||
@Example({
|
||||
status: 200,
|
||||
message: "สำเร็จ",
|
||||
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) {
|
||||
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_EMP", _record.profileEmployeeId);
|
||||
await new permission().PermissionOrgUserGet(
|
||||
req,
|
||||
"SYS_REGISTRY_EMP",
|
||||
_record.profileEmployeeId,
|
||||
);
|
||||
}
|
||||
|
||||
const record = await this.profileEducationHistoryRepo.findBy({
|
||||
profileEducationId: educationId,
|
||||
const record = await this.profileEducationHistoryRepo.find({
|
||||
where: {
|
||||
profileEducationId: educationId,
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
if (!record) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
@ -192,7 +98,7 @@ export class ProfileEducationsEmployeeController extends Controller {
|
|||
if (!body.profileEmployeeId) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId");
|
||||
}
|
||||
|
||||
|
||||
const profile = await this.profileEmployeeRepo.findOneBy({ id: body.profileEmployeeId });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
|
|
@ -205,6 +111,8 @@ export class ProfileEducationsEmployeeController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -226,20 +134,27 @@ export class ProfileEducationsEmployeeController extends Controller {
|
|||
) {
|
||||
const record = await this.profileEducationRepo.findOneBy({ id: educationId });
|
||||
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();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileEducationId = educationId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.profileEducationRepo.save(record),
|
||||
|
|
@ -256,7 +171,11 @@ export class ProfileEducationsEmployeeController extends Controller {
|
|||
) {
|
||||
const _record = await this.profileEducationRepo.findOneBy({ id: educationId });
|
||||
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({
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import {
|
||||
Controller,
|
||||
Post,
|
||||
Put,
|
||||
Delete,
|
||||
Route,
|
||||
Security,
|
||||
|
|
@ -9,24 +8,18 @@ import {
|
|||
Body,
|
||||
Path,
|
||||
Request,
|
||||
SuccessResponse,
|
||||
Response,
|
||||
Get,
|
||||
Query,
|
||||
Patch,
|
||||
Example,
|
||||
} from "tsoa";
|
||||
import HttpSuccess from "../interfaces/http-success";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import HttpStatus from "../interfaces/http-status";
|
||||
import {
|
||||
ProfileEducation,
|
||||
CreateProfileEducation,
|
||||
UpdateProfileEducation,
|
||||
CreateProfileEducationEmployee,
|
||||
} from "../entities/ProfileEducation";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { Profile } from "../entities/Profile";
|
||||
import { ProfileEducationHistory } from "../entities/ProfileEducationHistory";
|
||||
import { AppDataSource } from "../database/data-source";
|
||||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||
|
|
@ -47,6 +40,7 @@ export class ProfileEducationsEmployeeTempController extends Controller {
|
|||
}
|
||||
const getProfileEducation = await this.profileEducationRepo.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
if (!getProfileEducation) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
@ -55,46 +49,14 @@ export class ProfileEducationsEmployeeTempController extends Controller {
|
|||
}
|
||||
|
||||
@Get("{profileEmployeeId}")
|
||||
@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",
|
||||
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) {
|
||||
public async detailProfileEducation(
|
||||
@Path() profileEmployeeId: string,
|
||||
@Request() req: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||
const getProfileEducation = await this.profileEducationRepo.find({
|
||||
where: { profileEmployeeId: profileEmployeeId },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
if (!getProfileEducation) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
@ -103,76 +65,16 @@ export class ProfileEducationsEmployeeTempController extends Controller {
|
|||
}
|
||||
|
||||
@Get("history/{educationId}")
|
||||
@Example({
|
||||
status: 200,
|
||||
message: "สำเร็จ",
|
||||
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) {
|
||||
public async getProfileEducationHistory(
|
||||
@Path() educationId: string,
|
||||
@Request() req: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||
const record = await this.profileEducationHistoryRepo.findBy({
|
||||
profileEducationId: educationId,
|
||||
const record = await this.profileEducationHistoryRepo.find({
|
||||
where: {
|
||||
profileEducationId: educationId,
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
if (!record) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
@ -201,6 +103,8 @@ export class ProfileEducationsEmployeeTempController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -227,15 +131,18 @@ export class ProfileEducationsEmployeeTempController extends Controller {
|
|||
const history = new ProfileEducationHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileEducationId = educationId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.profileEducationRepo.save(record),
|
||||
|
|
|
|||
|
|
@ -612,6 +612,8 @@ export class ProfileEmployeeController extends Controller {
|
|||
profile.createdFullName = request.user.name;
|
||||
profile.lastUpdateUserId = request.user.sub;
|
||||
profile.lastUpdateFullName = request.user.name;
|
||||
profile.createdAt = new Date();
|
||||
profile.lastUpdatedAt = new Date();
|
||||
profile.dateRetire = calculateRetireDate(profile.birthDate);
|
||||
profile.dateRetireLaw = calculateRetireLaw(profile.birthDate);
|
||||
profile.citizenId = Extension.CheckCitizen(profile.citizenId);
|
||||
|
|
@ -666,6 +668,9 @@ export class ProfileEmployeeController extends Controller {
|
|||
await this.profileHistoryRepo.save(
|
||||
Object.assign(new ProfileEmployeeHistory(), {
|
||||
...record,
|
||||
lastUpdateUserId: request.user.sub,
|
||||
lastUpdateFullName: request.user.name,
|
||||
lastUpdatedAt: new Date(),
|
||||
profileEmployeeId: id,
|
||||
id: undefined,
|
||||
}),
|
||||
|
|
@ -681,6 +686,7 @@ export class ProfileEmployeeController extends Controller {
|
|||
Object.assign(record, body);
|
||||
record.lastUpdateUserId = request.user.sub;
|
||||
record.lastUpdateFullName = request.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
record.dateRetire = calculateRetireDate(record.birthDate);
|
||||
record.dateRetireLaw = calculateRetireLaw(record.birthDate);
|
||||
record.citizenId = Extension.CheckCitizen(record.citizenId);
|
||||
|
|
@ -1228,6 +1234,12 @@ export class ProfileEmployeeController extends Controller {
|
|||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
const findRevision = await this.orgRevisionRepo.findOne({
|
||||
where: { orgRevisionIsCurrent: true },
|
||||
});
|
||||
if (!findRevision) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||
}
|
||||
const data = await Promise.all(
|
||||
record.map((_data) => {
|
||||
const shortName =
|
||||
|
|
@ -1250,6 +1262,45 @@ export class ProfileEmployeeController extends Controller {
|
|||
: _data.profileEmployeeEmployment.reduce((latest, current) => {
|
||||
return latest.date > current.date ? latest : current;
|
||||
}).date;
|
||||
const root =
|
||||
_data.current_holders.length == 0 ||
|
||||
(_data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot == null)
|
||||
? null
|
||||
: _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot;
|
||||
|
||||
const child1 =
|
||||
_data.current_holders == null ||
|
||||
_data.current_holders.length == 0 ||
|
||||
_data.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null
|
||||
? null
|
||||
: _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1;
|
||||
|
||||
const child2 =
|
||||
_data.current_holders == null ||
|
||||
_data.current_holders.length == 0 ||
|
||||
_data.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null
|
||||
? null
|
||||
: _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2;
|
||||
|
||||
const child3 =
|
||||
_data.current_holders == null ||
|
||||
_data.current_holders.length == 0 ||
|
||||
_data.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null
|
||||
? null
|
||||
: _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3;
|
||||
|
||||
const child4 =
|
||||
_data.current_holders == null ||
|
||||
_data.current_holders.length == 0 ||
|
||||
_data.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null
|
||||
? null
|
||||
: _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4;
|
||||
|
||||
let _child1 = child1 == null ? "" : `${child1.orgChild1Name}/`;
|
||||
let _child2 = child2 == null ? "" : `${child2.orgChild2Name}/`;
|
||||
let _child3 = child3 == null ? "" : `${child3.orgChild3Name}/`;
|
||||
let _child4 = child4 == null ? "" : `${child4.orgChild4Name}/`;
|
||||
return {
|
||||
id: _data.id,
|
||||
prefix: _data.prefix,
|
||||
|
|
@ -1329,6 +1380,7 @@ export class ProfileEmployeeController extends Controller {
|
|||
child4: _data.child4Temp ? _data.child4Temp : null,
|
||||
child4Id: _data.child4IdTemp ? _data.child4IdTemp : null,
|
||||
child4ShortName: _data.child4ShortNameTemp ? _data.child4ShortNameTemp : null,
|
||||
org: `${_child4}${_child3}${_child2}${_child1}${root?.orgRootName ?? ""}`,
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
|
@ -2205,6 +2257,7 @@ export class ProfileEmployeeController extends Controller {
|
|||
|
||||
profileEmp.lastUpdateUserId = request.user.sub;
|
||||
profileEmp.lastUpdateFullName = request.user.name;
|
||||
profileEmp.lastUpdatedAt = new Date();
|
||||
profileEmp.nodeTemp = String(body.node);
|
||||
profileEmp.nodeIdTemp = body.nodeId;
|
||||
profileEmp.orgRevisionIdTemp = body.orgRevisionId;
|
||||
|
|
@ -2923,13 +2976,18 @@ export class ProfileEmployeeController extends Controller {
|
|||
if (!profileEmp) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้");
|
||||
|
||||
const history = new ProfileEmployeeInformationHistory();
|
||||
Object.assign(history, { ...profileEmp, id: undefined });
|
||||
Object.assign(profileEmp, body);
|
||||
Object.assign(history, { ...profileEmp, id: undefined });
|
||||
history.profileEmployeeId = profileEmployeeId;
|
||||
history.lastUpdateFullName = request.user.name;
|
||||
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.lastUpdateFullName = request.user.name;
|
||||
profileEmp.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.profileRepo.save(profileEmp),
|
||||
|
|
@ -3103,24 +3161,26 @@ export class ProfileEmployeeController extends Controller {
|
|||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
await new permission().PermissionOrgUserUpdate(request, "SYS_REGISTRY_EMP", profile.id);
|
||||
|
||||
const employment = new ProfileEmployeeEmployment();
|
||||
// const history = new ProfileEmployeeEmploymentHistory();
|
||||
Object.assign(employment, body);
|
||||
employment.profileEmployeeId = profileEmployeeId;
|
||||
employment.createdUserId = request.user.sub;
|
||||
employment.createdFullName = request.user.name;
|
||||
employment.lastUpdateUserId = request.user.sub;
|
||||
employment.lastUpdateFullName = request.user.name;
|
||||
await this.employmentRepository.save(employment);
|
||||
// if (employment) {
|
||||
// Object.assign(history, { ...employment, id: undefined });
|
||||
// history.profileEmployeeEmploymentId = employment.id;
|
||||
// history.createdUserId = request.user.sub;
|
||||
// history.createdFullName = request.user.name;
|
||||
// history.lastUpdateFullName = request.user.name;
|
||||
// history.lastUpdateUserId = request.user.sub;
|
||||
// await this.employmentHistoryRepository.save(history);
|
||||
// }
|
||||
const data = new ProfileEmployeeEmployment();
|
||||
|
||||
const meta = {
|
||||
createdUserId: request.user.sub,
|
||||
createdFullName: request.user.name,
|
||||
lastUpdateUserId: request.user.sub,
|
||||
lastUpdateFullName: request.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
profileEmployeeId: profileEmployeeId,
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
const history = new ProfileEmployeeEmploymentHistory();
|
||||
Object.assign(history, { ...data, id: undefined });
|
||||
|
||||
await this.employmentRepository.save(data);
|
||||
history.profileEmployeeEmploymentId = data.id;
|
||||
await this.employmentHistoryRepository.save(history);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
|
|
@ -3176,14 +3236,19 @@ export class ProfileEmployeeController extends Controller {
|
|||
);
|
||||
|
||||
const history = new ProfileEmployeeEmploymentHistory();
|
||||
Object.assign(history, { ...employment, id: undefined });
|
||||
Object.assign(employment, body);
|
||||
Object.assign(history, { ...employment, id: undefined });
|
||||
|
||||
employment.lastUpdateUserId = request.user.sub;
|
||||
employment.lastUpdateFullName = request.user.name;
|
||||
employment.lastUpdatedAt = new Date();
|
||||
history.profileEmployeeEmploymentId = id;
|
||||
history.lastUpdateFullName = request.user.name;
|
||||
history.lastUpdateUserId = request.user.sub;
|
||||
history.lastUpdateFullName = request.user.name;
|
||||
history.createdUserId = request.user.sub;
|
||||
history.createdFullName = request.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.employmentRepository.save(employment),
|
||||
|
|
@ -3210,6 +3275,7 @@ export class ProfileEmployeeController extends Controller {
|
|||
statusTemp: "REPORT",
|
||||
lastUpdateUserId: request.user.sub,
|
||||
lastUpdateFullName: request.user.name,
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -609,6 +609,8 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
profile.createdFullName = request.user.name;
|
||||
profile.lastUpdateUserId = request.user.sub;
|
||||
profile.lastUpdateFullName = request.user.name;
|
||||
profile.createdAt = new Date();
|
||||
profile.lastUpdatedAt = new Date();
|
||||
profile.dateRetire = calculateRetireDate(profile.birthDate);
|
||||
profile.dateRetireLaw = calculateRetireLaw(profile.birthDate);
|
||||
profile.citizenId = Extension.CheckCitizen(profile.citizenId);
|
||||
|
|
@ -678,6 +680,7 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
Object.assign(record, body);
|
||||
record.lastUpdateUserId = request.user.sub;
|
||||
record.lastUpdateFullName = request.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
record.dateRetire = calculateRetireDate(record.birthDate);
|
||||
record.dateRetireLaw = calculateRetireLaw(record.birthDate);
|
||||
record.citizenId = Extension.CheckCitizen(record.citizenId);
|
||||
|
|
@ -2192,6 +2195,7 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
|
||||
profileEmp.lastUpdateUserId = request.user.sub;
|
||||
profileEmp.lastUpdateFullName = request.user.name;
|
||||
profileEmp.lastUpdatedAt = new Date();
|
||||
profileEmp.nodeTemp = String(body.node);
|
||||
profileEmp.nodeIdTemp = body.nodeId;
|
||||
profileEmp.orgRevisionIdTemp = body.orgRevisionId;
|
||||
|
|
@ -2916,8 +2920,10 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
history.profileEmployeeId = profileEmployeeId;
|
||||
history.lastUpdateFullName = request.user.name;
|
||||
history.lastUpdateUserId = request.user.sub;
|
||||
history.lastUpdatedAt = new Date();
|
||||
profileEmp.lastUpdateUserId = request.user.sub;
|
||||
profileEmp.lastUpdateFullName = request.user.name;
|
||||
profileEmp.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.profileRepo.save(profileEmp),
|
||||
|
|
@ -3084,6 +3090,8 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
employment.createdFullName = request.user.name;
|
||||
employment.lastUpdateUserId = request.user.sub;
|
||||
employment.lastUpdateFullName = request.user.name;
|
||||
employment.createdAt = new Date();
|
||||
employment.lastUpdatedAt = new Date();
|
||||
await this.employmentRepository.save(employment);
|
||||
// if (employment) {
|
||||
// Object.assign(history, { ...employment, id: undefined });
|
||||
|
|
@ -3136,14 +3144,16 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
if (!employment) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
||||
const history = new ProfileEmployeeEmploymentHistory();
|
||||
Object.assign(history, { ...employment, id: undefined });
|
||||
Object.assign(employment, body);
|
||||
Object.assign(history, { ...employment, id: undefined });
|
||||
|
||||
employment.lastUpdateUserId = request.user.sub;
|
||||
employment.lastUpdateFullName = request.user.name;
|
||||
employment.lastUpdatedAt = new Date();
|
||||
history.profileEmployeeEmploymentId = id;
|
||||
history.lastUpdateFullName = request.user.name;
|
||||
history.lastUpdateUserId = request.user.sub;
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.employmentRepository.save(employment),
|
||||
|
|
@ -3171,6 +3181,7 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
statusTemp: "REPORT",
|
||||
lastUpdateUserId: request.user.sub,
|
||||
lastUpdateFullName: request.user.name,
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
|
|
@ -41,18 +40,6 @@ export class ProfileFamilyCoupleController extends Controller {
|
|||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const familyCouple = await this.ProfileFamilyCouple.findOne({
|
||||
select: [
|
||||
"id",
|
||||
"couplePrefix",
|
||||
"coupleFirstName",
|
||||
"coupleLastName",
|
||||
"coupleLastNameOld",
|
||||
"coupleCareer",
|
||||
"coupleCitizenId",
|
||||
"coupleLive",
|
||||
"relationship",
|
||||
"profileId",
|
||||
],
|
||||
where: { profileId: profile.id },
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
|
|
@ -61,22 +48,6 @@ export class ProfileFamilyCoupleController extends Controller {
|
|||
}
|
||||
|
||||
@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) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||
const profile = await this.profileRepo.findOne({
|
||||
|
|
@ -87,18 +58,6 @@ export class ProfileFamilyCoupleController extends Controller {
|
|||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const familyCouple = await this.ProfileFamilyCouple.findOne({
|
||||
select: [
|
||||
"id",
|
||||
"couplePrefix",
|
||||
"coupleFirstName",
|
||||
"coupleLastName",
|
||||
"coupleLastNameOld",
|
||||
"coupleCareer",
|
||||
"coupleCitizenId",
|
||||
"coupleLive",
|
||||
"relationship",
|
||||
"profileId",
|
||||
],
|
||||
where: { profileId },
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
|
|
@ -152,31 +111,6 @@ export class ProfileFamilyCoupleController extends Controller {
|
|||
}
|
||||
|
||||
@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) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||
const profile = await this.profileRepo.findOne({
|
||||
|
|
@ -236,6 +170,8 @@ export class ProfileFamilyCoupleController extends Controller {
|
|||
familyCouple.createdFullName = req.user.name;
|
||||
familyCouple.lastUpdateUserId = req.user.sub;
|
||||
familyCouple.lastUpdateFullName = req.user.name;
|
||||
familyCouple.createdAt = new Date();
|
||||
familyCouple.lastUpdatedAt = new Date();
|
||||
|
||||
profile.relationship = familyCouple.relationship; //update profileEmployee.relationship
|
||||
const history = new ProfileFamilyCoupleHistory();
|
||||
|
|
@ -267,10 +203,13 @@ export class ProfileFamilyCoupleController extends Controller {
|
|||
history.profileFamilyCoupleId = familyCouple.id;
|
||||
familyCouple.lastUpdateUserId = req.user.sub;
|
||||
familyCouple.lastUpdateFullName = req.user.name;
|
||||
familyCouple.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.ProfileFamilyCouple.save(familyCouple),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
|
|
@ -41,18 +40,6 @@ export class ProfileFamilyCoupleEmployeeController extends Controller {
|
|||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const familyCouple = await this.ProfileFamilyCouple.findOne({
|
||||
select: [
|
||||
"id",
|
||||
"couplePrefix",
|
||||
"coupleFirstName",
|
||||
"coupleLastName",
|
||||
"coupleLastNameOld",
|
||||
"coupleCareer",
|
||||
"coupleCitizenId",
|
||||
"coupleLive",
|
||||
"relationship",
|
||||
"profileId",
|
||||
],
|
||||
where: { profileEmployeeId: profile.id },
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
|
|
@ -61,22 +48,6 @@ export class ProfileFamilyCoupleEmployeeController extends Controller {
|
|||
}
|
||||
|
||||
@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) {
|
||||
const profile = await this.profileRepo.findOne({
|
||||
where: { id: profileEmployeeId },
|
||||
|
|
@ -87,18 +58,6 @@ export class ProfileFamilyCoupleEmployeeController extends Controller {
|
|||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profile.id);
|
||||
|
||||
const familyCouple = await this.ProfileFamilyCouple.findOne({
|
||||
select: [
|
||||
"id",
|
||||
"couplePrefix",
|
||||
"coupleFirstName",
|
||||
"coupleLastName",
|
||||
"coupleLastNameOld",
|
||||
"coupleCareer",
|
||||
"coupleCitizenId",
|
||||
"coupleLive",
|
||||
"relationship",
|
||||
"profileEmployeeId",
|
||||
],
|
||||
where: { profileEmployeeId },
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
|
|
@ -152,32 +111,10 @@ export class ProfileFamilyCoupleEmployeeController extends Controller {
|
|||
}
|
||||
|
||||
@Get("history/{profileEmployeeId}")
|
||||
@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",
|
||||
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
||||
},
|
||||
],
|
||||
})
|
||||
public async familyCoupleHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
||||
public async familyCoupleHistory(
|
||||
@Path() profileEmployeeId: string,
|
||||
@Request() req: RequestWithUser,
|
||||
) {
|
||||
const profile = await this.profileRepo.findOne({
|
||||
where: { id: profileEmployeeId },
|
||||
});
|
||||
|
|
@ -237,6 +174,8 @@ export class ProfileFamilyCoupleEmployeeController extends Controller {
|
|||
familyCouple.createdFullName = req.user.name;
|
||||
familyCouple.lastUpdateUserId = req.user.sub;
|
||||
familyCouple.lastUpdateFullName = req.user.name;
|
||||
familyCouple.createdAt = new Date();
|
||||
familyCouple.lastUpdatedAt = new Date();
|
||||
|
||||
profile.relationship = familyCouple.relationship; //update profileEmployee.relationship
|
||||
const history = new ProfileFamilyCoupleHistory();
|
||||
|
|
@ -256,7 +195,7 @@ export class ProfileFamilyCoupleEmployeeController extends Controller {
|
|||
@Body() body: UpdateProfileFamilyCouple,
|
||||
@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({
|
||||
profileEmployeeId: profileEmployeeId,
|
||||
});
|
||||
|
|
@ -270,10 +209,13 @@ export class ProfileFamilyCoupleEmployeeController extends Controller {
|
|||
history.profileFamilyCoupleId = familyCouple.id;
|
||||
familyCouple.lastUpdateUserId = req.user.sub;
|
||||
familyCouple.lastUpdateFullName = req.user.name;
|
||||
familyCouple.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.ProfileFamilyCouple.save(familyCouple),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
|
|
@ -41,18 +40,6 @@ export class ProfileFamilyCoupleEmployeeTempController extends Controller {
|
|||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const familyCouple = await this.ProfileFamilyCouple.findOne({
|
||||
select: [
|
||||
"id",
|
||||
"couplePrefix",
|
||||
"coupleFirstName",
|
||||
"coupleLastName",
|
||||
"coupleLastNameOld",
|
||||
"coupleCareer",
|
||||
"coupleCitizenId",
|
||||
"coupleLive",
|
||||
"relationship",
|
||||
"profileId",
|
||||
],
|
||||
where: { profileEmployeeId: profile.id },
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
|
|
@ -61,22 +48,6 @@ export class ProfileFamilyCoupleEmployeeTempController extends Controller {
|
|||
}
|
||||
|
||||
@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) {
|
||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||
const profile = await this.profileRepo.findOne({
|
||||
|
|
@ -87,18 +58,6 @@ export class ProfileFamilyCoupleEmployeeTempController extends Controller {
|
|||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const familyCouple = await this.ProfileFamilyCouple.findOne({
|
||||
select: [
|
||||
"id",
|
||||
"couplePrefix",
|
||||
"coupleFirstName",
|
||||
"coupleLastName",
|
||||
"coupleLastNameOld",
|
||||
"coupleCareer",
|
||||
"coupleCitizenId",
|
||||
"coupleLive",
|
||||
"relationship",
|
||||
"profileEmployeeId",
|
||||
],
|
||||
where: { profileEmployeeId },
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
|
|
@ -153,32 +112,10 @@ export class ProfileFamilyCoupleEmployeeTempController extends Controller {
|
|||
}
|
||||
|
||||
@Get("history/{profileEmployeeId}")
|
||||
@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",
|
||||
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
||||
},
|
||||
],
|
||||
})
|
||||
public async familyCoupleHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
||||
public async familyCoupleHistory(
|
||||
@Path() profileEmployeeId: string,
|
||||
@Request() req: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||
const profile = await this.profileRepo.findOne({
|
||||
where: { id: profileEmployeeId },
|
||||
|
|
@ -237,6 +174,8 @@ export class ProfileFamilyCoupleEmployeeTempController extends Controller {
|
|||
familyCouple.createdFullName = req.user.name;
|
||||
familyCouple.lastUpdateUserId = req.user.sub;
|
||||
familyCouple.lastUpdateFullName = req.user.name;
|
||||
familyCouple.createdAt = new Date();
|
||||
familyCouple.lastUpdatedAt = new Date();
|
||||
await this.ProfileFamilyCouple.save(familyCouple);
|
||||
|
||||
profile.relationship = familyCouple.relationship; //update profileEmployee.relationship
|
||||
|
|
@ -271,10 +210,13 @@ export class ProfileFamilyCoupleEmployeeTempController extends Controller {
|
|||
history.profileFamilyCoupleId = familyCouple.id;
|
||||
familyCouple.lastUpdateUserId = req.user.sub;
|
||||
familyCouple.lastUpdateFullName = req.user.name;
|
||||
familyCouple.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.ProfileFamilyCouple.save(familyCouple),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
|
|
@ -41,16 +40,6 @@ export class ProfileFamilyFatherController extends Controller {
|
|||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const familyFather = await this.ProfileFamilyFather.findOne({
|
||||
select: [
|
||||
"id",
|
||||
"fatherPrefix",
|
||||
"fatherFirstName",
|
||||
"fatherLastName",
|
||||
"fatherCareer",
|
||||
"fatherCitizenId",
|
||||
"fatherLive",
|
||||
"profileId",
|
||||
],
|
||||
where: { profileId: profile.id },
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
|
|
@ -59,20 +48,6 @@ export class ProfileFamilyFatherController extends Controller {
|
|||
}
|
||||
|
||||
@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) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||
const profile = await this.profileRepo.findOne({
|
||||
|
|
@ -83,16 +58,6 @@ export class ProfileFamilyFatherController extends Controller {
|
|||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const familyFather = await this.ProfileFamilyFather.findOne({
|
||||
select: [
|
||||
"id",
|
||||
"fatherPrefix",
|
||||
"fatherFirstName",
|
||||
"fatherLastName",
|
||||
"fatherCareer",
|
||||
"fatherCitizenId",
|
||||
"fatherLive",
|
||||
"profileId",
|
||||
],
|
||||
where: { profileId },
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
|
|
@ -142,29 +107,6 @@ export class ProfileFamilyFatherController extends Controller {
|
|||
}
|
||||
|
||||
@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) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||
const profile = await this.profileRepo.findOne({
|
||||
|
|
@ -216,12 +158,14 @@ export class ProfileFamilyFatherController extends Controller {
|
|||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id);
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id);
|
||||
familyFather.fatherCitizenId = Extension.CheckCitizen(String(body.fatherCitizenId));
|
||||
familyFather.createdUserId = req.user.sub;
|
||||
familyFather.createdFullName = req.user.name;
|
||||
familyFather.lastUpdateUserId = req.user.sub;
|
||||
familyFather.lastUpdateFullName = req.user.name;
|
||||
familyFather.createdAt = new Date();
|
||||
familyFather.lastUpdatedAt = new Date();
|
||||
|
||||
const history = new ProfileFamilyFatherHistory();
|
||||
Object.assign(history, { ...familyFather, id: undefined });
|
||||
|
|
@ -239,7 +183,7 @@ export class ProfileFamilyFatherController extends Controller {
|
|||
@Body() body: UpdateProfileFamilyFather,
|
||||
@Path() profileId: string,
|
||||
) {
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||
const familyFather = await this.ProfileFamilyFather.findOneBy({ profileId: profileId });
|
||||
if (!familyFather) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
||||
|
|
@ -251,10 +195,13 @@ export class ProfileFamilyFatherController extends Controller {
|
|||
history.profileFamilyFatherId = familyFather.id; //profileFamilyFatherId
|
||||
familyFather.lastUpdateUserId = req.user.sub;
|
||||
familyFather.lastUpdateFullName = req.user.name;
|
||||
familyFather.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.ProfileFamilyFather.save(familyFather),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
|
|
@ -41,16 +40,6 @@ export class ProfileFamilyFatherEmployeeController extends Controller {
|
|||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const familyFather = await this.ProfileFamilyFather.findOne({
|
||||
select: [
|
||||
"id",
|
||||
"fatherPrefix",
|
||||
"fatherFirstName",
|
||||
"fatherLastName",
|
||||
"fatherCareer",
|
||||
"fatherCitizenId",
|
||||
"fatherLive",
|
||||
"profileId",
|
||||
],
|
||||
where: { profileEmployeeId: profile.id },
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
|
|
@ -59,20 +48,6 @@ export class ProfileFamilyFatherEmployeeController extends Controller {
|
|||
}
|
||||
|
||||
@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) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
||||
const profile = await this.profileRepo.findOne({
|
||||
|
|
@ -82,16 +57,6 @@ export class ProfileFamilyFatherEmployeeController extends Controller {
|
|||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const familyFather = await this.ProfileFamilyFather.findOne({
|
||||
select: [
|
||||
"id",
|
||||
"fatherPrefix",
|
||||
"fatherFirstName",
|
||||
"fatherLastName",
|
||||
"fatherCareer",
|
||||
"fatherCitizenId",
|
||||
"fatherLive",
|
||||
"profileEmployeeId",
|
||||
],
|
||||
where: { profileEmployeeId },
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
|
|
@ -141,30 +106,10 @@ export class ProfileFamilyFatherEmployeeController extends Controller {
|
|||
}
|
||||
|
||||
@Get("history/{profileEmployeeId}")
|
||||
@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",
|
||||
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
||||
},
|
||||
],
|
||||
})
|
||||
public async familyFatherHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
||||
public async familyFatherHistory(
|
||||
@Path() profileEmployeeId: string,
|
||||
@Request() req: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
||||
const profile = await this.profileRepo.findOne({
|
||||
where: { id: profileEmployeeId },
|
||||
|
|
@ -221,6 +166,8 @@ export class ProfileFamilyFatherEmployeeController extends Controller {
|
|||
familyFather.createdFullName = req.user.name;
|
||||
familyFather.lastUpdateUserId = req.user.sub;
|
||||
familyFather.lastUpdateFullName = req.user.name;
|
||||
familyFather.createdAt = new Date();
|
||||
familyFather.lastUpdatedAt = new Date();
|
||||
|
||||
const history = new ProfileFamilyFatherHistory();
|
||||
Object.assign(history, { ...familyFather, id: undefined });
|
||||
|
|
@ -252,10 +199,13 @@ export class ProfileFamilyFatherEmployeeController extends Controller {
|
|||
history.profileFamilyFatherId = familyFather.id;
|
||||
familyFather.lastUpdateUserId = req.user.sub;
|
||||
familyFather.lastUpdateFullName = req.user.name;
|
||||
familyFather.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.ProfileFamilyFather.save(familyFather),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
|
|
@ -41,16 +40,6 @@ export class ProfileFamilyFatherEmployeeTempController extends Controller {
|
|||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const familyFather = await this.ProfileFamilyFather.findOne({
|
||||
select: [
|
||||
"id",
|
||||
"fatherPrefix",
|
||||
"fatherFirstName",
|
||||
"fatherLastName",
|
||||
"fatherCareer",
|
||||
"fatherCitizenId",
|
||||
"fatherLive",
|
||||
"profileId",
|
||||
],
|
||||
where: { profileEmployeeId: profile.id },
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
|
|
@ -59,20 +48,6 @@ export class ProfileFamilyFatherEmployeeTempController extends Controller {
|
|||
}
|
||||
|
||||
@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) {
|
||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||
const profile = await this.profileRepo.findOne({
|
||||
|
|
@ -83,16 +58,6 @@ export class ProfileFamilyFatherEmployeeTempController extends Controller {
|
|||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const familyFather = await this.ProfileFamilyFather.findOne({
|
||||
select: [
|
||||
"id",
|
||||
"fatherPrefix",
|
||||
"fatherFirstName",
|
||||
"fatherLastName",
|
||||
"fatherCareer",
|
||||
"fatherCitizenId",
|
||||
"fatherLive",
|
||||
"profileEmployeeId",
|
||||
],
|
||||
where: { profileEmployeeId },
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
|
|
@ -142,30 +107,10 @@ export class ProfileFamilyFatherEmployeeTempController extends Controller {
|
|||
}
|
||||
|
||||
@Get("history/{profileEmployeeId}")
|
||||
@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",
|
||||
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
||||
},
|
||||
],
|
||||
})
|
||||
public async familyFatherHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
||||
public async familyFatherHistory(
|
||||
@Path() profileEmployeeId: string,
|
||||
@Request() req: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||
const profile = await this.profileRepo.findOne({
|
||||
where: { id: profileEmployeeId },
|
||||
|
|
@ -222,6 +167,8 @@ export class ProfileFamilyFatherEmployeeTempController extends Controller {
|
|||
familyFather.createdFullName = req.user.name;
|
||||
familyFather.lastUpdateUserId = req.user.sub;
|
||||
familyFather.lastUpdateFullName = req.user.name;
|
||||
familyFather.createdAt = new Date();
|
||||
familyFather.lastUpdatedAt = new Date();
|
||||
|
||||
const history = new ProfileFamilyFatherHistory();
|
||||
Object.assign(history, { ...familyFather, id: undefined });
|
||||
|
|
@ -253,10 +200,13 @@ export class ProfileFamilyFatherEmployeeTempController extends Controller {
|
|||
history.profileFamilyFatherId = familyFather.id;
|
||||
familyFather.lastUpdateUserId = req.user.sub;
|
||||
familyFather.lastUpdateFullName = req.user.name;
|
||||
familyFather.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.ProfileFamilyFather.save(familyFather),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
|
|
@ -41,16 +40,6 @@ export class ProfileFamilyMotherController extends Controller {
|
|||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const familyMother = await this.ProfileFamilyMother.findOne({
|
||||
select: [
|
||||
"id",
|
||||
"motherPrefix",
|
||||
"motherFirstName",
|
||||
"motherLastName",
|
||||
"motherCareer",
|
||||
"motherCitizenId",
|
||||
"motherLive",
|
||||
"profileId",
|
||||
],
|
||||
where: { profileId: profile.id },
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
|
|
@ -59,20 +48,6 @@ export class ProfileFamilyMotherController extends Controller {
|
|||
}
|
||||
|
||||
@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) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||
const profile = await this.profileRepo.findOne({
|
||||
|
|
@ -83,16 +58,6 @@ export class ProfileFamilyMotherController extends Controller {
|
|||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const familyMother = await this.ProfileFamilyMother.findOne({
|
||||
select: [
|
||||
"id",
|
||||
"motherPrefix",
|
||||
"motherFirstName",
|
||||
"motherLastName",
|
||||
"motherCareer",
|
||||
"motherCitizenId",
|
||||
"motherLive",
|
||||
"profileId",
|
||||
],
|
||||
where: { profileId },
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
|
|
@ -142,29 +107,6 @@ export class ProfileFamilyMotherController extends Controller {
|
|||
}
|
||||
|
||||
@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) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||
const profile = await this.profileRepo.findOne({
|
||||
|
|
@ -215,12 +157,14 @@ export class ProfileFamilyMotherController extends Controller {
|
|||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id);
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id);
|
||||
familyMother.motherCitizenId = Extension.CheckCitizen(String(body.motherCitizenId));
|
||||
familyMother.createdUserId = req.user.sub;
|
||||
familyMother.createdFullName = req.user.name;
|
||||
familyMother.lastUpdateUserId = req.user.sub;
|
||||
familyMother.lastUpdateFullName = req.user.name;
|
||||
familyMother.createdAt = new Date();
|
||||
familyMother.lastUpdatedAt = new Date();
|
||||
|
||||
const history = new ProfileFamilyMotherHistory();
|
||||
Object.assign(history, { ...familyMother, id: undefined });
|
||||
|
|
@ -238,7 +182,7 @@ export class ProfileFamilyMotherController extends Controller {
|
|||
@Body() body: UpdateProfileFamilyMother,
|
||||
@Path() profileId: string,
|
||||
) {
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||
const familyMother = await this.ProfileFamilyMother.findOneBy({ profileId: profileId });
|
||||
if (!familyMother) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
||||
|
|
@ -250,10 +194,13 @@ export class ProfileFamilyMotherController extends Controller {
|
|||
history.profileFamilyMotherId = familyMother.id;
|
||||
familyMother.lastUpdateUserId = req.user.sub;
|
||||
familyMother.lastUpdateFullName = req.user.name;
|
||||
familyMother.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.ProfileFamilyMother.save(familyMother),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
|
|
@ -41,16 +40,6 @@ export class ProfileFamilyMotherEmployeeController extends Controller {
|
|||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const familyMother = await this.ProfileFamilyMother.findOne({
|
||||
select: [
|
||||
"id",
|
||||
"motherPrefix",
|
||||
"motherFirstName",
|
||||
"motherLastName",
|
||||
"motherCareer",
|
||||
"motherCitizenId",
|
||||
"motherLive",
|
||||
"profileId",
|
||||
],
|
||||
where: { profileEmployeeId: profile.id },
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
|
|
@ -59,20 +48,6 @@ export class ProfileFamilyMotherEmployeeController extends Controller {
|
|||
}
|
||||
|
||||
@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) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
||||
const profile = await this.profileRepo.findOne({
|
||||
|
|
@ -83,16 +58,6 @@ export class ProfileFamilyMotherEmployeeController extends Controller {
|
|||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const familyMother = await this.ProfileFamilyMother.findOne({
|
||||
select: [
|
||||
"id",
|
||||
"motherPrefix",
|
||||
"motherFirstName",
|
||||
"motherLastName",
|
||||
"motherCareer",
|
||||
"motherCitizenId",
|
||||
"motherLive",
|
||||
"profileEmployeeId",
|
||||
],
|
||||
where: { profileEmployeeId },
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
|
|
@ -142,30 +107,10 @@ export class ProfileFamilyMotherEmployeeController extends Controller {
|
|||
}
|
||||
|
||||
@Get("history/{profileEmployeeId}")
|
||||
@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",
|
||||
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
||||
},
|
||||
],
|
||||
})
|
||||
public async familyMotherHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
||||
public async familyMotherHistory(
|
||||
@Path() profileEmployeeId: string,
|
||||
@Request() req: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
||||
const profile = await this.profileRepo.findOne({
|
||||
where: { id: profileEmployeeId },
|
||||
|
|
@ -221,6 +166,8 @@ export class ProfileFamilyMotherEmployeeController extends Controller {
|
|||
familyMother.createdFullName = req.user.name;
|
||||
familyMother.lastUpdateUserId = req.user.sub;
|
||||
familyMother.lastUpdateFullName = req.user.name;
|
||||
familyMother.createdAt = new Date();
|
||||
familyMother.lastUpdatedAt = new Date();
|
||||
|
||||
const history = new ProfileFamilyMotherHistory();
|
||||
Object.assign(history, { ...familyMother, id: undefined });
|
||||
|
|
@ -252,10 +199,13 @@ export class ProfileFamilyMotherEmployeeController extends Controller {
|
|||
history.profileFamilyMotherId = familyMother.id;
|
||||
familyMother.lastUpdateUserId = req.user.sub;
|
||||
familyMother.lastUpdateFullName = req.user.name;
|
||||
familyMother.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.ProfileFamilyMother.save(familyMother),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
|
|
@ -41,16 +40,6 @@ export class ProfileFamilyMotherEmployeeTempController extends Controller {
|
|||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const familyMother = await this.ProfileFamilyMother.findOne({
|
||||
select: [
|
||||
"id",
|
||||
"motherPrefix",
|
||||
"motherFirstName",
|
||||
"motherLastName",
|
||||
"motherCareer",
|
||||
"motherCitizenId",
|
||||
"motherLive",
|
||||
"profileId",
|
||||
],
|
||||
where: { profileEmployeeId: profile.id },
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
|
|
@ -59,20 +48,6 @@ export class ProfileFamilyMotherEmployeeTempController extends Controller {
|
|||
}
|
||||
|
||||
@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) {
|
||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||
const profile = await this.profileRepo.findOne({
|
||||
|
|
@ -83,16 +58,6 @@ export class ProfileFamilyMotherEmployeeTempController extends Controller {
|
|||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const familyMother = await this.ProfileFamilyMother.findOne({
|
||||
select: [
|
||||
"id",
|
||||
"motherPrefix",
|
||||
"motherFirstName",
|
||||
"motherLastName",
|
||||
"motherCareer",
|
||||
"motherCitizenId",
|
||||
"motherLive",
|
||||
"profileEmployeeId",
|
||||
],
|
||||
where: { profileEmployeeId },
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
|
|
@ -142,30 +107,10 @@ export class ProfileFamilyMotherEmployeeTempController extends Controller {
|
|||
}
|
||||
|
||||
@Get("history/{profileEmployeeId}")
|
||||
@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",
|
||||
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
||||
},
|
||||
],
|
||||
})
|
||||
public async familyMotherHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
||||
public async familyMotherHistory(
|
||||
@Path() profileEmployeeId: string,
|
||||
@Request() req: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||
const profile = await this.profileRepo.findOne({
|
||||
where: { id: profileEmployeeId },
|
||||
|
|
@ -222,6 +167,8 @@ export class ProfileFamilyMotherEmployeeTempController extends Controller {
|
|||
familyMother.createdFullName = req.user.name;
|
||||
familyMother.lastUpdateUserId = req.user.sub;
|
||||
familyMother.lastUpdateFullName = req.user.name;
|
||||
familyMother.createdAt = new Date();
|
||||
familyMother.lastUpdatedAt = new Date();
|
||||
|
||||
const history = new ProfileFamilyMotherHistory();
|
||||
Object.assign(history, { ...familyMother, id: undefined });
|
||||
|
|
@ -253,10 +200,13 @@ export class ProfileFamilyMotherEmployeeTempController extends Controller {
|
|||
history.profileFamilyMotherId = familyMother.id;
|
||||
familyMother.lastUpdateUserId = req.user.sub;
|
||||
familyMother.lastUpdateFullName = req.user.name;
|
||||
familyMother.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.ProfileFamilyMother.save(familyMother),
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ export class ProfileGovernmentHistoryController extends Controller {
|
|||
public async getGovHistoryUser(@Request() request: { user: Record<string, any> }) {
|
||||
const orgRevision = await this.orgRevisionRepository.findOne({
|
||||
select: ["id"],
|
||||
where: {
|
||||
where: {
|
||||
orgRevisionIsDraft: false,
|
||||
orgRevisionIsCurrent: true,
|
||||
},
|
||||
|
|
@ -141,7 +141,7 @@ export class ProfileGovernmentHistoryController extends Controller {
|
|||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||
const orgRevision = await this.orgRevisionRepository.findOne({
|
||||
select: ["id"],
|
||||
where: {
|
||||
where: {
|
||||
orgRevisionIsDraft: false,
|
||||
orgRevisionIsCurrent: true,
|
||||
},
|
||||
|
|
@ -242,7 +242,7 @@ export class ProfileGovernmentHistoryController extends Controller {
|
|||
public async getGovHistoryAdmin(@Path() profileId: string) {
|
||||
const orgRevision = await this.orgRevisionRepository.findOne({
|
||||
select: ["id"],
|
||||
where: {
|
||||
where: {
|
||||
orgRevisionIsDraft: false,
|
||||
orgRevisionIsCurrent: true,
|
||||
},
|
||||
|
|
@ -389,15 +389,18 @@ export class ProfileGovernmentHistoryController extends Controller {
|
|||
const history = new ProfileGovernment();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileId = profileId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([this.profileRepo.save(record), this.govRepo.save(history)]);
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
|||
public async getGovHistoryUser(@Request() request: { user: Record<string, any> }) {
|
||||
const orgRevision = await this.orgRevisionRepository.findOne({
|
||||
select: ["id"],
|
||||
where: {
|
||||
where: {
|
||||
orgRevisionIsDraft: false,
|
||||
orgRevisionIsCurrent: true,
|
||||
},
|
||||
|
|
@ -147,7 +147,7 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
|||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
||||
const orgRevision = await this.orgRevisionRepository.findOne({
|
||||
select: ["id"],
|
||||
where: {
|
||||
where: {
|
||||
orgRevisionIsDraft: false,
|
||||
orgRevisionIsCurrent: true,
|
||||
},
|
||||
|
|
@ -238,7 +238,7 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
|||
public async getGovHistoryAdmin(@Path() profileEmployeeId: string) {
|
||||
const orgRevision = await this.orgRevisionRepository.findOne({
|
||||
select: ["id"],
|
||||
where: {
|
||||
where: {
|
||||
orgRevisionIsDraft: false,
|
||||
orgRevisionIsCurrent: true,
|
||||
},
|
||||
|
|
@ -343,7 +343,7 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
|||
@Get("history/{profileEmployeeId}")
|
||||
@Example({})
|
||||
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({
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
where: { profileEmployeeId: profileEmployeeId },
|
||||
|
|
@ -362,7 +362,7 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
|||
@Body() body: UpdateProfileGovernment,
|
||||
@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({
|
||||
where: { id: profileEmployeeId },
|
||||
});
|
||||
|
|
@ -371,15 +371,18 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
|||
const history = new ProfileGovernment();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileEmployeeId = profileEmployeeId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([this.profileEmployeeRepo.save(record), this.govRepo.save(history)]);
|
||||
return new HttpSuccess();
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ export class ProfileGovernmentEmployeeTempController extends Controller {
|
|||
public async getGovHistoryUser(@Request() request: { user: Record<string, any> }) {
|
||||
const orgRevision = await this.orgRevisionRepository.findOne({
|
||||
select: ["id"],
|
||||
where: {
|
||||
where: {
|
||||
orgRevisionIsDraft: false,
|
||||
orgRevisionIsCurrent: true,
|
||||
},
|
||||
|
|
@ -147,7 +147,7 @@ export class ProfileGovernmentEmployeeTempController extends Controller {
|
|||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||
const orgRevision = await this.orgRevisionRepository.findOne({
|
||||
select: ["id"],
|
||||
where: {
|
||||
where: {
|
||||
orgRevisionIsDraft: false,
|
||||
orgRevisionIsCurrent: true,
|
||||
},
|
||||
|
|
@ -239,7 +239,7 @@ export class ProfileGovernmentEmployeeTempController extends Controller {
|
|||
public async getGovHistoryAdmin(@Path() profileEmployeeId: string) {
|
||||
const orgRevision = await this.orgRevisionRepository.findOne({
|
||||
select: ["id"],
|
||||
where: {
|
||||
where: {
|
||||
orgRevisionIsDraft: false,
|
||||
orgRevisionIsCurrent: true,
|
||||
},
|
||||
|
|
@ -372,15 +372,18 @@ export class ProfileGovernmentEmployeeTempController extends Controller {
|
|||
const history = new ProfileGovernment();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileEmployeeId = profileEmployeeId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([this.profileEmployeeRepo.save(record), this.govRepo.save(history)]);
|
||||
return new HttpSuccess();
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {
|
|||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
Path,
|
||||
|
|
@ -37,36 +36,18 @@ export class ProfileHonorController extends Controller {
|
|||
}
|
||||
const record = await this.honorRepo.find({
|
||||
where: { profileId: profile.id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
||||
@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) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
@ -87,56 +68,22 @@ export class ProfileHonorController extends Controller {
|
|||
profileId: profile.id,
|
||||
},
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
||||
@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) {
|
||||
const _record = await this.honorRepo.findOneBy({ id: honorId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
||||
}
|
||||
const record = await this.honorHistoryRepo.findBy({
|
||||
profileHonorId: honorId,
|
||||
const _record = await this.honorRepo.findOneBy({ id: honorId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
||||
}
|
||||
const record = await this.honorHistoryRepo.find({
|
||||
where: {
|
||||
profileHonorId: honorId,
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
|
@ -146,9 +93,9 @@ export class ProfileHonorController extends Controller {
|
|||
if (!body.profileId) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
|
||||
}
|
||||
|
||||
|
||||
const profile = await this.profileRepo.findOneBy({ id: body.profileId });
|
||||
|
||||
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
|
|
@ -161,6 +108,8 @@ export class ProfileHonorController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -187,15 +136,18 @@ export class ProfileHonorController extends Controller {
|
|||
const history = new ProfileHonorHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileHonorId = honorId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([this.honorRepo.save(record), this.honorHistoryRepo.save(history)]);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {
|
|||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
Path,
|
||||
|
|
@ -41,36 +40,18 @@ export class ProfileHonorEmployeeController extends Controller {
|
|||
}
|
||||
const record = await this.honorRepo.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
||||
@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) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
@ -91,57 +72,27 @@ export class ProfileHonorEmployeeController extends Controller {
|
|||
profileEmployeeId: profile.id,
|
||||
},
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
||||
@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) {
|
||||
const _record = await this.honorRepo.findOneBy({ id: honorId });
|
||||
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({
|
||||
profileHonorId: honorId,
|
||||
const record = await this.honorHistoryRepo.find({
|
||||
where: {
|
||||
profileHonorId: honorId,
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
|
@ -165,6 +116,8 @@ export class ProfileHonorEmployeeController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -186,20 +139,27 @@ export class ProfileHonorEmployeeController extends Controller {
|
|||
) {
|
||||
const record = await this.honorRepo.findOneBy({ id: honorId });
|
||||
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();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileHonorId = honorId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([this.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) {
|
||||
const _record = await this.honorRepo.findOneBy({ id: honorId });
|
||||
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({
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {
|
|||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
Path,
|
||||
|
|
@ -41,36 +40,18 @@ export class ProfileHonorEmployeeTempController extends Controller {
|
|||
}
|
||||
const record = await this.honorRepo.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
||||
@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) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
@ -91,53 +72,19 @@ export class ProfileHonorEmployeeTempController extends Controller {
|
|||
profileEmployeeId: profile.id,
|
||||
},
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
||||
@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) {
|
||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||
const record = await this.honorHistoryRepo.findBy({
|
||||
profileHonorId: honorId,
|
||||
const record = await this.honorHistoryRepo.find({
|
||||
where: {
|
||||
profileHonorId: honorId,
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
|
@ -162,6 +109,8 @@ export class ProfileHonorEmployeeTempController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -189,15 +138,18 @@ export class ProfileHonorEmployeeTempController extends Controller {
|
|||
const history = new ProfileHonorHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileHonorId = honorId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([this.honorRepo.save(record), this.honorHistoryRepo.save(history)]);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {
|
|||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
Path,
|
||||
|
|
@ -48,41 +47,12 @@ export class ProfileInsigniaController extends Controller {
|
|||
},
|
||||
},
|
||||
where: { profileId: profile.id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
||||
@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) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||
const record = await this.insigniaRepo.find({
|
||||
|
|
@ -92,70 +62,17 @@ export class ProfileInsigniaController extends Controller {
|
|||
},
|
||||
},
|
||||
where: { profileId },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
||||
@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) {
|
||||
const _record = await this.insigniaRepo.findOneBy({ id: InsigniaId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
||||
}
|
||||
const _record = await this.insigniaRepo.findOneBy({ id: InsigniaId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
||||
}
|
||||
const record = await this.insigniaHistoryRepo.find({
|
||||
relations: {
|
||||
insignia: {
|
||||
|
|
@ -165,6 +82,7 @@ export class ProfileInsigniaController extends Controller {
|
|||
where: {
|
||||
profileInsigniaId: InsigniaId,
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
|
@ -174,7 +92,7 @@ export class ProfileInsigniaController extends Controller {
|
|||
if (!body.profileId) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
|
||||
}
|
||||
|
||||
|
||||
const profile = await this.profileRepo.findOneBy({ id: body.profileId });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
|
|
@ -195,6 +113,8 @@ export class ProfileInsigniaController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -228,15 +148,18 @@ export class ProfileInsigniaController extends Controller {
|
|||
const history = new ProfileInsigniaHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileInsigniaId = insigniaId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([this.insigniaRepo.save(record), this.insigniaHistoryRepo.save(history)]);
|
||||
|
||||
|
|
@ -247,14 +170,18 @@ export class ProfileInsigniaController extends Controller {
|
|||
public async deleteInsignia(@Path() insigniaId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.insigniaRepo.findOneBy({ id: insigniaId });
|
||||
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({
|
||||
profileInsigniaId: insigniaId,
|
||||
});
|
||||
|
||||
|
||||
const result = await this.insigniaRepo.delete({ id: insigniaId });
|
||||
|
||||
|
||||
if (result.affected == undefined || result.affected <= 0) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
|
@ -291,6 +218,8 @@ export class ProfileInsigniaController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {
|
|||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
Path,
|
||||
|
|
@ -48,41 +47,12 @@ export class ProfileInsigniaEmployeeController extends Controller {
|
|||
},
|
||||
},
|
||||
where: { profileEmployeeId: profile.id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
||||
@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) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
||||
const record = await this.insigniaRepo.find({
|
||||
|
|
@ -92,69 +62,20 @@ export class ProfileInsigniaEmployeeController extends Controller {
|
|||
},
|
||||
},
|
||||
where: { profileEmployeeId },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
||||
@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) {
|
||||
const _record = await this.insigniaRepo.findOneBy({ id: InsigniaId });
|
||||
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({
|
||||
relations: {
|
||||
|
|
@ -165,6 +86,7 @@ export class ProfileInsigniaEmployeeController extends Controller {
|
|||
where: {
|
||||
profileInsigniaId: InsigniaId,
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
|
@ -182,7 +104,7 @@ export class ProfileInsigniaEmployeeController extends Controller {
|
|||
if (!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({
|
||||
where: { id: body.insigniaId },
|
||||
|
|
@ -198,6 +120,8 @@ export class ProfileInsigniaEmployeeController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -219,7 +143,11 @@ export class ProfileInsigniaEmployeeController extends Controller {
|
|||
) {
|
||||
const record = await this.insigniaRepo.findOneBy({ id: insigniaId });
|
||||
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({
|
||||
where: { id: body.insigniaId },
|
||||
|
|
@ -231,15 +159,18 @@ export class ProfileInsigniaEmployeeController extends Controller {
|
|||
const history = new ProfileInsigniaHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileInsigniaId = insigniaId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([this.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) {
|
||||
const _record = await this.insigniaRepo.findOneBy({ id: insigniaId });
|
||||
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({
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {
|
|||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
Path,
|
||||
|
|
@ -48,41 +47,12 @@ export class ProfileInsigniaEmployeeTempController extends Controller {
|
|||
},
|
||||
},
|
||||
where: { profileEmployeeId: profile.id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
||||
@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) {
|
||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||
const record = await this.insigniaRepo.find({
|
||||
|
|
@ -92,65 +62,12 @@ export class ProfileInsigniaEmployeeTempController extends Controller {
|
|||
},
|
||||
},
|
||||
where: { profileEmployeeId },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
||||
@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) {
|
||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||
const record = await this.insigniaHistoryRepo.find({
|
||||
|
|
@ -162,6 +79,7 @@ export class ProfileInsigniaEmployeeTempController extends Controller {
|
|||
where: {
|
||||
profileInsigniaId: InsigniaId,
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
|
@ -196,6 +114,8 @@ export class ProfileInsigniaEmployeeTempController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -230,15 +150,18 @@ export class ProfileInsigniaEmployeeTempController extends Controller {
|
|||
const history = new ProfileInsigniaHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileInsigniaId = insigniaId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([this.insigniaRepo.save(record), this.insigniaHistoryRepo.save(history)]);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {
|
|||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
Path,
|
||||
|
|
@ -25,7 +24,6 @@ import HttpError from "../interfaces/http-error";
|
|||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { Profile } from "../entities/Profile";
|
||||
import { LeaveType } from "../entities/LeaveType";
|
||||
import { Brackets } from "typeorm";
|
||||
import permission from "../interfaces/permission";
|
||||
@Route("api/v1/org/profile/leave")
|
||||
@Tags("ProfileLeave")
|
||||
|
|
@ -121,50 +119,18 @@ export class ProfileLeaveController extends Controller {
|
|||
const record = await this.leaveRepo.find({
|
||||
relations: { leaveType: true },
|
||||
where: { profileId: profile.id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
||||
@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) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||
const record = await this.leaveRepo.find({
|
||||
relations: { leaveType: true },
|
||||
where: { profileId },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
|
@ -175,87 +141,21 @@ export class ProfileLeaveController extends Controller {
|
|||
const record = await this.leaveRepo.find({
|
||||
relations: { leaveType: true },
|
||||
where: { profileId },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
||||
@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) {
|
||||
const _record = await this.leaveRepo.findOneBy({ id: leaveId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
||||
}
|
||||
const _record = await this.leaveRepo.findOneBy({ id: leaveId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
||||
}
|
||||
const record = await this.leaveHistoryRepo.find({
|
||||
relations: { leaveType: true },
|
||||
where: { profileLeaveId: leaveId },
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
|
@ -286,6 +186,8 @@ export class ProfileLeaveController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -319,15 +221,18 @@ export class ProfileLeaveController extends Controller {
|
|||
const history = new ProfileLeaveHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileLeaveId = leaveId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([this.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) {
|
||||
const _record = await this.leaveRepo.findOneBy({ id: leaveId });
|
||||
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({
|
||||
profileLeaveId: leaveId,
|
||||
|
|
@ -378,6 +287,8 @@ export class ProfileLeaveController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {
|
|||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
Path,
|
||||
|
|
@ -44,6 +43,7 @@ export class ProfileLeaveEmployeeController extends Controller {
|
|||
const record = await this.leaveRepo.find({
|
||||
relations: { leaveType: true },
|
||||
where: { profileEmployeeId: profile.id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
|
@ -54,6 +54,7 @@ export class ProfileLeaveEmployeeController extends Controller {
|
|||
const record = await this.leaveRepo.find({
|
||||
relations: { leaveType: true },
|
||||
where: { profileEmployeeId: profileId },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
|
@ -64,6 +65,7 @@ export class ProfileLeaveEmployeeController extends Controller {
|
|||
const record = await this.leaveRepo.find({
|
||||
relations: { leaveType: true },
|
||||
where: { profileEmployeeId: profileId },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
|
@ -72,18 +74,22 @@ export class ProfileLeaveEmployeeController extends Controller {
|
|||
public async leaveHistory(@Path() leaveId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.leaveRepo.findOneBy({ id: leaveId });
|
||||
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({
|
||||
relations: { leaveType: true },
|
||||
where: { profileLeaveId: leaveId },
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
||||
@Post()
|
||||
public async newLeave(@Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeLeave) {
|
||||
|
||||
if (!body.profileEmployeeId) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
|
||||
}
|
||||
|
|
@ -108,6 +114,8 @@ export class ProfileLeaveEmployeeController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -129,7 +137,11 @@ export class ProfileLeaveEmployeeController extends Controller {
|
|||
) {
|
||||
const record = await this.leaveRepo.findOneBy({ id: leaveId });
|
||||
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({
|
||||
where: { id: body.leaveTypeId },
|
||||
|
|
@ -141,15 +153,18 @@ export class ProfileLeaveEmployeeController extends Controller {
|
|||
const history = new ProfileLeaveHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileLeaveId = leaveId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([this.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) {
|
||||
const _record = await this.leaveRepo.findOneBy({ id: leaveId });
|
||||
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({
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {
|
|||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
Path,
|
||||
|
|
@ -44,6 +43,7 @@ export class ProfileLeaveEmployeeTempController extends Controller {
|
|||
const record = await this.leaveRepo.find({
|
||||
relations: { leaveType: true },
|
||||
where: { profileEmployeeId: profile.id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
|
@ -54,6 +54,7 @@ export class ProfileLeaveEmployeeTempController extends Controller {
|
|||
const record = await this.leaveRepo.find({
|
||||
relations: { leaveType: true },
|
||||
where: { profileEmployeeId: profileId },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
|
@ -64,6 +65,7 @@ export class ProfileLeaveEmployeeTempController extends Controller {
|
|||
const record = await this.leaveRepo.find({
|
||||
relations: { leaveType: true },
|
||||
where: { profileEmployeeId: profileId },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
|
@ -74,6 +76,7 @@ export class ProfileLeaveEmployeeTempController extends Controller {
|
|||
const record = await this.leaveHistoryRepo.find({
|
||||
relations: { leaveType: true },
|
||||
where: { profileLeaveId: leaveId },
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
|
@ -104,6 +107,8 @@ export class ProfileLeaveEmployeeTempController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -138,15 +143,18 @@ export class ProfileLeaveEmployeeTempController extends Controller {
|
|||
const history = new ProfileLeaveHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileLeaveId = leaveId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([this.leaveRepo.save(record), this.leaveHistoryRepo.save(history)]);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {
|
|||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
Path,
|
||||
|
|
@ -37,61 +36,27 @@ export class ProfileNopaidController extends Controller {
|
|||
}
|
||||
const lists = await this.nopaidRepository.find({
|
||||
where: { profileId: profile.id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
||||
@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) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||
const lists = await this.nopaidRepository.find({
|
||||
where: { profileId },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
||||
@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) {
|
||||
const _record = await this.nopaidRepository.findOneBy({ id: nopaidId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
||||
};
|
||||
const _record = await this.nopaidRepository.findOneBy({ id: nopaidId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
||||
}
|
||||
const record = await this.nopaidHistoryRepository.find({
|
||||
where: { profileNopaidId: nopaidId },
|
||||
order: { createdAt: "DESC" },
|
||||
|
|
@ -104,7 +69,7 @@ export class ProfileNopaidController extends Controller {
|
|||
if (!body.profileId) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
|
||||
}
|
||||
|
||||
|
||||
const profile = await this.profileRepository.findOneBy({ id: body.profileId });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
|
|
@ -118,6 +83,8 @@ export class ProfileNopaidController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -144,15 +111,18 @@ export class ProfileNopaidController extends Controller {
|
|||
const history = new ProfileNopaidHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileNopaidId = nopaidId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.nopaidRepository.save(record),
|
||||
|
|
@ -166,7 +136,11 @@ export class ProfileNopaidController extends Controller {
|
|||
public async deleteNopaid(@Path() nopaidId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.nopaidRepository.findOneBy({ id: nopaidId });
|
||||
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({
|
||||
profileNopaidId: nopaidId,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {
|
|||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
Path,
|
||||
|
|
@ -41,20 +40,24 @@ export class ProfileNopaidEmployeeController extends Controller {
|
|||
}
|
||||
const lists = await this.nopaidRepository.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
||||
@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({
|
||||
where: { profileEmployeeId: profileId },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
||||
@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({
|
||||
where: { profileNopaidId: nopaidId },
|
||||
order: { createdAt: "DESC" },
|
||||
|
|
@ -67,7 +70,6 @@ export class ProfileNopaidEmployeeController extends Controller {
|
|||
@Request() req: RequestWithUser,
|
||||
@Body() body: CreateProfileEmployeeNopaid,
|
||||
) {
|
||||
|
||||
if (!body.profileEmployeeId) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
|
||||
}
|
||||
|
|
@ -85,6 +87,8 @@ export class ProfileNopaidEmployeeController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -106,20 +110,27 @@ export class ProfileNopaidEmployeeController extends Controller {
|
|||
) {
|
||||
const record = await this.nopaidRepository.findOneBy({ id: nopaidId });
|
||||
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();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileNopaidId = nopaidId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.nopaidRepository.save(record),
|
||||
|
|
@ -133,7 +144,11 @@ export class ProfileNopaidEmployeeController extends Controller {
|
|||
public async deleteNopaid(@Path() nopaidId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.nopaidRepository.findOneBy({ id: nopaidId });
|
||||
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({
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {
|
|||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
Path,
|
||||
|
|
@ -41,6 +40,7 @@ export class ProfileNopaidEmployeeTempController extends Controller {
|
|||
}
|
||||
const lists = await this.nopaidRepository.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
|
@ -50,6 +50,7 @@ export class ProfileNopaidEmployeeTempController extends Controller {
|
|||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||
const lists = await this.nopaidRepository.find({
|
||||
where: { profileEmployeeId: profileId },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
|
@ -87,6 +88,8 @@ export class ProfileNopaidEmployeeTempController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -114,15 +117,18 @@ export class ProfileNopaidEmployeeTempController extends Controller {
|
|||
const history = new ProfileNopaidHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileNopaidId = nopaidId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.nopaidRepository.save(record),
|
||||
|
|
|
|||
|
|
@ -37,53 +37,22 @@ export class ProfileOtherController extends Controller {
|
|||
}
|
||||
const lists = await this.otherRepository.find({
|
||||
where: { profileId: profile.id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
||||
@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) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||
const lists = await this.otherRepository.find({
|
||||
where: { profileId: profileId },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
||||
@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) {
|
||||
// const _record = await this.otherRepository.findOneBy({ id: otherId });
|
||||
// if (_record) {
|
||||
|
|
@ -101,7 +70,7 @@ export class ProfileOtherController extends Controller {
|
|||
if (!body.profileId) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
|
||||
}
|
||||
|
||||
|
||||
const profile = await this.profileRepository.findOneBy({ id: body.profileId });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
|
|
@ -115,6 +84,8 @@ export class ProfileOtherController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -141,15 +112,18 @@ export class ProfileOtherController extends Controller {
|
|||
const history = new ProfileOtherHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileOtherId = otherId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.otherRepository.save(record),
|
||||
|
|
@ -161,10 +135,14 @@ export class ProfileOtherController extends Controller {
|
|||
|
||||
@Delete("{otherId}")
|
||||
public async deleteOther(@Path() otherId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.otherRepository.findOneBy({ id: otherId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
||||
}
|
||||
const _record = await this.otherRepository.findOneBy({ id: otherId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserDelete(
|
||||
req,
|
||||
"SYS_REGISTRY_OFFICER",
|
||||
_record.profileId,
|
||||
);
|
||||
}
|
||||
await this.otherHistoryRepository.delete({
|
||||
profileOtherId: otherId,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {
|
|||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
Path,
|
||||
|
|
@ -41,6 +40,7 @@ export class ProfileOtherEmployeeController extends Controller {
|
|||
}
|
||||
const lists = await this.otherRepository.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
|
@ -50,6 +50,7 @@ export class ProfileOtherEmployeeController extends Controller {
|
|||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId);
|
||||
const lists = await this.otherRepository.find({
|
||||
where: { profileEmployeeId: profileId },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
|
@ -58,7 +59,11 @@ export class ProfileOtherEmployeeController extends Controller {
|
|||
public async otherHistory(@Path() otherId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.otherRepository.findOneBy({ id: otherId });
|
||||
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({
|
||||
where: { profileOtherId: otherId },
|
||||
|
|
@ -86,6 +91,8 @@ export class ProfileOtherEmployeeController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -105,23 +112,29 @@ export class ProfileOtherEmployeeController extends Controller {
|
|||
@Body() body: UpdateProfileOther,
|
||||
@Path() otherId: string,
|
||||
) {
|
||||
|
||||
const record = await this.otherRepository.findOneBy({ id: otherId });
|
||||
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();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileOtherId = otherId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.otherRepository.save(record),
|
||||
|
|
@ -135,7 +148,11 @@ export class ProfileOtherEmployeeController extends Controller {
|
|||
public async deleteOther(@Path() otherId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.otherRepository.findOneBy({ id: otherId });
|
||||
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({
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ export class ProfileOtherEmployeeTempController extends Controller {
|
|||
}
|
||||
const lists = await this.otherRepository.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
|
@ -50,6 +51,7 @@ export class ProfileOtherEmployeeTempController extends Controller {
|
|||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||
const lists = await this.otherRepository.find({
|
||||
where: { profileEmployeeId: profileId },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
|
@ -84,6 +86,8 @@ export class ProfileOtherEmployeeTempController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -111,15 +115,18 @@ export class ProfileOtherEmployeeTempController extends Controller {
|
|||
const history = new ProfileOtherHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileOtherId = otherId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.otherRepository.save(record),
|
||||
|
|
|
|||
|
|
@ -44,34 +44,6 @@ export class ProfileSalaryController extends Controller {
|
|||
}
|
||||
|
||||
@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) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||
const record = await this.salaryRepo.find({
|
||||
|
|
@ -92,63 +64,16 @@ export class ProfileSalaryController extends Controller {
|
|||
}
|
||||
|
||||
@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) {
|
||||
// const _record = await this.salaryRepo.findOneBy({ id: salaryId });
|
||||
// if (_record) {
|
||||
// await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
||||
// }
|
||||
const record = await this.salaryHistoryRepo.findBy({
|
||||
profileSalaryId: salaryId,
|
||||
// }
|
||||
const record = await this.salaryHistoryRepo.find({
|
||||
where: {
|
||||
profileSalaryId: salaryId,
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
|
@ -158,7 +83,7 @@ export class ProfileSalaryController extends Controller {
|
|||
if (!body.profileId) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
|
||||
}
|
||||
|
||||
|
||||
const profile = await this.profileRepo.findOneBy({ id: body.profileId });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
|
|
@ -178,6 +103,8 @@ export class ProfileSalaryController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -200,19 +127,22 @@ export class ProfileSalaryController extends Controller {
|
|||
const record = await this.salaryRepo.findOneBy({ id: salaryId });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", record.profileId);
|
||||
|
||||
|
||||
const history = new ProfileSalaryHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileSalaryId = salaryId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([this.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) {
|
||||
const _record = await this.salaryRepo.findOneBy({ id: salaryId });
|
||||
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({
|
||||
profileSalaryId: salaryId,
|
||||
|
|
@ -239,7 +173,11 @@ export class ProfileSalaryController extends Controller {
|
|||
}
|
||||
|
||||
@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 } });
|
||||
// if (source_item) {
|
||||
// await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", source_item.profileId);//ไม่แน่ใจOFFปิดไว้ก่อน
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {
|
|||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
Path,
|
||||
|
|
@ -49,10 +48,7 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
|
||||
@Get("{profileId}")
|
||||
public async getSalaryEmployee(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||
// const _record = await this.salaryRepo.findOneBy({ id: profileId });
|
||||
// if (_record) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId);
|
||||
// }
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId);
|
||||
const record = await this.salaryRepo.find({
|
||||
where: { profileEmployeeId: profileId },
|
||||
order: { order: "ASC" },
|
||||
|
|
@ -63,10 +59,6 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
@Get("admin/{profileId}")
|
||||
public async getSalaryEmployeeAdmin(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||
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({
|
||||
where: { profileEmployeeId: profileId },
|
||||
order: { order: "ASC" },
|
||||
|
|
@ -78,10 +70,17 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
public async salaryHistory(@Path() salaryId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.salaryRepo.findOneBy({ id: salaryId });
|
||||
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({
|
||||
profileSalaryId: salaryId,
|
||||
const record = await this.salaryHistoryRepo.find({
|
||||
where: {
|
||||
profileSalaryId: salaryId,
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
|
@ -114,6 +113,8 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -133,23 +134,29 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
@Body() body: UpdateProfileSalaryEmployee,
|
||||
@Path() salaryId: string,
|
||||
) {
|
||||
|
||||
const record = await this.salaryRepo.findOneBy({ id: salaryId });
|
||||
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();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileSalaryId = salaryId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([this.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) {
|
||||
const _record = await this.salaryRepo.findOneBy({ id: salaryId });
|
||||
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({
|
||||
|
|
@ -177,10 +188,18 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
}
|
||||
|
||||
@Get("swap/{direction}/{salaryId}")
|
||||
public async swapSalaryEmployee(@Path() direction: string, salaryId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.salaryRepo.findOneBy({ id: salaryId });
|
||||
public async swapSalaryEmployee(
|
||||
@Path() direction: string,
|
||||
salaryId: string,
|
||||
@Request() req: RequestWithUser,
|
||||
) {
|
||||
const _record = await this.salaryRepo.findOneBy({ id: salaryId });
|
||||
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 } });
|
||||
if (source_item == null) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {
|
|||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
Path,
|
||||
|
|
@ -70,8 +69,11 @@ export class ProfileSalaryEmployeeTempController extends Controller {
|
|||
@Get("history/{salaryId}")
|
||||
public async salaryHistory(@Path() salaryId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||
const record = await this.salaryHistoryRepo.findBy({
|
||||
profileSalaryId: salaryId,
|
||||
const record = await this.salaryHistoryRepo.find({
|
||||
where: {
|
||||
profileSalaryId: salaryId,
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
|
@ -105,6 +107,8 @@ export class ProfileSalaryEmployeeTempController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -132,15 +136,18 @@ export class ProfileSalaryEmployeeTempController extends Controller {
|
|||
const history = new ProfileSalaryHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileSalaryId = salaryId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([this.salaryRepo.save(record), this.salaryHistoryRepo.save(history)]);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {
|
|||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
Path,
|
||||
|
|
@ -41,103 +40,32 @@ export class ProfileTrainingController extends Controller {
|
|||
}
|
||||
const record = await this.trainingRepo.find({
|
||||
where: { profileId: profile.id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
||||
@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) {
|
||||
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);
|
||||
}
|
||||
|
||||
@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) {
|
||||
const _record = await this.trainingRepo.findOneBy({ id: trainingId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
||||
}
|
||||
const record = await this.trainingHistoryRepo.findBy({
|
||||
profileTrainingId: trainingId,
|
||||
const record = await this.trainingHistoryRepo.find({
|
||||
where: {
|
||||
profileTrainingId: trainingId,
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
|
@ -147,7 +75,7 @@ export class ProfileTrainingController extends Controller {
|
|||
if (!body.profileId) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
|
||||
}
|
||||
|
||||
|
||||
const profile = await this.profileRepo.findOneBy({ id: body.profileId });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
|
|
@ -161,6 +89,8 @@ export class ProfileTrainingController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -187,15 +117,18 @@ export class ProfileTrainingController extends Controller {
|
|||
const history = new ProfileTrainingHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileTrainingId = trainingId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([this.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) {
|
||||
const _record = await this.trainingRepo.findOneBy({ id: trainingId });
|
||||
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({
|
||||
profileTrainingId: trainingId,
|
||||
|
|
|
|||
|
|
@ -41,104 +41,37 @@ export class ProfileTrainingEmployeeController extends Controller {
|
|||
}
|
||||
const record = await this.trainingRepo.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
||||
@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) {
|
||||
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);
|
||||
}
|
||||
|
||||
@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) {
|
||||
const _record = await this.trainingRepo.findOneBy({ id: trainingId });
|
||||
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({
|
||||
profileTrainingId: trainingId,
|
||||
const record = await this.trainingHistoryRepo.find({
|
||||
where: {
|
||||
profileTrainingId: trainingId,
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
|
@ -158,7 +91,6 @@ export class ProfileTrainingEmployeeController extends Controller {
|
|||
}
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profile.id);
|
||||
|
||||
|
||||
const data = new ProfileTraining();
|
||||
|
||||
const meta = {
|
||||
|
|
@ -166,6 +98,8 @@ export class ProfileTrainingEmployeeController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -187,20 +121,27 @@ export class ProfileTrainingEmployeeController extends Controller {
|
|||
) {
|
||||
const record = await this.trainingRepo.findOneBy({ id: trainingId });
|
||||
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();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileTrainingId = trainingId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([this.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) {
|
||||
const _record = await this.trainingRepo.findOneBy({ id: trainingId });
|
||||
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({
|
||||
|
|
|
|||
|
|
@ -41,100 +41,29 @@ export class ProfileTrainingEmployeeTempController extends Controller {
|
|||
}
|
||||
const record = await this.trainingRepo.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
||||
@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) {
|
||||
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);
|
||||
}
|
||||
|
||||
@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) {
|
||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||
const record = await this.trainingHistoryRepo.findBy({
|
||||
profileTrainingId: trainingId,
|
||||
const record = await this.trainingHistoryRepo.find({
|
||||
where: {
|
||||
profileTrainingId: trainingId,
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
|
@ -162,6 +91,8 @@ export class ProfileTrainingEmployeeTempController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -189,15 +120,18 @@ export class ProfileTrainingEmployeeTempController extends Controller {
|
|||
const history = new ProfileTrainingHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileTrainingId = trainingId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([this.trainingRepo.save(record), this.trainingHistoryRepo.save(history)]);
|
||||
|
||||
|
|
|
|||
|
|
@ -96,6 +96,8 @@ export class ProvinceController extends Controller {
|
|||
_province.createdFullName = request.user.name;
|
||||
_province.lastUpdateUserId = request.user.sub;
|
||||
_province.lastUpdateFullName = request.user.name;
|
||||
_province.createdAt = new Date();
|
||||
_province.lastUpdatedAt = new Date();
|
||||
await this.provinceRepository.save(_province);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
@ -127,6 +129,7 @@ export class ProvinceController extends Controller {
|
|||
|
||||
_province.lastUpdateUserId = request.user.sub;
|
||||
_province.lastUpdateFullName = request.user.name;
|
||||
_province.lastUpdatedAt = new Date();
|
||||
this.provinceRepository.merge(_province, requestBody);
|
||||
await this.provinceRepository.save(_province);
|
||||
return new HttpSuccess();
|
||||
|
|
|
|||
|
|
@ -55,6 +55,8 @@ export class RankController extends Controller {
|
|||
rank.createdFullName = request.user.name;
|
||||
rank.lastUpdateUserId = request.user.sub;
|
||||
rank.lastUpdateFullName = request.user.name;
|
||||
rank.createdAt = new Date();
|
||||
rank.lastUpdatedAt = new Date();
|
||||
await this.rankRepository.save(rank);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
@ -88,6 +90,7 @@ export class RankController extends Controller {
|
|||
|
||||
rank.lastUpdateUserId = request.user.sub;
|
||||
rank.lastUpdateFullName = request.user.name;
|
||||
rank.lastUpdatedAt = new Date();
|
||||
this.rankRepository.merge(rank, requestBody);
|
||||
await this.rankRepository.save(rank);
|
||||
return new HttpSuccess();
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue