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,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -101,7 +103,9 @@ export class AuthRoleAttrController extends Controller {
|
||||||
body.authSysId = body.authSysId?.toUpperCase();
|
body.authSysId = body.authSysId?.toUpperCase();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([this.authRoleAttrRepo.save(record)]);
|
await Promise.all([this.authRoleAttrRepo.save(record)]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,8 @@ export class AuthRoleController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -100,6 +102,7 @@ export class AuthRoleController extends Controller {
|
||||||
|
|
||||||
posMaster.lastUpdateUserId = req.user.sub;
|
posMaster.lastUpdateUserId = req.user.sub;
|
||||||
posMaster.lastUpdateFullName = req.user.name;
|
posMaster.lastUpdateFullName = req.user.name;
|
||||||
|
posMaster.lastUpdatedAt = new Date();
|
||||||
posMaster.authRoleId = body.authRoleId;
|
posMaster.authRoleId = body.authRoleId;
|
||||||
await this.posMasterRepository.save(posMaster);
|
await this.posMasterRepository.save(posMaster);
|
||||||
|
|
||||||
|
|
@ -142,6 +145,7 @@ export class AuthRoleController extends Controller {
|
||||||
|
|
||||||
posMaster.lastUpdateUserId = req.user.sub;
|
posMaster.lastUpdateUserId = req.user.sub;
|
||||||
posMaster.lastUpdateFullName = req.user.name;
|
posMaster.lastUpdateFullName = req.user.name;
|
||||||
|
posMaster.lastUpdatedAt = new Date();
|
||||||
posMaster.authRoleId = body.authRoleId;
|
posMaster.authRoleId = body.authRoleId;
|
||||||
await this.employeePosMasterRepository.save(posMaster);
|
await this.employeePosMasterRepository.save(posMaster);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
|
|
@ -184,6 +188,8 @@ export class AuthRoleController extends Controller {
|
||||||
roleName: body.roleName,
|
roleName: body.roleName,
|
||||||
roleDescription: body.roleDescription,
|
roleDescription: body.roleDescription,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
lastUpdateUserId: req.user.sub,
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const roleAttrData = await this.authRoleAttrRepo.find({
|
const roleAttrData = await this.authRoleAttrRepo.find({
|
||||||
|
|
@ -208,6 +214,8 @@ export class AuthRoleController extends Controller {
|
||||||
// createdFullName: req.user.name,
|
// createdFullName: req.user.name,
|
||||||
// lastUpdateUserId: req.user.sub,
|
// lastUpdateUserId: req.user.sub,
|
||||||
// lastUpdateFullName: req.user.name,
|
// lastUpdateFullName: req.user.name,
|
||||||
|
// createdAt: new Date(),
|
||||||
|
// lastUpdatedAt: new Date(),
|
||||||
// });
|
// });
|
||||||
// return newAttr;
|
// return newAttr;
|
||||||
// });
|
// });
|
||||||
|
|
@ -228,6 +236,8 @@ export class AuthRoleController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
});
|
});
|
||||||
return newAttr;
|
return newAttr;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,8 @@ export class AuthSysController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -92,7 +94,9 @@ export class AuthSysController extends Controller {
|
||||||
body.id = body.id?.toUpperCase();
|
body.id = body.id?.toUpperCase();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([this.authSysRepo.save(record)]);
|
await Promise.all([this.authSysRepo.save(record)]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,8 +53,10 @@ export class BloodGroupController extends Controller {
|
||||||
const bloodGroup = Object.assign(new BloodGroup(), requestBody);
|
const bloodGroup = Object.assign(new BloodGroup(), requestBody);
|
||||||
bloodGroup.createdUserId = request.user.sub;
|
bloodGroup.createdUserId = request.user.sub;
|
||||||
bloodGroup.createdFullName = request.user.name;
|
bloodGroup.createdFullName = request.user.name;
|
||||||
|
bloodGroup.createdAt = new Date();
|
||||||
bloodGroup.lastUpdateUserId = request.user.sub;
|
bloodGroup.lastUpdateUserId = request.user.sub;
|
||||||
bloodGroup.lastUpdateFullName = request.user.name;
|
bloodGroup.lastUpdateFullName = request.user.name;
|
||||||
|
bloodGroup.lastUpdatedAt = new Date();
|
||||||
await this.bloodGroupRepository.save(bloodGroup);
|
await this.bloodGroupRepository.save(bloodGroup);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
@ -88,6 +90,7 @@ export class BloodGroupController extends Controller {
|
||||||
|
|
||||||
bloodGroup.lastUpdateUserId = request.user.sub;
|
bloodGroup.lastUpdateUserId = request.user.sub;
|
||||||
bloodGroup.lastUpdateFullName = request.user.name;
|
bloodGroup.lastUpdateFullName = request.user.name;
|
||||||
|
bloodGroup.lastUpdatedAt = new Date();
|
||||||
this.bloodGroupRepository.merge(bloodGroup, requestBody);
|
this.bloodGroupRepository.merge(bloodGroup, requestBody);
|
||||||
await this.bloodGroupRepository.save(bloodGroup);
|
await this.bloodGroupRepository.save(bloodGroup);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
|
|
|
||||||
|
|
@ -77,12 +77,14 @@ export class ChangePositionController extends Controller {
|
||||||
|
|
||||||
const changePosition = new ChangePosition();
|
const changePosition = new ChangePosition();
|
||||||
Object.assign(changePosition, body);
|
Object.assign(changePosition, body);
|
||||||
(changePosition.date = new Date()),
|
changePosition.date = new Date();
|
||||||
(changePosition.status = "WAITTING"),
|
changePosition.status = "WAITTING";
|
||||||
(changePosition.createdUserId = request.user.sub);
|
changePosition.createdUserId = request.user.sub;
|
||||||
changePosition.createdFullName = request.user.name;
|
changePosition.createdFullName = request.user.name;
|
||||||
|
changePosition.createdAt = new Date();
|
||||||
changePosition.lastUpdateUserId = request.user.sub;
|
changePosition.lastUpdateUserId = request.user.sub;
|
||||||
changePosition.lastUpdateFullName = request.user.name;
|
changePosition.lastUpdateFullName = request.user.name;
|
||||||
|
changePosition.lastUpdatedAt = new Date();
|
||||||
await this.changePositionRepository.save(changePosition);
|
await this.changePositionRepository.save(changePosition);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
@ -143,6 +145,7 @@ export class ChangePositionController extends Controller {
|
||||||
Object.assign(changePosition, body);
|
Object.assign(changePosition, body);
|
||||||
changePosition.lastUpdateUserId = request.user.sub;
|
changePosition.lastUpdateUserId = request.user.sub;
|
||||||
changePosition.lastUpdateFullName = request.user.name;
|
changePosition.lastUpdateFullName = request.user.name;
|
||||||
|
changePosition.lastUpdatedAt = new Date();
|
||||||
await this.changePositionRepository.save(changePosition);
|
await this.changePositionRepository.save(changePosition);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
@ -236,12 +239,14 @@ export class ChangePositionController extends Controller {
|
||||||
let positionOld = data.positionOld ? `${data.positionOld}` : "";
|
let positionOld = data.positionOld ? `${data.positionOld}` : "";
|
||||||
let rootOld = data.rootOld ? (data.positionOld ? `/${data.rootOld}` : `${data.rootOld}`) : "";
|
let rootOld = data.rootOld ? (data.positionOld ? `/${data.rootOld}` : `${data.rootOld}`) : "";
|
||||||
profiles.changePositionId = changePositionId;
|
profiles.changePositionId = changePositionId;
|
||||||
(profiles.organizationPositionOld = `${positionOld}${rootOld}`),
|
profiles.organizationPositionOld = `${positionOld}${rootOld}`;
|
||||||
(profiles.status = "WAITTING"),
|
profiles.status = "WAITTING";
|
||||||
(profiles.createdUserId = request.user.sub);
|
profiles.createdUserId = request.user.sub;
|
||||||
profiles.createdFullName = request.user.name;
|
profiles.createdFullName = request.user.name;
|
||||||
|
profiles.createdAt = new Date();
|
||||||
profiles.lastUpdateUserId = request.user.sub;
|
profiles.lastUpdateUserId = request.user.sub;
|
||||||
profiles.lastUpdateFullName = request.user.name;
|
profiles.lastUpdateFullName = request.user.name;
|
||||||
|
profiles.lastUpdatedAt = new Date();
|
||||||
profileChangePositions.push(profiles);
|
profileChangePositions.push(profiles);
|
||||||
}
|
}
|
||||||
await this.profileChangePositionRepository.save(profileChangePositions);
|
await this.profileChangePositionRepository.save(profileChangePositions);
|
||||||
|
|
@ -391,6 +396,7 @@ export class ChangePositionController extends Controller {
|
||||||
|
|
||||||
profileChangePos.lastUpdateUserId = request.user.sub;
|
profileChangePos.lastUpdateUserId = request.user.sub;
|
||||||
profileChangePos.lastUpdateFullName = request.user.name;
|
profileChangePos.lastUpdateFullName = request.user.name;
|
||||||
|
profileChangePos.lastUpdatedAt = new Date();
|
||||||
profileChangePos.educationOld = body.educationOld;
|
profileChangePos.educationOld = body.educationOld;
|
||||||
profileChangePos.posMasterNoOld = body.posMasterNoOld;
|
profileChangePos.posMasterNoOld = body.posMasterNoOld;
|
||||||
profileChangePos.positionTypeOld = body.positionTypeOld;
|
profileChangePos.positionTypeOld = body.positionTypeOld;
|
||||||
|
|
@ -512,6 +518,7 @@ export class ChangePositionController extends Controller {
|
||||||
|
|
||||||
profileChangePos.lastUpdateUserId = request.user.sub;
|
profileChangePos.lastUpdateUserId = request.user.sub;
|
||||||
profileChangePos.lastUpdateFullName = request.user.name;
|
profileChangePos.lastUpdateFullName = request.user.name;
|
||||||
|
profileChangePos.lastUpdatedAt = new Date();
|
||||||
profileChangePos.node = body.node;
|
profileChangePos.node = body.node;
|
||||||
profileChangePos.nodeId = body.nodeId;
|
profileChangePos.nodeId = body.nodeId;
|
||||||
profileChangePos.orgRevisionId = body.orgRevisionId;
|
profileChangePos.orgRevisionId = body.orgRevisionId;
|
||||||
|
|
@ -546,11 +553,13 @@ export class ChangePositionController extends Controller {
|
||||||
item.status = "REPORT";
|
item.status = "REPORT";
|
||||||
item.lastUpdateUserId = request.user.sub;
|
item.lastUpdateUserId = request.user.sub;
|
||||||
item.lastUpdateFullName = request.user.name;
|
item.lastUpdateFullName = request.user.name;
|
||||||
|
item.lastUpdatedAt = new Date();
|
||||||
if (item.profileChangePosition) {
|
if (item.profileChangePosition) {
|
||||||
for (const profile of item.profileChangePosition) {
|
for (const profile of item.profileChangePosition) {
|
||||||
profile.status = "REPORT";
|
profile.status = "REPORT";
|
||||||
profile.lastUpdateUserId = request.user.sub;
|
profile.lastUpdateUserId = request.user.sub;
|
||||||
profile.lastUpdateFullName = request.user.name;
|
profile.lastUpdateFullName = request.user.name;
|
||||||
|
profile.lastUpdatedAt = new Date();
|
||||||
await this.profileChangePositionRepository.save(profile);
|
await this.profileChangePositionRepository.save(profile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -103,8 +103,10 @@ export class DistrictController extends Controller {
|
||||||
|
|
||||||
_district.createdUserId = request.user.sub;
|
_district.createdUserId = request.user.sub;
|
||||||
_district.createdFullName = request.user.name;
|
_district.createdFullName = request.user.name;
|
||||||
|
_district.createdAt = new Date();
|
||||||
_district.lastUpdateUserId = request.user.sub;
|
_district.lastUpdateUserId = request.user.sub;
|
||||||
_district.lastUpdateFullName = request.user.name;
|
_district.lastUpdateFullName = request.user.name;
|
||||||
|
_district.lastUpdatedAt = new Date();
|
||||||
await this.districtRepository.save(_district);
|
await this.districtRepository.save(_district);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
@ -144,6 +146,7 @@ export class DistrictController extends Controller {
|
||||||
|
|
||||||
_district.lastUpdateUserId = request.user.sub;
|
_district.lastUpdateUserId = request.user.sub;
|
||||||
_district.lastUpdateFullName = request.user.name;
|
_district.lastUpdateFullName = request.user.name;
|
||||||
|
_district.lastUpdatedAt = new Date();
|
||||||
this.districtRepository.merge(_district, requestBody);
|
this.districtRepository.merge(_district, requestBody);
|
||||||
await this.districtRepository.save(_district);
|
await this.districtRepository.save(_district);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
|
|
|
||||||
|
|
@ -53,8 +53,10 @@ export class EducationLevelController extends Controller {
|
||||||
const educationLevel = Object.assign(new EducationLevel(), requestBody);
|
const educationLevel = Object.assign(new EducationLevel(), requestBody);
|
||||||
educationLevel.createdUserId = request.user.sub;
|
educationLevel.createdUserId = request.user.sub;
|
||||||
educationLevel.createdFullName = request.user.name;
|
educationLevel.createdFullName = request.user.name;
|
||||||
|
educationLevel.createdAt = new Date();
|
||||||
educationLevel.lastUpdateUserId = request.user.sub;
|
educationLevel.lastUpdateUserId = request.user.sub;
|
||||||
educationLevel.lastUpdateFullName = request.user.name;
|
educationLevel.lastUpdateFullName = request.user.name;
|
||||||
|
educationLevel.lastUpdatedAt = new Date();
|
||||||
await this.educationLevelRepository.save(educationLevel);
|
await this.educationLevelRepository.save(educationLevel);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
@ -88,6 +90,7 @@ export class EducationLevelController extends Controller {
|
||||||
|
|
||||||
educationLevel.lastUpdateUserId = request.user.sub;
|
educationLevel.lastUpdateUserId = request.user.sub;
|
||||||
educationLevel.lastUpdateFullName = request.user.name;
|
educationLevel.lastUpdateFullName = request.user.name;
|
||||||
|
educationLevel.lastUpdatedAt = new Date();
|
||||||
this.educationLevelRepository.merge(educationLevel, requestBody);
|
this.educationLevelRepository.merge(educationLevel, requestBody);
|
||||||
await this.educationLevelRepository.save(educationLevel);
|
await this.educationLevelRepository.save(educationLevel);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,8 @@ export class EmployeePosLevelController extends Controller {
|
||||||
EmpPosLevel.createdFullName = request.user.name;
|
EmpPosLevel.createdFullName = request.user.name;
|
||||||
EmpPosLevel.lastUpdateUserId = request.user.sub;
|
EmpPosLevel.lastUpdateUserId = request.user.sub;
|
||||||
EmpPosLevel.lastUpdateFullName = request.user.name;
|
EmpPosLevel.lastUpdateFullName = request.user.name;
|
||||||
|
EmpPosLevel.createdAt = new Date();
|
||||||
|
EmpPosLevel.lastUpdatedAt = new Date();
|
||||||
await this.employeePosLevelRepository.save(EmpPosLevel);
|
await this.employeePosLevelRepository.save(EmpPosLevel);
|
||||||
return new HttpSuccess(EmpPosLevel.id);
|
return new HttpSuccess(EmpPosLevel.id);
|
||||||
}
|
}
|
||||||
|
|
@ -125,6 +127,7 @@ export class EmployeePosLevelController extends Controller {
|
||||||
}
|
}
|
||||||
EmpPosLevel.lastUpdateUserId = request.user.sub;
|
EmpPosLevel.lastUpdateUserId = request.user.sub;
|
||||||
EmpPosLevel.lastUpdateFullName = request.user.name;
|
EmpPosLevel.lastUpdateFullName = request.user.name;
|
||||||
|
EmpPosLevel.lastUpdatedAt = new Date();
|
||||||
this.employeePosLevelRepository.merge(EmpPosLevel, requestBody);
|
this.employeePosLevelRepository.merge(EmpPosLevel, requestBody);
|
||||||
await this.employeePosLevelRepository.save(EmpPosLevel);
|
await this.employeePosLevelRepository.save(EmpPosLevel);
|
||||||
return new HttpSuccess(EmpPosLevel.id);
|
return new HttpSuccess(EmpPosLevel.id);
|
||||||
|
|
@ -139,11 +142,14 @@ export class EmployeePosLevelController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Delete("{id}")
|
@Delete("{id}")
|
||||||
async deleteType(@Path() id: string) {
|
async deleteType(@Path() id: string) {
|
||||||
let result :any
|
let result: any;
|
||||||
try {
|
try {
|
||||||
result = await this.employeePosLevelRepository.delete({ id: id });
|
result = await this.employeePosLevelRepository.delete({ id: id });
|
||||||
} catch {
|
} catch {
|
||||||
throw new HttpError( HttpStatusCode.NOT_FOUND, "ไม่สามารถลบได้เนื่องจากมีการใช้งานระดับชั้นงานนี้อยู่");
|
throw new HttpError(
|
||||||
|
HttpStatusCode.NOT_FOUND,
|
||||||
|
"ไม่สามารถลบได้เนื่องจากมีการใช้งานระดับชั้นงานนี้อยู่",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (result.affected == undefined || result.affected <= 0) {
|
if (result.affected == undefined || result.affected <= 0) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,8 @@ export class EmployeePosTypeController extends Controller {
|
||||||
EmpPosType.createdFullName = request.user.name;
|
EmpPosType.createdFullName = request.user.name;
|
||||||
EmpPosType.lastUpdateUserId = request.user.sub;
|
EmpPosType.lastUpdateUserId = request.user.sub;
|
||||||
EmpPosType.lastUpdateFullName = request.user.name;
|
EmpPosType.lastUpdateFullName = request.user.name;
|
||||||
|
EmpPosType.createdAt = new Date();
|
||||||
|
EmpPosType.lastUpdatedAt = new Date();
|
||||||
await this.employeePosTypeRepository.save(EmpPosType);
|
await this.employeePosTypeRepository.save(EmpPosType);
|
||||||
return new HttpSuccess(EmpPosType.id);
|
return new HttpSuccess(EmpPosType.id);
|
||||||
}
|
}
|
||||||
|
|
@ -120,6 +122,7 @@ export class EmployeePosTypeController extends Controller {
|
||||||
}
|
}
|
||||||
EmpPosType.lastUpdateUserId = request.user.sub;
|
EmpPosType.lastUpdateUserId = request.user.sub;
|
||||||
EmpPosType.lastUpdateFullName = request.user.name;
|
EmpPosType.lastUpdateFullName = request.user.name;
|
||||||
|
EmpPosType.lastUpdatedAt = new Date();
|
||||||
this.employeePosTypeRepository.merge(EmpPosType, requestBody);
|
this.employeePosTypeRepository.merge(EmpPosType, requestBody);
|
||||||
await this.employeePosTypeRepository.save(EmpPosType);
|
await this.employeePosTypeRepository.save(EmpPosType);
|
||||||
return new HttpSuccess(EmpPosType.id);
|
return new HttpSuccess(EmpPosType.id);
|
||||||
|
|
@ -134,11 +137,14 @@ export class EmployeePosTypeController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Delete("{id}")
|
@Delete("{id}")
|
||||||
async deleteType(@Path() id: string) {
|
async deleteType(@Path() id: string) {
|
||||||
let result :any
|
let result: any;
|
||||||
try {
|
try {
|
||||||
result = await this.employeePosTypeRepository.delete({ id: id });
|
result = await this.employeePosTypeRepository.delete({ id: id });
|
||||||
} catch {
|
} catch {
|
||||||
throw new HttpError( HttpStatusCode.NOT_FOUND, "ไม่สามารถลบได้เนื่องจากมีการใช้งานระดับกลุ่มงานนี้อยู่");
|
throw new HttpError(
|
||||||
|
HttpStatusCode.NOT_FOUND,
|
||||||
|
"ไม่สามารถลบได้เนื่องจากมีการใช้งานระดับกลุ่มงานนี้อยู่",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (result.affected == undefined || result.affected <= 0) {
|
if (result.affected == undefined || result.affected <= 0) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
|
||||||
|
|
@ -107,8 +107,10 @@ export class EmployeePositionController extends Controller {
|
||||||
|
|
||||||
empPosDict.createdUserId = request.user.sub;
|
empPosDict.createdUserId = request.user.sub;
|
||||||
empPosDict.createdFullName = request.user.name;
|
empPosDict.createdFullName = request.user.name;
|
||||||
|
empPosDict.createdAt = new Date();
|
||||||
empPosDict.lastUpdateUserId = request.user.sub;
|
empPosDict.lastUpdateUserId = request.user.sub;
|
||||||
empPosDict.lastUpdateFullName = request.user.name;
|
empPosDict.lastUpdateFullName = request.user.name;
|
||||||
|
empPosDict.lastUpdatedAt = new Date();
|
||||||
await this.employeePosDictRepository.save(empPosDict);
|
await this.employeePosDictRepository.save(empPosDict);
|
||||||
return new HttpSuccess(empPosDict.id);
|
return new HttpSuccess(empPosDict.id);
|
||||||
}
|
}
|
||||||
|
|
@ -162,6 +164,7 @@ export class EmployeePositionController extends Controller {
|
||||||
|
|
||||||
empPosDict.lastUpdateUserId = request.user.sub;
|
empPosDict.lastUpdateUserId = request.user.sub;
|
||||||
empPosDict.lastUpdateFullName = request.user.name;
|
empPosDict.lastUpdateFullName = request.user.name;
|
||||||
|
empPosDict.lastUpdatedAt = new Date();
|
||||||
this.employeePosDictRepository.merge(empPosDict, requestBody);
|
this.employeePosDictRepository.merge(empPosDict, requestBody);
|
||||||
await this.employeePosDictRepository.save(empPosDict);
|
await this.employeePosDictRepository.save(empPosDict);
|
||||||
return new HttpSuccess(empPosDict.id);
|
return new HttpSuccess(empPosDict.id);
|
||||||
|
|
@ -582,8 +585,10 @@ export class EmployeePositionController extends Controller {
|
||||||
|
|
||||||
posMaster.createdUserId = request.user.sub;
|
posMaster.createdUserId = request.user.sub;
|
||||||
posMaster.createdFullName = request.user.name;
|
posMaster.createdFullName = request.user.name;
|
||||||
|
posMaster.createdAt = new Date();
|
||||||
posMaster.lastUpdateUserId = request.user.sub;
|
posMaster.lastUpdateUserId = request.user.sub;
|
||||||
posMaster.lastUpdateFullName = request.user.name;
|
posMaster.lastUpdateFullName = request.user.name;
|
||||||
|
posMaster.lastUpdatedAt = new Date();
|
||||||
await this.employeePosMasterRepository.save(posMaster);
|
await this.employeePosMasterRepository.save(posMaster);
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
requestBody.positions.map(async (x: any) => {
|
requestBody.positions.map(async (x: any) => {
|
||||||
|
|
@ -595,8 +600,10 @@ export class EmployeePositionController extends Controller {
|
||||||
position.posMasterId = posMaster.id;
|
position.posMasterId = posMaster.id;
|
||||||
position.createdUserId = request.user.sub;
|
position.createdUserId = request.user.sub;
|
||||||
position.createdFullName = request.user.name;
|
position.createdFullName = request.user.name;
|
||||||
|
position.createdAt = new Date();
|
||||||
position.lastUpdateUserId = request.user.sub;
|
position.lastUpdateUserId = request.user.sub;
|
||||||
position.lastUpdateFullName = request.user.name;
|
position.lastUpdateFullName = request.user.name;
|
||||||
|
position.lastUpdatedAt = new Date();
|
||||||
await this.employeePositionRepository.save(position);
|
await this.employeePositionRepository.save(position);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
@ -787,8 +794,10 @@ export class EmployeePositionController extends Controller {
|
||||||
|
|
||||||
posMaster.createdUserId = request.user.sub; //สงสัยว่าทำให้ bug แก้ไขไม่ได้
|
posMaster.createdUserId = request.user.sub; //สงสัยว่าทำให้ bug แก้ไขไม่ได้
|
||||||
posMaster.createdFullName = request.user.name;
|
posMaster.createdFullName = request.user.name;
|
||||||
|
posMaster.createdAt = new Date();
|
||||||
posMaster.lastUpdateUserId = request.user.sub;
|
posMaster.lastUpdateUserId = request.user.sub;
|
||||||
posMaster.lastUpdateFullName = request.user.name;
|
posMaster.lastUpdateFullName = request.user.name;
|
||||||
|
posMaster.lastUpdatedAt = new Date();
|
||||||
await this.employeePosMasterRepository.save(posMaster);
|
await this.employeePosMasterRepository.save(posMaster);
|
||||||
await this.employeePositionRepository.delete({ posMasterId: posMaster.id });
|
await this.employeePositionRepository.delete({ posMasterId: posMaster.id });
|
||||||
|
|
||||||
|
|
@ -802,8 +811,10 @@ export class EmployeePositionController extends Controller {
|
||||||
position.posMasterId = posMaster.id;
|
position.posMasterId = posMaster.id;
|
||||||
position.createdUserId = request.user.sub;
|
position.createdUserId = request.user.sub;
|
||||||
position.createdFullName = request.user.name;
|
position.createdFullName = request.user.name;
|
||||||
|
position.createdAt = new Date();
|
||||||
position.lastUpdateUserId = request.user.sub;
|
position.lastUpdateUserId = request.user.sub;
|
||||||
position.lastUpdateFullName = request.user.name;
|
position.lastUpdateFullName = request.user.name;
|
||||||
|
position.lastUpdatedAt = new Date();
|
||||||
await this.employeePositionRepository.save(position);
|
await this.employeePositionRepository.save(position);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
@ -1186,7 +1197,10 @@ export class EmployeePositionController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Post("sort")
|
@Post("sort")
|
||||||
async SortEmp(@Body() requestBody: { id: string; type: number; sortId: string[] }, @Request() request: RequestWithUser) {
|
async SortEmp(
|
||||||
|
@Body() requestBody: { id: string; type: number; sortId: string[] },
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
|
) {
|
||||||
await new permission().PermissionUpdate(request, "SYS_ORG_EMP");
|
await new permission().PermissionUpdate(request, "SYS_ORG_EMP");
|
||||||
switch (requestBody.type) {
|
switch (requestBody.type) {
|
||||||
case 0: {
|
case 0: {
|
||||||
|
|
@ -1614,8 +1628,10 @@ export class EmployeePositionController extends Controller {
|
||||||
posMaster.posMasterOrder = maxPosMasterOrder += 1;
|
posMaster.posMasterOrder = maxPosMasterOrder += 1;
|
||||||
posMaster.createdUserId = request.user.sub;
|
posMaster.createdUserId = request.user.sub;
|
||||||
posMaster.createdFullName = request.user.name;
|
posMaster.createdFullName = request.user.name;
|
||||||
|
posMaster.createdAt = new Date();
|
||||||
posMaster.lastUpdateUserId = request.user.sub;
|
posMaster.lastUpdateUserId = request.user.sub;
|
||||||
posMaster.lastUpdateFullName = request.user.name;
|
posMaster.lastUpdateFullName = request.user.name;
|
||||||
|
posMaster.lastUpdatedAt = new Date();
|
||||||
await this.employeePosMasterRepository.save(posMaster);
|
await this.employeePosMasterRepository.save(posMaster);
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
@ -2078,7 +2094,7 @@ export class EmployeePositionController extends Controller {
|
||||||
@Post("profile")
|
@Post("profile")
|
||||||
async createEmpHolder(
|
async createEmpHolder(
|
||||||
@Body() requestBody: { posMaster: string; position: string; profileId: string; isSit: boolean },
|
@Body() requestBody: { posMaster: string; position: string; profileId: string; isSit: boolean },
|
||||||
@Request() request: RequestWithUser
|
@Request() request: RequestWithUser,
|
||||||
) {
|
) {
|
||||||
await new permission().PermissionCreate(request, "SYS_ORG_EMP");
|
await new permission().PermissionCreate(request, "SYS_ORG_EMP");
|
||||||
const dataMaster = await this.employeePosMasterRepository.findOne({
|
const dataMaster = await this.employeePosMasterRepository.findOne({
|
||||||
|
|
@ -2144,7 +2160,10 @@ export class EmployeePositionController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Post("dna")
|
@Post("dna")
|
||||||
async dnaEmp(@Body() requestBody: { draftPositionId: string; publishPositionId: string }, @Request() request: RequestWithUser) {
|
async dnaEmp(
|
||||||
|
@Body() requestBody: { draftPositionId: string; publishPositionId: string },
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
|
) {
|
||||||
await new permission().PermissionDelete(request, "SYS_ORG_EMP");
|
await new permission().PermissionDelete(request, "SYS_ORG_EMP");
|
||||||
const findDraft = await this.orgRevisionRepository.findOne({
|
const findDraft = await this.orgRevisionRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,8 @@ export class GenderController extends Controller {
|
||||||
_gender.createdFullName = request.user.name;
|
_gender.createdFullName = request.user.name;
|
||||||
_gender.lastUpdateUserId = request.user.sub;
|
_gender.lastUpdateUserId = request.user.sub;
|
||||||
_gender.lastUpdateFullName = request.user.name;
|
_gender.lastUpdateFullName = request.user.name;
|
||||||
|
_gender.createdAt = new Date();
|
||||||
|
_gender.lastUpdatedAt = new Date();
|
||||||
await this.genderRepository.save(_gender);
|
await this.genderRepository.save(_gender);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
@ -129,6 +131,7 @@ export class GenderController extends Controller {
|
||||||
|
|
||||||
_gender.lastUpdateUserId = request.user.sub;
|
_gender.lastUpdateUserId = request.user.sub;
|
||||||
_gender.lastUpdateFullName = request.user.name;
|
_gender.lastUpdateFullName = request.user.name;
|
||||||
|
_gender.lastUpdatedAt = new Date();
|
||||||
this.genderRepository.merge(_gender, requestBody);
|
this.genderRepository.merge(_gender, requestBody);
|
||||||
await this.genderRepository.save(_gender);
|
await this.genderRepository.save(_gender);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
|
|
|
||||||
|
|
@ -175,6 +175,8 @@ export class ImportDataController extends Controller {
|
||||||
profile.createdFullName = request.user.name;
|
profile.createdFullName = request.user.name;
|
||||||
profile.lastUpdateUserId = request.user.sub;
|
profile.lastUpdateUserId = request.user.sub;
|
||||||
profile.lastUpdateFullName = request.user.name;
|
profile.lastUpdateFullName = request.user.name;
|
||||||
|
profile.createdAt = new Date();
|
||||||
|
profile.lastUpdatedAt = new Date();
|
||||||
profiles.push(profile);
|
profiles.push(profile);
|
||||||
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
||||||
|
|
||||||
|
|
@ -248,6 +250,8 @@ export class ImportDataController extends Controller {
|
||||||
profileEmp.createdFullName = request.user.name;
|
profileEmp.createdFullName = request.user.name;
|
||||||
profileEmp.lastUpdateUserId = request.user.sub;
|
profileEmp.lastUpdateUserId = request.user.sub;
|
||||||
profileEmp.lastUpdateFullName = request.user.name;
|
profileEmp.lastUpdateFullName = request.user.name;
|
||||||
|
profileEmp.createdAt = new Date();
|
||||||
|
profileEmp.lastUpdatedAt = new Date();
|
||||||
profiles.push(profileEmp);
|
profiles.push(profileEmp);
|
||||||
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
||||||
|
|
||||||
|
|
@ -336,6 +340,8 @@ export class ImportDataController extends Controller {
|
||||||
profileSalary.createdFullName = request.user.name;
|
profileSalary.createdFullName = request.user.name;
|
||||||
profileSalary.lastUpdateUserId = request.user.sub;
|
profileSalary.lastUpdateUserId = request.user.sub;
|
||||||
profileSalary.lastUpdateFullName = request.user.name;
|
profileSalary.lastUpdateFullName = request.user.name;
|
||||||
|
profileSalary.createdAt = new Date();
|
||||||
|
profileSalary.lastUpdatedAt = new Date();
|
||||||
// profileSalarys.push(profileSalary);
|
// profileSalarys.push(profileSalary);
|
||||||
// await this.salaryRepository.save(profileSalary);
|
// await this.salaryRepository.save(profileSalary);
|
||||||
// if (profileSalarys.length === BATCH_SIZE) {
|
// if (profileSalarys.length === BATCH_SIZE) {
|
||||||
|
|
@ -428,6 +434,8 @@ export class ImportDataController extends Controller {
|
||||||
profileSalary.createdFullName = request.user.name;
|
profileSalary.createdFullName = request.user.name;
|
||||||
profileSalary.lastUpdateUserId = request.user.sub;
|
profileSalary.lastUpdateUserId = request.user.sub;
|
||||||
profileSalary.lastUpdateFullName = request.user.name;
|
profileSalary.lastUpdateFullName = request.user.name;
|
||||||
|
profileSalary.createdAt = new Date();
|
||||||
|
profileSalary.lastUpdatedAt = new Date();
|
||||||
// profileSalarys.push(profileSalary);
|
// profileSalarys.push(profileSalary);
|
||||||
// await this.salaryRepository.save(profileSalary);
|
// await this.salaryRepository.save(profileSalary);
|
||||||
// if (profileSalarys.length === BATCH_SIZE) {
|
// if (profileSalarys.length === BATCH_SIZE) {
|
||||||
|
|
@ -509,6 +517,8 @@ export class ImportDataController extends Controller {
|
||||||
profileFather.createdFullName = request.user.name;
|
profileFather.createdFullName = request.user.name;
|
||||||
profileFather.lastUpdateUserId = request.user.sub;
|
profileFather.lastUpdateUserId = request.user.sub;
|
||||||
profileFather.lastUpdateFullName = request.user.name;
|
profileFather.lastUpdateFullName = request.user.name;
|
||||||
|
profileFather.createdAt = new Date();
|
||||||
|
profileFather.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
profileMother.profileId = _item.id;
|
profileMother.profileId = _item.id;
|
||||||
profileMother.motherPrefix = existingProfile.MOTHER_RANK_NAME;
|
profileMother.motherPrefix = existingProfile.MOTHER_RANK_NAME;
|
||||||
|
|
@ -518,6 +528,8 @@ export class ImportDataController extends Controller {
|
||||||
profileMother.createdFullName = request.user.name;
|
profileMother.createdFullName = request.user.name;
|
||||||
profileMother.lastUpdateUserId = request.user.sub;
|
profileMother.lastUpdateUserId = request.user.sub;
|
||||||
profileMother.lastUpdateFullName = request.user.name;
|
profileMother.lastUpdateFullName = request.user.name;
|
||||||
|
profileMother.createdAt = new Date();
|
||||||
|
profileMother.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
profileCouple.profileId = _item.id;
|
profileCouple.profileId = _item.id;
|
||||||
profileCouple.couplePrefix = existingProfile.SPOUSE_RANK_NAME;
|
profileCouple.couplePrefix = existingProfile.SPOUSE_RANK_NAME;
|
||||||
|
|
@ -539,6 +551,8 @@ export class ImportDataController extends Controller {
|
||||||
profileCouple.createdFullName = request.user.name;
|
profileCouple.createdFullName = request.user.name;
|
||||||
profileCouple.lastUpdateUserId = request.user.sub;
|
profileCouple.lastUpdateUserId = request.user.sub;
|
||||||
profileCouple.lastUpdateFullName = request.user.name;
|
profileCouple.lastUpdateFullName = request.user.name;
|
||||||
|
profileCouple.createdAt = new Date();
|
||||||
|
profileCouple.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
// fathers.push(profileFather);
|
// fathers.push(profileFather);
|
||||||
// mothers.push(profileMother);
|
// mothers.push(profileMother);
|
||||||
|
|
@ -633,6 +647,8 @@ export class ImportDataController extends Controller {
|
||||||
profileFather.createdFullName = request.user.name;
|
profileFather.createdFullName = request.user.name;
|
||||||
profileFather.lastUpdateUserId = request.user.sub;
|
profileFather.lastUpdateUserId = request.user.sub;
|
||||||
profileFather.lastUpdateFullName = request.user.name;
|
profileFather.lastUpdateFullName = request.user.name;
|
||||||
|
profileFather.createdAt = new Date();
|
||||||
|
profileFather.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
profileMother.profileEmployeeId = _item.id;
|
profileMother.profileEmployeeId = _item.id;
|
||||||
profileMother.motherPrefix = existingProfile.MOTHER_RANK_NAME;
|
profileMother.motherPrefix = existingProfile.MOTHER_RANK_NAME;
|
||||||
|
|
@ -642,6 +658,8 @@ export class ImportDataController extends Controller {
|
||||||
profileMother.createdFullName = request.user.name;
|
profileMother.createdFullName = request.user.name;
|
||||||
profileMother.lastUpdateUserId = request.user.sub;
|
profileMother.lastUpdateUserId = request.user.sub;
|
||||||
profileMother.lastUpdateFullName = request.user.name;
|
profileMother.lastUpdateFullName = request.user.name;
|
||||||
|
profileMother.createdAt = new Date();
|
||||||
|
profileMother.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
profileCouple.profileEmployeeId = _item.id;
|
profileCouple.profileEmployeeId = _item.id;
|
||||||
profileCouple.couplePrefix = existingProfile.SPOUSE_RANK_NAME;
|
profileCouple.couplePrefix = existingProfile.SPOUSE_RANK_NAME;
|
||||||
|
|
@ -663,6 +681,8 @@ export class ImportDataController extends Controller {
|
||||||
profileCouple.createdFullName = request.user.name;
|
profileCouple.createdFullName = request.user.name;
|
||||||
profileCouple.lastUpdateUserId = request.user.sub;
|
profileCouple.lastUpdateUserId = request.user.sub;
|
||||||
profileCouple.lastUpdateFullName = request.user.name;
|
profileCouple.lastUpdateFullName = request.user.name;
|
||||||
|
profileCouple.createdAt = new Date();
|
||||||
|
profileCouple.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
// fathers.push(profileFather);
|
// fathers.push(profileFather);
|
||||||
// mothers.push(profileMother);
|
// mothers.push(profileMother);
|
||||||
|
|
@ -720,6 +740,8 @@ export class ImportDataController extends Controller {
|
||||||
educationMis.createdFullName = request.user.name;
|
educationMis.createdFullName = request.user.name;
|
||||||
educationMis.lastUpdateUserId = request.user.sub;
|
educationMis.lastUpdateUserId = request.user.sub;
|
||||||
educationMis.lastUpdateFullName = request.user.name;
|
educationMis.lastUpdateFullName = request.user.name;
|
||||||
|
educationMis.createdAt = new Date();
|
||||||
|
educationMis.lastUpdatedAt = new Date();
|
||||||
educationMis_.push(educationMis);
|
educationMis_.push(educationMis);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
@ -786,6 +808,8 @@ export class ImportDataController extends Controller {
|
||||||
education.createdFullName = request.user.name;
|
education.createdFullName = request.user.name;
|
||||||
education.lastUpdateUserId = request.user.sub;
|
education.lastUpdateUserId = request.user.sub;
|
||||||
education.lastUpdateFullName = request.user.name;
|
education.lastUpdateFullName = request.user.name;
|
||||||
|
education.createdAt = new Date();
|
||||||
|
education.lastUpdatedAt = new Date();
|
||||||
// await educations.push(await education);
|
// await educations.push(await education);
|
||||||
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
||||||
await this.educationRepository.save(await education);
|
await this.educationRepository.save(await education);
|
||||||
|
|
@ -860,6 +884,8 @@ export class ImportDataController extends Controller {
|
||||||
education.createdFullName = request.user.name;
|
education.createdFullName = request.user.name;
|
||||||
education.lastUpdateUserId = request.user.sub;
|
education.lastUpdateUserId = request.user.sub;
|
||||||
education.lastUpdateFullName = request.user.name;
|
education.lastUpdateFullName = request.user.name;
|
||||||
|
education.createdAt = new Date();
|
||||||
|
education.lastUpdatedAt = new Date();
|
||||||
// educations.push(education);
|
// educations.push(education);
|
||||||
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
||||||
await this.educationRepository.save(education);
|
await this.educationRepository.save(education);
|
||||||
|
|
@ -898,6 +924,8 @@ export class ImportDataController extends Controller {
|
||||||
prov.createdFullName = request.user.name;
|
prov.createdFullName = request.user.name;
|
||||||
prov.lastUpdateUserId = request.user.sub;
|
prov.lastUpdateUserId = request.user.sub;
|
||||||
prov.lastUpdateFullName = request.user.name;
|
prov.lastUpdateFullName = request.user.name;
|
||||||
|
prov.createdAt = new Date();
|
||||||
|
prov.lastUpdatedAt = new Date();
|
||||||
provinces_.push(prov);
|
provinces_.push(prov);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
@ -930,6 +958,8 @@ export class ImportDataController extends Controller {
|
||||||
amh.createdFullName = request.user.name;
|
amh.createdFullName = request.user.name;
|
||||||
amh.lastUpdateUserId = request.user.sub;
|
amh.lastUpdateUserId = request.user.sub;
|
||||||
amh.lastUpdateFullName = request.user.name;
|
amh.lastUpdateFullName = request.user.name;
|
||||||
|
amh.createdAt = new Date();
|
||||||
|
amh.lastUpdatedAt = new Date();
|
||||||
amphur_.push(amh);
|
amphur_.push(amh);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
@ -963,6 +993,8 @@ export class ImportDataController extends Controller {
|
||||||
subD.createdFullName = request.user.name;
|
subD.createdFullName = request.user.name;
|
||||||
subD.lastUpdateUserId = request.user.sub;
|
subD.lastUpdateUserId = request.user.sub;
|
||||||
subD.lastUpdateFullName = request.user.name;
|
subD.lastUpdateFullName = request.user.name;
|
||||||
|
subD.createdAt = new Date();
|
||||||
|
subD.lastUpdatedAt = new Date();
|
||||||
subDistrict_.push(subD);
|
subDistrict_.push(subD);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
@ -1112,6 +1144,8 @@ export class ImportDataController extends Controller {
|
||||||
_item.createdFullName = request.user.name;
|
_item.createdFullName = request.user.name;
|
||||||
_item.lastUpdateUserId = request.user.sub;
|
_item.lastUpdateUserId = request.user.sub;
|
||||||
_item.lastUpdateFullName = request.user.name;
|
_item.lastUpdateFullName = request.user.name;
|
||||||
|
_item.createdAt = new Date();
|
||||||
|
_item.lastUpdatedAt = new Date();
|
||||||
// profileDatas.push(_item);
|
// profileDatas.push(_item);
|
||||||
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
||||||
await this.profileRepo.save(_item);
|
await this.profileRepo.save(_item);
|
||||||
|
|
@ -1265,6 +1299,8 @@ export class ImportDataController extends Controller {
|
||||||
_item.createdFullName = request.user.name;
|
_item.createdFullName = request.user.name;
|
||||||
_item.lastUpdateUserId = request.user.sub;
|
_item.lastUpdateUserId = request.user.sub;
|
||||||
_item.lastUpdateFullName = request.user.name;
|
_item.lastUpdateFullName = request.user.name;
|
||||||
|
_item.createdAt = new Date();
|
||||||
|
_item.lastUpdatedAt = new Date();
|
||||||
// profileDatas.push(_item);
|
// profileDatas.push(_item);
|
||||||
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
||||||
await this.profileEmpRepo.save(_item);
|
await this.profileEmpRepo.save(_item);
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,8 @@ export class InsigniaController extends Controller {
|
||||||
insignia.createdFullName = request.user.name;
|
insignia.createdFullName = request.user.name;
|
||||||
insignia.lastUpdateUserId = request.user.sub;
|
insignia.lastUpdateUserId = request.user.sub;
|
||||||
insignia.lastUpdateFullName = request.user.name;
|
insignia.lastUpdateFullName = request.user.name;
|
||||||
|
insignia.createdAt = new Date();
|
||||||
|
insignia.lastUpdatedAt = new Date();
|
||||||
await this.insigniaRepository.save(insignia);
|
await this.insigniaRepository.save(insignia);
|
||||||
return new HttpSuccess(insignia.id);
|
return new HttpSuccess(insignia.id);
|
||||||
}
|
}
|
||||||
|
|
@ -113,6 +115,7 @@ export class InsigniaController extends Controller {
|
||||||
|
|
||||||
insignia.lastUpdateUserId = request.user.sub;
|
insignia.lastUpdateUserId = request.user.sub;
|
||||||
insignia.lastUpdateFullName = request.user.name;
|
insignia.lastUpdateFullName = request.user.name;
|
||||||
|
insignia.lastUpdatedAt = new Date();
|
||||||
this.insigniaRepository.merge(insignia, requestBody);
|
this.insigniaRepository.merge(insignia, requestBody);
|
||||||
await this.insigniaRepository.save(insignia);
|
await this.insigniaRepository.save(insignia);
|
||||||
return new HttpSuccess(insignia.id);
|
return new HttpSuccess(insignia.id);
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import HttpStatusCode from "../interfaces/http-status";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
import { Equal, ILike, In, IsNull, Like, Not, Brackets, Between } from "typeorm";
|
import { Equal, ILike, In, IsNull, Like, Not, Brackets, Between } from "typeorm";
|
||||||
import { InsigniaType, CreateInsigniaType, UpdateInsigniaType } from "../entities/InsigniaType";
|
import { InsigniaType, CreateInsigniaType, UpdateInsigniaType } from "../entities/InsigniaType";
|
||||||
import { Insignia, } from "../entities/Insignia";
|
import { Insignia } from "../entities/Insignia";
|
||||||
|
|
||||||
@Route("api/v1/org/insignia/insignia-type")
|
@Route("api/v1/org/insignia/insignia-type")
|
||||||
@Tags("InsigniaType")
|
@Tags("InsigniaType")
|
||||||
|
|
@ -33,7 +33,6 @@ import { Insignia, } from "../entities/Insignia";
|
||||||
)
|
)
|
||||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||||
export class InsigniaTypeController extends Controller {
|
export class InsigniaTypeController extends Controller {
|
||||||
|
|
||||||
private insigniaTypeRepository = AppDataSource.getRepository(InsigniaType);
|
private insigniaTypeRepository = AppDataSource.getRepository(InsigniaType);
|
||||||
private insigniaRepository = AppDataSource.getRepository(Insignia);
|
private insigniaRepository = AppDataSource.getRepository(Insignia);
|
||||||
|
|
||||||
|
|
@ -48,7 +47,6 @@ export class InsigniaTypeController extends Controller {
|
||||||
@Body() requestBody: CreateInsigniaType,
|
@Body() requestBody: CreateInsigniaType,
|
||||||
@Request() request: { user: Record<string, any> },
|
@Request() request: { user: Record<string, any> },
|
||||||
) {
|
) {
|
||||||
|
|
||||||
const insigniaType = Object.assign(new InsigniaType(), requestBody);
|
const insigniaType = Object.assign(new InsigniaType(), requestBody);
|
||||||
if (!insigniaType) {
|
if (!insigniaType) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
@ -68,6 +66,8 @@ export class InsigniaTypeController extends Controller {
|
||||||
insigniaType.createdFullName = request.user.name;
|
insigniaType.createdFullName = request.user.name;
|
||||||
insigniaType.lastUpdateUserId = request.user.sub;
|
insigniaType.lastUpdateUserId = request.user.sub;
|
||||||
insigniaType.lastUpdateFullName = request.user.name;
|
insigniaType.lastUpdateFullName = request.user.name;
|
||||||
|
insigniaType.createdAt = new Date();
|
||||||
|
insigniaType.lastUpdatedAt = new Date();
|
||||||
await this.insigniaTypeRepository.save(insigniaType);
|
await this.insigniaTypeRepository.save(insigniaType);
|
||||||
return new HttpSuccess(insigniaType.id);
|
return new HttpSuccess(insigniaType.id);
|
||||||
}
|
}
|
||||||
|
|
@ -104,6 +104,7 @@ export class InsigniaTypeController extends Controller {
|
||||||
|
|
||||||
insigniaType.lastUpdateUserId = request.user.sub;
|
insigniaType.lastUpdateUserId = request.user.sub;
|
||||||
insigniaType.lastUpdateFullName = request.user.name;
|
insigniaType.lastUpdateFullName = request.user.name;
|
||||||
|
insigniaType.lastUpdatedAt = new Date();
|
||||||
this.insigniaTypeRepository.merge(insigniaType, requestBody);
|
this.insigniaTypeRepository.merge(insigniaType, requestBody);
|
||||||
await this.insigniaTypeRepository.save(insigniaType);
|
await this.insigniaTypeRepository.save(insigniaType);
|
||||||
return new HttpSuccess(insigniaType.id);
|
return new HttpSuccess(insigniaType.id);
|
||||||
|
|
@ -123,10 +124,13 @@ export class InsigniaTypeController extends Controller {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลลำดับชั้นเครื่องราชอิสริยาภรณ์นี้");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลลำดับชั้นเครื่องราชอิสริยาภรณ์นี้");
|
||||||
}
|
}
|
||||||
const Insignia = await this.insigniaRepository.find({
|
const Insignia = await this.insigniaRepository.find({
|
||||||
where: { insigniaTypeId: id }
|
where: { insigniaTypeId: id },
|
||||||
});
|
});
|
||||||
if (Insignia.length > 0) {
|
if (Insignia.length > 0) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถลบได้ เนื่องจากพบข้อมูลที่ตารางเครื่องราชอิสริยาภรณ์");
|
throw new HttpError(
|
||||||
|
HttpStatusCode.NOT_FOUND,
|
||||||
|
"ไม่สามารถลบได้ เนื่องจากพบข้อมูลที่ตารางเครื่องราชอิสริยาภรณ์",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
await this.insigniaTypeRepository.remove(delInsigniaType);
|
await this.insigniaTypeRepository.remove(delInsigniaType);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
|
|
@ -143,7 +147,7 @@ export class InsigniaTypeController extends Controller {
|
||||||
const insigniaType_Active = await this.insigniaTypeRepository.find({
|
const insigniaType_Active = await this.insigniaTypeRepository.find({
|
||||||
select: ["id", "name", "createdAt", "lastUpdatedAt", "lastUpdateFullName", "isActive"],
|
select: ["id", "name", "createdAt", "lastUpdatedAt", "lastUpdateFullName", "isActive"],
|
||||||
where: { isActive: true },
|
where: { isActive: true },
|
||||||
order: { "name": "ASC" }
|
order: { name: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(insigniaType_Active);
|
return new HttpSuccess(insigniaType_Active);
|
||||||
}
|
}
|
||||||
|
|
@ -163,7 +167,10 @@ export class InsigniaTypeController extends Controller {
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
});
|
});
|
||||||
if (!insigniaType) {
|
if (!insigniaType) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลลำดับชั้นเครื่องราชอิสริยาภรณ์ นี้");
|
throw new HttpError(
|
||||||
|
HttpStatusCode.NOT_FOUND,
|
||||||
|
"ไม่พบข้อมูลลำดับชั้นเครื่องราชอิสริยาภรณ์ นี้",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return new HttpSuccess(insigniaType);
|
return new HttpSuccess(insigniaType);
|
||||||
}
|
}
|
||||||
|
|
@ -178,7 +185,7 @@ export class InsigniaTypeController extends Controller {
|
||||||
async GetInsigniaType() {
|
async GetInsigniaType() {
|
||||||
const insigniaTypeAll = await this.insigniaTypeRepository.find({
|
const insigniaTypeAll = await this.insigniaTypeRepository.find({
|
||||||
select: ["id", "name", "createdAt", "lastUpdatedAt", "lastUpdateFullName", "isActive"],
|
select: ["id", "name", "createdAt", "lastUpdatedAt", "lastUpdateFullName", "isActive"],
|
||||||
order: { "name": "ASC" }
|
order: { name: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(insigniaTypeAll);
|
return new HttpSuccess(insigniaTypeAll);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -167,6 +167,8 @@ export class OrgChild1Controller {
|
||||||
child1.createdFullName = request.user.name;
|
child1.createdFullName = request.user.name;
|
||||||
child1.lastUpdateUserId = request.user.sub;
|
child1.lastUpdateUserId = request.user.sub;
|
||||||
child1.lastUpdateFullName = request.user.name;
|
child1.lastUpdateFullName = request.user.name;
|
||||||
|
child1.createdAt = new Date();
|
||||||
|
child1.lastUpdatedAt = new Date();
|
||||||
child1.orgRevisionId = String(rootIdExits?.orgRevisionId);
|
child1.orgRevisionId = String(rootIdExits?.orgRevisionId);
|
||||||
child1.orgRootId = String(rootIdExits?.id);
|
child1.orgRootId = String(rootIdExits?.id);
|
||||||
child1.orgChild1Order =
|
child1.orgChild1Order =
|
||||||
|
|
|
||||||
|
|
@ -152,6 +152,8 @@ export class OrgChild2Controller extends Controller {
|
||||||
child2.createdFullName = request.user.name;
|
child2.createdFullName = request.user.name;
|
||||||
child2.lastUpdateUserId = request.user.sub;
|
child2.lastUpdateUserId = request.user.sub;
|
||||||
child2.lastUpdateFullName = request.user.name;
|
child2.lastUpdateFullName = request.user.name;
|
||||||
|
child2.createdAt = new Date();
|
||||||
|
child2.lastUpdatedAt = new Date();
|
||||||
child2.orgRootId = String(child1?.orgRootId);
|
child2.orgRootId = String(child1?.orgRootId);
|
||||||
child2.orgRevisionId = String(child1?.orgRevisionId);
|
child2.orgRevisionId = String(child1?.orgRevisionId);
|
||||||
child2.orgChild1Id = String(child1?.id);
|
child2.orgChild1Id = String(child1?.id);
|
||||||
|
|
|
||||||
|
|
@ -131,6 +131,8 @@ export class OrgChild3Controller {
|
||||||
child3.createdFullName = request.user.name;
|
child3.createdFullName = request.user.name;
|
||||||
child3.lastUpdateUserId = request.user.sub;
|
child3.lastUpdateUserId = request.user.sub;
|
||||||
child3.lastUpdateFullName = request.user.name;
|
child3.lastUpdateFullName = request.user.name;
|
||||||
|
child3.createdAt = new Date();
|
||||||
|
child3.lastUpdatedAt = new Date();
|
||||||
child3.orgRootId = String(child2?.orgRootId);
|
child3.orgRootId = String(child2?.orgRootId);
|
||||||
child3.orgChild1Id = String(child2?.orgChild1Id);
|
child3.orgChild1Id = String(child2?.orgChild1Id);
|
||||||
child3.orgRevisionId = String(child2?.orgRevisionId);
|
child3.orgRevisionId = String(child2?.orgRevisionId);
|
||||||
|
|
|
||||||
|
|
@ -150,6 +150,8 @@ export class OrgChild4Controller extends Controller {
|
||||||
child4.createdFullName = request.user.name;
|
child4.createdFullName = request.user.name;
|
||||||
child4.lastUpdateUserId = request.user.sub;
|
child4.lastUpdateUserId = request.user.sub;
|
||||||
child4.lastUpdateFullName = request.user.name;
|
child4.lastUpdateFullName = request.user.name;
|
||||||
|
child4.createdAt = new Date();
|
||||||
|
child4.lastUpdatedAt = new Date();
|
||||||
child4.orgRootId = String(child3?.orgRootId);
|
child4.orgRootId = String(child3?.orgRootId);
|
||||||
child4.orgChild1Id = String(child3?.orgChild1Id);
|
child4.orgChild1Id = String(child3?.orgChild1Id);
|
||||||
child4.orgChild2Id = String(child3?.orgChild2Id);
|
child4.orgChild2Id = String(child3?.orgChild2Id);
|
||||||
|
|
|
||||||
|
|
@ -152,6 +152,8 @@ export class OrgRootController extends Controller {
|
||||||
orgRoot.createdFullName = request.user.name;
|
orgRoot.createdFullName = request.user.name;
|
||||||
orgRoot.lastUpdateUserId = request.user.sub;
|
orgRoot.lastUpdateUserId = request.user.sub;
|
||||||
orgRoot.lastUpdateFullName = request.user.name;
|
orgRoot.lastUpdateFullName = request.user.name;
|
||||||
|
orgRoot.createdAt = new Date();
|
||||||
|
orgRoot.lastUpdatedAt = new Date();
|
||||||
orgRoot.orgRootOrder = order == null || order.orgRootOrder == null ? 1 : order.orgRootOrder + 1;
|
orgRoot.orgRootOrder = order == null || order.orgRootOrder == null ? 1 : order.orgRootOrder + 1;
|
||||||
await this.orgRootRepository.save(orgRoot);
|
await this.orgRootRepository.save(orgRoot);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -128,6 +128,8 @@ export class OrganizationController extends Controller {
|
||||||
revision.createdFullName = request.user.name;
|
revision.createdFullName = request.user.name;
|
||||||
revision.lastUpdateUserId = request.user.sub;
|
revision.lastUpdateUserId = request.user.sub;
|
||||||
revision.lastUpdateFullName = request.user.name;
|
revision.lastUpdateFullName = request.user.name;
|
||||||
|
revision.createdAt = new Date();
|
||||||
|
revision.lastUpdatedAt = new Date();
|
||||||
await this.orgRevisionRepository.save(revision);
|
await this.orgRevisionRepository.save(revision);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
|
@ -3443,6 +3445,20 @@ export class OrganizationController extends Controller {
|
||||||
"orgChild1s.orgChild2s.orgChild3s",
|
"orgChild1s.orgChild2s.orgChild3s",
|
||||||
"orgChild1s.orgChild2s.orgChild3s.orgChild4s",
|
"orgChild1s.orgChild2s.orgChild3s.orgChild4s",
|
||||||
],
|
],
|
||||||
|
order: {
|
||||||
|
orgChild1s: {
|
||||||
|
orgChild1Order: "ASC",
|
||||||
|
orgChild2s: {
|
||||||
|
orgChild2Order: "ASC",
|
||||||
|
orgChild3s: {
|
||||||
|
orgChild3Order: "ASC",
|
||||||
|
orgChild4s: {
|
||||||
|
orgChild4Order: "ASC",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
return new HttpSuccess(data);
|
return new HttpSuccess(data);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -828,6 +828,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
profile.dutyTimeEffectiveDate = body.effectiveDate;
|
profile.dutyTimeEffectiveDate = body.effectiveDate;
|
||||||
profile.lastUpdateUserId = req.user.sub;
|
profile.lastUpdateUserId = req.user.sub;
|
||||||
profile.lastUpdateFullName = req.user.name;
|
profile.lastUpdateFullName = req.user.name;
|
||||||
|
profile.lastUpdatedAt = new Date();
|
||||||
await this.profileRepo.save(profile);
|
await this.profileRepo.save(profile);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
@ -874,6 +875,8 @@ export class OrganizationDotnetController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,8 @@ export class PosExecutiveController extends Controller {
|
||||||
posExecutive.createdFullName = request.user.name;
|
posExecutive.createdFullName = request.user.name;
|
||||||
posExecutive.lastUpdateUserId = request.user.sub;
|
posExecutive.lastUpdateUserId = request.user.sub;
|
||||||
posExecutive.lastUpdateFullName = request.user.name;
|
posExecutive.lastUpdateFullName = request.user.name;
|
||||||
|
posExecutive.createdAt = new Date();
|
||||||
|
posExecutive.lastUpdatedAt = new Date();
|
||||||
await this.posExecutiveRepository.save(posExecutive);
|
await this.posExecutiveRepository.save(posExecutive);
|
||||||
return new HttpSuccess(posExecutive.id);
|
return new HttpSuccess(posExecutive.id);
|
||||||
}
|
}
|
||||||
|
|
@ -138,6 +140,7 @@ export class PosExecutiveController extends Controller {
|
||||||
posExecutive.posExecutiveName = requestBody.posExecutiveName;
|
posExecutive.posExecutiveName = requestBody.posExecutiveName;
|
||||||
posExecutive.lastUpdateUserId = request.user.sub;
|
posExecutive.lastUpdateUserId = request.user.sub;
|
||||||
posExecutive.lastUpdateFullName = request.user.name;
|
posExecutive.lastUpdateFullName = request.user.name;
|
||||||
|
posExecutive.lastUpdatedAt = new Date();
|
||||||
// this.posExecutiveRepository.merge(posExecutive, requestBody);
|
// this.posExecutiveRepository.merge(posExecutive, requestBody);
|
||||||
await this.posExecutiveRepository.save(posExecutive);
|
await this.posExecutiveRepository.save(posExecutive);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,8 @@ export class PosLevelController extends Controller {
|
||||||
posLevel.createdFullName = request.user.name;
|
posLevel.createdFullName = request.user.name;
|
||||||
posLevel.lastUpdateUserId = request.user.sub;
|
posLevel.lastUpdateUserId = request.user.sub;
|
||||||
posLevel.lastUpdateFullName = request.user.name;
|
posLevel.lastUpdateFullName = request.user.name;
|
||||||
|
posLevel.createdAt = new Date();
|
||||||
|
posLevel.lastUpdatedAt = new Date();
|
||||||
await this.posLevelRepository.save(posLevel);
|
await this.posLevelRepository.save(posLevel);
|
||||||
return new HttpSuccess(posLevel);
|
return new HttpSuccess(posLevel);
|
||||||
}
|
}
|
||||||
|
|
@ -144,6 +146,7 @@ export class PosLevelController extends Controller {
|
||||||
|
|
||||||
posLevel.lastUpdateUserId = request.user.sub;
|
posLevel.lastUpdateUserId = request.user.sub;
|
||||||
posLevel.lastUpdateFullName = request.user.name;
|
posLevel.lastUpdateFullName = request.user.name;
|
||||||
|
posLevel.lastUpdatedAt = new Date();
|
||||||
this.posLevelRepository.merge(posLevel, requestBody);
|
this.posLevelRepository.merge(posLevel, requestBody);
|
||||||
await this.posLevelRepository.save(posLevel);
|
await this.posLevelRepository.save(posLevel);
|
||||||
return new HttpSuccess(posLevel.id);
|
return new HttpSuccess(posLevel.id);
|
||||||
|
|
@ -158,11 +161,14 @@ export class PosLevelController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Delete("{id}")
|
@Delete("{id}")
|
||||||
async deleteLevel(@Path() id: string) {
|
async deleteLevel(@Path() id: string) {
|
||||||
let result :any
|
let result: any;
|
||||||
try {
|
try {
|
||||||
result = await this.posLevelRepository.delete({ id: id });
|
result = await this.posLevelRepository.delete({ id: id });
|
||||||
} catch {
|
} catch {
|
||||||
throw new HttpError( HttpStatusCode.NOT_FOUND, "ไม่สามารถลบได้เนื่องจากมีการใช้งานระดับตำแหน่งนี้อยู่");
|
throw new HttpError(
|
||||||
|
HttpStatusCode.NOT_FOUND,
|
||||||
|
"ไม่สามารถลบได้เนื่องจากมีการใช้งานระดับตำแหน่งนี้อยู่",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (result.affected == undefined || result.affected <= 0) {
|
if (result.affected == undefined || result.affected <= 0) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,8 @@ export class PosMasterActController extends Controller {
|
||||||
posMasterAct.createdFullName = request.user.name;
|
posMasterAct.createdFullName = request.user.name;
|
||||||
posMasterAct.lastUpdateUserId = request.user.sub;
|
posMasterAct.lastUpdateUserId = request.user.sub;
|
||||||
posMasterAct.lastUpdateFullName = request.user.name;
|
posMasterAct.lastUpdateFullName = request.user.name;
|
||||||
|
posMasterAct.createdAt = new Date();
|
||||||
|
posMasterAct.lastUpdatedAt = new Date();
|
||||||
await this.posMasterActRepository.save(posMasterAct);
|
await this.posMasterActRepository.save(posMasterAct);
|
||||||
return new HttpSuccess(posMasterAct);
|
return new HttpSuccess(posMasterAct);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,8 @@ export class PosTypeController extends Controller {
|
||||||
posType.createdFullName = request.user.name;
|
posType.createdFullName = request.user.name;
|
||||||
posType.lastUpdateUserId = request.user.sub;
|
posType.lastUpdateUserId = request.user.sub;
|
||||||
posType.lastUpdateFullName = request.user.name;
|
posType.lastUpdateFullName = request.user.name;
|
||||||
|
posType.createdAt = new Date();
|
||||||
|
posType.lastUpdatedAt = new Date();
|
||||||
await this.posTypeRepository.save(posType);
|
await this.posTypeRepository.save(posType);
|
||||||
return new HttpSuccess(posType);
|
return new HttpSuccess(posType);
|
||||||
}
|
}
|
||||||
|
|
@ -104,6 +106,7 @@ export class PosTypeController extends Controller {
|
||||||
}
|
}
|
||||||
posType.lastUpdateUserId = request.user.sub;
|
posType.lastUpdateUserId = request.user.sub;
|
||||||
posType.lastUpdateFullName = request.user.name;
|
posType.lastUpdateFullName = request.user.name;
|
||||||
|
posType.lastUpdatedAt = new Date();
|
||||||
this.posTypeRepository.merge(posType, requestBody);
|
this.posTypeRepository.merge(posType, requestBody);
|
||||||
await this.posTypeRepository.save(posType);
|
await this.posTypeRepository.save(posType);
|
||||||
return new HttpSuccess(posType.id);
|
return new HttpSuccess(posType.id);
|
||||||
|
|
@ -118,11 +121,14 @@ export class PosTypeController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Delete("{id}")
|
@Delete("{id}")
|
||||||
async deleteType(@Path() id: string) {
|
async deleteType(@Path() id: string) {
|
||||||
let result :any
|
let result: any;
|
||||||
try {
|
try {
|
||||||
result = await this.posTypeRepository.delete({ id: id });
|
result = await this.posTypeRepository.delete({ id: id });
|
||||||
} catch {
|
} catch {
|
||||||
throw new HttpError( HttpStatusCode.NOT_FOUND, "ไม่สามารถลบได้เนื่องจากมีการใช้งานประเภทตำแหน่งนี้อยู่");
|
throw new HttpError(
|
||||||
|
HttpStatusCode.NOT_FOUND,
|
||||||
|
"ไม่สามารถลบได้เนื่องจากมีการใช้งานประเภทตำแหน่งนี้อยู่",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (result.affected == undefined || result.affected <= 0) {
|
if (result.affected == undefined || result.affected <= 0) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
|
||||||
|
|
@ -143,6 +143,8 @@ export class PositionController extends Controller {
|
||||||
posDict.createdFullName = request.user.name;
|
posDict.createdFullName = request.user.name;
|
||||||
posDict.lastUpdateUserId = request.user.sub;
|
posDict.lastUpdateUserId = request.user.sub;
|
||||||
posDict.lastUpdateFullName = request.user.name;
|
posDict.lastUpdateFullName = request.user.name;
|
||||||
|
posDict.createdAt = new Date();
|
||||||
|
posDict.lastUpdatedAt = new Date();
|
||||||
await this.posDictRepository.save(posDict);
|
await this.posDictRepository.save(posDict);
|
||||||
return new HttpSuccess(posDict.id);
|
return new HttpSuccess(posDict.id);
|
||||||
}
|
}
|
||||||
|
|
@ -222,6 +224,8 @@ export class PositionController extends Controller {
|
||||||
posExecutive.createdFullName = request.user.name;
|
posExecutive.createdFullName = request.user.name;
|
||||||
posExecutive.lastUpdateUserId = request.user.sub;
|
posExecutive.lastUpdateUserId = request.user.sub;
|
||||||
posExecutive.lastUpdateFullName = request.user.name;
|
posExecutive.lastUpdateFullName = request.user.name;
|
||||||
|
posExecutive.createdAt = new Date();
|
||||||
|
posExecutive.lastUpdatedAt = new Date();
|
||||||
await this.posExecutiveRepository.save(posExecutive);
|
await this.posExecutiveRepository.save(posExecutive);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -246,6 +250,8 @@ export class PositionController extends Controller {
|
||||||
posDict.createdFullName = request.user.name;
|
posDict.createdFullName = request.user.name;
|
||||||
posDict.lastUpdateUserId = request.user.sub;
|
posDict.lastUpdateUserId = request.user.sub;
|
||||||
posDict.lastUpdateFullName = request.user.name;
|
posDict.lastUpdateFullName = request.user.name;
|
||||||
|
posDict.createdAt = new Date();
|
||||||
|
posDict.lastUpdatedAt = new Date();
|
||||||
await this.posDictRepository.save(posDict);
|
await this.posDictRepository.save(posDict);
|
||||||
return new HttpSuccess(posDict.id);
|
return new HttpSuccess(posDict.id);
|
||||||
}
|
}
|
||||||
|
|
@ -331,16 +337,17 @@ export class PositionController extends Controller {
|
||||||
Object.assign(posDict, requestBody);
|
Object.assign(posDict, requestBody);
|
||||||
posDict.lastUpdateUserId = request.user.sub;
|
posDict.lastUpdateUserId = request.user.sub;
|
||||||
posDict.lastUpdateFullName = request.user.name;
|
posDict.lastUpdateFullName = request.user.name;
|
||||||
(posDict.posDictName = requestBody.posDictName),
|
posDict.lastUpdatedAt = new Date();
|
||||||
(posDict.posDictField = requestBody.posDictField),
|
posDict.posDictName = requestBody.posDictName;
|
||||||
(posDict.posTypeId = requestBody.posTypeId),
|
posDict.posDictField = requestBody.posDictField;
|
||||||
(posDict.posLevelId = requestBody.posLevelId),
|
posDict.posTypeId = requestBody.posTypeId;
|
||||||
(posDict.posExecutiveId = requestBody.posExecutiveId ? requestBody.posExecutiveId : null),
|
posDict.posLevelId = requestBody.posLevelId;
|
||||||
(posDict.posDictExecutiveField = requestBody.posDictExecutiveField
|
posDict.posExecutiveId = requestBody.posExecutiveId ? requestBody.posExecutiveId : null;
|
||||||
|
posDict.posDictExecutiveField = requestBody.posDictExecutiveField
|
||||||
? requestBody.posDictExecutiveField
|
? requestBody.posDictExecutiveField
|
||||||
: ""),
|
: "";
|
||||||
(posDict.posDictArea = requestBody.posDictArea ? requestBody.posDictArea : ""),
|
posDict.posDictArea = requestBody.posDictArea ? requestBody.posDictArea : "";
|
||||||
(posDict.isSpecial = requestBody.isSpecial),
|
posDict.isSpecial = requestBody.isSpecial;
|
||||||
// this.posDictRepository.merge(posDict, requestBody);
|
// this.posDictRepository.merge(posDict, requestBody);
|
||||||
await this.posDictRepository.save(posDict);
|
await this.posDictRepository.save(posDict);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
|
|
@ -743,6 +750,8 @@ export class PositionController extends Controller {
|
||||||
posMaster.createdFullName = request.user.name;
|
posMaster.createdFullName = request.user.name;
|
||||||
posMaster.lastUpdateUserId = request.user.sub;
|
posMaster.lastUpdateUserId = request.user.sub;
|
||||||
posMaster.lastUpdateFullName = request.user.name;
|
posMaster.lastUpdateFullName = request.user.name;
|
||||||
|
posMaster.createdAt = new Date();
|
||||||
|
posMaster.lastUpdatedAt = new Date();
|
||||||
await this.posMasterRepository.save(posMaster);
|
await this.posMasterRepository.save(posMaster);
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
requestBody.positions.map(async (x: any) => {
|
requestBody.positions.map(async (x: any) => {
|
||||||
|
|
@ -761,6 +770,8 @@ export class PositionController extends Controller {
|
||||||
position.createdFullName = request.user.name;
|
position.createdFullName = request.user.name;
|
||||||
position.lastUpdateUserId = request.user.sub;
|
position.lastUpdateUserId = request.user.sub;
|
||||||
position.lastUpdateFullName = request.user.name;
|
position.lastUpdateFullName = request.user.name;
|
||||||
|
position.createdAt = new Date();
|
||||||
|
position.lastUpdatedAt = new Date();
|
||||||
await this.positionRepository.save(position);
|
await this.positionRepository.save(position);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
@ -948,6 +959,8 @@ export class PositionController extends Controller {
|
||||||
posMaster.createdFullName = request.user.name;
|
posMaster.createdFullName = request.user.name;
|
||||||
posMaster.lastUpdateUserId = request.user.sub;
|
posMaster.lastUpdateUserId = request.user.sub;
|
||||||
posMaster.lastUpdateFullName = request.user.name;
|
posMaster.lastUpdateFullName = request.user.name;
|
||||||
|
posMaster.createdAt = new Date();
|
||||||
|
posMaster.lastUpdatedAt = new Date();
|
||||||
await this.posMasterRepository.save(posMaster);
|
await this.posMasterRepository.save(posMaster);
|
||||||
await this.positionRepository.delete({ posMasterId: posMaster.id });
|
await this.positionRepository.delete({ posMasterId: posMaster.id });
|
||||||
|
|
||||||
|
|
@ -970,6 +983,8 @@ export class PositionController extends Controller {
|
||||||
position.createdFullName = request.user.name;
|
position.createdFullName = request.user.name;
|
||||||
position.lastUpdateUserId = request.user.sub;
|
position.lastUpdateUserId = request.user.sub;
|
||||||
position.lastUpdateFullName = request.user.name;
|
position.lastUpdateFullName = request.user.name;
|
||||||
|
position.createdAt = new Date();
|
||||||
|
position.lastUpdatedAt = new Date();
|
||||||
await this.positionRepository.save(position);
|
await this.positionRepository.save(position);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
@ -1407,7 +1422,10 @@ export class PositionController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Post("sort")
|
@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");
|
await new permission().PermissionUpdate(request, "SYS_ORG");
|
||||||
switch (requestBody.type) {
|
switch (requestBody.type) {
|
||||||
case 0: {
|
case 0: {
|
||||||
|
|
@ -2014,6 +2032,8 @@ export class PositionController extends Controller {
|
||||||
posMaster.createdFullName = request.user.name;
|
posMaster.createdFullName = request.user.name;
|
||||||
posMaster.lastUpdateUserId = request.user.sub;
|
posMaster.lastUpdateUserId = request.user.sub;
|
||||||
posMaster.lastUpdateFullName = request.user.name;
|
posMaster.lastUpdateFullName = request.user.name;
|
||||||
|
posMaster.createdAt = new Date();
|
||||||
|
posMaster.lastUpdatedAt = new Date();
|
||||||
await this.posMasterRepository.save(posMaster);
|
await this.posMasterRepository.save(posMaster);
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
@ -2476,7 +2496,7 @@ export class PositionController extends Controller {
|
||||||
@Post("profile")
|
@Post("profile")
|
||||||
async createHolder(
|
async createHolder(
|
||||||
@Body() requestBody: { posMaster: string; position: string; profileId: string; isSit: boolean },
|
@Body() requestBody: { posMaster: string; position: string; profileId: string; isSit: boolean },
|
||||||
@Request() request: RequestWithUser
|
@Request() request: RequestWithUser,
|
||||||
) {
|
) {
|
||||||
await new permission().PermissionUpdate(request, "SYS_ORG");
|
await new permission().PermissionUpdate(request, "SYS_ORG");
|
||||||
const dataMaster = await this.posMasterRepository.findOne({
|
const dataMaster = await this.posMasterRepository.findOne({
|
||||||
|
|
@ -2540,7 +2560,10 @@ export class PositionController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Post("dna")
|
@Post("dna")
|
||||||
async dna(@Body() requestBody: { draftPositionId: string; publishPositionId: string }, @Request() request: RequestWithUser) {
|
async dna(
|
||||||
|
@Body() requestBody: { draftPositionId: string; publishPositionId: string },
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
|
) {
|
||||||
await new permission().PermissionUpdate(request, "SYS_ORG");
|
await new permission().PermissionUpdate(request, "SYS_ORG");
|
||||||
const findDraft = await this.orgRevisionRepository.findOne({
|
const findDraft = await this.orgRevisionRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,8 @@ export class PrefixController extends Controller {
|
||||||
_prefix.createdFullName = request.user.name;
|
_prefix.createdFullName = request.user.name;
|
||||||
_prefix.lastUpdateUserId = request.user.sub;
|
_prefix.lastUpdateUserId = request.user.sub;
|
||||||
_prefix.lastUpdateFullName = request.user.name;
|
_prefix.lastUpdateFullName = request.user.name;
|
||||||
|
_prefix.createdAt = new Date();
|
||||||
|
_prefix.lastUpdatedAt = new Date();
|
||||||
await this.prefixRepository.save(_prefix);
|
await this.prefixRepository.save(_prefix);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
@ -128,6 +130,7 @@ export class PrefixController extends Controller {
|
||||||
|
|
||||||
_prefix.lastUpdateUserId = request.user.sub;
|
_prefix.lastUpdateUserId = request.user.sub;
|
||||||
_prefix.lastUpdateFullName = request.user.name;
|
_prefix.lastUpdateFullName = request.user.name;
|
||||||
|
_prefix.lastUpdatedAt = new Date();
|
||||||
this.prefixRepository.merge(_prefix, requestBody);
|
this.prefixRepository.merge(_prefix, requestBody);
|
||||||
await this.prefixRepository.save(_prefix);
|
await this.prefixRepository.save(_prefix);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
Example,
|
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
Path,
|
Path,
|
||||||
|
|
@ -41,6 +40,7 @@ export class ProfileAbilityController extends Controller {
|
||||||
}
|
}
|
||||||
const getProfileAbilityId = await this.profileAbilityRepo.find({
|
const getProfileAbilityId = await this.profileAbilityRepo.find({
|
||||||
where: { profileId: profile.id },
|
where: { profileId: profile.id },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
if (!getProfileAbilityId) {
|
if (!getProfileAbilityId) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
@ -49,31 +49,12 @@ export class ProfileAbilityController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileId}")
|
@Get("{profileId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "ad7d0955-7bcd-4ed0-911c-2edceba12579",
|
|
||||||
createdAt: "2024-03-12T21:37:35.037Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-12T21:37:35.037Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "test bar",
|
|
||||||
lastUpdateFullName: "test bar",
|
|
||||||
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
remark: "ต้องส่งให้ทันก่อนวันที่ 15 มีนาคม",
|
|
||||||
detail: "-",
|
|
||||||
reference: "-",
|
|
||||||
dateStart: "2024-03-13T04:36:06.000Z",
|
|
||||||
dateEnd: "2024-03-13T04:36:06.000Z",
|
|
||||||
field: "ความมั่นคง",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async detailProfileAbility(@Path() profileId: string, @Request() req: RequestWithUser) {
|
public async detailProfileAbility(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||||
const getProfileAbilityId = await this.profileAbilityRepo.findBy({ profileId });
|
const getProfileAbilityId = await this.profileAbilityRepo.find({
|
||||||
|
where: { profileId: profileId },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
|
});
|
||||||
if (!getProfileAbilityId) {
|
if (!getProfileAbilityId) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
}
|
}
|
||||||
|
|
@ -81,44 +62,6 @@ export class ProfileAbilityController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{abilityId}")
|
@Get("history/{abilityId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "1c92cd8a-e176-48af-ac00-c018fb4c9895",
|
|
||||||
createdAt: "2024-03-12T21:38:56.342Z",
|
|
||||||
createdUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
lastUpdatedAt: "2024-03-12T21:38:56.342Z",
|
|
||||||
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
createdFullName: "string",
|
|
||||||
lastUpdateFullName: "test bar",
|
|
||||||
remark: "ต้องส่งให้ทันก่อนวันที่ 15 มีนาคม",
|
|
||||||
detail: "ด่วน",
|
|
||||||
reference: "-",
|
|
||||||
dateStart: "2024-03-13T04:36:06.000Z",
|
|
||||||
dateEnd: "2024-03-13T04:36:06.000Z",
|
|
||||||
field: "ความมั่นคง",
|
|
||||||
profileAbilityId: "ad7d0955-7bcd-4ed0-911c-2edceba12579",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "2fb95768-cb62-40a3-9540-5a561d640959",
|
|
||||||
createdAt: "2024-03-12T21:39:06.094Z",
|
|
||||||
createdUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
lastUpdatedAt: "2024-03-12T21:39:06.094Z",
|
|
||||||
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
createdFullName: "string",
|
|
||||||
lastUpdateFullName: "test bar",
|
|
||||||
remark: "ต้องส่งให้ทันก่อนวันที่ 15 มีนาคม",
|
|
||||||
detail: "ด่วนมากสุด",
|
|
||||||
reference: "-",
|
|
||||||
dateStart: "2024-03-13T04:36:06.000Z",
|
|
||||||
dateEnd: "2024-03-13T04:36:06.000Z",
|
|
||||||
field: "ความมั่นคง",
|
|
||||||
profileAbilityId: "ad7d0955-7bcd-4ed0-911c-2edceba12579",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async getProfileAbilityHistory(
|
public async getProfileAbilityHistory(
|
||||||
@Path() abilityId: string,
|
@Path() abilityId: string,
|
||||||
@Request() req: RequestWithUser,
|
@Request() req: RequestWithUser,
|
||||||
|
|
@ -130,8 +73,8 @@ export class ProfileAbilityController extends Controller {
|
||||||
// await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
// await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
||||||
// }
|
// }
|
||||||
const record = await this.profileAbilityHistoryRepo.find({
|
const record = await this.profileAbilityHistoryRepo.find({
|
||||||
relations: ["histories"],
|
|
||||||
where: { profileAbilityId: abilityId },
|
where: { profileAbilityId: abilityId },
|
||||||
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!record) {
|
if (!record) {
|
||||||
|
|
@ -161,6 +104,8 @@ export class ProfileAbilityController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -187,15 +132,18 @@ export class ProfileAbilityController extends Controller {
|
||||||
const history = new ProfileAbilityHistory();
|
const history = new ProfileAbilityHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileAbilityId = abilityId;
|
history.profileAbilityId = abilityId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.profileAbilityRepo.save(record),
|
this.profileAbilityRepo.save(record),
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
Example,
|
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
Path,
|
Path,
|
||||||
|
|
@ -13,9 +12,7 @@ import {
|
||||||
Tags,
|
Tags,
|
||||||
} from "tsoa";
|
} from "tsoa";
|
||||||
import { AppDataSource } from "../database/data-source";
|
import { AppDataSource } from "../database/data-source";
|
||||||
import { Profile } from "../entities/Profile";
|
|
||||||
import {
|
import {
|
||||||
CreateProfileAbility,
|
|
||||||
CreateProfileAbilityEmployee,
|
CreateProfileAbilityEmployee,
|
||||||
ProfileAbility,
|
ProfileAbility,
|
||||||
UpdateProfileAbility,
|
UpdateProfileAbility,
|
||||||
|
|
@ -43,6 +40,7 @@ export class ProfileAbilityEmployeeController extends Controller {
|
||||||
}
|
}
|
||||||
const getProfileAbilityId = await this.profileAbilityRepo.find({
|
const getProfileAbilityId = await this.profileAbilityRepo.find({
|
||||||
where: { profileEmployeeId: profile.id },
|
where: { profileEmployeeId: profile.id },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
if (!getProfileAbilityId) {
|
if (!getProfileAbilityId) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
@ -51,31 +49,15 @@ export class ProfileAbilityEmployeeController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileEmployeeId}")
|
@Get("{profileEmployeeId}")
|
||||||
@Example({
|
public async detailProfileAbility(
|
||||||
status: 200,
|
@Path() profileEmployeeId: string,
|
||||||
message: "สำเร็จ",
|
@Request() req: RequestWithUser,
|
||||||
result: [
|
) {
|
||||||
{
|
|
||||||
id: "ad7d0955-7bcd-4ed0-911c-2edceba12579",
|
|
||||||
createdAt: "2024-03-12T21:37:35.037Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-12T21:37:35.037Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "test bar",
|
|
||||||
lastUpdateFullName: "test bar",
|
|
||||||
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
remark: "ต้องส่งให้ทันก่อนวันที่ 15 มีนาคม",
|
|
||||||
detail: "-",
|
|
||||||
reference: "-",
|
|
||||||
dateStart: "2024-03-13T04:36:06.000Z",
|
|
||||||
dateEnd: "2024-03-13T04:36:06.000Z",
|
|
||||||
field: "ความมั่นคง",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async detailProfileAbility(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
||||||
const getProfileAbilityId = await this.profileAbilityRepo.findBy({ profileEmployeeId });
|
const getProfileAbilityId = await this.profileAbilityRepo.find({
|
||||||
|
where: { profileEmployeeId: profileEmployeeId },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
|
});
|
||||||
if (!getProfileAbilityId) {
|
if (!getProfileAbilityId) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
}
|
}
|
||||||
|
|
@ -83,45 +65,10 @@ export class ProfileAbilityEmployeeController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{abilityId}")
|
@Get("history/{abilityId}")
|
||||||
@Example({
|
public async getProfileAbilityHistory(
|
||||||
status: 200,
|
@Path() abilityId: string,
|
||||||
message: "สำเร็จ",
|
@Request() req: RequestWithUser,
|
||||||
result: [
|
) {
|
||||||
{
|
|
||||||
id: "1c92cd8a-e176-48af-ac00-c018fb4c9895",
|
|
||||||
createdAt: "2024-03-12T21:38:56.342Z",
|
|
||||||
createdUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
lastUpdatedAt: "2024-03-12T21:38:56.342Z",
|
|
||||||
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
createdFullName: "string",
|
|
||||||
lastUpdateFullName: "test bar",
|
|
||||||
remark: "ต้องส่งให้ทันก่อนวันที่ 15 มีนาคม",
|
|
||||||
detail: "ด่วน",
|
|
||||||
reference: "-",
|
|
||||||
dateStart: "2024-03-13T04:36:06.000Z",
|
|
||||||
dateEnd: "2024-03-13T04:36:06.000Z",
|
|
||||||
field: "ความมั่นคง",
|
|
||||||
profileAbilityId: "ad7d0955-7bcd-4ed0-911c-2edceba12579",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "2fb95768-cb62-40a3-9540-5a561d640959",
|
|
||||||
createdAt: "2024-03-12T21:39:06.094Z",
|
|
||||||
createdUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
lastUpdatedAt: "2024-03-12T21:39:06.094Z",
|
|
||||||
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
createdFullName: "string",
|
|
||||||
lastUpdateFullName: "test bar",
|
|
||||||
remark: "ต้องส่งให้ทันก่อนวันที่ 15 มีนาคม",
|
|
||||||
detail: "ด่วนมากสุด",
|
|
||||||
reference: "-",
|
|
||||||
dateStart: "2024-03-13T04:36:06.000Z",
|
|
||||||
dateEnd: "2024-03-13T04:36:06.000Z",
|
|
||||||
field: "ความมั่นคง",
|
|
||||||
profileAbilityId: "ad7d0955-7bcd-4ed0-911c-2edceba12579",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async getProfileAbilityHistory(@Path() abilityId: string, @Request() req: RequestWithUser) {
|
|
||||||
const _record = await this.profileAbilityRepo.findOneBy({ id: abilityId });
|
const _record = await this.profileAbilityRepo.findOneBy({ id: abilityId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserGet(
|
await new permission().PermissionOrgUserGet(
|
||||||
|
|
@ -130,8 +77,9 @@ export class ProfileAbilityEmployeeController extends Controller {
|
||||||
_record.profileEmployeeId,
|
_record.profileEmployeeId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const record = await this.profileAbilityHistoryRepo.findBy({
|
const record = await this.profileAbilityHistoryRepo.find({
|
||||||
profileAbilityId: abilityId,
|
where: { profileAbilityId: abilityId },
|
||||||
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
if (!record) {
|
if (!record) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
@ -160,6 +108,8 @@ export class ProfileAbilityEmployeeController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -181,20 +131,27 @@ export class ProfileAbilityEmployeeController extends Controller {
|
||||||
) {
|
) {
|
||||||
const record = await this.profileAbilityRepo.findOneBy({ id: abilityId });
|
const record = await this.profileAbilityRepo.findOneBy({ id: abilityId });
|
||||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId);
|
await new permission().PermissionOrgUserUpdate(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
record.profileEmployeeId,
|
||||||
|
);
|
||||||
|
|
||||||
const history = new ProfileAbilityHistory();
|
const history = new ProfileAbilityHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileAbilityId = abilityId;
|
history.profileAbilityId = abilityId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.profileAbilityRepo.save(record),
|
this.profileAbilityRepo.save(record),
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
Example,
|
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
Path,
|
Path,
|
||||||
|
|
@ -13,9 +12,7 @@ import {
|
||||||
Tags,
|
Tags,
|
||||||
} from "tsoa";
|
} from "tsoa";
|
||||||
import { AppDataSource } from "../database/data-source";
|
import { AppDataSource } from "../database/data-source";
|
||||||
import { Profile } from "../entities/Profile";
|
|
||||||
import {
|
import {
|
||||||
CreateProfileAbility,
|
|
||||||
CreateProfileAbilityEmployee,
|
CreateProfileAbilityEmployee,
|
||||||
ProfileAbility,
|
ProfileAbility,
|
||||||
UpdateProfileAbility,
|
UpdateProfileAbility,
|
||||||
|
|
@ -43,6 +40,7 @@ export class ProfileAbilityEmployeeTempController extends Controller {
|
||||||
}
|
}
|
||||||
const getProfileAbilityId = await this.profileAbilityRepo.find({
|
const getProfileAbilityId = await this.profileAbilityRepo.find({
|
||||||
where: { profileEmployeeId: profile.id },
|
where: { profileEmployeeId: profile.id },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
if (!getProfileAbilityId) {
|
if (!getProfileAbilityId) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
@ -51,31 +49,15 @@ export class ProfileAbilityEmployeeTempController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileEmployeeId}")
|
@Get("{profileEmployeeId}")
|
||||||
@Example({
|
public async detailProfileAbility(
|
||||||
status: 200,
|
@Path() profileEmployeeId: string,
|
||||||
message: "สำเร็จ",
|
@Request() req: RequestWithUser,
|
||||||
result: [
|
) {
|
||||||
{
|
|
||||||
id: "ad7d0955-7bcd-4ed0-911c-2edceba12579",
|
|
||||||
createdAt: "2024-03-12T21:37:35.037Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-12T21:37:35.037Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "test bar",
|
|
||||||
lastUpdateFullName: "test bar",
|
|
||||||
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
remark: "ต้องส่งให้ทันก่อนวันที่ 15 มีนาคม",
|
|
||||||
detail: "-",
|
|
||||||
reference: "-",
|
|
||||||
dateStart: "2024-03-13T04:36:06.000Z",
|
|
||||||
dateEnd: "2024-03-13T04:36:06.000Z",
|
|
||||||
field: "ความมั่นคง",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async detailProfileAbility(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
|
||||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||||
const getProfileAbilityId = await this.profileAbilityRepo.findBy({ profileEmployeeId });
|
const getProfileAbilityId = await this.profileAbilityRepo.find({
|
||||||
|
where: { profileEmployeeId: profileEmployeeId },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
|
});
|
||||||
if (!getProfileAbilityId) {
|
if (!getProfileAbilityId) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
}
|
}
|
||||||
|
|
@ -83,52 +65,17 @@ export class ProfileAbilityEmployeeTempController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{abilityId}")
|
@Get("history/{abilityId}")
|
||||||
@Example({
|
public async getProfileAbilityHistory(
|
||||||
status: 200,
|
@Path() abilityId: string,
|
||||||
message: "สำเร็จ",
|
@Request() req: RequestWithUser,
|
||||||
result: [
|
) {
|
||||||
{
|
|
||||||
id: "1c92cd8a-e176-48af-ac00-c018fb4c9895",
|
|
||||||
createdAt: "2024-03-12T21:38:56.342Z",
|
|
||||||
createdUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
lastUpdatedAt: "2024-03-12T21:38:56.342Z",
|
|
||||||
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
createdFullName: "string",
|
|
||||||
lastUpdateFullName: "test bar",
|
|
||||||
remark: "ต้องส่งให้ทันก่อนวันที่ 15 มีนาคม",
|
|
||||||
detail: "ด่วน",
|
|
||||||
reference: "-",
|
|
||||||
dateStart: "2024-03-13T04:36:06.000Z",
|
|
||||||
dateEnd: "2024-03-13T04:36:06.000Z",
|
|
||||||
field: "ความมั่นคง",
|
|
||||||
profileAbilityId: "ad7d0955-7bcd-4ed0-911c-2edceba12579",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "2fb95768-cb62-40a3-9540-5a561d640959",
|
|
||||||
createdAt: "2024-03-12T21:39:06.094Z",
|
|
||||||
createdUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
lastUpdatedAt: "2024-03-12T21:39:06.094Z",
|
|
||||||
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
createdFullName: "string",
|
|
||||||
lastUpdateFullName: "test bar",
|
|
||||||
remark: "ต้องส่งให้ทันก่อนวันที่ 15 มีนาคม",
|
|
||||||
detail: "ด่วนมากสุด",
|
|
||||||
reference: "-",
|
|
||||||
dateStart: "2024-03-13T04:36:06.000Z",
|
|
||||||
dateEnd: "2024-03-13T04:36:06.000Z",
|
|
||||||
field: "ความมั่นคง",
|
|
||||||
profileAbilityId: "ad7d0955-7bcd-4ed0-911c-2edceba12579",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async getProfileAbilityHistory(@Path() abilityId: string, @Request() req: RequestWithUser) {
|
|
||||||
const _record = await this.profileAbilityRepo.findOneBy({ id: abilityId });
|
const _record = await this.profileAbilityRepo.findOneBy({ id: abilityId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||||
}
|
}
|
||||||
|
const record = await this.profileAbilityHistoryRepo.find({
|
||||||
const record = await this.profileAbilityHistoryRepo.findBy({
|
where: { profileAbilityId: abilityId },
|
||||||
profileAbilityId: abilityId,
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
if (!record) {
|
if (!record) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
@ -157,6 +104,8 @@ export class ProfileAbilityEmployeeTempController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -178,20 +127,23 @@ export class ProfileAbilityEmployeeTempController extends Controller {
|
||||||
) {
|
) {
|
||||||
const record = await this.profileAbilityRepo.findOneBy({ id: abilityId });
|
const record = await this.profileAbilityRepo.findOneBy({ id: abilityId });
|
||||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP")
|
await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");
|
||||||
|
|
||||||
const history = new ProfileAbilityHistory();
|
const history = new ProfileAbilityHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileAbilityId = abilityId;
|
history.profileAbilityId = abilityId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.profileAbilityRepo.save(record),
|
this.profileAbilityRepo.save(record),
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,4 @@
|
||||||
import {
|
import { Controller, Route, Security, Tags, Body, Path, Request, Get, Patch } from "tsoa";
|
||||||
Controller,
|
|
||||||
Post,
|
|
||||||
Put,
|
|
||||||
Delete,
|
|
||||||
Route,
|
|
||||||
Security,
|
|
||||||
Tags,
|
|
||||||
Body,
|
|
||||||
Path,
|
|
||||||
Request,
|
|
||||||
SuccessResponse,
|
|
||||||
Response,
|
|
||||||
Get,
|
|
||||||
Query,
|
|
||||||
Patch,
|
|
||||||
Example,
|
|
||||||
} from "tsoa";
|
|
||||||
|
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
import HttpSuccess from "../interfaces/http-success";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
|
|
@ -23,9 +6,6 @@ import HttpStatus from "../interfaces/http-status";
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
import { RequestWithUser } from "../middlewares/user";
|
||||||
import { Profile, ProfileAddressHistory, UpdateProfileAddress } from "../entities/Profile";
|
import { Profile, ProfileAddressHistory, UpdateProfileAddress } from "../entities/Profile";
|
||||||
import { AppDataSource } from "../database/data-source";
|
import { AppDataSource } from "../database/data-source";
|
||||||
import { Province } from "../entities/Province";
|
|
||||||
import { District } from "../entities/District";
|
|
||||||
import { SubDistrict } from "../entities/SubDistrict";
|
|
||||||
import permission from "../interfaces/permission";
|
import permission from "../interfaces/permission";
|
||||||
@Route("api/v1/org/profile/address")
|
@Route("api/v1/org/profile/address")
|
||||||
@Tags("ProfileAddress")
|
@Tags("ProfileAddress")
|
||||||
|
|
@ -55,6 +35,7 @@ export class ProfileAddressController extends Controller {
|
||||||
"currentSubDistrictId",
|
"currentSubDistrictId",
|
||||||
"currentZipCode",
|
"currentZipCode",
|
||||||
],
|
],
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
if (!getProfileAddress) {
|
if (!getProfileAddress) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
@ -105,33 +86,32 @@ export class ProfileAddressController extends Controller {
|
||||||
}
|
}
|
||||||
const record = await this.profileAddressHistoryRepo.find({
|
const record = await this.profileAddressHistoryRepo.find({
|
||||||
where: { profileId: profile.id },
|
where: { profileId: profile.id },
|
||||||
relations: {
|
relations: [
|
||||||
registrationProvince: true,
|
"registrationProvince",
|
||||||
registrationDistrict: true,
|
"registrationDistrict",
|
||||||
registrationSubDistrict: true,
|
"registrationSubDistrict",
|
||||||
currentProvince: true,
|
"currentProvince",
|
||||||
currentDistrict: true,
|
"currentDistrict",
|
||||||
currentSubDistrict: true,
|
"currentSubDistrict",
|
||||||
},
|
|
||||||
select: [
|
|
||||||
"registrationAddress",
|
|
||||||
"registrationProvinceId",
|
|
||||||
"registrationDistrictId",
|
|
||||||
"registrationSubDistrictId",
|
|
||||||
"registrationZipCode",
|
|
||||||
"currentAddress",
|
|
||||||
"currentProvinceId",
|
|
||||||
"currentDistrictId",
|
|
||||||
"currentSubDistrictId",
|
|
||||||
"currentZipCode",
|
|
||||||
"lastUpdateFullName",
|
|
||||||
"lastUpdatedAt",
|
|
||||||
],
|
],
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
if (!record) {
|
const _record = record.map((item) => ({
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
id: item.id,
|
||||||
}
|
currentAddress: item.currentAddress,
|
||||||
return new HttpSuccess(record);
|
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}")
|
@Get("history/{profileId}")
|
||||||
public async getProfileAddressHistory(@Path() profileId: string, @Request() req: RequestWithUser) {
|
public async getProfileAddressHistory(
|
||||||
|
@Path() profileId: string,
|
||||||
|
@Request() req: RequestWithUser,
|
||||||
|
) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||||
const record = await this.profileAddressHistoryRepo.find({
|
const record = await this.profileAddressHistoryRepo.find({
|
||||||
where: { profileId: profileId },
|
where: { profileId: profileId },
|
||||||
relations: {
|
relations: [
|
||||||
registrationProvince: true,
|
"registrationProvince",
|
||||||
registrationDistrict: true,
|
"registrationDistrict",
|
||||||
registrationSubDistrict: true,
|
"registrationSubDistrict",
|
||||||
currentProvince: true,
|
"currentProvince",
|
||||||
currentDistrict: true,
|
"currentDistrict",
|
||||||
currentSubDistrict: true,
|
"currentSubDistrict",
|
||||||
},
|
|
||||||
select: [
|
|
||||||
"registrationAddress",
|
|
||||||
"registrationProvinceId",
|
|
||||||
"registrationDistrictId",
|
|
||||||
"registrationSubDistrictId",
|
|
||||||
"registrationZipCode",
|
|
||||||
"currentAddress",
|
|
||||||
"currentProvinceId",
|
|
||||||
"currentDistrictId",
|
|
||||||
"currentSubDistrictId",
|
|
||||||
"currentZipCode",
|
|
||||||
"lastUpdateFullName",
|
|
||||||
"lastUpdatedAt",
|
|
||||||
],
|
],
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
if (!record) {
|
const _record = record.map((item) => ({
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
id: item.id,
|
||||||
}
|
currentAddress: item.currentAddress,
|
||||||
return new HttpSuccess(record);
|
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();
|
const history = new ProfileAddressHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileId = profileId;
|
history.profileId = profileId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.profileRepo.save(record),
|
this.profileRepo.save(record),
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,11 @@
|
||||||
import {
|
import { Controller, Route, Security, Tags, Body, Path, Request, Get, Patch } from "tsoa";
|
||||||
Controller,
|
|
||||||
Post,
|
|
||||||
Put,
|
|
||||||
Delete,
|
|
||||||
Route,
|
|
||||||
Security,
|
|
||||||
Tags,
|
|
||||||
Body,
|
|
||||||
Path,
|
|
||||||
Request,
|
|
||||||
SuccessResponse,
|
|
||||||
Response,
|
|
||||||
Get,
|
|
||||||
Query,
|
|
||||||
Patch,
|
|
||||||
Example,
|
|
||||||
} from "tsoa";
|
|
||||||
|
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
import HttpSuccess from "../interfaces/http-success";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
import HttpStatus from "../interfaces/http-status";
|
import HttpStatus from "../interfaces/http-status";
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
import { RequestWithUser } from "../middlewares/user";
|
||||||
import { Profile, ProfileAddressHistory, UpdateProfileAddress } from "../entities/Profile";
|
import { ProfileAddressHistory } from "../entities/Profile";
|
||||||
import { AppDataSource } from "../database/data-source";
|
import { AppDataSource } from "../database/data-source";
|
||||||
import { Province } from "../entities/Province";
|
|
||||||
import { District } from "../entities/District";
|
|
||||||
import { SubDistrict } from "../entities/SubDistrict";
|
|
||||||
import { ProfileEmployee, UpdateProfileAddressEmployee } from "../entities/ProfileEmployee";
|
import { ProfileEmployee, UpdateProfileAddressEmployee } from "../entities/ProfileEmployee";
|
||||||
import permission from "../interfaces/permission";
|
import permission from "../interfaces/permission";
|
||||||
@Route("api/v1/org/profile-employee/address")
|
@Route("api/v1/org/profile-employee/address")
|
||||||
|
|
@ -56,6 +36,7 @@ export class ProfileAddressEmployeeController extends Controller {
|
||||||
"currentSubDistrictId",
|
"currentSubDistrictId",
|
||||||
"currentZipCode",
|
"currentZipCode",
|
||||||
],
|
],
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
if (!getProfileAddress) {
|
if (!getProfileAddress) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
@ -69,7 +50,10 @@ export class ProfileAddressEmployeeController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("{profileEmployeeId}")
|
@Get("{profileEmployeeId}")
|
||||||
public async detailProfileAddress(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
public async detailProfileAddress(
|
||||||
|
@Path() profileEmployeeId: string,
|
||||||
|
@Request() req: RequestWithUser,
|
||||||
|
) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
||||||
const getProfileAddress = await this.profileEmployeeRepo.findOne({
|
const getProfileAddress = await this.profileEmployeeRepo.findOne({
|
||||||
where: { id: profileEmployeeId },
|
where: { id: profileEmployeeId },
|
||||||
|
|
@ -106,33 +90,32 @@ export class ProfileAddressEmployeeController extends Controller {
|
||||||
}
|
}
|
||||||
const record = await this.profileAddressHistoryRepo.find({
|
const record = await this.profileAddressHistoryRepo.find({
|
||||||
where: { profileEmployeeId: profile.id },
|
where: { profileEmployeeId: profile.id },
|
||||||
relations: {
|
relations: [
|
||||||
registrationProvince: true,
|
"registrationProvince",
|
||||||
registrationDistrict: true,
|
"registrationDistrict",
|
||||||
registrationSubDistrict: true,
|
"registrationSubDistrict",
|
||||||
currentProvince: true,
|
"currentProvince",
|
||||||
currentDistrict: true,
|
"currentDistrict",
|
||||||
currentSubDistrict: true,
|
"currentSubDistrict",
|
||||||
},
|
|
||||||
select: [
|
|
||||||
"registrationAddress",
|
|
||||||
"registrationProvinceId",
|
|
||||||
"registrationDistrictId",
|
|
||||||
"registrationSubDistrictId",
|
|
||||||
"registrationZipCode",
|
|
||||||
"currentAddress",
|
|
||||||
"currentProvinceId",
|
|
||||||
"currentDistrictId",
|
|
||||||
"currentSubDistrictId",
|
|
||||||
"currentZipCode",
|
|
||||||
"lastUpdateFullName",
|
|
||||||
"lastUpdatedAt",
|
|
||||||
],
|
],
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
if (!record) {
|
const _record = record.map((item) => ({
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
id: item.id,
|
||||||
}
|
currentAddress: item.currentAddress,
|
||||||
return new HttpSuccess(record);
|
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}")
|
@Get("history/{profileId}")
|
||||||
public async getProfileAddressHistory(@Path() profileId: string, @Request() req: RequestWithUser) {
|
public async getProfileAddressHistory(
|
||||||
|
@Path() profileId: string,
|
||||||
|
@Request() req: RequestWithUser,
|
||||||
|
) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId);
|
||||||
const record = await this.profileAddressHistoryRepo.find({
|
const record = await this.profileAddressHistoryRepo.find({
|
||||||
where: { profileEmployeeId: profileId },
|
where: { profileEmployeeId: profileId },
|
||||||
relations: {
|
relations: [
|
||||||
registrationProvince: true,
|
"registrationProvince",
|
||||||
registrationDistrict: true,
|
"registrationDistrict",
|
||||||
registrationSubDistrict: true,
|
"registrationSubDistrict",
|
||||||
currentProvince: true,
|
"currentProvince",
|
||||||
currentDistrict: true,
|
"currentDistrict",
|
||||||
currentSubDistrict: true,
|
"currentSubDistrict",
|
||||||
},
|
|
||||||
select: [
|
|
||||||
"registrationAddress",
|
|
||||||
"registrationProvinceId",
|
|
||||||
"registrationDistrictId",
|
|
||||||
"registrationSubDistrictId",
|
|
||||||
"registrationZipCode",
|
|
||||||
"currentAddress",
|
|
||||||
"currentProvinceId",
|
|
||||||
"currentDistrictId",
|
|
||||||
"currentSubDistrictId",
|
|
||||||
"currentZipCode",
|
|
||||||
"lastUpdateFullName",
|
|
||||||
"lastUpdatedAt",
|
|
||||||
],
|
],
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
if (!record) {
|
const _record = record.map((item) => ({
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
id: item.id,
|
||||||
}
|
currentAddress: item.currentAddress,
|
||||||
return new HttpSuccess(record);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -192,15 +177,18 @@ export class ProfileAddressEmployeeController extends Controller {
|
||||||
const history = new ProfileAddressHistory();
|
const history = new ProfileAddressHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileEmployeeId = profileId;
|
history.profileEmployeeId = profileId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.profileEmployeeRepo.save(record),
|
this.profileEmployeeRepo.save(record),
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,11 @@
|
||||||
import {
|
import { Controller, Route, Security, Tags, Body, Path, Request, Get, Patch } from "tsoa";
|
||||||
Controller,
|
|
||||||
Post,
|
|
||||||
Put,
|
|
||||||
Delete,
|
|
||||||
Route,
|
|
||||||
Security,
|
|
||||||
Tags,
|
|
||||||
Body,
|
|
||||||
Path,
|
|
||||||
Request,
|
|
||||||
SuccessResponse,
|
|
||||||
Response,
|
|
||||||
Get,
|
|
||||||
Query,
|
|
||||||
Patch,
|
|
||||||
Example,
|
|
||||||
} from "tsoa";
|
|
||||||
|
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
import HttpSuccess from "../interfaces/http-success";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
import HttpStatus from "../interfaces/http-status";
|
import HttpStatus from "../interfaces/http-status";
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
import { RequestWithUser } from "../middlewares/user";
|
||||||
import { Profile, ProfileAddressHistory, UpdateProfileAddress } from "../entities/Profile";
|
import { ProfileAddressHistory } from "../entities/Profile";
|
||||||
import { AppDataSource } from "../database/data-source";
|
import { AppDataSource } from "../database/data-source";
|
||||||
import { Province } from "../entities/Province";
|
|
||||||
import { District } from "../entities/District";
|
|
||||||
import { SubDistrict } from "../entities/SubDistrict";
|
|
||||||
import { ProfileEmployee, UpdateProfileAddressEmployee } from "../entities/ProfileEmployee";
|
import { ProfileEmployee, UpdateProfileAddressEmployee } from "../entities/ProfileEmployee";
|
||||||
import permission from "../interfaces/permission";
|
import permission from "../interfaces/permission";
|
||||||
@Route("api/v1/org/profile-temp/address")
|
@Route("api/v1/org/profile-temp/address")
|
||||||
|
|
@ -56,6 +36,7 @@ export class ProfileAddressEmployeeTempController extends Controller {
|
||||||
"currentSubDistrictId",
|
"currentSubDistrictId",
|
||||||
"currentZipCode",
|
"currentZipCode",
|
||||||
],
|
],
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
if (!getProfileAddress) {
|
if (!getProfileAddress) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
@ -109,33 +90,32 @@ export class ProfileAddressEmployeeTempController extends Controller {
|
||||||
}
|
}
|
||||||
const record = await this.profileAddressHistoryRepo.find({
|
const record = await this.profileAddressHistoryRepo.find({
|
||||||
where: { profileEmployeeId: profile.id },
|
where: { profileEmployeeId: profile.id },
|
||||||
relations: {
|
relations: [
|
||||||
registrationProvince: true,
|
"registrationProvince",
|
||||||
registrationDistrict: true,
|
"registrationDistrict",
|
||||||
registrationSubDistrict: true,
|
"registrationSubDistrict",
|
||||||
currentProvince: true,
|
"currentProvince",
|
||||||
currentDistrict: true,
|
"currentDistrict",
|
||||||
currentSubDistrict: true,
|
"currentSubDistrict",
|
||||||
},
|
|
||||||
select: [
|
|
||||||
"registrationAddress",
|
|
||||||
"registrationProvinceId",
|
|
||||||
"registrationDistrictId",
|
|
||||||
"registrationSubDistrictId",
|
|
||||||
"registrationZipCode",
|
|
||||||
"currentAddress",
|
|
||||||
"currentProvinceId",
|
|
||||||
"currentDistrictId",
|
|
||||||
"currentSubDistrictId",
|
|
||||||
"currentZipCode",
|
|
||||||
"lastUpdateFullName",
|
|
||||||
"lastUpdatedAt",
|
|
||||||
],
|
],
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
if (!record) {
|
const _record = record.map((item) => ({
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
id: item.id,
|
||||||
}
|
currentAddress: item.currentAddress,
|
||||||
return new HttpSuccess(record);
|
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");
|
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||||
const record = await this.profileAddressHistoryRepo.find({
|
const record = await this.profileAddressHistoryRepo.find({
|
||||||
where: { profileEmployeeId: profileId },
|
where: { profileEmployeeId: profileId },
|
||||||
relations: {
|
relations: [
|
||||||
registrationProvince: true,
|
"registrationProvince",
|
||||||
registrationDistrict: true,
|
"registrationDistrict",
|
||||||
registrationSubDistrict: true,
|
"registrationSubDistrict",
|
||||||
currentProvince: true,
|
"currentProvince",
|
||||||
currentDistrict: true,
|
"currentDistrict",
|
||||||
currentSubDistrict: true,
|
"currentSubDistrict",
|
||||||
},
|
|
||||||
select: [
|
|
||||||
"registrationAddress",
|
|
||||||
"registrationProvinceId",
|
|
||||||
"registrationDistrictId",
|
|
||||||
"registrationSubDistrictId",
|
|
||||||
"registrationZipCode",
|
|
||||||
"currentAddress",
|
|
||||||
"currentProvinceId",
|
|
||||||
"currentDistrictId",
|
|
||||||
"currentSubDistrictId",
|
|
||||||
"currentZipCode",
|
|
||||||
"lastUpdateFullName",
|
|
||||||
"lastUpdatedAt",
|
|
||||||
],
|
],
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
if (!record) {
|
const _record = record.map((item) => ({
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
id: item.id,
|
||||||
}
|
currentAddress: item.currentAddress,
|
||||||
return new HttpSuccess(record);
|
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();
|
const history = new ProfileAddressHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileEmployeeId = profileId;
|
history.profileEmployeeId = profileId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.profileEmployeeRepo.save(record),
|
this.profileEmployeeRepo.save(record),
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import {
|
import {
|
||||||
Controller,
|
Controller,
|
||||||
Post,
|
Post,
|
||||||
Put,
|
|
||||||
Delete,
|
Delete,
|
||||||
Route,
|
Route,
|
||||||
Security,
|
Security,
|
||||||
|
|
@ -9,12 +8,8 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Path,
|
Path,
|
||||||
Request,
|
Request,
|
||||||
SuccessResponse,
|
|
||||||
Response,
|
|
||||||
Get,
|
Get,
|
||||||
Query,
|
|
||||||
Patch,
|
Patch,
|
||||||
Example,
|
|
||||||
} from "tsoa";
|
} from "tsoa";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
import HttpStatus from "../interfaces/http-status";
|
import HttpStatus from "../interfaces/http-status";
|
||||||
|
|
@ -46,6 +41,7 @@ export class ProfileAssessmentsController extends Controller {
|
||||||
}
|
}
|
||||||
const getProfileAssessments = await this.profileAssessmentsRepository.find({
|
const getProfileAssessments = await this.profileAssessmentsRepository.find({
|
||||||
where: { profileId: profile.id },
|
where: { profileId: profile.id },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
if (!getProfileAssessments) {
|
if (!getProfileAssessments) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
@ -54,36 +50,15 @@ export class ProfileAssessmentsController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileId}")
|
@Get("{profileId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "f723bf42-a61c-4af4-ba8b-0e4ad0a89a80",
|
|
||||||
createdAt: "2024-03-12T20:56:45.986Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-12T20:56:45.986Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "test bar",
|
|
||||||
lastUpdateFullName: "test bar",
|
|
||||||
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
name: "สาวิตรี ศรีสมัย",
|
|
||||||
date: "2024-03-13T03:55:42.000Z",
|
|
||||||
point1: 0,
|
|
||||||
point1Total: 0,
|
|
||||||
point2: 0,
|
|
||||||
point2Total: 0,
|
|
||||||
pointSum: 0,
|
|
||||||
pointSumTotal: 0,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async detailProfileAssessments(
|
public async detailProfileAssessments(
|
||||||
@Path() profileId: string,
|
@Path() profileId: string,
|
||||||
@Request() req: RequestWithUser,
|
@Request() req: RequestWithUser,
|
||||||
) {
|
) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||||
const getProfileAssessments = await this.profileAssessmentsRepository.findBy({ profileId });
|
const getProfileAssessments = await this.profileAssessmentsRepository.find({
|
||||||
|
where: { profileId: profileId },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
|
});
|
||||||
if (!getProfileAssessments) {
|
if (!getProfileAssessments) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
}
|
}
|
||||||
|
|
@ -91,54 +66,20 @@ export class ProfileAssessmentsController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{assessmentId}")
|
@Get("history/{assessmentId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "47b3e370-be05-4469-a34f-e4a04747f54e",
|
|
||||||
createdAt: "2024-03-12T20:59:39.774Z",
|
|
||||||
createdUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
lastUpdatedAt: "2024-03-12T20:59:39.774Z",
|
|
||||||
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
createdFullName: "string",
|
|
||||||
lastUpdateFullName: "test bar",
|
|
||||||
name: "สาวิตรี ศรีสมัย",
|
|
||||||
date: "2024-03-13T03:55:42.000Z",
|
|
||||||
point1: 0,
|
|
||||||
point1Total: 0,
|
|
||||||
point2: 100,
|
|
||||||
point2Total: 100,
|
|
||||||
pointSum: 100,
|
|
||||||
pointSumTotal: 100,
|
|
||||||
profileAssessmentId: "f723bf42-a61c-4af4-ba8b-0e4ad0a89a80",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "ecff89b1-9bef-49a9-83f5-8be3cecb8ca7",
|
|
||||||
createdAt: "2024-03-12T20:58:19.450Z",
|
|
||||||
createdUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
lastUpdatedAt: "2024-03-12T20:58:19.450Z",
|
|
||||||
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
createdFullName: "string",
|
|
||||||
lastUpdateFullName: "test bar",
|
|
||||||
name: "สาวิตรี ศรีสมัย",
|
|
||||||
date: "2024-03-13T03:55:42.000Z",
|
|
||||||
point1: 50,
|
|
||||||
point1Total: 50,
|
|
||||||
point2: 100,
|
|
||||||
point2Total: 100,
|
|
||||||
pointSum: 150,
|
|
||||||
pointSumTotal: 150,
|
|
||||||
profileAssessmentId: "f723bf42-a61c-4af4-ba8b-0e4ad0a89a80",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async getProfileAssessmentsHistory(
|
public async getProfileAssessmentsHistory(
|
||||||
@Path() assessmentId: string,
|
@Path() assessmentId: string,
|
||||||
@Request() req: RequestWithUser,
|
@Request() req: RequestWithUser,
|
||||||
) {
|
) {
|
||||||
const record = await this.profileAssessmentsHistoryRepository.findBy({
|
const _record = await this.profileAssessmentsRepository.findOneBy({
|
||||||
|
id: assessmentId,
|
||||||
|
});
|
||||||
|
if (_record)
|
||||||
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
||||||
|
const record = await this.profileAssessmentsHistoryRepository.find({
|
||||||
|
where: {
|
||||||
profileAssessmentId: assessmentId,
|
profileAssessmentId: assessmentId,
|
||||||
|
},
|
||||||
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!record) {
|
if (!record) {
|
||||||
|
|
@ -176,6 +117,8 @@ export class ProfileAssessmentsController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
const history = new ProfileAssessmentHistory();
|
const history = new ProfileAssessmentHistory();
|
||||||
|
|
@ -201,15 +144,18 @@ export class ProfileAssessmentsController extends Controller {
|
||||||
const history = new ProfileAssessmentHistory();
|
const history = new ProfileAssessmentHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileAssessmentId = assessmentId;
|
history.profileAssessmentId = assessmentId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.profileAssessmentsRepository.save(record),
|
this.profileAssessmentsRepository.save(record),
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import {
|
import {
|
||||||
Controller,
|
Controller,
|
||||||
Post,
|
Post,
|
||||||
Put,
|
|
||||||
Delete,
|
Delete,
|
||||||
Route,
|
Route,
|
||||||
Security,
|
Security,
|
||||||
|
|
@ -9,12 +8,8 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Path,
|
Path,
|
||||||
Request,
|
Request,
|
||||||
SuccessResponse,
|
|
||||||
Response,
|
|
||||||
Get,
|
Get,
|
||||||
Query,
|
|
||||||
Patch,
|
Patch,
|
||||||
Example,
|
|
||||||
} from "tsoa";
|
} from "tsoa";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
import HttpStatus from "../interfaces/http-status";
|
import HttpStatus from "../interfaces/http-status";
|
||||||
|
|
@ -46,6 +41,7 @@ export class ProfileAssessmentsEmployeeController extends Controller {
|
||||||
}
|
}
|
||||||
const getProfileAssessments = await this.profileAssessmentsRepository.find({
|
const getProfileAssessments = await this.profileAssessmentsRepository.find({
|
||||||
where: { profileEmployeeId: profile.id },
|
where: { profileEmployeeId: profile.id },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
if (!getProfileAssessments) {
|
if (!getProfileAssessments) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
@ -54,34 +50,16 @@ export class ProfileAssessmentsEmployeeController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileEmployeeId}")
|
@Get("{profileEmployeeId}")
|
||||||
@Example({
|
public async detailProfileAssessments(
|
||||||
status: 200,
|
@Path() profileEmployeeId: string,
|
||||||
message: "สำเร็จ",
|
@Request() req: RequestWithUser,
|
||||||
result: [
|
) {
|
||||||
{
|
|
||||||
id: "f723bf42-a61c-4af4-ba8b-0e4ad0a89a80",
|
|
||||||
createdAt: "2024-03-12T20:56:45.986Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-12T20:56:45.986Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "test bar",
|
|
||||||
lastUpdateFullName: "test bar",
|
|
||||||
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
name: "สาวิตรี ศรีสมัย",
|
|
||||||
date: "2024-03-13T03:55:42.000Z",
|
|
||||||
point1: 0,
|
|
||||||
point1Total: 0,
|
|
||||||
point2: 0,
|
|
||||||
point2Total: 0,
|
|
||||||
pointSum: 0,
|
|
||||||
pointSumTotal: 0,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async detailProfileAssessments(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
||||||
const getProfileAssessments = await this.profileAssessmentsRepository.findBy({
|
const getProfileAssessments = await this.profileAssessmentsRepository.find({
|
||||||
profileEmployeeId,
|
where: {
|
||||||
|
profileEmployeeId: profileEmployeeId,
|
||||||
|
},
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
if (!getProfileAssessments) {
|
if (!getProfileAssessments) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
@ -90,55 +68,19 @@ export class ProfileAssessmentsEmployeeController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{assessmentId}")
|
@Get("history/{assessmentId}")
|
||||||
@Example({
|
public async getProfileAssessmentsHistory(
|
||||||
status: 200,
|
@Path() assessmentId: string,
|
||||||
message: "สำเร็จ",
|
@Request() req: RequestWithUser,
|
||||||
result: [
|
) {
|
||||||
{
|
|
||||||
id: "47b3e370-be05-4469-a34f-e4a04747f54e",
|
|
||||||
createdAt: "2024-03-12T20:59:39.774Z",
|
|
||||||
createdUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
lastUpdatedAt: "2024-03-12T20:59:39.774Z",
|
|
||||||
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
createdFullName: "string",
|
|
||||||
lastUpdateFullName: "test bar",
|
|
||||||
name: "สาวิตรี ศรีสมัย",
|
|
||||||
date: "2024-03-13T03:55:42.000Z",
|
|
||||||
point1: 0,
|
|
||||||
point1Total: 0,
|
|
||||||
point2: 100,
|
|
||||||
point2Total: 100,
|
|
||||||
pointSum: 100,
|
|
||||||
pointSumTotal: 100,
|
|
||||||
profileAssessmentId: "f723bf42-a61c-4af4-ba8b-0e4ad0a89a80",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "ecff89b1-9bef-49a9-83f5-8be3cecb8ca7",
|
|
||||||
createdAt: "2024-03-12T20:58:19.450Z",
|
|
||||||
createdUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
lastUpdatedAt: "2024-03-12T20:58:19.450Z",
|
|
||||||
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
createdFullName: "string",
|
|
||||||
lastUpdateFullName: "test bar",
|
|
||||||
name: "สาวิตรี ศรีสมัย",
|
|
||||||
date: "2024-03-13T03:55:42.000Z",
|
|
||||||
point1: 50,
|
|
||||||
point1Total: 50,
|
|
||||||
point2: 100,
|
|
||||||
point2Total: 100,
|
|
||||||
pointSum: 150,
|
|
||||||
pointSumTotal: 150,
|
|
||||||
profileAssessmentId: "f723bf42-a61c-4af4-ba8b-0e4ad0a89a80",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async getProfileAssessmentsHistory(@Path() assessmentId: string, @Request() req: RequestWithUser) {
|
|
||||||
const _record = await this.profileAssessmentsRepository.findOneBy({ id: assessmentId });
|
const _record = await this.profileAssessmentsRepository.findOneBy({ id: assessmentId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileId);
|
||||||
}
|
}
|
||||||
const record = await this.profileAssessmentsHistoryRepository.findBy({
|
const record = await this.profileAssessmentsHistoryRepository.find({
|
||||||
|
where: {
|
||||||
profileAssessmentId: assessmentId,
|
profileAssessmentId: assessmentId,
|
||||||
|
},
|
||||||
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
if (!record) {
|
if (!record) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
@ -168,6 +110,8 @@ export class ProfileAssessmentsEmployeeController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
const history = new ProfileAssessmentHistory();
|
const history = new ProfileAssessmentHistory();
|
||||||
|
|
@ -188,20 +132,27 @@ export class ProfileAssessmentsEmployeeController extends Controller {
|
||||||
) {
|
) {
|
||||||
const record = await this.profileAssessmentsRepository.findOneBy({ id: assessmentId });
|
const record = await this.profileAssessmentsRepository.findOneBy({ id: assessmentId });
|
||||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId);
|
await new permission().PermissionOrgUserUpdate(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
record.profileEmployeeId,
|
||||||
|
);
|
||||||
|
|
||||||
const history = new ProfileAssessmentHistory();
|
const history = new ProfileAssessmentHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileAssessmentId = assessmentId;
|
history.profileAssessmentId = assessmentId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.profileAssessmentsRepository.save(record),
|
this.profileAssessmentsRepository.save(record),
|
||||||
|
|
@ -218,7 +169,11 @@ export class ProfileAssessmentsEmployeeController extends Controller {
|
||||||
) {
|
) {
|
||||||
const _record = await this.profileAssessmentsRepository.findOneBy({ id: assessmentId });
|
const _record = await this.profileAssessmentsRepository.findOneBy({ id: assessmentId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
|
await new permission().PermissionOrgUserDelete(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
_record.profileEmployeeId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
await this.profileAssessmentsHistoryRepository.delete({
|
await this.profileAssessmentsHistoryRepository.delete({
|
||||||
profileAssessmentId: assessmentId,
|
profileAssessmentId: assessmentId,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import {
|
import {
|
||||||
Controller,
|
Controller,
|
||||||
Post,
|
Post,
|
||||||
Put,
|
|
||||||
Delete,
|
Delete,
|
||||||
Route,
|
Route,
|
||||||
Security,
|
Security,
|
||||||
|
|
@ -9,12 +8,8 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Path,
|
Path,
|
||||||
Request,
|
Request,
|
||||||
SuccessResponse,
|
|
||||||
Response,
|
|
||||||
Get,
|
Get,
|
||||||
Query,
|
|
||||||
Patch,
|
Patch,
|
||||||
Example,
|
|
||||||
} from "tsoa";
|
} from "tsoa";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
import HttpStatus from "../interfaces/http-status";
|
import HttpStatus from "../interfaces/http-status";
|
||||||
|
|
@ -46,6 +41,7 @@ export class ProfileAssessmentsEmployeeTempController extends Controller {
|
||||||
}
|
}
|
||||||
const getProfileAssessments = await this.profileAssessmentsRepository.find({
|
const getProfileAssessments = await this.profileAssessmentsRepository.find({
|
||||||
where: { profileEmployeeId: profile.id },
|
where: { profileEmployeeId: profile.id },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
if (!getProfileAssessments) {
|
if (!getProfileAssessments) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
@ -54,34 +50,16 @@ export class ProfileAssessmentsEmployeeTempController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileEmployeeId}")
|
@Get("{profileEmployeeId}")
|
||||||
@Example({
|
public async detailProfileAssessments(
|
||||||
status: 200,
|
@Path() profileEmployeeId: string,
|
||||||
message: "สำเร็จ",
|
@Request() req: RequestWithUser,
|
||||||
result: [
|
) {
|
||||||
{
|
|
||||||
id: "f723bf42-a61c-4af4-ba8b-0e4ad0a89a80",
|
|
||||||
createdAt: "2024-03-12T20:56:45.986Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-12T20:56:45.986Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "test bar",
|
|
||||||
lastUpdateFullName: "test bar",
|
|
||||||
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
name: "สาวิตรี ศรีสมัย",
|
|
||||||
date: "2024-03-13T03:55:42.000Z",
|
|
||||||
point1: 0,
|
|
||||||
point1Total: 0,
|
|
||||||
point2: 0,
|
|
||||||
point2Total: 0,
|
|
||||||
pointSum: 0,
|
|
||||||
pointSumTotal: 0,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async detailProfileAssessments(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
|
||||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||||
const getProfileAssessments = await this.profileAssessmentsRepository.findBy({
|
const getProfileAssessments = await this.profileAssessmentsRepository.find({
|
||||||
profileEmployeeId,
|
where: {
|
||||||
|
profileEmployeeId: profileEmployeeId,
|
||||||
|
},
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
if (!getProfileAssessments) {
|
if (!getProfileAssessments) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
@ -90,52 +68,16 @@ export class ProfileAssessmentsEmployeeTempController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{assessmentId}")
|
@Get("history/{assessmentId}")
|
||||||
@Example({
|
public async getProfileAssessmentsHistory(
|
||||||
status: 200,
|
@Path() assessmentId: string,
|
||||||
message: "สำเร็จ",
|
@Request() req: RequestWithUser,
|
||||||
result: [
|
) {
|
||||||
{
|
|
||||||
id: "47b3e370-be05-4469-a34f-e4a04747f54e",
|
|
||||||
createdAt: "2024-03-12T20:59:39.774Z",
|
|
||||||
createdUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
lastUpdatedAt: "2024-03-12T20:59:39.774Z",
|
|
||||||
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
createdFullName: "string",
|
|
||||||
lastUpdateFullName: "test bar",
|
|
||||||
name: "สาวิตรี ศรีสมัย",
|
|
||||||
date: "2024-03-13T03:55:42.000Z",
|
|
||||||
point1: 0,
|
|
||||||
point1Total: 0,
|
|
||||||
point2: 100,
|
|
||||||
point2Total: 100,
|
|
||||||
pointSum: 100,
|
|
||||||
pointSumTotal: 100,
|
|
||||||
profileAssessmentId: "f723bf42-a61c-4af4-ba8b-0e4ad0a89a80",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "ecff89b1-9bef-49a9-83f5-8be3cecb8ca7",
|
|
||||||
createdAt: "2024-03-12T20:58:19.450Z",
|
|
||||||
createdUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
lastUpdatedAt: "2024-03-12T20:58:19.450Z",
|
|
||||||
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
createdFullName: "string",
|
|
||||||
lastUpdateFullName: "test bar",
|
|
||||||
name: "สาวิตรี ศรีสมัย",
|
|
||||||
date: "2024-03-13T03:55:42.000Z",
|
|
||||||
point1: 50,
|
|
||||||
point1Total: 50,
|
|
||||||
point2: 100,
|
|
||||||
point2Total: 100,
|
|
||||||
pointSum: 150,
|
|
||||||
pointSumTotal: 150,
|
|
||||||
profileAssessmentId: "f723bf42-a61c-4af4-ba8b-0e4ad0a89a80",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async getProfileAssessmentsHistory(@Path() assessmentId: string, @Request() req: RequestWithUser) {
|
|
||||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||||
const record = await this.profileAssessmentsHistoryRepository.findBy({
|
const record = await this.profileAssessmentsHistoryRepository.find({
|
||||||
|
where: {
|
||||||
profileAssessmentId: assessmentId,
|
profileAssessmentId: assessmentId,
|
||||||
|
},
|
||||||
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!record) {
|
if (!record) {
|
||||||
|
|
@ -166,6 +108,8 @@ export class ProfileAssessmentsEmployeeTempController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
const history = new ProfileAssessmentHistory();
|
const history = new ProfileAssessmentHistory();
|
||||||
|
|
@ -191,15 +135,18 @@ export class ProfileAssessmentsEmployeeTempController extends Controller {
|
||||||
const history = new ProfileAssessmentHistory();
|
const history = new ProfileAssessmentHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileAssessmentId = assessmentId;
|
history.profileAssessmentId = assessmentId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.profileAssessmentsRepository.save(record),
|
this.profileAssessmentsRepository.save(record),
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ export class ProfileAvatarController extends Controller {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||||
const lists = await this.avatarRepository.find({
|
const lists = await this.avatarRepository.find({
|
||||||
where: { profileId: profileId },
|
where: { profileId: profileId },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
@ -27,7 +28,6 @@ export class ProfileAvatarController extends Controller {
|
||||||
async getProfile(@Path() id: string, @Request() req: RequestWithUser) {
|
async getProfile(@Path() id: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", id);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", id);
|
||||||
const profile = await this.profileRepository.findOne({
|
const profile = await this.profileRepository.findOne({
|
||||||
select: ["id", "avatar", "avatarName"],
|
|
||||||
where: { id },
|
where: { id },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -39,7 +39,6 @@ export class ProfileAvatarController extends Controller {
|
||||||
@Get("profileId-admin/{id}")
|
@Get("profileId-admin/{id}")
|
||||||
async getProfileAdmin(@Path() id: string) {
|
async getProfileAdmin(@Path() id: string) {
|
||||||
const profile = await this.profileRepository.findOne({
|
const profile = await this.profileRepository.findOne({
|
||||||
select: ["id", "avatar", "avatarName"],
|
|
||||||
where: { id },
|
where: { id },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -49,7 +48,11 @@ export class ProfileAvatarController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("select/{profileId}/{id}")
|
@Get("select/{profileId}/{id}")
|
||||||
public async selectAvatar(@Path() profileId: string, @Path() id: string, @Request() req: RequestWithUser) {
|
public async selectAvatar(
|
||||||
|
@Path() profileId: string,
|
||||||
|
@Path() id: string,
|
||||||
|
@Request() req: RequestWithUser,
|
||||||
|
) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||||
const result = await this.avatarRepository.findOneBy({ id: id });
|
const result = await this.avatarRepository.findOneBy({ id: id });
|
||||||
if (!result) {
|
if (!result) {
|
||||||
|
|
@ -94,6 +97,8 @@ export class ProfileAvatarController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -129,11 +134,14 @@ export class ProfileAvatarController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Delete("{avatarId}")
|
@Delete("{avatarId}")
|
||||||
public async deleteAvatar(@Path() avatarId: string, @Request() req: RequestWithUser)
|
public async deleteAvatar(@Path() avatarId: string, @Request() req: RequestWithUser) {
|
||||||
{
|
|
||||||
const _record = await this.avatarRepository.findOneBy({ id: avatarId });
|
const _record = await this.avatarRepository.findOneBy({ id: avatarId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
await new permission().PermissionOrgUserDelete(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_OFFICER",
|
||||||
|
_record.profileId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
const result = await this.avatarRepository.delete({ id: avatarId });
|
const result = await this.avatarRepository.delete({ id: avatarId });
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ export class ProfileAvatarEmployeeController extends Controller {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
||||||
const lists = await this.avatarRepository.find({
|
const lists = await this.avatarRepository.find({
|
||||||
where: { profileEmployeeId },
|
where: { profileEmployeeId },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
@ -30,7 +31,6 @@ export class ProfileAvatarEmployeeController extends Controller {
|
||||||
async getProfile(@Path() id: string, @Request() req: RequestWithUser) {
|
async getProfile(@Path() id: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", id);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", id);
|
||||||
const profile = await this.profileRepository.findOne({
|
const profile = await this.profileRepository.findOne({
|
||||||
select: ["id", "avatar", "avatarName"],
|
|
||||||
where: { id },
|
where: { id },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -42,7 +42,6 @@ export class ProfileAvatarEmployeeController extends Controller {
|
||||||
@Get("profileEmployeeId-admin/{id}")
|
@Get("profileEmployeeId-admin/{id}")
|
||||||
async getProfileAdmin(@Path() id: string) {
|
async getProfileAdmin(@Path() id: string) {
|
||||||
const profile = await this.profileRepository.findOne({
|
const profile = await this.profileRepository.findOne({
|
||||||
select: ["id", "avatar", "avatarName"],
|
|
||||||
where: { id },
|
where: { id },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -103,6 +102,8 @@ export class ProfileAvatarEmployeeController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -141,7 +142,11 @@ export class ProfileAvatarEmployeeController extends Controller {
|
||||||
public async deleteAvatarEmployee(@Path() avatarId: string, @Request() req: RequestWithUser) {
|
public async deleteAvatarEmployee(@Path() avatarId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.avatarRepository.findOneBy({ id: avatarId });
|
const _record = await this.avatarRepository.findOneBy({ id: avatarId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
|
await new permission().PermissionOrgUserDelete(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
_record.profileEmployeeId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
const result = await this.avatarRepository.delete({ id: avatarId });
|
const result = await this.avatarRepository.delete({ id: avatarId });
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ export class ProfileAvatarEmployeeTempController extends Controller {
|
||||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||||
const lists = await this.avatarRepository.find({
|
const lists = await this.avatarRepository.find({
|
||||||
where: { profileEmployeeId },
|
where: { profileEmployeeId },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
@ -30,7 +31,6 @@ export class ProfileAvatarEmployeeTempController extends Controller {
|
||||||
async getProfile(@Path() id: string, @Request() req: RequestWithUser) {
|
async getProfile(@Path() id: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||||
const profile = await this.profileRepository.findOne({
|
const profile = await this.profileRepository.findOne({
|
||||||
select: ["id", "avatar", "avatarName"],
|
|
||||||
where: { id },
|
where: { id },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -42,7 +42,6 @@ export class ProfileAvatarEmployeeTempController extends Controller {
|
||||||
@Get("profileEmployeeId-admin/{id}")
|
@Get("profileEmployeeId-admin/{id}")
|
||||||
async getProfileAdmin(@Path() id: string) {
|
async getProfileAdmin(@Path() id: string) {
|
||||||
const profile = await this.profileRepository.findOne({
|
const profile = await this.profileRepository.findOne({
|
||||||
select: ["id", "avatar", "avatarName"],
|
|
||||||
where: { id },
|
where: { id },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -57,7 +56,7 @@ export class ProfileAvatarEmployeeTempController extends Controller {
|
||||||
@Path() id: string,
|
@Path() id: string,
|
||||||
@Request() req: RequestWithUser,
|
@Request() req: RequestWithUser,
|
||||||
) {
|
) {
|
||||||
// await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); //ไม่แน่ใจTEMPปิดไว้ก่อน
|
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||||
const result = await this.avatarRepository.findOneBy({ id: id });
|
const result = await this.avatarRepository.findOneBy({ id: id });
|
||||||
if (!result) {
|
if (!result) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
@ -104,6 +103,8 @@ export class ProfileAvatarEmployeeTempController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
Example,
|
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
Path,
|
Path,
|
||||||
|
|
@ -41,85 +40,34 @@ export class ProfileCertificateController extends Controller {
|
||||||
}
|
}
|
||||||
const record = await this.certificateRepo.find({
|
const record = await this.certificateRepo.find({
|
||||||
where: { profileId: profile.id },
|
where: { profileId: profile.id },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileId}")
|
@Get("{profileId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "e1ef9c3d-079a-40d8-8332-664c3e9a5a70",
|
|
||||||
createdAt: "2024-03-12T03:02:27.532Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-12T03:02:27.532Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
expireDate: "2024-03-12T10:01:48.000Z",
|
|
||||||
issueDate: "2024-03-12T10:01:48.000Z",
|
|
||||||
certificateNo: "string",
|
|
||||||
certificateType: "string",
|
|
||||||
issuer: "string",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async getCertificate(@Path() profileId: string, @Request() req: RequestWithUser) {
|
public async getCertificate(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||||
const record = await this.certificateRepo.findBy({ profileId });
|
const record = await this.certificateRepo.find({
|
||||||
|
where: { profileId: profileId },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{certificateId}")
|
@Get("history/{certificateId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "c0ecf986-b290-44ca-b45e-f4448cdd34dd",
|
|
||||||
createdAt: "2024-03-12T03:03:30.169Z",
|
|
||||||
createdUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
lastUpdatedAt: "2024-03-12T03:03:30.169Z",
|
|
||||||
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
createdFullName: "string",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
expireDate: "2024-03-12T10:03:05.000Z",
|
|
||||||
issueDate: "2024-03-12T10:03:05.000Z",
|
|
||||||
certificateNo: "no",
|
|
||||||
certificateType: "type",
|
|
||||||
issuer: "issuer",
|
|
||||||
profileCertificateId: "e1ef9c3d-079a-40d8-8332-664c3e9a5a70",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "dc4c2800-5fc5-4ec3-b19a-c4a27beac35f",
|
|
||||||
createdAt: "2024-03-12T03:02:27.583Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-12T03:02:27.583Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
expireDate: "2024-03-12T10:01:48.000Z",
|
|
||||||
issueDate: "2024-03-12T10:01:48.000Z",
|
|
||||||
certificateNo: "string",
|
|
||||||
certificateType: "string",
|
|
||||||
issuer: "string",
|
|
||||||
profileCertificateId: "e1ef9c3d-079a-40d8-8332-664c3e9a5a70",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async certificateHistory(@Path() certificateId: string, @Request() req: RequestWithUser) {
|
public async certificateHistory(@Path() certificateId: string, @Request() req: RequestWithUser) {
|
||||||
// const _record = await this.certificateRepo.findOneBy({ id: certificateId });
|
// const _record = await this.certificateRepo.findOneBy({ id: certificateId });
|
||||||
// if (_record) {
|
// if (_record) {
|
||||||
// await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
// await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
||||||
// }
|
// }
|
||||||
const record = await this.certificateHistoryRepo.findBy({
|
const record = await this.certificateHistoryRepo.find({
|
||||||
|
where: {
|
||||||
profileCertificateId: certificateId,
|
profileCertificateId: certificateId,
|
||||||
|
},
|
||||||
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post()
|
@Post()
|
||||||
|
|
@ -145,6 +93,8 @@ export class ProfileCertificateController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -171,15 +121,18 @@ export class ProfileCertificateController extends Controller {
|
||||||
const history = new ProfileCertificateHistory();
|
const history = new ProfileCertificateHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileCertificateId = certificateId;
|
history.profileCertificateId = certificateId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.certificateRepo.save(record),
|
this.certificateRepo.save(record),
|
||||||
|
|
@ -193,7 +146,11 @@ export class ProfileCertificateController extends Controller {
|
||||||
public async deleteCertificate(@Path() certificateId: string, @Request() req: RequestWithUser) {
|
public async deleteCertificate(@Path() certificateId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.certificateRepo.findOneBy({ id: certificateId });
|
const _record = await this.certificateRepo.findOneBy({ id: certificateId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
await new permission().PermissionOrgUserDelete(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_OFFICER",
|
||||||
|
_record.profileId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
await this.certificateHistoryRepo.delete({
|
await this.certificateHistoryRepo.delete({
|
||||||
profileCertificateId: certificateId,
|
profileCertificateId: certificateId,
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
Example,
|
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
Path,
|
Path,
|
||||||
|
|
@ -41,82 +40,36 @@ export class ProfileCertificateEmployeeController extends Controller {
|
||||||
}
|
}
|
||||||
const record = await this.certificateRepo.find({
|
const record = await this.certificateRepo.find({
|
||||||
where: { profileEmployeeId: profile.id },
|
where: { profileEmployeeId: profile.id },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileEmployeeId}")
|
@Get("{profileEmployeeId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "e1ef9c3d-079a-40d8-8332-664c3e9a5a70",
|
|
||||||
createdAt: "2024-03-12T03:02:27.532Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-12T03:02:27.532Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
expireDate: "2024-03-12T10:01:48.000Z",
|
|
||||||
issueDate: "2024-03-12T10:01:48.000Z",
|
|
||||||
certificateNo: "string",
|
|
||||||
certificateType: "string",
|
|
||||||
issuer: "string",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async getCertificate(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
public async getCertificate(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
||||||
const record = await this.certificateRepo.findBy({ profileEmployeeId });
|
const record = await this.certificateRepo.find({
|
||||||
|
where: { profileEmployeeId: profileEmployeeId },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{certificateId}")
|
@Get("history/{certificateId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "c0ecf986-b290-44ca-b45e-f4448cdd34dd",
|
|
||||||
createdAt: "2024-03-12T03:03:30.169Z",
|
|
||||||
createdUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
lastUpdatedAt: "2024-03-12T03:03:30.169Z",
|
|
||||||
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
createdFullName: "string",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
expireDate: "2024-03-12T10:03:05.000Z",
|
|
||||||
issueDate: "2024-03-12T10:03:05.000Z",
|
|
||||||
certificateNo: "no",
|
|
||||||
certificateType: "type",
|
|
||||||
issuer: "issuer",
|
|
||||||
profileCertificateId: "e1ef9c3d-079a-40d8-8332-664c3e9a5a70",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "dc4c2800-5fc5-4ec3-b19a-c4a27beac35f",
|
|
||||||
createdAt: "2024-03-12T03:02:27.583Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-12T03:02:27.583Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
expireDate: "2024-03-12T10:01:48.000Z",
|
|
||||||
issueDate: "2024-03-12T10:01:48.000Z",
|
|
||||||
certificateNo: "string",
|
|
||||||
certificateType: "string",
|
|
||||||
issuer: "string",
|
|
||||||
profileCertificateId: "e1ef9c3d-079a-40d8-8332-664c3e9a5a70",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async certificateHistory(@Path() certificateId: string, @Request() req: RequestWithUser) {
|
public async certificateHistory(@Path() certificateId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.certificateRepo.findOneBy({ id: certificateId });
|
const _record = await this.certificateRepo.findOneBy({ id: certificateId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
|
await new permission().PermissionOrgUserGet(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
_record.profileEmployeeId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
const record = await this.certificateHistoryRepo.findBy({
|
const record = await this.certificateHistoryRepo.find({
|
||||||
|
where: {
|
||||||
profileCertificateId: certificateId,
|
profileCertificateId: certificateId,
|
||||||
|
},
|
||||||
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
@ -143,6 +96,8 @@ export class ProfileCertificateEmployeeController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -164,20 +119,27 @@ export class ProfileCertificateEmployeeController extends Controller {
|
||||||
) {
|
) {
|
||||||
const record = await this.certificateRepo.findOneBy({ id: certificateId });
|
const record = await this.certificateRepo.findOneBy({ id: certificateId });
|
||||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId);
|
await new permission().PermissionOrgUserUpdate(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
record.profileEmployeeId,
|
||||||
|
);
|
||||||
|
|
||||||
const history = new ProfileCertificateHistory();
|
const history = new ProfileCertificateHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileCertificateId = certificateId;
|
history.profileCertificateId = certificateId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.certificateRepo.save(record),
|
this.certificateRepo.save(record),
|
||||||
|
|
@ -191,7 +153,11 @@ export class ProfileCertificateEmployeeController extends Controller {
|
||||||
public async deleteCertificate(@Path() certificateId: string, @Request() req: RequestWithUser) {
|
public async deleteCertificate(@Path() certificateId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.certificateRepo.findOneBy({ id: certificateId });
|
const _record = await this.certificateRepo.findOneBy({ id: certificateId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
|
await new permission().PermissionOrgUserDelete(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
_record.profileEmployeeId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
await this.certificateHistoryRepo.delete({
|
await this.certificateHistoryRepo.delete({
|
||||||
profileCertificateId: certificateId,
|
profileCertificateId: certificateId,
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
Example,
|
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
Path,
|
Path,
|
||||||
|
|
@ -41,79 +40,29 @@ export class ProfileCertificateEmployeeTempController extends Controller {
|
||||||
}
|
}
|
||||||
const record = await this.certificateRepo.find({
|
const record = await this.certificateRepo.find({
|
||||||
where: { profileEmployeeId: profile.id },
|
where: { profileEmployeeId: profile.id },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileEmployeeId}")
|
@Get("{profileEmployeeId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "e1ef9c3d-079a-40d8-8332-664c3e9a5a70",
|
|
||||||
createdAt: "2024-03-12T03:02:27.532Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-12T03:02:27.532Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
expireDate: "2024-03-12T10:01:48.000Z",
|
|
||||||
issueDate: "2024-03-12T10:01:48.000Z",
|
|
||||||
certificateNo: "string",
|
|
||||||
certificateType: "string",
|
|
||||||
issuer: "string",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async getCertificate(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
public async getCertificate(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||||
const record = await this.certificateRepo.findBy({ profileEmployeeId });
|
const record = await this.certificateRepo.find({
|
||||||
|
where: { profileEmployeeId },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{certificateId}")
|
@Get("history/{certificateId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "c0ecf986-b290-44ca-b45e-f4448cdd34dd",
|
|
||||||
createdAt: "2024-03-12T03:03:30.169Z",
|
|
||||||
createdUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
lastUpdatedAt: "2024-03-12T03:03:30.169Z",
|
|
||||||
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
createdFullName: "string",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
expireDate: "2024-03-12T10:03:05.000Z",
|
|
||||||
issueDate: "2024-03-12T10:03:05.000Z",
|
|
||||||
certificateNo: "no",
|
|
||||||
certificateType: "type",
|
|
||||||
issuer: "issuer",
|
|
||||||
profileCertificateId: "e1ef9c3d-079a-40d8-8332-664c3e9a5a70",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "dc4c2800-5fc5-4ec3-b19a-c4a27beac35f",
|
|
||||||
createdAt: "2024-03-12T03:02:27.583Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-12T03:02:27.583Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
expireDate: "2024-03-12T10:01:48.000Z",
|
|
||||||
issueDate: "2024-03-12T10:01:48.000Z",
|
|
||||||
certificateNo: "string",
|
|
||||||
certificateType: "string",
|
|
||||||
issuer: "string",
|
|
||||||
profileCertificateId: "e1ef9c3d-079a-40d8-8332-664c3e9a5a70",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async certificateHistory(@Path() certificateId: string, @Request() req: RequestWithUser) {
|
public async certificateHistory(@Path() certificateId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||||
const record = await this.certificateHistoryRepo.findBy({
|
const record = await this.certificateHistoryRepo.find({
|
||||||
|
where: {
|
||||||
profileCertificateId: certificateId,
|
profileCertificateId: certificateId,
|
||||||
|
},
|
||||||
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
@ -141,6 +90,8 @@ export class ProfileCertificateEmployeeTempController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -168,15 +119,18 @@ export class ProfileCertificateEmployeeTempController extends Controller {
|
||||||
const history = new ProfileCertificateHistory();
|
const history = new ProfileCertificateHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileCertificateId = certificateId;
|
history.profileCertificateId = certificateId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.certificateRepo.save(record),
|
this.certificateRepo.save(record),
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
Example,
|
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
Path,
|
Path,
|
||||||
|
|
@ -24,7 +23,6 @@ import {
|
||||||
ProfileChangeName,
|
ProfileChangeName,
|
||||||
UpdateProfileChangeName,
|
UpdateProfileChangeName,
|
||||||
} from "../entities/ProfileChangeName";
|
} from "../entities/ProfileChangeName";
|
||||||
import CallAPI from "../interfaces/call-api";
|
|
||||||
import { updateName } from "../keycloak";
|
import { updateName } from "../keycloak";
|
||||||
import permission from "../interfaces/permission";
|
import permission from "../interfaces/permission";
|
||||||
@Route("api/v1/org/profile/changeName")
|
@Route("api/v1/org/profile/changeName")
|
||||||
|
|
@ -43,61 +41,22 @@ export class ProfileChangeNameController extends Controller {
|
||||||
}
|
}
|
||||||
const lists = await this.changeNameRepository.find({
|
const lists = await this.changeNameRepository.find({
|
||||||
where: { profileId: profile.id },
|
where: { profileId: profile.id },
|
||||||
select: ["id", "prefix", "firstName", "lastName", "status"],
|
|
||||||
order: { createdAt: "ASC" },
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileId}")
|
@Get("{profileId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
|
||||||
prefix: "string",
|
|
||||||
firstName: "string",
|
|
||||||
lastName: "string",
|
|
||||||
status: "string",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async getChangeName(@Path() profileId: string, @Request() req: RequestWithUser) {
|
public async getChangeName(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||||
const lists = await this.changeNameRepository.find({
|
const lists = await this.changeNameRepository.find({
|
||||||
where: { profileId: profileId },
|
where: { profileId: profileId },
|
||||||
select: ["id", "prefix", "firstName", "lastName", "status"],
|
|
||||||
order: { createdAt: "ASC" },
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{changeNameId}")
|
@Get("history/{changeNameId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
|
||||||
prefix: "string",
|
|
||||||
firstName: "string",
|
|
||||||
lastName: "string",
|
|
||||||
status: "string",
|
|
||||||
createdFullName: "string",
|
|
||||||
createdAt: "string",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
|
||||||
prefix: "string",
|
|
||||||
firstName: "string",
|
|
||||||
lastName: "string",
|
|
||||||
status: "string",
|
|
||||||
createdFullName: "string",
|
|
||||||
createdAt: "string",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async changeNameHistory(@Path() changeNameId: string, @Request() req: RequestWithUser) {
|
public async changeNameHistory(@Path() changeNameId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.changeNameRepository.findOneBy({ id: changeNameId });
|
const _record = await this.changeNameRepository.findOneBy({ id: changeNameId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
|
|
@ -105,15 +64,6 @@ export class ProfileChangeNameController extends Controller {
|
||||||
}
|
}
|
||||||
const record = await this.changeNameHistoryRepository.find({
|
const record = await this.changeNameHistoryRepository.find({
|
||||||
where: { profileChangeNameId: changeNameId },
|
where: { profileChangeNameId: changeNameId },
|
||||||
select: [
|
|
||||||
"id",
|
|
||||||
"prefix",
|
|
||||||
"firstName",
|
|
||||||
"lastName",
|
|
||||||
"status",
|
|
||||||
"lastUpdateFullName",
|
|
||||||
"lastUpdatedAt",
|
|
||||||
],
|
|
||||||
order: { createdAt: "DESC" },
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
|
|
@ -141,6 +91,8 @@ export class ProfileChangeNameController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -179,15 +131,18 @@ export class ProfileChangeNameController extends Controller {
|
||||||
const history = new ProfileChangeNameHistory();
|
const history = new ProfileChangeNameHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileChangeNameId = changeNameId;
|
history.profileChangeNameId = changeNameId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.changeNameRepository.save(record),
|
this.changeNameRepository.save(record),
|
||||||
|
|
@ -228,7 +183,11 @@ export class ProfileChangeNameController extends Controller {
|
||||||
public async deleteTraning(@Path() changeNameId: string, @Request() req: RequestWithUser) {
|
public async deleteTraning(@Path() changeNameId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.changeNameRepository.findOneBy({ id: changeNameId });
|
const _record = await this.changeNameRepository.findOneBy({ id: changeNameId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
await new permission().PermissionOrgUserDelete(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_OFFICER",
|
||||||
|
_record.profileId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
await this.changeNameHistoryRepository.delete({
|
await this.changeNameHistoryRepository.delete({
|
||||||
profileChangeNameId: changeNameId,
|
profileChangeNameId: changeNameId,
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
Example,
|
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
Path,
|
Path,
|
||||||
|
|
@ -18,9 +17,7 @@ import HttpStatus from "../interfaces/http-status";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
import { ProfileChangeNameHistory } from "../entities/ProfileChangeNameHistory";
|
import { ProfileChangeNameHistory } from "../entities/ProfileChangeNameHistory";
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
import { RequestWithUser } from "../middlewares/user";
|
||||||
import { Profile } from "../entities/Profile";
|
|
||||||
import {
|
import {
|
||||||
CreateProfileChangeName,
|
|
||||||
CreateProfileChangeNameEmployee,
|
CreateProfileChangeNameEmployee,
|
||||||
ProfileChangeName,
|
ProfileChangeName,
|
||||||
UpdateProfileChangeName,
|
UpdateProfileChangeName,
|
||||||
|
|
@ -44,78 +41,33 @@ export class ProfileChangeNameEmployeeController extends Controller {
|
||||||
}
|
}
|
||||||
const lists = await this.changeNameRepository.find({
|
const lists = await this.changeNameRepository.find({
|
||||||
where: { profileEmployeeId: profile.id },
|
where: { profileEmployeeId: profile.id },
|
||||||
select: ["id", "prefix", "firstName", "lastName", "status"],
|
|
||||||
order: { createdAt: "ASC" },
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileEmployeeId}")
|
@Get("{profileEmployeeId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
|
||||||
prefix: "string",
|
|
||||||
firstName: "string",
|
|
||||||
lastName: "string",
|
|
||||||
status: "string",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async getChangeName(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
public async getChangeName(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
||||||
const lists = await this.changeNameRepository.find({
|
const lists = await this.changeNameRepository.find({
|
||||||
where: { profileEmployeeId: profileEmployeeId },
|
where: { profileEmployeeId: profileEmployeeId },
|
||||||
select: ["id", "prefix", "firstName", "lastName", "status"],
|
|
||||||
order: { createdAt: "ASC" },
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{changeNameId}")
|
@Get("history/{changeNameId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
|
||||||
prefix: "string",
|
|
||||||
firstName: "string",
|
|
||||||
lastName: "string",
|
|
||||||
status: "string",
|
|
||||||
createdFullName: "string",
|
|
||||||
createdAt: "string",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
|
||||||
prefix: "string",
|
|
||||||
firstName: "string",
|
|
||||||
lastName: "string",
|
|
||||||
status: "string",
|
|
||||||
createdFullName: "string",
|
|
||||||
createdAt: "string",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async changeNameHistory(@Path() changeNameId: string, @Request() req: RequestWithUser) {
|
public async changeNameHistory(@Path() changeNameId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.changeNameRepository.findOneBy({ id: changeNameId });
|
const _record = await this.changeNameRepository.findOneBy({ id: changeNameId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId,
|
await new permission().PermissionOrgUserGet(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
_record.profileEmployeeId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const record = await this.changeNameHistoryRepository.find({
|
const record = await this.changeNameHistoryRepository.find({
|
||||||
where: { profileChangeNameId: changeNameId },
|
where: { profileChangeNameId: changeNameId },
|
||||||
select: [
|
|
||||||
"id",
|
|
||||||
"prefix",
|
|
||||||
"firstName",
|
|
||||||
"lastName",
|
|
||||||
"status",
|
|
||||||
"lastUpdateFullName",
|
|
||||||
"lastUpdatedAt",
|
|
||||||
],
|
|
||||||
order: { createdAt: "DESC" },
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
|
|
@ -143,6 +95,8 @@ export class ProfileChangeNameEmployeeController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -176,20 +130,27 @@ export class ProfileChangeNameEmployeeController extends Controller {
|
||||||
) {
|
) {
|
||||||
const record = await this.changeNameRepository.findOneBy({ id: changeNameId });
|
const record = await this.changeNameRepository.findOneBy({ id: changeNameId });
|
||||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId);
|
await new permission().PermissionOrgUserUpdate(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
record.profileEmployeeId,
|
||||||
|
);
|
||||||
|
|
||||||
const history = new ProfileChangeNameHistory();
|
const history = new ProfileChangeNameHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileChangeNameId = changeNameId;
|
history.profileChangeNameId = changeNameId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.changeNameRepository.save(record),
|
this.changeNameRepository.save(record),
|
||||||
|
|
@ -222,7 +183,11 @@ export class ProfileChangeNameEmployeeController extends Controller {
|
||||||
public async deleteTraning(@Path() changeNameId: string, @Request() req: RequestWithUser) {
|
public async deleteTraning(@Path() changeNameId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.changeNameRepository.findOneBy({ id: changeNameId });
|
const _record = await this.changeNameRepository.findOneBy({ id: changeNameId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
|
await new permission().PermissionOrgUserDelete(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
_record.profileEmployeeId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
await this.changeNameHistoryRepository.delete({
|
await this.changeNameHistoryRepository.delete({
|
||||||
profileChangeNameId: changeNameId,
|
profileChangeNameId: changeNameId,
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
Example,
|
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
Path,
|
Path,
|
||||||
|
|
@ -18,9 +17,7 @@ import HttpStatus from "../interfaces/http-status";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
import { ProfileChangeNameHistory } from "../entities/ProfileChangeNameHistory";
|
import { ProfileChangeNameHistory } from "../entities/ProfileChangeNameHistory";
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
import { RequestWithUser } from "../middlewares/user";
|
||||||
import { Profile } from "../entities/Profile";
|
|
||||||
import {
|
import {
|
||||||
CreateProfileChangeName,
|
|
||||||
CreateProfileChangeNameEmployee,
|
CreateProfileChangeNameEmployee,
|
||||||
ProfileChangeName,
|
ProfileChangeName,
|
||||||
UpdateProfileChangeName,
|
UpdateProfileChangeName,
|
||||||
|
|
@ -44,74 +41,26 @@ export class ProfileChangeNameEmployeeTempController extends Controller {
|
||||||
}
|
}
|
||||||
const lists = await this.changeNameRepository.find({
|
const lists = await this.changeNameRepository.find({
|
||||||
where: { profileEmployeeId: profile.id },
|
where: { profileEmployeeId: profile.id },
|
||||||
select: ["id", "prefix", "firstName", "lastName", "status"],
|
|
||||||
order: { createdAt: "ASC" },
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileEmployeeId}")
|
@Get("{profileEmployeeId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
|
||||||
prefix: "string",
|
|
||||||
firstName: "string",
|
|
||||||
lastName: "string",
|
|
||||||
status: "string",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async getChangeName(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
public async getChangeName(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||||
const lists = await this.changeNameRepository.find({
|
const lists = await this.changeNameRepository.find({
|
||||||
where: { profileEmployeeId: profileEmployeeId },
|
where: { profileEmployeeId: profileEmployeeId },
|
||||||
select: ["id", "prefix", "firstName", "lastName", "status"],
|
|
||||||
order: { createdAt: "ASC" },
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{changeNameId}")
|
@Get("history/{changeNameId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
|
||||||
prefix: "string",
|
|
||||||
firstName: "string",
|
|
||||||
lastName: "string",
|
|
||||||
status: "string",
|
|
||||||
createdFullName: "string",
|
|
||||||
createdAt: "string",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
|
||||||
prefix: "string",
|
|
||||||
firstName: "string",
|
|
||||||
lastName: "string",
|
|
||||||
status: "string",
|
|
||||||
createdFullName: "string",
|
|
||||||
createdAt: "string",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async changeNameHistory(@Path() changeNameId: string, @Request() req: RequestWithUser) {
|
public async changeNameHistory(@Path() changeNameId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||||
const record = await this.changeNameHistoryRepository.find({
|
const record = await this.changeNameHistoryRepository.find({
|
||||||
where: { profileChangeNameId: changeNameId },
|
where: { profileChangeNameId: changeNameId },
|
||||||
select: [
|
|
||||||
"id",
|
|
||||||
"prefix",
|
|
||||||
"firstName",
|
|
||||||
"lastName",
|
|
||||||
"status",
|
|
||||||
"lastUpdateFullName",
|
|
||||||
"lastUpdatedAt",
|
|
||||||
],
|
|
||||||
order: { createdAt: "DESC" },
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
|
|
@ -140,6 +89,8 @@ export class ProfileChangeNameEmployeeTempController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -179,15 +130,18 @@ export class ProfileChangeNameEmployeeTempController extends Controller {
|
||||||
const history = new ProfileChangeNameHistory();
|
const history = new ProfileChangeNameHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileChangeNameId = changeNameId;
|
history.profileChangeNameId = changeNameId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.changeNameRepository.save(record),
|
this.changeNameRepository.save(record),
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
Example,
|
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
Path,
|
Path,
|
||||||
|
|
@ -42,6 +41,7 @@ export class ProfileChildrenController extends Controller {
|
||||||
}
|
}
|
||||||
const lists = await this.childrenRepository.find({
|
const lists = await this.childrenRepository.find({
|
||||||
where: { profileId: profile.id },
|
where: { profileId: profile.id },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
@ -51,6 +51,7 @@ export class ProfileChildrenController extends Controller {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||||
const lists = await this.childrenRepository.find({
|
const lists = await this.childrenRepository.find({
|
||||||
where: { profileId: profileId },
|
where: { profileId: profileId },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
@ -82,6 +83,8 @@ export class ProfileChildrenController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -109,16 +112,19 @@ export class ProfileChildrenController extends Controller {
|
||||||
|
|
||||||
const history = new ProfileChildrenHistory();
|
const history = new ProfileChildrenHistory();
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
record.childrenCitizenId = Extension.CheckCitizen(String(record.childrenCitizenId));
|
record.childrenCitizenId = Extension.CheckCitizen(String(record.childrenCitizenId));
|
||||||
history.profileChildrenId = record.id;
|
history.profileChildrenId = record.id;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.childrenRepository.save(record),
|
this.childrenRepository.save(record),
|
||||||
this.childrenHistoryRepository.save(history),
|
this.childrenHistoryRepository.save(history),
|
||||||
|
|
@ -131,7 +137,11 @@ export class ProfileChildrenController extends Controller {
|
||||||
public async deleteTraning(@Path() childrenId: string, @Request() req: RequestWithUser) {
|
public async deleteTraning(@Path() childrenId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.childrenRepository.findOneBy({ id: childrenId });
|
const _record = await this.childrenRepository.findOneBy({ id: childrenId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
await new permission().PermissionOrgUserDelete(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_OFFICER",
|
||||||
|
_record.profileId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
await this.childrenHistoryRepository.delete({
|
await this.childrenHistoryRepository.delete({
|
||||||
profileChildrenId: childrenId,
|
profileChildrenId: childrenId,
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
Example,
|
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
Path,
|
Path,
|
||||||
|
|
@ -18,9 +17,7 @@ import HttpStatus from "../interfaces/http-status";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
import { ProfileChildrenHistory } from "../entities/ProfileChildrenHistory";
|
import { ProfileChildrenHistory } from "../entities/ProfileChildrenHistory";
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
import { RequestWithUser } from "../middlewares/user";
|
||||||
import { Profile } from "../entities/Profile";
|
|
||||||
import {
|
import {
|
||||||
CreateProfileChildren,
|
|
||||||
CreateProfileChildrenEmployee,
|
CreateProfileChildrenEmployee,
|
||||||
ProfileChildren,
|
ProfileChildren,
|
||||||
UpdateProfileChildren,
|
UpdateProfileChildren,
|
||||||
|
|
@ -44,6 +41,7 @@ export class ProfileChildrenEmployeeController extends Controller {
|
||||||
}
|
}
|
||||||
const lists = await this.childrenRepository.find({
|
const lists = await this.childrenRepository.find({
|
||||||
where: { profileEmployeeId: profile.id },
|
where: { profileEmployeeId: profile.id },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
@ -53,6 +51,7 @@ export class ProfileChildrenEmployeeController extends Controller {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
||||||
const lists = await this.childrenRepository.find({
|
const lists = await this.childrenRepository.find({
|
||||||
where: { profileEmployeeId: profileEmployeeId },
|
where: { profileEmployeeId: profileEmployeeId },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
@ -61,7 +60,10 @@ export class ProfileChildrenEmployeeController extends Controller {
|
||||||
public async childrenHistory(@Path() childrenId: string, @Request() req: RequestWithUser) {
|
public async childrenHistory(@Path() childrenId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.childrenRepository.findOneBy({ id: childrenId });
|
const _record = await this.childrenRepository.findOneBy({ id: childrenId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId,
|
await new permission().PermissionOrgUserGet(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
_record.profileEmployeeId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const record = await this.childrenHistoryRepository.find({
|
const record = await this.childrenHistoryRepository.find({
|
||||||
|
|
@ -89,6 +91,8 @@ export class ProfileChildrenEmployeeController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -112,20 +116,27 @@ export class ProfileChildrenEmployeeController extends Controller {
|
||||||
) {
|
) {
|
||||||
const record = await this.childrenRepository.findOneBy({ id: childrenId });
|
const record = await this.childrenRepository.findOneBy({ id: childrenId });
|
||||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId);
|
await new permission().PermissionOrgUserUpdate(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
record.profileEmployeeId,
|
||||||
|
);
|
||||||
|
|
||||||
const history = new ProfileChildrenHistory();
|
const history = new ProfileChildrenHistory();
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
record.childrenCitizenId = Extension.CheckCitizen(String(record.childrenCitizenId));
|
record.childrenCitizenId = Extension.CheckCitizen(String(record.childrenCitizenId));
|
||||||
history.profileChildrenId = record.id;
|
history.profileChildrenId = record.id;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.childrenRepository.save(record),
|
this.childrenRepository.save(record),
|
||||||
|
|
@ -139,7 +150,11 @@ export class ProfileChildrenEmployeeController extends Controller {
|
||||||
public async deleteTraning(@Path() childrenId: string, @Request() req: RequestWithUser) {
|
public async deleteTraning(@Path() childrenId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.childrenRepository.findOneBy({ id: childrenId });
|
const _record = await this.childrenRepository.findOneBy({ id: childrenId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
|
await new permission().PermissionOrgUserDelete(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
_record.profileEmployeeId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
await this.childrenHistoryRepository.delete({
|
await this.childrenHistoryRepository.delete({
|
||||||
profileChildrenId: childrenId,
|
profileChildrenId: childrenId,
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
Example,
|
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
Path,
|
Path,
|
||||||
|
|
@ -18,9 +17,7 @@ import HttpStatus from "../interfaces/http-status";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
import { ProfileChildrenHistory } from "../entities/ProfileChildrenHistory";
|
import { ProfileChildrenHistory } from "../entities/ProfileChildrenHistory";
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
import { RequestWithUser } from "../middlewares/user";
|
||||||
import { Profile } from "../entities/Profile";
|
|
||||||
import {
|
import {
|
||||||
CreateProfileChildren,
|
|
||||||
CreateProfileChildrenEmployee,
|
CreateProfileChildrenEmployee,
|
||||||
ProfileChildren,
|
ProfileChildren,
|
||||||
UpdateProfileChildren,
|
UpdateProfileChildren,
|
||||||
|
|
@ -44,6 +41,7 @@ export class ProfileChildrenEmployeeTempController extends Controller {
|
||||||
}
|
}
|
||||||
const lists = await this.childrenRepository.find({
|
const lists = await this.childrenRepository.find({
|
||||||
where: { profileEmployeeId: profile.id },
|
where: { profileEmployeeId: profile.id },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
@ -53,6 +51,7 @@ export class ProfileChildrenEmployeeTempController extends Controller {
|
||||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||||
const lists = await this.childrenRepository.find({
|
const lists = await this.childrenRepository.find({
|
||||||
where: { profileEmployeeId: profileEmployeeId },
|
where: { profileEmployeeId: profileEmployeeId },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
@ -86,6 +85,8 @@ export class ProfileChildrenEmployeeTempController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -112,16 +113,19 @@ export class ProfileChildrenEmployeeTempController extends Controller {
|
||||||
|
|
||||||
const history = new ProfileChildrenHistory();
|
const history = new ProfileChildrenHistory();
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
record.childrenCitizenId = Extension.CheckCitizen(String(record.childrenCitizenId));
|
record.childrenCitizenId = Extension.CheckCitizen(String(record.childrenCitizenId));
|
||||||
history.profileChildrenId = record.id;
|
history.profileChildrenId = record.id;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.childrenRepository.save(record),
|
this.childrenRepository.save(record),
|
||||||
|
|
|
||||||
|
|
@ -1268,6 +1268,8 @@ export class ProfileController extends Controller {
|
||||||
profile.createdFullName = request.user.name;
|
profile.createdFullName = request.user.name;
|
||||||
profile.lastUpdateUserId = request.user.sub;
|
profile.lastUpdateUserId = request.user.sub;
|
||||||
profile.lastUpdateFullName = request.user.name;
|
profile.lastUpdateFullName = request.user.name;
|
||||||
|
profile.createdAt = new Date();
|
||||||
|
profile.lastUpdatedAt = new Date();
|
||||||
profile.dateRetire = calculateRetireDate(profile.birthDate);
|
profile.dateRetire = calculateRetireDate(profile.birthDate);
|
||||||
profile.dateRetireLaw = calculateRetireLaw(profile.birthDate);
|
profile.dateRetireLaw = calculateRetireLaw(profile.birthDate);
|
||||||
await this.profileRepo.save(profile);
|
await this.profileRepo.save(profile);
|
||||||
|
|
@ -1310,6 +1312,8 @@ export class ProfileController extends Controller {
|
||||||
profile.createdFullName = request.user.name;
|
profile.createdFullName = request.user.name;
|
||||||
profile.lastUpdateUserId = request.user.sub;
|
profile.lastUpdateUserId = request.user.sub;
|
||||||
profile.lastUpdateFullName = request.user.name;
|
profile.lastUpdateFullName = request.user.name;
|
||||||
|
profile.createdAt = new Date();
|
||||||
|
profile.lastUpdatedAt = new Date();
|
||||||
await this.profileRepo.save(profile);
|
await this.profileRepo.save(profile);
|
||||||
return new HttpSuccess(profile.id);
|
return new HttpSuccess(profile.id);
|
||||||
}
|
}
|
||||||
|
|
@ -1346,6 +1350,8 @@ export class ProfileController extends Controller {
|
||||||
profile.createdFullName = request.user.name;
|
profile.createdFullName = request.user.name;
|
||||||
profile.lastUpdateUserId = request.user.sub;
|
profile.lastUpdateUserId = request.user.sub;
|
||||||
profile.lastUpdateFullName = request.user.name;
|
profile.lastUpdateFullName = request.user.name;
|
||||||
|
profile.createdAt = new Date();
|
||||||
|
profile.lastUpdatedAt = new Date();
|
||||||
await this.profileRepo.save(profile);
|
await this.profileRepo.save(profile);
|
||||||
return new HttpSuccess(profile.id);
|
return new HttpSuccess(profile.id);
|
||||||
}
|
}
|
||||||
|
|
@ -1386,6 +1392,7 @@ export class ProfileController extends Controller {
|
||||||
profile.isProbation = false;
|
profile.isProbation = false;
|
||||||
profile.lastUpdateUserId = req.user.sub;
|
profile.lastUpdateUserId = req.user.sub;
|
||||||
profile.lastUpdateFullName = req.user.name;
|
profile.lastUpdateFullName = req.user.name;
|
||||||
|
profile.lastUpdatedAt = new Date();
|
||||||
const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), {
|
const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), {
|
||||||
profileId: body.profileId,
|
profileId: body.profileId,
|
||||||
date: body.date,
|
date: body.date,
|
||||||
|
|
@ -1419,6 +1426,8 @@ export class ProfileController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
});
|
});
|
||||||
await Promise.all([this.salaryRepository.save(profileSalary)]);
|
await Promise.all([this.salaryRepository.save(profileSalary)]);
|
||||||
}
|
}
|
||||||
|
|
@ -1468,6 +1477,7 @@ export class ProfileController extends Controller {
|
||||||
_profile.dateLeave = dateLeave_;
|
_profile.dateLeave = dateLeave_;
|
||||||
_profile.lastUpdateUserId = req.user.sub;
|
_profile.lastUpdateUserId = req.user.sub;
|
||||||
_profile.lastUpdateFullName = req.user.name;
|
_profile.lastUpdateFullName = req.user.name;
|
||||||
|
_profile.lastUpdatedAt = new Date();
|
||||||
const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), {
|
const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), {
|
||||||
profileId: body.profileId,
|
profileId: body.profileId,
|
||||||
date: body.date,
|
date: body.date,
|
||||||
|
|
@ -1498,6 +1508,8 @@ export class ProfileController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
});
|
});
|
||||||
await Promise.all([this.profileRepo.save(_profile), this.salaryRepository.save(profileSalary)]);
|
await Promise.all([this.profileRepo.save(_profile), this.salaryRepository.save(profileSalary)]);
|
||||||
|
|
||||||
|
|
@ -1546,6 +1558,7 @@ export class ProfileController extends Controller {
|
||||||
_profile.dateLeave = dateLeave_;
|
_profile.dateLeave = dateLeave_;
|
||||||
_profile.lastUpdateUserId = req.user.sub;
|
_profile.lastUpdateUserId = req.user.sub;
|
||||||
_profile.lastUpdateFullName = req.user.name;
|
_profile.lastUpdateFullName = req.user.name;
|
||||||
|
_profile.lastUpdatedAt = new Date();
|
||||||
const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), {
|
const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), {
|
||||||
profileId: body.profileId,
|
profileId: body.profileId,
|
||||||
date: body.date,
|
date: body.date,
|
||||||
|
|
@ -1576,6 +1589,8 @@ export class ProfileController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
});
|
});
|
||||||
await Promise.all([this.profileRepo.save(_profile), this.salaryRepository.save(profileSalary)]);
|
await Promise.all([this.profileRepo.save(_profile), this.salaryRepository.save(profileSalary)]);
|
||||||
|
|
||||||
|
|
@ -1624,6 +1639,7 @@ export class ProfileController extends Controller {
|
||||||
_profile.dateLeave = dateLeave_;
|
_profile.dateLeave = dateLeave_;
|
||||||
_profile.lastUpdateUserId = req.user.sub;
|
_profile.lastUpdateUserId = req.user.sub;
|
||||||
_profile.lastUpdateFullName = req.user.name;
|
_profile.lastUpdateFullName = req.user.name;
|
||||||
|
_profile.lastUpdatedAt = new Date();
|
||||||
const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), {
|
const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), {
|
||||||
profileId: body.profileId,
|
profileId: body.profileId,
|
||||||
date: body.date,
|
date: body.date,
|
||||||
|
|
@ -1654,6 +1670,8 @@ export class ProfileController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
});
|
});
|
||||||
// //เพิ่มวินัย
|
// //เพิ่มวินัย
|
||||||
// const profileDiscipline: ProfileDiscipline = Object.assign(new ProfileDiscipline(), {
|
// const profileDiscipline: ProfileDiscipline = Object.assign(new ProfileDiscipline(), {
|
||||||
|
|
@ -1664,6 +1682,8 @@ export class ProfileController extends Controller {
|
||||||
// createdFullName: req.user.name,
|
// createdFullName: req.user.name,
|
||||||
// lastUpdateUserId: req.user.sub,
|
// lastUpdateUserId: req.user.sub,
|
||||||
// lastUpdateFullName: req.user.name,
|
// lastUpdateFullName: req.user.name,
|
||||||
|
// createdAt: new Date(),
|
||||||
|
// lastUpdatedAt: new Date(),
|
||||||
// });
|
// });
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.profileRepo.save(_profile),
|
this.profileRepo.save(_profile),
|
||||||
|
|
@ -1716,6 +1736,7 @@ export class ProfileController extends Controller {
|
||||||
_profile.dateLeave = dateLeave_;
|
_profile.dateLeave = dateLeave_;
|
||||||
_profile.lastUpdateUserId = req.user.sub;
|
_profile.lastUpdateUserId = req.user.sub;
|
||||||
_profile.lastUpdateFullName = req.user.name;
|
_profile.lastUpdateFullName = req.user.name;
|
||||||
|
_profile.lastUpdatedAt = new Date();
|
||||||
const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), {
|
const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), {
|
||||||
profileId: body.profileId,
|
profileId: body.profileId,
|
||||||
date: body.date,
|
date: body.date,
|
||||||
|
|
@ -1746,6 +1767,8 @@ export class ProfileController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
});
|
});
|
||||||
await Promise.all([this.profileRepo.save(_profile), this.salaryRepository.save(profileSalary)]);
|
await Promise.all([this.profileRepo.save(_profile), this.salaryRepository.save(profileSalary)]);
|
||||||
|
|
||||||
|
|
@ -1824,6 +1847,8 @@ export class ProfileController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
});
|
});
|
||||||
await Promise.all([this.profileRepo.save(_profile), this.salaryRepository.save(profileSalary)]);
|
await Promise.all([this.profileRepo.save(_profile), this.salaryRepository.save(profileSalary)]);
|
||||||
|
|
||||||
|
|
@ -1895,6 +1920,8 @@ export class ProfileController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
});
|
});
|
||||||
await Promise.all([this.salaryRepository.save(profileSalary)]);
|
await Promise.all([this.salaryRepository.save(profileSalary)]);
|
||||||
|
|
||||||
|
|
@ -1966,6 +1993,8 @@ export class ProfileController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
});
|
});
|
||||||
await Promise.all([this.salaryRepository.save(profileSalary)]);
|
await Promise.all([this.salaryRepository.save(profileSalary)]);
|
||||||
|
|
||||||
|
|
@ -2037,6 +2066,8 @@ export class ProfileController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
});
|
});
|
||||||
await Promise.all([this.salaryRepository.save(profileSalary)]);
|
await Promise.all([this.salaryRepository.save(profileSalary)]);
|
||||||
|
|
||||||
|
|
@ -2108,6 +2139,8 @@ export class ProfileController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
});
|
});
|
||||||
await Promise.all([this.salaryRepository.save(profileSalary)]);
|
await Promise.all([this.salaryRepository.save(profileSalary)]);
|
||||||
|
|
||||||
|
|
@ -2179,6 +2212,8 @@ export class ProfileController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
});
|
});
|
||||||
await Promise.all([this.salaryRepository.save(profileSalary)]);
|
await Promise.all([this.salaryRepository.save(profileSalary)]);
|
||||||
|
|
||||||
|
|
@ -2221,6 +2256,7 @@ export class ProfileController extends Controller {
|
||||||
profile.dateLeave = null_;
|
profile.dateLeave = null_;
|
||||||
profile.lastUpdateUserId = req.user.sub;
|
profile.lastUpdateUserId = req.user.sub;
|
||||||
profile.lastUpdateFullName = req.user.name;
|
profile.lastUpdateFullName = req.user.name;
|
||||||
|
profile.lastUpdatedAt = new Date();
|
||||||
// const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), {
|
// const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), {
|
||||||
// profileId: body.profileId,
|
// profileId: body.profileId,
|
||||||
// date: body.date,
|
// date: body.date,
|
||||||
|
|
@ -2251,6 +2287,8 @@ export class ProfileController extends Controller {
|
||||||
// createdFullName: req.user.name,
|
// createdFullName: req.user.name,
|
||||||
// lastUpdateUserId: req.user.sub,
|
// lastUpdateUserId: req.user.sub,
|
||||||
// lastUpdateFullName: req.user.name,
|
// lastUpdateFullName: req.user.name,
|
||||||
|
// createdAt: new Date(),
|
||||||
|
// lastUpdatedAt: new Date(),
|
||||||
// });
|
// });
|
||||||
await Promise.all([this.profileRepo.save(profile)]);
|
await Promise.all([this.profileRepo.save(profile)]);
|
||||||
|
|
||||||
|
|
@ -2350,6 +2388,12 @@ export class ProfileController extends Controller {
|
||||||
|
|
||||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้");
|
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(
|
await this.profileHistoryRepo.save(
|
||||||
Object.assign(new ProfileHistory(), {
|
Object.assign(new ProfileHistory(), {
|
||||||
...record,
|
...record,
|
||||||
|
|
@ -2357,12 +2401,6 @@ export class ProfileController extends Controller {
|
||||||
id: undefined,
|
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);
|
await this.profileRepo.save(record);
|
||||||
|
|
||||||
if (record != null && record.keycloak != null) {
|
if (record != null && record.keycloak != null) {
|
||||||
|
|
@ -5461,6 +5499,8 @@ export class ProfileController extends Controller {
|
||||||
profile.createdFullName = request.user.name;
|
profile.createdFullName = request.user.name;
|
||||||
profile.lastUpdateUserId = request.user.sub;
|
profile.lastUpdateUserId = request.user.sub;
|
||||||
profile.lastUpdateFullName = request.user.name;
|
profile.lastUpdateFullName = request.user.name;
|
||||||
|
profile.createdAt = new Date();
|
||||||
|
profile.lastUpdatedAt = new Date();
|
||||||
// return new HttpSuccess(profile);
|
// return new HttpSuccess(profile);
|
||||||
await this.profileRepo.save(profile);
|
await this.profileRepo.save(profile);
|
||||||
return new HttpSuccess(profile.id);
|
return new HttpSuccess(profile.id);
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
Example,
|
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
Path,
|
Path,
|
||||||
|
|
@ -41,53 +40,22 @@ export class ProfileDevelopmentController extends Controller {
|
||||||
}
|
}
|
||||||
const lists = await this.developmentRepository.find({
|
const lists = await this.developmentRepository.find({
|
||||||
where: { profileId: profile.id },
|
where: { profileId: profile.id },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileId}")
|
@Get("{profileId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
|
||||||
isActive: true,
|
|
||||||
date: "2024-03-12T10:09:47.000Z",
|
|
||||||
reference: "string",
|
|
||||||
detail: "string",
|
|
||||||
refCommandNo: "string",
|
|
||||||
refCommandDate: "2024-03-12T10:09:47.000Z",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async getDevelopment(@Path() profileId: string, @Request() req: RequestWithUser) {
|
public async getDevelopment(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||||
const lists = await this.developmentRepository.find({
|
const lists = await this.developmentRepository.find({
|
||||||
where: { profileId: profileId },
|
where: { profileId: profileId },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{developmentId}")
|
@Get("history/{developmentId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
|
||||||
isActive: true,
|
|
||||||
date: "2024-03-12T10:09:47.000Z",
|
|
||||||
detail: "string",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
|
||||||
isActive: true,
|
|
||||||
date: "2024-03-12T10:09:47.000Z",
|
|
||||||
detail: "string",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async developmentHistory(@Path() developmentId: string, @Request() req: RequestWithUser) {
|
public async developmentHistory(@Path() developmentId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.developmentRepository.findOneBy({ id: developmentId });
|
const _record = await this.developmentRepository.findOneBy({ id: developmentId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
|
|
@ -122,6 +90,8 @@ export class ProfileDevelopmentController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -150,15 +120,18 @@ export class ProfileDevelopmentController extends Controller {
|
||||||
const history = new ProfileDevelopmentHistory();
|
const history = new ProfileDevelopmentHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileDevelopmentId = developmentId;
|
history.profileDevelopmentId = developmentId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.developmentRepository.save(record),
|
this.developmentRepository.save(record),
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
Example,
|
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
Path,
|
Path,
|
||||||
|
|
@ -41,6 +40,7 @@ export class ProfileDevelopmentEmployeeController extends Controller {
|
||||||
}
|
}
|
||||||
const lists = await this.developmentRepository.find({
|
const lists = await this.developmentRepository.find({
|
||||||
where: { profileEmployeeId: profile.id },
|
where: { profileEmployeeId: profile.id },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
@ -50,6 +50,7 @@ export class ProfileDevelopmentEmployeeController extends Controller {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId);
|
||||||
const lists = await this.developmentRepository.find({
|
const lists = await this.developmentRepository.find({
|
||||||
where: { profileEmployeeId: profileId },
|
where: { profileEmployeeId: profileId },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
@ -93,6 +94,8 @@ export class ProfileDevelopmentEmployeeController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -125,15 +128,18 @@ export class ProfileDevelopmentEmployeeController extends Controller {
|
||||||
const history = new ProfileDevelopmentHistory();
|
const history = new ProfileDevelopmentHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileDevelopmentId = developmentId;
|
history.profileDevelopmentId = developmentId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.developmentRepository.save(record),
|
this.developmentRepository.save(record),
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
Example,
|
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
Path,
|
Path,
|
||||||
|
|
@ -41,6 +40,7 @@ export class ProfileDevelopmentEmployeeTempController extends Controller {
|
||||||
}
|
}
|
||||||
const lists = await this.developmentRepository.find({
|
const lists = await this.developmentRepository.find({
|
||||||
where: { profileEmployeeId: profile.id },
|
where: { profileEmployeeId: profile.id },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
@ -50,6 +50,7 @@ export class ProfileDevelopmentEmployeeTempController extends Controller {
|
||||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||||
const lists = await this.developmentRepository.find({
|
const lists = await this.developmentRepository.find({
|
||||||
where: { profileEmployeeId: profileId },
|
where: { profileEmployeeId: profileId },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
@ -87,6 +88,8 @@ export class ProfileDevelopmentEmployeeTempController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -116,15 +119,18 @@ export class ProfileDevelopmentEmployeeTempController extends Controller {
|
||||||
const history = new ProfileDevelopmentHistory();
|
const history = new ProfileDevelopmentHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileDevelopmentId = developmentId;
|
history.profileDevelopmentId = developmentId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.developmentRepository.save(record),
|
this.developmentRepository.save(record),
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
Example,
|
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
Path,
|
Path,
|
||||||
|
|
@ -41,17 +40,7 @@ export class ProfileDisciplineController extends Controller {
|
||||||
}
|
}
|
||||||
const lists = await this.disciplineRepository.find({
|
const lists = await this.disciplineRepository.find({
|
||||||
where: { profileId: profile.id },
|
where: { profileId: profile.id },
|
||||||
select: [
|
order: { createdAt: "ASC" },
|
||||||
"id",
|
|
||||||
"date",
|
|
||||||
"level",
|
|
||||||
"detail",
|
|
||||||
"unStigma",
|
|
||||||
"refCommandNo",
|
|
||||||
"refCommandDate",
|
|
||||||
"lastUpdateFullName",
|
|
||||||
"lastUpdatedAt",
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
@ -61,17 +50,7 @@ export class ProfileDisciplineController extends Controller {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||||
const lists = await this.disciplineRepository.find({
|
const lists = await this.disciplineRepository.find({
|
||||||
where: { profileId: profileId },
|
where: { profileId: profileId },
|
||||||
select: [
|
order: { createdAt: "ASC" },
|
||||||
"id",
|
|
||||||
"date",
|
|
||||||
"level",
|
|
||||||
"detail",
|
|
||||||
"unStigma",
|
|
||||||
"refCommandNo",
|
|
||||||
"refCommandDate",
|
|
||||||
"lastUpdateFullName",
|
|
||||||
"lastUpdatedAt",
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
@ -81,46 +60,12 @@ export class ProfileDisciplineController extends Controller {
|
||||||
await new permission().PermissionGet(req, "SYS_SALARY_OFFICER");
|
await new permission().PermissionGet(req, "SYS_SALARY_OFFICER");
|
||||||
const lists = await this.disciplineRepository.find({
|
const lists = await this.disciplineRepository.find({
|
||||||
where: { profileId: profileId },
|
where: { profileId: profileId },
|
||||||
select: [
|
order: { createdAt: "ASC" },
|
||||||
"id",
|
|
||||||
"date",
|
|
||||||
"level",
|
|
||||||
"detail",
|
|
||||||
"unStigma",
|
|
||||||
"refCommandNo",
|
|
||||||
"refCommandDate",
|
|
||||||
"lastUpdateFullName",
|
|
||||||
"lastUpdatedAt",
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{disciplineId}")
|
@Get("history/{disciplineId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
|
||||||
date: "2024-03-12T10:09:47.000Z",
|
|
||||||
level: "string",
|
|
||||||
detail: "string",
|
|
||||||
unStigma: "string",
|
|
||||||
refCommandNo: "string",
|
|
||||||
refCommandDate: "2024-03-12T10:09:47.000Z",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "ba0e2f82-014e-46c6-8b82-a7c28eb5325f",
|
|
||||||
date: "2024-03-12T10:09:47.000Z",
|
|
||||||
level: "string",
|
|
||||||
detail: "string",
|
|
||||||
unStigma: "string",
|
|
||||||
refCommandNo: "string",
|
|
||||||
refCommandDate: "2024-03-12T10:09:47.000Z",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async disciplineHistory(@Path() disciplineId: string, @Request() req: RequestWithUser) {
|
public async disciplineHistory(@Path() disciplineId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.disciplineRepository.findOneBy({ id: disciplineId });
|
const _record = await this.disciplineRepository.findOneBy({ id: disciplineId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
|
|
@ -128,17 +73,6 @@ export class ProfileDisciplineController extends Controller {
|
||||||
}
|
}
|
||||||
const record = await this.disciplineHistoryRepository.find({
|
const record = await this.disciplineHistoryRepository.find({
|
||||||
where: { profileDisciplineId: disciplineId },
|
where: { profileDisciplineId: disciplineId },
|
||||||
select: [
|
|
||||||
"id",
|
|
||||||
"date",
|
|
||||||
"level",
|
|
||||||
"detail",
|
|
||||||
"unStigma",
|
|
||||||
"refCommandNo",
|
|
||||||
"refCommandDate",
|
|
||||||
"lastUpdateFullName",
|
|
||||||
"lastUpdatedAt",
|
|
||||||
],
|
|
||||||
order: { createdAt: "DESC" },
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
|
|
@ -167,6 +101,8 @@ export class ProfileDisciplineController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -193,15 +129,18 @@ export class ProfileDisciplineController extends Controller {
|
||||||
const history = new ProfileDisciplineHistory();
|
const history = new ProfileDisciplineHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileDisciplineId = disciplineId;
|
history.profileDisciplineId = disciplineId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.disciplineRepository.save(record),
|
this.disciplineRepository.save(record),
|
||||||
|
|
@ -215,7 +154,11 @@ export class ProfileDisciplineController extends Controller {
|
||||||
public async deleteDiscipline(@Path() disciplineId: string, @Request() req: RequestWithUser) {
|
public async deleteDiscipline(@Path() disciplineId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.disciplineRepository.findOneBy({ id: disciplineId });
|
const _record = await this.disciplineRepository.findOneBy({ id: disciplineId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
await new permission().PermissionOrgUserDelete(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_OFFICER",
|
||||||
|
_record.profileId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
await this.disciplineHistoryRepository.delete({
|
await this.disciplineHistoryRepository.delete({
|
||||||
profileDisciplineId: disciplineId,
|
profileDisciplineId: disciplineId,
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
Example,
|
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
Path,
|
Path,
|
||||||
|
|
@ -41,52 +40,17 @@ export class ProfileDisciplineEmployeeController extends Controller {
|
||||||
}
|
}
|
||||||
const lists = await this.disciplineRepository.find({
|
const lists = await this.disciplineRepository.find({
|
||||||
where: { profileEmployeeId: profile.id },
|
where: { profileEmployeeId: profile.id },
|
||||||
select: [
|
order: { createdAt: "ASC" },
|
||||||
"id",
|
|
||||||
"date",
|
|
||||||
"level",
|
|
||||||
"detail",
|
|
||||||
"unStigma",
|
|
||||||
"refCommandNo",
|
|
||||||
"refCommandDate",
|
|
||||||
"lastUpdateFullName",
|
|
||||||
"lastUpdatedAt",
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileId}")
|
@Get("{profileId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
|
||||||
date: "2024-03-12T10:09:47.000Z",
|
|
||||||
level: "string",
|
|
||||||
detail: "string",
|
|
||||||
unStigma: "string",
|
|
||||||
refCommandNo: "string",
|
|
||||||
refCommandDate: "2024-03-12T10:09:47.000Z",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async getDiscipline(@Path() profileId: string, @Request() req: RequestWithUser) {
|
public async getDiscipline(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId);
|
||||||
const lists = await this.disciplineRepository.find({
|
const lists = await this.disciplineRepository.find({
|
||||||
where: { profileEmployeeId: profileId },
|
where: { profileEmployeeId: profileId },
|
||||||
select: [
|
order: { createdAt: "ASC" },
|
||||||
"id",
|
|
||||||
"date",
|
|
||||||
"level",
|
|
||||||
"detail",
|
|
||||||
"unStigma",
|
|
||||||
"refCommandNo",
|
|
||||||
"refCommandDate",
|
|
||||||
"lastUpdateFullName",
|
|
||||||
"lastUpdatedAt",
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
@ -96,17 +60,7 @@ export class ProfileDisciplineEmployeeController extends Controller {
|
||||||
await new permission().PermissionGet(req, "SYS_WAGE");
|
await new permission().PermissionGet(req, "SYS_WAGE");
|
||||||
const lists = await this.disciplineRepository.find({
|
const lists = await this.disciplineRepository.find({
|
||||||
where: { profileEmployeeId: profileId },
|
where: { profileEmployeeId: profileId },
|
||||||
select: [
|
order: { createdAt: "ASC" },
|
||||||
"id",
|
|
||||||
"date",
|
|
||||||
"level",
|
|
||||||
"detail",
|
|
||||||
"unStigma",
|
|
||||||
"refCommandNo",
|
|
||||||
"refCommandDate",
|
|
||||||
"lastUpdateFullName",
|
|
||||||
"lastUpdatedAt",
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
@ -115,21 +69,14 @@ export class ProfileDisciplineEmployeeController extends Controller {
|
||||||
public async disciplineHistory(@Path() disciplineId: string, @Request() req: RequestWithUser) {
|
public async disciplineHistory(@Path() disciplineId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.disciplineRepository.findOneBy({ id: disciplineId });
|
const _record = await this.disciplineRepository.findOneBy({ id: disciplineId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
|
await new permission().PermissionOrgUserGet(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
_record.profileEmployeeId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
const record = await this.disciplineHistoryRepository.find({
|
const record = await this.disciplineHistoryRepository.find({
|
||||||
where: { profileDisciplineId: disciplineId },
|
where: { profileDisciplineId: disciplineId },
|
||||||
select: [
|
|
||||||
"id",
|
|
||||||
"date",
|
|
||||||
"level",
|
|
||||||
"detail",
|
|
||||||
"unStigma",
|
|
||||||
"refCommandNo",
|
|
||||||
"refCommandDate",
|
|
||||||
"lastUpdateFullName",
|
|
||||||
"lastUpdatedAt",
|
|
||||||
],
|
|
||||||
order: { createdAt: "DESC" },
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
|
|
@ -157,6 +104,8 @@ export class ProfileDisciplineEmployeeController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -178,20 +127,27 @@ export class ProfileDisciplineEmployeeController extends Controller {
|
||||||
) {
|
) {
|
||||||
const record = await this.disciplineRepository.findOneBy({ id: disciplineId });
|
const record = await this.disciplineRepository.findOneBy({ id: disciplineId });
|
||||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId)
|
await new permission().PermissionOrgUserUpdate(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
record.profileEmployeeId,
|
||||||
|
);
|
||||||
|
|
||||||
const history = new ProfileDisciplineHistory();
|
const history = new ProfileDisciplineHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileDisciplineId = disciplineId;
|
history.profileDisciplineId = disciplineId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.disciplineRepository.save(record),
|
this.disciplineRepository.save(record),
|
||||||
|
|
@ -205,7 +161,11 @@ export class ProfileDisciplineEmployeeController extends Controller {
|
||||||
public async deleteDiscipline(@Path() disciplineId: string, @Request() req: RequestWithUser) {
|
public async deleteDiscipline(@Path() disciplineId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.disciplineRepository.findOneBy({ id: disciplineId });
|
const _record = await this.disciplineRepository.findOneBy({ id: disciplineId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
|
await new permission().PermissionOrgUserDelete(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
_record.profileEmployeeId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
await this.disciplineHistoryRepository.delete({
|
await this.disciplineHistoryRepository.delete({
|
||||||
profileDisciplineId: disciplineId,
|
profileDisciplineId: disciplineId,
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
Example,
|
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
Path,
|
Path,
|
||||||
|
|
@ -41,52 +40,17 @@ export class ProfileDisciplineEmployeeTempController extends Controller {
|
||||||
}
|
}
|
||||||
const lists = await this.disciplineRepository.find({
|
const lists = await this.disciplineRepository.find({
|
||||||
where: { profileEmployeeId: profile.id },
|
where: { profileEmployeeId: profile.id },
|
||||||
select: [
|
order: { createdAt: "ASC" },
|
||||||
"id",
|
|
||||||
"date",
|
|
||||||
"level",
|
|
||||||
"detail",
|
|
||||||
"unStigma",
|
|
||||||
"refCommandNo",
|
|
||||||
"refCommandDate",
|
|
||||||
"lastUpdateFullName",
|
|
||||||
"lastUpdatedAt",
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileId}")
|
@Get("{profileId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
|
||||||
date: "2024-03-12T10:09:47.000Z",
|
|
||||||
level: "string",
|
|
||||||
detail: "string",
|
|
||||||
unStigma: "string",
|
|
||||||
refCommandNo: "string",
|
|
||||||
refCommandDate: "2024-03-12T10:09:47.000Z",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async getDiscipline(@Path() profileId: string, @Request() req: RequestWithUser) {
|
public async getDiscipline(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||||
const lists = await this.disciplineRepository.find({
|
const lists = await this.disciplineRepository.find({
|
||||||
where: { profileEmployeeId: profileId },
|
where: { profileEmployeeId: profileId },
|
||||||
select: [
|
order: { createdAt: "ASC" },
|
||||||
"id",
|
|
||||||
"date",
|
|
||||||
"level",
|
|
||||||
"detail",
|
|
||||||
"unStigma",
|
|
||||||
"refCommandNo",
|
|
||||||
"refCommandDate",
|
|
||||||
"lastUpdateFullName",
|
|
||||||
"lastUpdatedAt",
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
@ -96,17 +60,7 @@ export class ProfileDisciplineEmployeeTempController extends Controller {
|
||||||
await new permission().PermissionGet(req, "SYS_WAGE");
|
await new permission().PermissionGet(req, "SYS_WAGE");
|
||||||
const lists = await this.disciplineRepository.find({
|
const lists = await this.disciplineRepository.find({
|
||||||
where: { profileEmployeeId: profileId },
|
where: { profileEmployeeId: profileId },
|
||||||
select: [
|
order: { createdAt: "ASC" },
|
||||||
"id",
|
|
||||||
"date",
|
|
||||||
"level",
|
|
||||||
"detail",
|
|
||||||
"unStigma",
|
|
||||||
"refCommandNo",
|
|
||||||
"refCommandDate",
|
|
||||||
"lastUpdateFullName",
|
|
||||||
"lastUpdatedAt",
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
@ -116,17 +70,6 @@ export class ProfileDisciplineEmployeeTempController extends Controller {
|
||||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||||
const record = await this.disciplineHistoryRepository.find({
|
const record = await this.disciplineHistoryRepository.find({
|
||||||
where: { profileDisciplineId: disciplineId },
|
where: { profileDisciplineId: disciplineId },
|
||||||
select: [
|
|
||||||
"id",
|
|
||||||
"date",
|
|
||||||
"level",
|
|
||||||
"detail",
|
|
||||||
"unStigma",
|
|
||||||
"refCommandNo",
|
|
||||||
"refCommandDate",
|
|
||||||
"lastUpdateFullName",
|
|
||||||
"lastUpdatedAt",
|
|
||||||
],
|
|
||||||
order: { createdAt: "DESC" },
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
|
|
@ -155,6 +98,8 @@ export class ProfileDisciplineEmployeeTempController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -182,15 +127,18 @@ export class ProfileDisciplineEmployeeTempController extends Controller {
|
||||||
const history = new ProfileDisciplineHistory();
|
const history = new ProfileDisciplineHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileDisciplineId = disciplineId;
|
history.profileDisciplineId = disciplineId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.disciplineRepository.save(record),
|
this.disciplineRepository.save(record),
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
Example,
|
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
Path,
|
Path,
|
||||||
|
|
@ -37,77 +36,22 @@ export class ProfileDutyController extends Controller {
|
||||||
}
|
}
|
||||||
const lists = await this.dutyRepository.find({
|
const lists = await this.dutyRepository.find({
|
||||||
where: { profileId: profile.id },
|
where: { profileId: profile.id },
|
||||||
select: [
|
order: { createdAt: "ASC" },
|
||||||
"id",
|
|
||||||
"dateStart",
|
|
||||||
"dateEnd",
|
|
||||||
"reference",
|
|
||||||
"detail",
|
|
||||||
"refCommandNo",
|
|
||||||
"refCommandDate",
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileId}")
|
@Get("{profileId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
|
||||||
dateStart: "2024-03-12T10:09:47.000Z",
|
|
||||||
dateEnd: "string",
|
|
||||||
reference: "string",
|
|
||||||
detail: "string",
|
|
||||||
refCommandNo: "string",
|
|
||||||
refCommandDate: "2024-03-12T10:09:47.000Z",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async getDuty(@Path() profileId: string, @Request() req: RequestWithUser) {
|
public async getDuty(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||||
const lists = await this.dutyRepository.find({
|
const lists = await this.dutyRepository.find({
|
||||||
where: { profileId: profileId },
|
where: { profileId: profileId },
|
||||||
select: [
|
order: { createdAt: "ASC" },
|
||||||
"id",
|
|
||||||
"dateStart",
|
|
||||||
"dateEnd",
|
|
||||||
"reference",
|
|
||||||
"detail",
|
|
||||||
"refCommandNo",
|
|
||||||
"refCommandDate",
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{dutyId}")
|
@Get("history/{dutyId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
|
||||||
dateStart: "2024-03-12T10:09:47.000Z",
|
|
||||||
dateEnd: "string",
|
|
||||||
reference: "string",
|
|
||||||
detail: "string",
|
|
||||||
refCommandNo: "string",
|
|
||||||
refCommandDate: "2024-03-12T10:09:47.000Z",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
|
||||||
dateStart: "2024-03-12T10:09:47.000Z",
|
|
||||||
dateEnd: "string",
|
|
||||||
reference: "string",
|
|
||||||
detail: "string",
|
|
||||||
refCommandNo: "string",
|
|
||||||
refCommandDate: "2024-03-12T10:09:47.000Z",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async dutyHistory(@Path() dutyId: string, @Request() req: RequestWithUser) {
|
public async dutyHistory(@Path() dutyId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.dutyRepository.findOneBy({ id: dutyId });
|
const _record = await this.dutyRepository.findOneBy({ id: dutyId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
|
|
@ -115,17 +59,6 @@ export class ProfileDutyController extends Controller {
|
||||||
}
|
}
|
||||||
const record = await this.dutyHistoryRepository.find({
|
const record = await this.dutyHistoryRepository.find({
|
||||||
where: { profileDutyId: dutyId },
|
where: { profileDutyId: dutyId },
|
||||||
select: [
|
|
||||||
"id",
|
|
||||||
"dateStart",
|
|
||||||
"dateEnd",
|
|
||||||
"reference",
|
|
||||||
"detail",
|
|
||||||
"refCommandNo",
|
|
||||||
"refCommandDate",
|
|
||||||
"lastUpdateFullName",
|
|
||||||
"lastUpdatedAt",
|
|
||||||
],
|
|
||||||
order: { createdAt: "DESC" },
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
|
|
@ -150,6 +83,8 @@ export class ProfileDutyController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -176,15 +111,18 @@ export class ProfileDutyController extends Controller {
|
||||||
const history = new ProfileDutyHistory();
|
const history = new ProfileDutyHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileDutyId = dutyId;
|
history.profileDutyId = dutyId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([this.dutyRepository.save(record), this.dutyHistoryRepository.save(history)]);
|
await Promise.all([this.dutyRepository.save(record), this.dutyHistoryRepository.save(history)]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
Example,
|
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
Path,
|
Path,
|
||||||
|
|
@ -37,15 +36,7 @@ export class ProfileDutyEmployeeController extends Controller {
|
||||||
}
|
}
|
||||||
const lists = await this.dutyRepository.find({
|
const lists = await this.dutyRepository.find({
|
||||||
where: { profileEmployeeId: profile.id },
|
where: { profileEmployeeId: profile.id },
|
||||||
select: [
|
order: { createdAt: "ASC" },
|
||||||
"id",
|
|
||||||
"dateStart",
|
|
||||||
"dateEnd",
|
|
||||||
"reference",
|
|
||||||
"detail",
|
|
||||||
"refCommandNo",
|
|
||||||
"refCommandDate",
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
@ -55,15 +46,7 @@ export class ProfileDutyEmployeeController extends Controller {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId);
|
||||||
const lists = await this.dutyRepository.find({
|
const lists = await this.dutyRepository.find({
|
||||||
where: { profileEmployeeId: profileId },
|
where: { profileEmployeeId: profileId },
|
||||||
select: [
|
order: { createdAt: "ASC" },
|
||||||
"id",
|
|
||||||
"dateStart",
|
|
||||||
"dateEnd",
|
|
||||||
"reference",
|
|
||||||
"detail",
|
|
||||||
"refCommandNo",
|
|
||||||
"refCommandDate",
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
@ -72,21 +55,14 @@ export class ProfileDutyEmployeeController extends Controller {
|
||||||
public async dutyHistory(@Path() dutyId: string, @Request() req: RequestWithUser) {
|
public async dutyHistory(@Path() dutyId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.dutyRepository.findOneBy({ id: dutyId });
|
const _record = await this.dutyRepository.findOneBy({ id: dutyId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
|
await new permission().PermissionOrgUserGet(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
_record.profileEmployeeId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
const record = await this.dutyHistoryRepository.find({
|
const record = await this.dutyHistoryRepository.find({
|
||||||
where: { profileDutyId: dutyId },
|
where: { profileDutyId: dutyId },
|
||||||
select: [
|
|
||||||
"id",
|
|
||||||
"dateStart",
|
|
||||||
"dateEnd",
|
|
||||||
"reference",
|
|
||||||
"detail",
|
|
||||||
"refCommandNo",
|
|
||||||
"refCommandDate",
|
|
||||||
"lastUpdateFullName",
|
|
||||||
"lastUpdatedAt",
|
|
||||||
],
|
|
||||||
order: { createdAt: "DESC" },
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
|
|
@ -111,6 +87,8 @@ export class ProfileDutyEmployeeController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -132,20 +110,27 @@ export class ProfileDutyEmployeeController extends Controller {
|
||||||
) {
|
) {
|
||||||
const record = await this.dutyRepository.findOneBy({ id: dutyId });
|
const record = await this.dutyRepository.findOneBy({ id: dutyId });
|
||||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId)
|
await new permission().PermissionOrgUserUpdate(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
record.profileEmployeeId,
|
||||||
|
);
|
||||||
|
|
||||||
const history = new ProfileDutyHistory();
|
const history = new ProfileDutyHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileDutyId = dutyId;
|
history.profileDutyId = dutyId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([this.dutyRepository.save(record), this.dutyHistoryRepository.save(history)]);
|
await Promise.all([this.dutyRepository.save(record), this.dutyHistoryRepository.save(history)]);
|
||||||
|
|
||||||
|
|
@ -156,7 +141,11 @@ export class ProfileDutyEmployeeController extends Controller {
|
||||||
public async deleteDuty(@Path() dutyId: string, @Request() req: RequestWithUser) {
|
public async deleteDuty(@Path() dutyId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.dutyRepository.findOneBy({ id: dutyId });
|
const _record = await this.dutyRepository.findOneBy({ id: dutyId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
|
await new permission().PermissionOrgUserDelete(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
_record.profileEmployeeId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
await this.dutyHistoryRepository.delete({
|
await this.dutyHistoryRepository.delete({
|
||||||
profileDutyId: dutyId,
|
profileDutyId: dutyId,
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
Example,
|
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
Path,
|
Path,
|
||||||
|
|
@ -37,15 +36,7 @@ export class ProfileDutyEmployeeTempController extends Controller {
|
||||||
}
|
}
|
||||||
const lists = await this.dutyRepository.find({
|
const lists = await this.dutyRepository.find({
|
||||||
where: { profileEmployeeId: profile.id },
|
where: { profileEmployeeId: profile.id },
|
||||||
select: [
|
order: { createdAt: "ASC" },
|
||||||
"id",
|
|
||||||
"dateStart",
|
|
||||||
"dateEnd",
|
|
||||||
"reference",
|
|
||||||
"detail",
|
|
||||||
"refCommandNo",
|
|
||||||
"refCommandDate",
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
@ -55,15 +46,7 @@ export class ProfileDutyEmployeeTempController extends Controller {
|
||||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||||
const lists = await this.dutyRepository.find({
|
const lists = await this.dutyRepository.find({
|
||||||
where: { profileEmployeeId: profileId },
|
where: { profileEmployeeId: profileId },
|
||||||
select: [
|
order: { createdAt: "ASC" },
|
||||||
"id",
|
|
||||||
"dateStart",
|
|
||||||
"dateEnd",
|
|
||||||
"reference",
|
|
||||||
"detail",
|
|
||||||
"refCommandNo",
|
|
||||||
"refCommandDate",
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
@ -73,17 +56,6 @@ export class ProfileDutyEmployeeTempController extends Controller {
|
||||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||||
const record = await this.dutyHistoryRepository.find({
|
const record = await this.dutyHistoryRepository.find({
|
||||||
where: { profileDutyId: dutyId },
|
where: { profileDutyId: dutyId },
|
||||||
select: [
|
|
||||||
"id",
|
|
||||||
"dateStart",
|
|
||||||
"dateEnd",
|
|
||||||
"reference",
|
|
||||||
"detail",
|
|
||||||
"refCommandNo",
|
|
||||||
"refCommandDate",
|
|
||||||
"lastUpdateFullName",
|
|
||||||
"lastUpdatedAt",
|
|
||||||
],
|
|
||||||
order: { createdAt: "DESC" },
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
|
|
@ -109,6 +81,8 @@ export class ProfileDutyEmployeeTempController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -136,15 +110,18 @@ export class ProfileDutyEmployeeTempController extends Controller {
|
||||||
const history = new ProfileDutyHistory();
|
const history = new ProfileDutyHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileDutyId = dutyId;
|
history.profileDutyId = dutyId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([this.dutyRepository.save(record), this.dutyHistoryRepository.save(history)]);
|
await Promise.all([this.dutyRepository.save(record), this.dutyHistoryRepository.save(history)]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ import { AppDataSource } from "../database/data-source";
|
||||||
import { Profile } from "../entities/Profile";
|
import { Profile } from "../entities/Profile";
|
||||||
import { CreateProfileEdit, EditProfileEdit, ProfileEdit } from "../entities/ProfileEdit";
|
import { CreateProfileEdit, EditProfileEdit, ProfileEdit } from "../entities/ProfileEdit";
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
import { RequestWithUser } from "../middlewares/user";
|
||||||
import { IsNull, Not, Brackets } from "typeorm";
|
import { Brackets } from "typeorm";
|
||||||
|
|
||||||
@Route("api/v1/org/profile/edit")
|
@Route("api/v1/org/profile/edit")
|
||||||
@Tags("ProfileEdit")
|
@Tags("ProfileEdit")
|
||||||
|
|
@ -52,22 +52,14 @@ export class ProfileEditController extends Controller {
|
||||||
})
|
})
|
||||||
.andWhere(
|
.andWhere(
|
||||||
new Brackets((qb) => {
|
new Brackets((qb) => {
|
||||||
qb.where(
|
qb.where(keyword != "" && keyword != null ? "ProfileEdit.topic LIKE :keyword" : "1=1", {
|
||||||
keyword != "" && keyword != null
|
keyword: `%${keyword}%`,
|
||||||
? "ProfileEdit.topic LIKE :keyword"
|
}).orWhere(
|
||||||
: "1=1",
|
keyword != "" && keyword != null ? "ProfileEdit.detail LIKE :keyword" : "1=1",
|
||||||
{
|
{
|
||||||
keyword: `%${keyword}%`,
|
keyword: `%${keyword}%`,
|
||||||
},
|
},
|
||||||
)
|
);
|
||||||
.orWhere(
|
|
||||||
keyword != "" && keyword != null
|
|
||||||
? "ProfileEdit.detail LIKE :keyword"
|
|
||||||
: "1=1",
|
|
||||||
{
|
|
||||||
keyword: `%${keyword}%`,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.orderBy("ProfileEdit.createdAt", "ASC")
|
.orderBy("ProfileEdit.createdAt", "ASC")
|
||||||
|
|
@ -114,22 +106,14 @@ export class ProfileEditController extends Controller {
|
||||||
})
|
})
|
||||||
.andWhere(
|
.andWhere(
|
||||||
new Brackets((qb) => {
|
new Brackets((qb) => {
|
||||||
qb.where(
|
qb.where(keyword != "" && keyword != null ? "ProfileEdit.topic LIKE :keyword" : "1=1", {
|
||||||
keyword != "" && keyword != null
|
keyword: `%${keyword}%`,
|
||||||
? "ProfileEdit.topic LIKE :keyword"
|
}).orWhere(
|
||||||
: "1=1",
|
keyword != "" && keyword != null ? "ProfileEdit.detail LIKE :keyword" : "1=1",
|
||||||
{
|
{
|
||||||
keyword: `%${keyword}%`,
|
keyword: `%${keyword}%`,
|
||||||
},
|
},
|
||||||
)
|
);
|
||||||
.orWhere(
|
|
||||||
keyword != "" && keyword != null
|
|
||||||
? "ProfileEdit.detail LIKE :keyword"
|
|
||||||
: "1=1",
|
|
||||||
{
|
|
||||||
keyword: `%${keyword}%`,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.orderBy("ProfileEdit.createdAt", "ASC")
|
.orderBy("ProfileEdit.createdAt", "ASC")
|
||||||
|
|
@ -209,6 +193,8 @@ export class ProfileEditController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -226,7 +212,7 @@ export class ProfileEditController extends Controller {
|
||||||
) {
|
) {
|
||||||
// const record = await this.profileEditRepo.findOneBy({ id: editId });
|
// const record = await this.profileEditRepo.findOneBy({ id: editId });
|
||||||
const record = await this.profileEditRepo.findOne({
|
const record = await this.profileEditRepo.findOne({
|
||||||
where: { id: editId }
|
where: { id: editId },
|
||||||
});
|
});
|
||||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ import {
|
||||||
} from "../entities/ProfileEdit";
|
} from "../entities/ProfileEdit";
|
||||||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
import { RequestWithUser } from "../middlewares/user";
|
||||||
import { IsNull, Not, Brackets } from "typeorm";
|
import { Brackets } from "typeorm";
|
||||||
|
|
||||||
@Route("api/v1/org/profile-employee/edit")
|
@Route("api/v1/org/profile-employee/edit")
|
||||||
@Tags("ProfileEmployeeEdit")
|
@Tags("ProfileEmployeeEdit")
|
||||||
|
|
@ -203,6 +203,8 @@ export class ProfileEditEmployeeController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
data.status = "PENDING";
|
data.status = "PENDING";
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import {
|
import {
|
||||||
Controller,
|
Controller,
|
||||||
Post,
|
Post,
|
||||||
Put,
|
|
||||||
Delete,
|
Delete,
|
||||||
Route,
|
Route,
|
||||||
Security,
|
Security,
|
||||||
|
|
@ -9,12 +8,8 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Path,
|
Path,
|
||||||
Request,
|
Request,
|
||||||
SuccessResponse,
|
|
||||||
Response,
|
|
||||||
Get,
|
Get,
|
||||||
Query,
|
|
||||||
Patch,
|
Patch,
|
||||||
Example,
|
|
||||||
} from "tsoa";
|
} from "tsoa";
|
||||||
|
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
import HttpSuccess from "../interfaces/http-success";
|
||||||
|
|
@ -47,6 +42,7 @@ export class ProfileEducationsController extends Controller {
|
||||||
}
|
}
|
||||||
const getProfileEducation = await this.profileEducationRepo.find({
|
const getProfileEducation = await this.profileEducationRepo.find({
|
||||||
where: { profileId: profile.id },
|
where: { profileId: profile.id },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
if (!getProfileEducation) {
|
if (!getProfileEducation) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
@ -55,45 +51,12 @@ export class ProfileEducationsController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileId}")
|
@Get("{profileId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "f6c693b4-1a9b-4fbe-95c5-ed4da50d35b6",
|
|
||||||
createdAt: "2024-03-12T20:26:42.621Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-12T20:33:09.000Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "test bar",
|
|
||||||
lastUpdateFullName: "test bar",
|
|
||||||
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
isActive: true,
|
|
||||||
country: "string",
|
|
||||||
degree: "ปวส",
|
|
||||||
duration: "-",
|
|
||||||
durationYear: 0,
|
|
||||||
field: "ชางเทคนิค ชั้นสูง",
|
|
||||||
finishDate: "2024-03-13T03:23:31.000Z",
|
|
||||||
fundName: "-",
|
|
||||||
gpa: "3.64",
|
|
||||||
institute: "เทคโนเชียงใหม่",
|
|
||||||
other: "string",
|
|
||||||
startDate: "2024-03-13T03:23:31.000Z",
|
|
||||||
endDate: "2024-03-13T03:23:31.000Z",
|
|
||||||
educationLevel: "ปวส",
|
|
||||||
educationLevelId: "string",
|
|
||||||
positionPath: "string",
|
|
||||||
positionPathId: "string",
|
|
||||||
note: "string",
|
|
||||||
isDate: true,
|
|
||||||
isEducation: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async detailProfileEducation(@Path() profileId: string, @Request() req: RequestWithUser) {
|
public async detailProfileEducation(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||||
const getProfileEducation = await this.profileEducationRepo.findBy({ profileId });
|
const getProfileEducation = await this.profileEducationRepo.find({
|
||||||
|
where: { profileId: profileId },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
|
});
|
||||||
if (!getProfileEducation) {
|
if (!getProfileEducation) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
}
|
}
|
||||||
|
|
@ -101,79 +64,19 @@ export class ProfileEducationsController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{educationId}")
|
@Get("history/{educationId}")
|
||||||
@Example({
|
public async getProfileEducationHistory(
|
||||||
status: 200,
|
@Path() educationId: string,
|
||||||
message: "สำเร็จ",
|
@Request() req: RequestWithUser,
|
||||||
result: [
|
) {
|
||||||
{
|
|
||||||
id: "294aa117-6ce7-4c23-b5bd-fe1f12932c4a",
|
|
||||||
createdAt: "2024-03-12T20:29:45.251Z",
|
|
||||||
createdUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
lastUpdatedAt: "2024-03-12T20:29:45.251Z",
|
|
||||||
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
createdFullName: "string",
|
|
||||||
lastUpdateFullName: "test bar",
|
|
||||||
isActive: true,
|
|
||||||
country: "string",
|
|
||||||
degree: "ปวส",
|
|
||||||
duration: "-",
|
|
||||||
durationYear: 0,
|
|
||||||
field: "ชางเทคนิค",
|
|
||||||
finishDate: "2024-03-13T03:23:31.000Z",
|
|
||||||
fundName: "-",
|
|
||||||
gpa: "3.64",
|
|
||||||
institute: "เทคโนเชียงใหม่",
|
|
||||||
other: "string",
|
|
||||||
startDate: "2024-03-13T03:23:31.000Z",
|
|
||||||
endDate: "2024-03-13T03:23:31.000Z",
|
|
||||||
educationLevel: "ปวส",
|
|
||||||
educationLevelId: "string",
|
|
||||||
positionPath: "string",
|
|
||||||
positionPathId: "string",
|
|
||||||
note: "string",
|
|
||||||
isDate: true,
|
|
||||||
isEducation: true,
|
|
||||||
profileEducationId: "f6c693b4-1a9b-4fbe-95c5-ed4da50d35b6",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "2f00bd59-be3e-46d8-92a2-c4700baabf12",
|
|
||||||
createdAt: "2024-03-12T20:33:09.128Z",
|
|
||||||
createdUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
lastUpdatedAt: "2024-03-12T20:33:09.128Z",
|
|
||||||
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
createdFullName: "string",
|
|
||||||
lastUpdateFullName: "test bar",
|
|
||||||
isActive: true,
|
|
||||||
country: "string",
|
|
||||||
degree: "ปวส",
|
|
||||||
duration: "-",
|
|
||||||
durationYear: 0,
|
|
||||||
field: "ชางเทคนิค ชั้นสูง",
|
|
||||||
finishDate: "2024-03-13T03:23:31.000Z",
|
|
||||||
fundName: "-",
|
|
||||||
gpa: "3.64",
|
|
||||||
institute: "เทคโนเชียงใหม่",
|
|
||||||
other: "string",
|
|
||||||
startDate: "2024-03-13T03:23:31.000Z",
|
|
||||||
endDate: "2024-03-13T03:23:31.000Z",
|
|
||||||
educationLevel: "ปวส",
|
|
||||||
educationLevelId: "string",
|
|
||||||
positionPath: "string",
|
|
||||||
positionPathId: "string",
|
|
||||||
note: "string",
|
|
||||||
isDate: true,
|
|
||||||
isEducation: true,
|
|
||||||
profileEducationId: "f6c693b4-1a9b-4fbe-95c5-ed4da50d35b6",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async getProfileEducationHistory(@Path() educationId: string, @Request() req: RequestWithUser) {
|
|
||||||
// const _record = await this.profileEducationRepo.findOneBy({ id: educationId });
|
// const _record = await this.profileEducationRepo.findOneBy({ id: educationId });
|
||||||
// if (_record) {
|
// if (_record) {
|
||||||
// await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
// await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
||||||
// }
|
// }
|
||||||
const record = await this.profileEducationHistoryRepo.findBy({
|
const record = await this.profileEducationHistoryRepo.find({
|
||||||
|
where: {
|
||||||
profileEducationId: educationId,
|
profileEducationId: educationId,
|
||||||
|
},
|
||||||
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
if (!record) {
|
if (!record) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
@ -202,6 +105,8 @@ export class ProfileEducationsController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -228,15 +133,18 @@ export class ProfileEducationsController extends Controller {
|
||||||
const history = new ProfileEducationHistory();
|
const history = new ProfileEducationHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileEducationId = educationId;
|
history.profileEducationId = educationId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.profileEducationRepo.save(record),
|
this.profileEducationRepo.save(record),
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import {
|
import {
|
||||||
Controller,
|
Controller,
|
||||||
Post,
|
Post,
|
||||||
Put,
|
|
||||||
Delete,
|
Delete,
|
||||||
Route,
|
Route,
|
||||||
Security,
|
Security,
|
||||||
|
|
@ -9,24 +8,18 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Path,
|
Path,
|
||||||
Request,
|
Request,
|
||||||
SuccessResponse,
|
|
||||||
Response,
|
|
||||||
Get,
|
Get,
|
||||||
Query,
|
|
||||||
Patch,
|
Patch,
|
||||||
Example,
|
|
||||||
} from "tsoa";
|
} from "tsoa";
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
import HttpSuccess from "../interfaces/http-success";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
import HttpStatus from "../interfaces/http-status";
|
import HttpStatus from "../interfaces/http-status";
|
||||||
import {
|
import {
|
||||||
ProfileEducation,
|
ProfileEducation,
|
||||||
CreateProfileEducation,
|
|
||||||
UpdateProfileEducation,
|
UpdateProfileEducation,
|
||||||
CreateProfileEducationEmployee,
|
CreateProfileEducationEmployee,
|
||||||
} from "../entities/ProfileEducation";
|
} from "../entities/ProfileEducation";
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
import { RequestWithUser } from "../middlewares/user";
|
||||||
import { Profile } from "../entities/Profile";
|
|
||||||
import { ProfileEducationHistory } from "../entities/ProfileEducationHistory";
|
import { ProfileEducationHistory } from "../entities/ProfileEducationHistory";
|
||||||
import { AppDataSource } from "../database/data-source";
|
import { AppDataSource } from "../database/data-source";
|
||||||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||||
|
|
@ -47,6 +40,7 @@ export class ProfileEducationsEmployeeController extends Controller {
|
||||||
}
|
}
|
||||||
const getProfileEducation = await this.profileEducationRepo.find({
|
const getProfileEducation = await this.profileEducationRepo.find({
|
||||||
where: { profileEmployeeId: profile.id },
|
where: { profileEmployeeId: profile.id },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
if (!getProfileEducation) {
|
if (!getProfileEducation) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
@ -55,46 +49,14 @@ export class ProfileEducationsEmployeeController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileEmployeeId}")
|
@Get("{profileEmployeeId}")
|
||||||
@Example({
|
public async detailProfileEducation(
|
||||||
status: 200,
|
@Path() profileEmployeeId: string,
|
||||||
message: "สำเร็จ",
|
@Request() req: RequestWithUser,
|
||||||
result: [
|
) {
|
||||||
{
|
|
||||||
id: "f6c693b4-1a9b-4fbe-95c5-ed4da50d35b6",
|
|
||||||
createdAt: "2024-03-12T20:26:42.621Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-12T20:33:09.000Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "test bar",
|
|
||||||
lastUpdateFullName: "test bar",
|
|
||||||
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
isActive: true,
|
|
||||||
country: "string",
|
|
||||||
degree: "ปวส",
|
|
||||||
duration: "-",
|
|
||||||
durationYear: 0,
|
|
||||||
field: "ชางเทคนิค ชั้นสูง",
|
|
||||||
finishDate: "2024-03-13T03:23:31.000Z",
|
|
||||||
fundName: "-",
|
|
||||||
gpa: "3.64",
|
|
||||||
institute: "เทคโนเชียงใหม่",
|
|
||||||
other: "string",
|
|
||||||
startDate: "2024-03-13T03:23:31.000Z",
|
|
||||||
endDate: "2024-03-13T03:23:31.000Z",
|
|
||||||
educationLevel: "ปวส",
|
|
||||||
educationLevelId: "string",
|
|
||||||
positionPath: "string",
|
|
||||||
positionPathId: "string",
|
|
||||||
note: "string",
|
|
||||||
isDate: true,
|
|
||||||
isEducation: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async detailProfileEducation(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
||||||
const getProfileEducation = await this.profileEducationRepo.find({
|
const getProfileEducation = await this.profileEducationRepo.find({
|
||||||
where: { profileEmployeeId: profileEmployeeId },
|
where: { profileEmployeeId: profileEmployeeId },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
if (!getProfileEducation) {
|
if (!getProfileEducation) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
@ -103,80 +65,24 @@ export class ProfileEducationsEmployeeController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{educationId}")
|
@Get("history/{educationId}")
|
||||||
@Example({
|
public async getProfileEducationHistory(
|
||||||
status: 200,
|
@Path() educationId: string,
|
||||||
message: "สำเร็จ",
|
@Request() req: RequestWithUser,
|
||||||
result: [
|
) {
|
||||||
{
|
|
||||||
id: "294aa117-6ce7-4c23-b5bd-fe1f12932c4a",
|
|
||||||
createdAt: "2024-03-12T20:29:45.251Z",
|
|
||||||
createdUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
lastUpdatedAt: "2024-03-12T20:29:45.251Z",
|
|
||||||
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
createdFullName: "string",
|
|
||||||
lastUpdateFullName: "test bar",
|
|
||||||
isActive: true,
|
|
||||||
country: "string",
|
|
||||||
degree: "ปวส",
|
|
||||||
duration: "-",
|
|
||||||
durationYear: 0,
|
|
||||||
field: "ชางเทคนิค",
|
|
||||||
finishDate: "2024-03-13T03:23:31.000Z",
|
|
||||||
fundName: "-",
|
|
||||||
gpa: "3.64",
|
|
||||||
institute: "เทคโนเชียงใหม่",
|
|
||||||
other: "string",
|
|
||||||
startDate: "2024-03-13T03:23:31.000Z",
|
|
||||||
endDate: "2024-03-13T03:23:31.000Z",
|
|
||||||
educationLevel: "ปวส",
|
|
||||||
educationLevelId: "string",
|
|
||||||
positionPath: "string",
|
|
||||||
positionPathId: "string",
|
|
||||||
note: "string",
|
|
||||||
isDate: true,
|
|
||||||
isEducation: true,
|
|
||||||
profileEducationId: "f6c693b4-1a9b-4fbe-95c5-ed4da50d35b6",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "2f00bd59-be3e-46d8-92a2-c4700baabf12",
|
|
||||||
createdAt: "2024-03-12T20:33:09.128Z",
|
|
||||||
createdUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
lastUpdatedAt: "2024-03-12T20:33:09.128Z",
|
|
||||||
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
createdFullName: "string",
|
|
||||||
lastUpdateFullName: "test bar",
|
|
||||||
isActive: true,
|
|
||||||
country: "string",
|
|
||||||
degree: "ปวส",
|
|
||||||
duration: "-",
|
|
||||||
durationYear: 0,
|
|
||||||
field: "ชางเทคนิค ชั้นสูง",
|
|
||||||
finishDate: "2024-03-13T03:23:31.000Z",
|
|
||||||
fundName: "-",
|
|
||||||
gpa: "3.64",
|
|
||||||
institute: "เทคโนเชียงใหม่",
|
|
||||||
other: "string",
|
|
||||||
startDate: "2024-03-13T03:23:31.000Z",
|
|
||||||
endDate: "2024-03-13T03:23:31.000Z",
|
|
||||||
educationLevel: "ปวส",
|
|
||||||
educationLevelId: "string",
|
|
||||||
positionPath: "string",
|
|
||||||
positionPathId: "string",
|
|
||||||
note: "string",
|
|
||||||
isDate: true,
|
|
||||||
isEducation: true,
|
|
||||||
profileEducationId: "f6c693b4-1a9b-4fbe-95c5-ed4da50d35b6",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async getProfileEducationHistory(@Path() educationId: string, @Request() req: RequestWithUser) {
|
|
||||||
const _record = await this.profileEducationRepo.findOneBy({ id: educationId });
|
const _record = await this.profileEducationRepo.findOneBy({ id: educationId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
|
await new permission().PermissionOrgUserGet(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
_record.profileEmployeeId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const record = await this.profileEducationHistoryRepo.findBy({
|
const record = await this.profileEducationHistoryRepo.find({
|
||||||
|
where: {
|
||||||
profileEducationId: educationId,
|
profileEducationId: educationId,
|
||||||
|
},
|
||||||
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
if (!record) {
|
if (!record) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
@ -205,6 +111,8 @@ export class ProfileEducationsEmployeeController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -226,20 +134,27 @@ export class ProfileEducationsEmployeeController extends Controller {
|
||||||
) {
|
) {
|
||||||
const record = await this.profileEducationRepo.findOneBy({ id: educationId });
|
const record = await this.profileEducationRepo.findOneBy({ id: educationId });
|
||||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId);
|
await new permission().PermissionOrgUserUpdate(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
record.profileEmployeeId,
|
||||||
|
);
|
||||||
|
|
||||||
const history = new ProfileEducationHistory();
|
const history = new ProfileEducationHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileEducationId = educationId;
|
history.profileEducationId = educationId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.profileEducationRepo.save(record),
|
this.profileEducationRepo.save(record),
|
||||||
|
|
@ -256,7 +171,11 @@ export class ProfileEducationsEmployeeController extends Controller {
|
||||||
) {
|
) {
|
||||||
const _record = await this.profileEducationRepo.findOneBy({ id: educationId });
|
const _record = await this.profileEducationRepo.findOneBy({ id: educationId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
|
await new permission().PermissionOrgUserDelete(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
_record.profileEmployeeId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.profileEducationHistoryRepo.delete({
|
await this.profileEducationHistoryRepo.delete({
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import {
|
import {
|
||||||
Controller,
|
Controller,
|
||||||
Post,
|
Post,
|
||||||
Put,
|
|
||||||
Delete,
|
Delete,
|
||||||
Route,
|
Route,
|
||||||
Security,
|
Security,
|
||||||
|
|
@ -9,24 +8,18 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Path,
|
Path,
|
||||||
Request,
|
Request,
|
||||||
SuccessResponse,
|
|
||||||
Response,
|
|
||||||
Get,
|
Get,
|
||||||
Query,
|
|
||||||
Patch,
|
Patch,
|
||||||
Example,
|
|
||||||
} from "tsoa";
|
} from "tsoa";
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
import HttpSuccess from "../interfaces/http-success";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
import HttpStatus from "../interfaces/http-status";
|
import HttpStatus from "../interfaces/http-status";
|
||||||
import {
|
import {
|
||||||
ProfileEducation,
|
ProfileEducation,
|
||||||
CreateProfileEducation,
|
|
||||||
UpdateProfileEducation,
|
UpdateProfileEducation,
|
||||||
CreateProfileEducationEmployee,
|
CreateProfileEducationEmployee,
|
||||||
} from "../entities/ProfileEducation";
|
} from "../entities/ProfileEducation";
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
import { RequestWithUser } from "../middlewares/user";
|
||||||
import { Profile } from "../entities/Profile";
|
|
||||||
import { ProfileEducationHistory } from "../entities/ProfileEducationHistory";
|
import { ProfileEducationHistory } from "../entities/ProfileEducationHistory";
|
||||||
import { AppDataSource } from "../database/data-source";
|
import { AppDataSource } from "../database/data-source";
|
||||||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||||
|
|
@ -47,6 +40,7 @@ export class ProfileEducationsEmployeeTempController extends Controller {
|
||||||
}
|
}
|
||||||
const getProfileEducation = await this.profileEducationRepo.find({
|
const getProfileEducation = await this.profileEducationRepo.find({
|
||||||
where: { profileEmployeeId: profile.id },
|
where: { profileEmployeeId: profile.id },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
if (!getProfileEducation) {
|
if (!getProfileEducation) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
@ -55,46 +49,14 @@ export class ProfileEducationsEmployeeTempController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileEmployeeId}")
|
@Get("{profileEmployeeId}")
|
||||||
@Example({
|
public async detailProfileEducation(
|
||||||
status: 200,
|
@Path() profileEmployeeId: string,
|
||||||
message: "สำเร็จ",
|
@Request() req: RequestWithUser,
|
||||||
result: [
|
) {
|
||||||
{
|
|
||||||
id: "f6c693b4-1a9b-4fbe-95c5-ed4da50d35b6",
|
|
||||||
createdAt: "2024-03-12T20:26:42.621Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-12T20:33:09.000Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "test bar",
|
|
||||||
lastUpdateFullName: "test bar",
|
|
||||||
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
isActive: true,
|
|
||||||
country: "string",
|
|
||||||
degree: "ปวส",
|
|
||||||
duration: "-",
|
|
||||||
durationYear: 0,
|
|
||||||
field: "ชางเทคนิค ชั้นสูง",
|
|
||||||
finishDate: "2024-03-13T03:23:31.000Z",
|
|
||||||
fundName: "-",
|
|
||||||
gpa: "3.64",
|
|
||||||
institute: "เทคโนเชียงใหม่",
|
|
||||||
other: "string",
|
|
||||||
startDate: "2024-03-13T03:23:31.000Z",
|
|
||||||
endDate: "2024-03-13T03:23:31.000Z",
|
|
||||||
educationLevel: "ปวส",
|
|
||||||
educationLevelId: "string",
|
|
||||||
positionPath: "string",
|
|
||||||
positionPathId: "string",
|
|
||||||
note: "string",
|
|
||||||
isDate: true,
|
|
||||||
isEducation: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async detailProfileEducation(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
|
||||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||||
const getProfileEducation = await this.profileEducationRepo.find({
|
const getProfileEducation = await this.profileEducationRepo.find({
|
||||||
where: { profileEmployeeId: profileEmployeeId },
|
where: { profileEmployeeId: profileEmployeeId },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
if (!getProfileEducation) {
|
if (!getProfileEducation) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
@ -103,76 +65,16 @@ export class ProfileEducationsEmployeeTempController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{educationId}")
|
@Get("history/{educationId}")
|
||||||
@Example({
|
public async getProfileEducationHistory(
|
||||||
status: 200,
|
@Path() educationId: string,
|
||||||
message: "สำเร็จ",
|
@Request() req: RequestWithUser,
|
||||||
result: [
|
) {
|
||||||
{
|
|
||||||
id: "294aa117-6ce7-4c23-b5bd-fe1f12932c4a",
|
|
||||||
createdAt: "2024-03-12T20:29:45.251Z",
|
|
||||||
createdUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
lastUpdatedAt: "2024-03-12T20:29:45.251Z",
|
|
||||||
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
createdFullName: "string",
|
|
||||||
lastUpdateFullName: "test bar",
|
|
||||||
isActive: true,
|
|
||||||
country: "string",
|
|
||||||
degree: "ปวส",
|
|
||||||
duration: "-",
|
|
||||||
durationYear: 0,
|
|
||||||
field: "ชางเทคนิค",
|
|
||||||
finishDate: "2024-03-13T03:23:31.000Z",
|
|
||||||
fundName: "-",
|
|
||||||
gpa: "3.64",
|
|
||||||
institute: "เทคโนเชียงใหม่",
|
|
||||||
other: "string",
|
|
||||||
startDate: "2024-03-13T03:23:31.000Z",
|
|
||||||
endDate: "2024-03-13T03:23:31.000Z",
|
|
||||||
educationLevel: "ปวส",
|
|
||||||
educationLevelId: "string",
|
|
||||||
positionPath: "string",
|
|
||||||
positionPathId: "string",
|
|
||||||
note: "string",
|
|
||||||
isDate: true,
|
|
||||||
isEducation: true,
|
|
||||||
profileEducationId: "f6c693b4-1a9b-4fbe-95c5-ed4da50d35b6",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "2f00bd59-be3e-46d8-92a2-c4700baabf12",
|
|
||||||
createdAt: "2024-03-12T20:33:09.128Z",
|
|
||||||
createdUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
lastUpdatedAt: "2024-03-12T20:33:09.128Z",
|
|
||||||
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
createdFullName: "string",
|
|
||||||
lastUpdateFullName: "test bar",
|
|
||||||
isActive: true,
|
|
||||||
country: "string",
|
|
||||||
degree: "ปวส",
|
|
||||||
duration: "-",
|
|
||||||
durationYear: 0,
|
|
||||||
field: "ชางเทคนิค ชั้นสูง",
|
|
||||||
finishDate: "2024-03-13T03:23:31.000Z",
|
|
||||||
fundName: "-",
|
|
||||||
gpa: "3.64",
|
|
||||||
institute: "เทคโนเชียงใหม่",
|
|
||||||
other: "string",
|
|
||||||
startDate: "2024-03-13T03:23:31.000Z",
|
|
||||||
endDate: "2024-03-13T03:23:31.000Z",
|
|
||||||
educationLevel: "ปวส",
|
|
||||||
educationLevelId: "string",
|
|
||||||
positionPath: "string",
|
|
||||||
positionPathId: "string",
|
|
||||||
note: "string",
|
|
||||||
isDate: true,
|
|
||||||
isEducation: true,
|
|
||||||
profileEducationId: "f6c693b4-1a9b-4fbe-95c5-ed4da50d35b6",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async getProfileEducationHistory(@Path() educationId: string, @Request() req: RequestWithUser) {
|
|
||||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||||
const record = await this.profileEducationHistoryRepo.findBy({
|
const record = await this.profileEducationHistoryRepo.find({
|
||||||
|
where: {
|
||||||
profileEducationId: educationId,
|
profileEducationId: educationId,
|
||||||
|
},
|
||||||
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
if (!record) {
|
if (!record) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
@ -201,6 +103,8 @@ export class ProfileEducationsEmployeeTempController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -227,15 +131,18 @@ export class ProfileEducationsEmployeeTempController extends Controller {
|
||||||
const history = new ProfileEducationHistory();
|
const history = new ProfileEducationHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileEducationId = educationId;
|
history.profileEducationId = educationId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.profileEducationRepo.save(record),
|
this.profileEducationRepo.save(record),
|
||||||
|
|
|
||||||
|
|
@ -612,6 +612,8 @@ export class ProfileEmployeeController extends Controller {
|
||||||
profile.createdFullName = request.user.name;
|
profile.createdFullName = request.user.name;
|
||||||
profile.lastUpdateUserId = request.user.sub;
|
profile.lastUpdateUserId = request.user.sub;
|
||||||
profile.lastUpdateFullName = request.user.name;
|
profile.lastUpdateFullName = request.user.name;
|
||||||
|
profile.createdAt = new Date();
|
||||||
|
profile.lastUpdatedAt = new Date();
|
||||||
profile.dateRetire = calculateRetireDate(profile.birthDate);
|
profile.dateRetire = calculateRetireDate(profile.birthDate);
|
||||||
profile.dateRetireLaw = calculateRetireLaw(profile.birthDate);
|
profile.dateRetireLaw = calculateRetireLaw(profile.birthDate);
|
||||||
profile.citizenId = Extension.CheckCitizen(profile.citizenId);
|
profile.citizenId = Extension.CheckCitizen(profile.citizenId);
|
||||||
|
|
@ -666,6 +668,9 @@ export class ProfileEmployeeController extends Controller {
|
||||||
await this.profileHistoryRepo.save(
|
await this.profileHistoryRepo.save(
|
||||||
Object.assign(new ProfileEmployeeHistory(), {
|
Object.assign(new ProfileEmployeeHistory(), {
|
||||||
...record,
|
...record,
|
||||||
|
lastUpdateUserId: request.user.sub,
|
||||||
|
lastUpdateFullName: request.user.name,
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
profileEmployeeId: id,
|
profileEmployeeId: id,
|
||||||
id: undefined,
|
id: undefined,
|
||||||
}),
|
}),
|
||||||
|
|
@ -681,6 +686,7 @@ export class ProfileEmployeeController extends Controller {
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
record.lastUpdateUserId = request.user.sub;
|
record.lastUpdateUserId = request.user.sub;
|
||||||
record.lastUpdateFullName = request.user.name;
|
record.lastUpdateFullName = request.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
record.dateRetire = calculateRetireDate(record.birthDate);
|
record.dateRetire = calculateRetireDate(record.birthDate);
|
||||||
record.dateRetireLaw = calculateRetireLaw(record.birthDate);
|
record.dateRetireLaw = calculateRetireLaw(record.birthDate);
|
||||||
record.citizenId = Extension.CheckCitizen(record.citizenId);
|
record.citizenId = Extension.CheckCitizen(record.citizenId);
|
||||||
|
|
@ -1228,6 +1234,12 @@ export class ProfileEmployeeController extends Controller {
|
||||||
.skip((page - 1) * pageSize)
|
.skip((page - 1) * pageSize)
|
||||||
.take(pageSize)
|
.take(pageSize)
|
||||||
.getManyAndCount();
|
.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(
|
const data = await Promise.all(
|
||||||
record.map((_data) => {
|
record.map((_data) => {
|
||||||
const shortName =
|
const shortName =
|
||||||
|
|
@ -1250,6 +1262,45 @@ export class ProfileEmployeeController extends Controller {
|
||||||
: _data.profileEmployeeEmployment.reduce((latest, current) => {
|
: _data.profileEmployeeEmployment.reduce((latest, current) => {
|
||||||
return latest.date > current.date ? latest : current;
|
return latest.date > current.date ? latest : current;
|
||||||
}).date;
|
}).date;
|
||||||
|
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 {
|
return {
|
||||||
id: _data.id,
|
id: _data.id,
|
||||||
prefix: _data.prefix,
|
prefix: _data.prefix,
|
||||||
|
|
@ -1329,6 +1380,7 @@ export class ProfileEmployeeController extends Controller {
|
||||||
child4: _data.child4Temp ? _data.child4Temp : null,
|
child4: _data.child4Temp ? _data.child4Temp : null,
|
||||||
child4Id: _data.child4IdTemp ? _data.child4IdTemp : null,
|
child4Id: _data.child4IdTemp ? _data.child4IdTemp : null,
|
||||||
child4ShortName: _data.child4ShortNameTemp ? _data.child4ShortNameTemp : 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.lastUpdateUserId = request.user.sub;
|
||||||
profileEmp.lastUpdateFullName = request.user.name;
|
profileEmp.lastUpdateFullName = request.user.name;
|
||||||
|
profileEmp.lastUpdatedAt = new Date();
|
||||||
profileEmp.nodeTemp = String(body.node);
|
profileEmp.nodeTemp = String(body.node);
|
||||||
profileEmp.nodeIdTemp = body.nodeId;
|
profileEmp.nodeIdTemp = body.nodeId;
|
||||||
profileEmp.orgRevisionIdTemp = body.orgRevisionId;
|
profileEmp.orgRevisionIdTemp = body.orgRevisionId;
|
||||||
|
|
@ -2923,13 +2976,18 @@ export class ProfileEmployeeController extends Controller {
|
||||||
if (!profileEmp) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้");
|
if (!profileEmp) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้");
|
||||||
|
|
||||||
const history = new ProfileEmployeeInformationHistory();
|
const history = new ProfileEmployeeInformationHistory();
|
||||||
Object.assign(history, { ...profileEmp, id: undefined });
|
|
||||||
Object.assign(profileEmp, body);
|
Object.assign(profileEmp, body);
|
||||||
|
Object.assign(history, { ...profileEmp, id: undefined });
|
||||||
history.profileEmployeeId = profileEmployeeId;
|
history.profileEmployeeId = profileEmployeeId;
|
||||||
history.lastUpdateFullName = request.user.name;
|
history.lastUpdateFullName = request.user.name;
|
||||||
history.lastUpdateUserId = request.user.sub;
|
history.lastUpdateUserId = request.user.sub;
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
history.createdUserId = request.user.sub;
|
||||||
|
history.createdFullName = request.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
profileEmp.lastUpdateUserId = request.user.sub;
|
profileEmp.lastUpdateUserId = request.user.sub;
|
||||||
profileEmp.lastUpdateFullName = request.user.name;
|
profileEmp.lastUpdateFullName = request.user.name;
|
||||||
|
profileEmp.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.profileRepo.save(profileEmp),
|
this.profileRepo.save(profileEmp),
|
||||||
|
|
@ -3103,24 +3161,26 @@ export class ProfileEmployeeController extends Controller {
|
||||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
await new permission().PermissionOrgUserUpdate(request, "SYS_REGISTRY_EMP", profile.id);
|
await new permission().PermissionOrgUserUpdate(request, "SYS_REGISTRY_EMP", profile.id);
|
||||||
|
|
||||||
const employment = new ProfileEmployeeEmployment();
|
const data = new ProfileEmployeeEmployment();
|
||||||
// const history = new ProfileEmployeeEmploymentHistory();
|
|
||||||
Object.assign(employment, body);
|
const meta = {
|
||||||
employment.profileEmployeeId = profileEmployeeId;
|
createdUserId: request.user.sub,
|
||||||
employment.createdUserId = request.user.sub;
|
createdFullName: request.user.name,
|
||||||
employment.createdFullName = request.user.name;
|
lastUpdateUserId: request.user.sub,
|
||||||
employment.lastUpdateUserId = request.user.sub;
|
lastUpdateFullName: request.user.name,
|
||||||
employment.lastUpdateFullName = request.user.name;
|
createdAt: new Date(),
|
||||||
await this.employmentRepository.save(employment);
|
lastUpdatedAt: new Date(),
|
||||||
// if (employment) {
|
profileEmployeeId: profileEmployeeId,
|
||||||
// Object.assign(history, { ...employment, id: undefined });
|
};
|
||||||
// history.profileEmployeeEmploymentId = employment.id;
|
|
||||||
// history.createdUserId = request.user.sub;
|
Object.assign(data, { ...body, ...meta });
|
||||||
// history.createdFullName = request.user.name;
|
const history = new ProfileEmployeeEmploymentHistory();
|
||||||
// history.lastUpdateFullName = request.user.name;
|
Object.assign(history, { ...data, id: undefined });
|
||||||
// history.lastUpdateUserId = request.user.sub;
|
|
||||||
// await this.employmentHistoryRepository.save(history);
|
await this.employmentRepository.save(data);
|
||||||
// }
|
history.profileEmployeeEmploymentId = data.id;
|
||||||
|
await this.employmentHistoryRepository.save(history);
|
||||||
|
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3176,14 +3236,19 @@ export class ProfileEmployeeController extends Controller {
|
||||||
);
|
);
|
||||||
|
|
||||||
const history = new ProfileEmployeeEmploymentHistory();
|
const history = new ProfileEmployeeEmploymentHistory();
|
||||||
Object.assign(history, { ...employment, id: undefined });
|
|
||||||
Object.assign(employment, body);
|
Object.assign(employment, body);
|
||||||
|
Object.assign(history, { ...employment, id: undefined });
|
||||||
|
|
||||||
employment.lastUpdateUserId = request.user.sub;
|
employment.lastUpdateUserId = request.user.sub;
|
||||||
employment.lastUpdateFullName = request.user.name;
|
employment.lastUpdateFullName = request.user.name;
|
||||||
|
employment.lastUpdatedAt = new Date();
|
||||||
history.profileEmployeeEmploymentId = id;
|
history.profileEmployeeEmploymentId = id;
|
||||||
history.lastUpdateFullName = request.user.name;
|
|
||||||
history.lastUpdateUserId = request.user.sub;
|
history.lastUpdateUserId = request.user.sub;
|
||||||
|
history.lastUpdateFullName = request.user.name;
|
||||||
|
history.createdUserId = request.user.sub;
|
||||||
|
history.createdFullName = request.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.employmentRepository.save(employment),
|
this.employmentRepository.save(employment),
|
||||||
|
|
@ -3210,6 +3275,7 @@ export class ProfileEmployeeController extends Controller {
|
||||||
statusTemp: "REPORT",
|
statusTemp: "REPORT",
|
||||||
lastUpdateUserId: request.user.sub,
|
lastUpdateUserId: request.user.sub,
|
||||||
lastUpdateFullName: request.user.name,
|
lastUpdateFullName: request.user.name,
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -609,6 +609,8 @@ export class ProfileEmployeeTempController extends Controller {
|
||||||
profile.createdFullName = request.user.name;
|
profile.createdFullName = request.user.name;
|
||||||
profile.lastUpdateUserId = request.user.sub;
|
profile.lastUpdateUserId = request.user.sub;
|
||||||
profile.lastUpdateFullName = request.user.name;
|
profile.lastUpdateFullName = request.user.name;
|
||||||
|
profile.createdAt = new Date();
|
||||||
|
profile.lastUpdatedAt = new Date();
|
||||||
profile.dateRetire = calculateRetireDate(profile.birthDate);
|
profile.dateRetire = calculateRetireDate(profile.birthDate);
|
||||||
profile.dateRetireLaw = calculateRetireLaw(profile.birthDate);
|
profile.dateRetireLaw = calculateRetireLaw(profile.birthDate);
|
||||||
profile.citizenId = Extension.CheckCitizen(profile.citizenId);
|
profile.citizenId = Extension.CheckCitizen(profile.citizenId);
|
||||||
|
|
@ -678,6 +680,7 @@ export class ProfileEmployeeTempController extends Controller {
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
record.lastUpdateUserId = request.user.sub;
|
record.lastUpdateUserId = request.user.sub;
|
||||||
record.lastUpdateFullName = request.user.name;
|
record.lastUpdateFullName = request.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
record.dateRetire = calculateRetireDate(record.birthDate);
|
record.dateRetire = calculateRetireDate(record.birthDate);
|
||||||
record.dateRetireLaw = calculateRetireLaw(record.birthDate);
|
record.dateRetireLaw = calculateRetireLaw(record.birthDate);
|
||||||
record.citizenId = Extension.CheckCitizen(record.citizenId);
|
record.citizenId = Extension.CheckCitizen(record.citizenId);
|
||||||
|
|
@ -2192,6 +2195,7 @@ export class ProfileEmployeeTempController extends Controller {
|
||||||
|
|
||||||
profileEmp.lastUpdateUserId = request.user.sub;
|
profileEmp.lastUpdateUserId = request.user.sub;
|
||||||
profileEmp.lastUpdateFullName = request.user.name;
|
profileEmp.lastUpdateFullName = request.user.name;
|
||||||
|
profileEmp.lastUpdatedAt = new Date();
|
||||||
profileEmp.nodeTemp = String(body.node);
|
profileEmp.nodeTemp = String(body.node);
|
||||||
profileEmp.nodeIdTemp = body.nodeId;
|
profileEmp.nodeIdTemp = body.nodeId;
|
||||||
profileEmp.orgRevisionIdTemp = body.orgRevisionId;
|
profileEmp.orgRevisionIdTemp = body.orgRevisionId;
|
||||||
|
|
@ -2916,8 +2920,10 @@ export class ProfileEmployeeTempController extends Controller {
|
||||||
history.profileEmployeeId = profileEmployeeId;
|
history.profileEmployeeId = profileEmployeeId;
|
||||||
history.lastUpdateFullName = request.user.name;
|
history.lastUpdateFullName = request.user.name;
|
||||||
history.lastUpdateUserId = request.user.sub;
|
history.lastUpdateUserId = request.user.sub;
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
profileEmp.lastUpdateUserId = request.user.sub;
|
profileEmp.lastUpdateUserId = request.user.sub;
|
||||||
profileEmp.lastUpdateFullName = request.user.name;
|
profileEmp.lastUpdateFullName = request.user.name;
|
||||||
|
profileEmp.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.profileRepo.save(profileEmp),
|
this.profileRepo.save(profileEmp),
|
||||||
|
|
@ -3084,6 +3090,8 @@ export class ProfileEmployeeTempController extends Controller {
|
||||||
employment.createdFullName = request.user.name;
|
employment.createdFullName = request.user.name;
|
||||||
employment.lastUpdateUserId = request.user.sub;
|
employment.lastUpdateUserId = request.user.sub;
|
||||||
employment.lastUpdateFullName = request.user.name;
|
employment.lastUpdateFullName = request.user.name;
|
||||||
|
employment.createdAt = new Date();
|
||||||
|
employment.lastUpdatedAt = new Date();
|
||||||
await this.employmentRepository.save(employment);
|
await this.employmentRepository.save(employment);
|
||||||
// if (employment) {
|
// if (employment) {
|
||||||
// Object.assign(history, { ...employment, id: undefined });
|
// Object.assign(history, { ...employment, id: undefined });
|
||||||
|
|
@ -3136,14 +3144,16 @@ export class ProfileEmployeeTempController extends Controller {
|
||||||
if (!employment) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!employment) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
||||||
const history = new ProfileEmployeeEmploymentHistory();
|
const history = new ProfileEmployeeEmploymentHistory();
|
||||||
Object.assign(history, { ...employment, id: undefined });
|
|
||||||
Object.assign(employment, body);
|
Object.assign(employment, body);
|
||||||
|
Object.assign(history, { ...employment, id: undefined });
|
||||||
|
|
||||||
employment.lastUpdateUserId = request.user.sub;
|
employment.lastUpdateUserId = request.user.sub;
|
||||||
employment.lastUpdateFullName = request.user.name;
|
employment.lastUpdateFullName = request.user.name;
|
||||||
|
employment.lastUpdatedAt = new Date();
|
||||||
history.profileEmployeeEmploymentId = id;
|
history.profileEmployeeEmploymentId = id;
|
||||||
history.lastUpdateFullName = request.user.name;
|
history.lastUpdateFullName = request.user.name;
|
||||||
history.lastUpdateUserId = request.user.sub;
|
history.lastUpdateUserId = request.user.sub;
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.employmentRepository.save(employment),
|
this.employmentRepository.save(employment),
|
||||||
|
|
@ -3171,6 +3181,7 @@ export class ProfileEmployeeTempController extends Controller {
|
||||||
statusTemp: "REPORT",
|
statusTemp: "REPORT",
|
||||||
lastUpdateUserId: request.user.sub,
|
lastUpdateUserId: request.user.sub,
|
||||||
lastUpdateFullName: request.user.name,
|
lastUpdateFullName: request.user.name,
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import {
|
import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
|
||||||
Example,
|
Example,
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
|
|
@ -41,18 +40,6 @@ export class ProfileFamilyCoupleController extends Controller {
|
||||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||||
}
|
}
|
||||||
const familyCouple = await this.ProfileFamilyCouple.findOne({
|
const familyCouple = await this.ProfileFamilyCouple.findOne({
|
||||||
select: [
|
|
||||||
"id",
|
|
||||||
"couplePrefix",
|
|
||||||
"coupleFirstName",
|
|
||||||
"coupleLastName",
|
|
||||||
"coupleLastNameOld",
|
|
||||||
"coupleCareer",
|
|
||||||
"coupleCitizenId",
|
|
||||||
"coupleLive",
|
|
||||||
"relationship",
|
|
||||||
"profileId",
|
|
||||||
],
|
|
||||||
where: { profileId: profile.id },
|
where: { profileId: profile.id },
|
||||||
order: { lastUpdatedAt: "DESC" },
|
order: { lastUpdatedAt: "DESC" },
|
||||||
});
|
});
|
||||||
|
|
@ -61,22 +48,6 @@ export class ProfileFamilyCoupleController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileId}")
|
@Get("{profileId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: {
|
|
||||||
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
|
|
||||||
couplePrefix: "string",
|
|
||||||
coupleFirstName: "string",
|
|
||||||
coupleLastName: "string",
|
|
||||||
coupleLastNameOld: "string",
|
|
||||||
coupleCareer: "string",
|
|
||||||
coupleCitizenId: "string",
|
|
||||||
coupleLive: true,
|
|
||||||
relationship: "string",
|
|
||||||
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
public async getFamilyCouple(@Path() profileId: string, @Request() req: RequestWithUser) {
|
public async getFamilyCouple(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||||
const profile = await this.profileRepo.findOne({
|
const profile = await this.profileRepo.findOne({
|
||||||
|
|
@ -87,18 +58,6 @@ export class ProfileFamilyCoupleController extends Controller {
|
||||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||||
}
|
}
|
||||||
const familyCouple = await this.ProfileFamilyCouple.findOne({
|
const familyCouple = await this.ProfileFamilyCouple.findOne({
|
||||||
select: [
|
|
||||||
"id",
|
|
||||||
"couplePrefix",
|
|
||||||
"coupleFirstName",
|
|
||||||
"coupleLastName",
|
|
||||||
"coupleLastNameOld",
|
|
||||||
"coupleCareer",
|
|
||||||
"coupleCitizenId",
|
|
||||||
"coupleLive",
|
|
||||||
"relationship",
|
|
||||||
"profileId",
|
|
||||||
],
|
|
||||||
where: { profileId },
|
where: { profileId },
|
||||||
order: { lastUpdatedAt: "DESC" },
|
order: { lastUpdatedAt: "DESC" },
|
||||||
});
|
});
|
||||||
|
|
@ -152,31 +111,6 @@ export class ProfileFamilyCoupleController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{profileId}")
|
@Get("history/{profileId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
|
|
||||||
createdAt: "2024-03-19T11:00:29.769Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-19T11:00:29.769Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
couplePrefix: "string",
|
|
||||||
coupleFirstName: "string",
|
|
||||||
coupleLastName: "string",
|
|
||||||
coupleLastNameOld: "string",
|
|
||||||
coupleCareer: "string",
|
|
||||||
coupleCitizenId: "string",
|
|
||||||
coupleLive: true,
|
|
||||||
relationship: "string",
|
|
||||||
profileFamilyCoupleId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async familyCoupleHistory(@Path() profileId: string, @Request() req: RequestWithUser) {
|
public async familyCoupleHistory(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||||
const profile = await this.profileRepo.findOne({
|
const profile = await this.profileRepo.findOne({
|
||||||
|
|
@ -236,6 +170,8 @@ export class ProfileFamilyCoupleController extends Controller {
|
||||||
familyCouple.createdFullName = req.user.name;
|
familyCouple.createdFullName = req.user.name;
|
||||||
familyCouple.lastUpdateUserId = req.user.sub;
|
familyCouple.lastUpdateUserId = req.user.sub;
|
||||||
familyCouple.lastUpdateFullName = req.user.name;
|
familyCouple.lastUpdateFullName = req.user.name;
|
||||||
|
familyCouple.createdAt = new Date();
|
||||||
|
familyCouple.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
profile.relationship = familyCouple.relationship; //update profileEmployee.relationship
|
profile.relationship = familyCouple.relationship; //update profileEmployee.relationship
|
||||||
const history = new ProfileFamilyCoupleHistory();
|
const history = new ProfileFamilyCoupleHistory();
|
||||||
|
|
@ -267,10 +203,13 @@ export class ProfileFamilyCoupleController extends Controller {
|
||||||
history.profileFamilyCoupleId = familyCouple.id;
|
history.profileFamilyCoupleId = familyCouple.id;
|
||||||
familyCouple.lastUpdateUserId = req.user.sub;
|
familyCouple.lastUpdateUserId = req.user.sub;
|
||||||
familyCouple.lastUpdateFullName = req.user.name;
|
familyCouple.lastUpdateFullName = req.user.name;
|
||||||
|
familyCouple.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.ProfileFamilyCouple.save(familyCouple),
|
this.ProfileFamilyCouple.save(familyCouple),
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import {
|
import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
|
||||||
Example,
|
Example,
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
|
|
@ -41,18 +40,6 @@ export class ProfileFamilyCoupleEmployeeController extends Controller {
|
||||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||||
}
|
}
|
||||||
const familyCouple = await this.ProfileFamilyCouple.findOne({
|
const familyCouple = await this.ProfileFamilyCouple.findOne({
|
||||||
select: [
|
|
||||||
"id",
|
|
||||||
"couplePrefix",
|
|
||||||
"coupleFirstName",
|
|
||||||
"coupleLastName",
|
|
||||||
"coupleLastNameOld",
|
|
||||||
"coupleCareer",
|
|
||||||
"coupleCitizenId",
|
|
||||||
"coupleLive",
|
|
||||||
"relationship",
|
|
||||||
"profileId",
|
|
||||||
],
|
|
||||||
where: { profileEmployeeId: profile.id },
|
where: { profileEmployeeId: profile.id },
|
||||||
order: { lastUpdatedAt: "DESC" },
|
order: { lastUpdatedAt: "DESC" },
|
||||||
});
|
});
|
||||||
|
|
@ -61,22 +48,6 @@ export class ProfileFamilyCoupleEmployeeController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileEmployeeId}")
|
@Get("{profileEmployeeId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: {
|
|
||||||
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
|
|
||||||
couplePrefix: "string",
|
|
||||||
coupleFirstName: "string",
|
|
||||||
coupleLastName: "string",
|
|
||||||
coupleLastNameOld: "string",
|
|
||||||
coupleCareer: "string",
|
|
||||||
coupleCitizenId: "string",
|
|
||||||
coupleLive: true,
|
|
||||||
relationship: "string",
|
|
||||||
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
public async getFamilyCouple(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
public async getFamilyCouple(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
||||||
const profile = await this.profileRepo.findOne({
|
const profile = await this.profileRepo.findOne({
|
||||||
where: { id: profileEmployeeId },
|
where: { id: profileEmployeeId },
|
||||||
|
|
@ -87,18 +58,6 @@ export class ProfileFamilyCoupleEmployeeController extends Controller {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profile.id);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profile.id);
|
||||||
|
|
||||||
const familyCouple = await this.ProfileFamilyCouple.findOne({
|
const familyCouple = await this.ProfileFamilyCouple.findOne({
|
||||||
select: [
|
|
||||||
"id",
|
|
||||||
"couplePrefix",
|
|
||||||
"coupleFirstName",
|
|
||||||
"coupleLastName",
|
|
||||||
"coupleLastNameOld",
|
|
||||||
"coupleCareer",
|
|
||||||
"coupleCitizenId",
|
|
||||||
"coupleLive",
|
|
||||||
"relationship",
|
|
||||||
"profileEmployeeId",
|
|
||||||
],
|
|
||||||
where: { profileEmployeeId },
|
where: { profileEmployeeId },
|
||||||
order: { lastUpdatedAt: "DESC" },
|
order: { lastUpdatedAt: "DESC" },
|
||||||
});
|
});
|
||||||
|
|
@ -152,32 +111,10 @@ export class ProfileFamilyCoupleEmployeeController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{profileEmployeeId}")
|
@Get("history/{profileEmployeeId}")
|
||||||
@Example({
|
public async familyCoupleHistory(
|
||||||
status: 200,
|
@Path() profileEmployeeId: string,
|
||||||
message: "สำเร็จ",
|
@Request() req: RequestWithUser,
|
||||||
result: [
|
) {
|
||||||
{
|
|
||||||
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
|
|
||||||
createdAt: "2024-03-19T11:00:29.769Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-19T11:00:29.769Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
couplePrefix: "string",
|
|
||||||
coupleFirstName: "string",
|
|
||||||
coupleLastName: "string",
|
|
||||||
coupleLastNameOld: "string",
|
|
||||||
coupleCareer: "string",
|
|
||||||
coupleCitizenId: "string",
|
|
||||||
coupleLive: true,
|
|
||||||
relationship: "string",
|
|
||||||
profileFamilyCoupleId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async familyCoupleHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
|
||||||
const profile = await this.profileRepo.findOne({
|
const profile = await this.profileRepo.findOne({
|
||||||
where: { id: profileEmployeeId },
|
where: { id: profileEmployeeId },
|
||||||
});
|
});
|
||||||
|
|
@ -237,6 +174,8 @@ export class ProfileFamilyCoupleEmployeeController extends Controller {
|
||||||
familyCouple.createdFullName = req.user.name;
|
familyCouple.createdFullName = req.user.name;
|
||||||
familyCouple.lastUpdateUserId = req.user.sub;
|
familyCouple.lastUpdateUserId = req.user.sub;
|
||||||
familyCouple.lastUpdateFullName = req.user.name;
|
familyCouple.lastUpdateFullName = req.user.name;
|
||||||
|
familyCouple.createdAt = new Date();
|
||||||
|
familyCouple.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
profile.relationship = familyCouple.relationship; //update profileEmployee.relationship
|
profile.relationship = familyCouple.relationship; //update profileEmployee.relationship
|
||||||
const history = new ProfileFamilyCoupleHistory();
|
const history = new ProfileFamilyCoupleHistory();
|
||||||
|
|
@ -256,7 +195,7 @@ export class ProfileFamilyCoupleEmployeeController extends Controller {
|
||||||
@Body() body: UpdateProfileFamilyCouple,
|
@Body() body: UpdateProfileFamilyCouple,
|
||||||
@Path() profileEmployeeId: string,
|
@Path() profileEmployeeId: string,
|
||||||
) {
|
) {
|
||||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profileEmployeeId)
|
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
||||||
const familyCouple = await this.ProfileFamilyCouple.findOneBy({
|
const familyCouple = await this.ProfileFamilyCouple.findOneBy({
|
||||||
profileEmployeeId: profileEmployeeId,
|
profileEmployeeId: profileEmployeeId,
|
||||||
});
|
});
|
||||||
|
|
@ -270,10 +209,13 @@ export class ProfileFamilyCoupleEmployeeController extends Controller {
|
||||||
history.profileFamilyCoupleId = familyCouple.id;
|
history.profileFamilyCoupleId = familyCouple.id;
|
||||||
familyCouple.lastUpdateUserId = req.user.sub;
|
familyCouple.lastUpdateUserId = req.user.sub;
|
||||||
familyCouple.lastUpdateFullName = req.user.name;
|
familyCouple.lastUpdateFullName = req.user.name;
|
||||||
|
familyCouple.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.ProfileFamilyCouple.save(familyCouple),
|
this.ProfileFamilyCouple.save(familyCouple),
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import {
|
import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
|
||||||
Example,
|
Example,
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
|
|
@ -41,18 +40,6 @@ export class ProfileFamilyCoupleEmployeeTempController extends Controller {
|
||||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||||
}
|
}
|
||||||
const familyCouple = await this.ProfileFamilyCouple.findOne({
|
const familyCouple = await this.ProfileFamilyCouple.findOne({
|
||||||
select: [
|
|
||||||
"id",
|
|
||||||
"couplePrefix",
|
|
||||||
"coupleFirstName",
|
|
||||||
"coupleLastName",
|
|
||||||
"coupleLastNameOld",
|
|
||||||
"coupleCareer",
|
|
||||||
"coupleCitizenId",
|
|
||||||
"coupleLive",
|
|
||||||
"relationship",
|
|
||||||
"profileId",
|
|
||||||
],
|
|
||||||
where: { profileEmployeeId: profile.id },
|
where: { profileEmployeeId: profile.id },
|
||||||
order: { lastUpdatedAt: "DESC" },
|
order: { lastUpdatedAt: "DESC" },
|
||||||
});
|
});
|
||||||
|
|
@ -61,22 +48,6 @@ export class ProfileFamilyCoupleEmployeeTempController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileEmployeeId}")
|
@Get("{profileEmployeeId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: {
|
|
||||||
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
|
|
||||||
couplePrefix: "string",
|
|
||||||
coupleFirstName: "string",
|
|
||||||
coupleLastName: "string",
|
|
||||||
coupleLastNameOld: "string",
|
|
||||||
coupleCareer: "string",
|
|
||||||
coupleCitizenId: "string",
|
|
||||||
coupleLive: true,
|
|
||||||
relationship: "string",
|
|
||||||
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
public async getFamilyCouple(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
public async getFamilyCouple(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||||
const profile = await this.profileRepo.findOne({
|
const profile = await this.profileRepo.findOne({
|
||||||
|
|
@ -87,18 +58,6 @@ export class ProfileFamilyCoupleEmployeeTempController extends Controller {
|
||||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||||
}
|
}
|
||||||
const familyCouple = await this.ProfileFamilyCouple.findOne({
|
const familyCouple = await this.ProfileFamilyCouple.findOne({
|
||||||
select: [
|
|
||||||
"id",
|
|
||||||
"couplePrefix",
|
|
||||||
"coupleFirstName",
|
|
||||||
"coupleLastName",
|
|
||||||
"coupleLastNameOld",
|
|
||||||
"coupleCareer",
|
|
||||||
"coupleCitizenId",
|
|
||||||
"coupleLive",
|
|
||||||
"relationship",
|
|
||||||
"profileEmployeeId",
|
|
||||||
],
|
|
||||||
where: { profileEmployeeId },
|
where: { profileEmployeeId },
|
||||||
order: { lastUpdatedAt: "DESC" },
|
order: { lastUpdatedAt: "DESC" },
|
||||||
});
|
});
|
||||||
|
|
@ -153,32 +112,10 @@ export class ProfileFamilyCoupleEmployeeTempController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{profileEmployeeId}")
|
@Get("history/{profileEmployeeId}")
|
||||||
@Example({
|
public async familyCoupleHistory(
|
||||||
status: 200,
|
@Path() profileEmployeeId: string,
|
||||||
message: "สำเร็จ",
|
@Request() req: RequestWithUser,
|
||||||
result: [
|
) {
|
||||||
{
|
|
||||||
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
|
|
||||||
createdAt: "2024-03-19T11:00:29.769Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-19T11:00:29.769Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
couplePrefix: "string",
|
|
||||||
coupleFirstName: "string",
|
|
||||||
coupleLastName: "string",
|
|
||||||
coupleLastNameOld: "string",
|
|
||||||
coupleCareer: "string",
|
|
||||||
coupleCitizenId: "string",
|
|
||||||
coupleLive: true,
|
|
||||||
relationship: "string",
|
|
||||||
profileFamilyCoupleId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async familyCoupleHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
|
||||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||||
const profile = await this.profileRepo.findOne({
|
const profile = await this.profileRepo.findOne({
|
||||||
where: { id: profileEmployeeId },
|
where: { id: profileEmployeeId },
|
||||||
|
|
@ -237,6 +174,8 @@ export class ProfileFamilyCoupleEmployeeTempController extends Controller {
|
||||||
familyCouple.createdFullName = req.user.name;
|
familyCouple.createdFullName = req.user.name;
|
||||||
familyCouple.lastUpdateUserId = req.user.sub;
|
familyCouple.lastUpdateUserId = req.user.sub;
|
||||||
familyCouple.lastUpdateFullName = req.user.name;
|
familyCouple.lastUpdateFullName = req.user.name;
|
||||||
|
familyCouple.createdAt = new Date();
|
||||||
|
familyCouple.lastUpdatedAt = new Date();
|
||||||
await this.ProfileFamilyCouple.save(familyCouple);
|
await this.ProfileFamilyCouple.save(familyCouple);
|
||||||
|
|
||||||
profile.relationship = familyCouple.relationship; //update profileEmployee.relationship
|
profile.relationship = familyCouple.relationship; //update profileEmployee.relationship
|
||||||
|
|
@ -271,10 +210,13 @@ export class ProfileFamilyCoupleEmployeeTempController extends Controller {
|
||||||
history.profileFamilyCoupleId = familyCouple.id;
|
history.profileFamilyCoupleId = familyCouple.id;
|
||||||
familyCouple.lastUpdateUserId = req.user.sub;
|
familyCouple.lastUpdateUserId = req.user.sub;
|
||||||
familyCouple.lastUpdateFullName = req.user.name;
|
familyCouple.lastUpdateFullName = req.user.name;
|
||||||
|
familyCouple.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.ProfileFamilyCouple.save(familyCouple),
|
this.ProfileFamilyCouple.save(familyCouple),
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import {
|
import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
|
||||||
Example,
|
Example,
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
|
|
@ -41,16 +40,6 @@ export class ProfileFamilyFatherController extends Controller {
|
||||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||||
}
|
}
|
||||||
const familyFather = await this.ProfileFamilyFather.findOne({
|
const familyFather = await this.ProfileFamilyFather.findOne({
|
||||||
select: [
|
|
||||||
"id",
|
|
||||||
"fatherPrefix",
|
|
||||||
"fatherFirstName",
|
|
||||||
"fatherLastName",
|
|
||||||
"fatherCareer",
|
|
||||||
"fatherCitizenId",
|
|
||||||
"fatherLive",
|
|
||||||
"profileId",
|
|
||||||
],
|
|
||||||
where: { profileId: profile.id },
|
where: { profileId: profile.id },
|
||||||
order: { lastUpdatedAt: "DESC" },
|
order: { lastUpdatedAt: "DESC" },
|
||||||
});
|
});
|
||||||
|
|
@ -59,20 +48,6 @@ export class ProfileFamilyFatherController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileId}")
|
@Get("{profileId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: {
|
|
||||||
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
|
|
||||||
fatherPrefix: "string",
|
|
||||||
fatherFirstName: "string",
|
|
||||||
fatherLastName: "string",
|
|
||||||
fatherCareer: "string",
|
|
||||||
fatherCitizenId: "string",
|
|
||||||
fatherLive: true,
|
|
||||||
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
public async getFamilyFather(@Path() profileId: string, @Request() req: RequestWithUser) {
|
public async getFamilyFather(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||||
const profile = await this.profileRepo.findOne({
|
const profile = await this.profileRepo.findOne({
|
||||||
|
|
@ -83,16 +58,6 @@ export class ProfileFamilyFatherController extends Controller {
|
||||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||||
}
|
}
|
||||||
const familyFather = await this.ProfileFamilyFather.findOne({
|
const familyFather = await this.ProfileFamilyFather.findOne({
|
||||||
select: [
|
|
||||||
"id",
|
|
||||||
"fatherPrefix",
|
|
||||||
"fatherFirstName",
|
|
||||||
"fatherLastName",
|
|
||||||
"fatherCareer",
|
|
||||||
"fatherCitizenId",
|
|
||||||
"fatherLive",
|
|
||||||
"profileId",
|
|
||||||
],
|
|
||||||
where: { profileId },
|
where: { profileId },
|
||||||
order: { lastUpdatedAt: "DESC" },
|
order: { lastUpdatedAt: "DESC" },
|
||||||
});
|
});
|
||||||
|
|
@ -142,29 +107,6 @@ export class ProfileFamilyFatherController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{profileId}")
|
@Get("history/{profileId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
|
|
||||||
createdAt: "2024-03-19T11:00:29.769Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-19T11:00:29.769Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
fatherPrefix: "string",
|
|
||||||
fatherFirstName: "string",
|
|
||||||
fatherLastName: "string",
|
|
||||||
fatherCareer: "string",
|
|
||||||
fatherCitizenId: "string",
|
|
||||||
fatherLive: true,
|
|
||||||
profileFamilyFatherId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async familyFatherHistory(@Path() profileId: string, @Request() req: RequestWithUser) {
|
public async familyFatherHistory(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||||
const profile = await this.profileRepo.findOne({
|
const profile = await this.profileRepo.findOne({
|
||||||
|
|
@ -222,6 +164,8 @@ export class ProfileFamilyFatherController extends Controller {
|
||||||
familyFather.createdFullName = req.user.name;
|
familyFather.createdFullName = req.user.name;
|
||||||
familyFather.lastUpdateUserId = req.user.sub;
|
familyFather.lastUpdateUserId = req.user.sub;
|
||||||
familyFather.lastUpdateFullName = req.user.name;
|
familyFather.lastUpdateFullName = req.user.name;
|
||||||
|
familyFather.createdAt = new Date();
|
||||||
|
familyFather.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
const history = new ProfileFamilyFatherHistory();
|
const history = new ProfileFamilyFatherHistory();
|
||||||
Object.assign(history, { ...familyFather, id: undefined });
|
Object.assign(history, { ...familyFather, id: undefined });
|
||||||
|
|
@ -251,10 +195,13 @@ export class ProfileFamilyFatherController extends Controller {
|
||||||
history.profileFamilyFatherId = familyFather.id; //profileFamilyFatherId
|
history.profileFamilyFatherId = familyFather.id; //profileFamilyFatherId
|
||||||
familyFather.lastUpdateUserId = req.user.sub;
|
familyFather.lastUpdateUserId = req.user.sub;
|
||||||
familyFather.lastUpdateFullName = req.user.name;
|
familyFather.lastUpdateFullName = req.user.name;
|
||||||
|
familyFather.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.ProfileFamilyFather.save(familyFather),
|
this.ProfileFamilyFather.save(familyFather),
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import {
|
import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
|
||||||
Example,
|
Example,
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
|
|
@ -41,16 +40,6 @@ export class ProfileFamilyFatherEmployeeController extends Controller {
|
||||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||||
}
|
}
|
||||||
const familyFather = await this.ProfileFamilyFather.findOne({
|
const familyFather = await this.ProfileFamilyFather.findOne({
|
||||||
select: [
|
|
||||||
"id",
|
|
||||||
"fatherPrefix",
|
|
||||||
"fatherFirstName",
|
|
||||||
"fatherLastName",
|
|
||||||
"fatherCareer",
|
|
||||||
"fatherCitizenId",
|
|
||||||
"fatherLive",
|
|
||||||
"profileId",
|
|
||||||
],
|
|
||||||
where: { profileEmployeeId: profile.id },
|
where: { profileEmployeeId: profile.id },
|
||||||
order: { lastUpdatedAt: "DESC" },
|
order: { lastUpdatedAt: "DESC" },
|
||||||
});
|
});
|
||||||
|
|
@ -59,20 +48,6 @@ export class ProfileFamilyFatherEmployeeController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileEmployeeId}")
|
@Get("{profileEmployeeId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: {
|
|
||||||
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
|
|
||||||
fatherPrefix: "string",
|
|
||||||
fatherFirstName: "string",
|
|
||||||
fatherLastName: "string",
|
|
||||||
fatherCareer: "string",
|
|
||||||
fatherCitizenId: "string",
|
|
||||||
fatherLive: true,
|
|
||||||
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
public async getFamilyFather(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
public async getFamilyFather(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
||||||
const profile = await this.profileRepo.findOne({
|
const profile = await this.profileRepo.findOne({
|
||||||
|
|
@ -82,16 +57,6 @@ export class ProfileFamilyFatherEmployeeController extends Controller {
|
||||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||||
}
|
}
|
||||||
const familyFather = await this.ProfileFamilyFather.findOne({
|
const familyFather = await this.ProfileFamilyFather.findOne({
|
||||||
select: [
|
|
||||||
"id",
|
|
||||||
"fatherPrefix",
|
|
||||||
"fatherFirstName",
|
|
||||||
"fatherLastName",
|
|
||||||
"fatherCareer",
|
|
||||||
"fatherCitizenId",
|
|
||||||
"fatherLive",
|
|
||||||
"profileEmployeeId",
|
|
||||||
],
|
|
||||||
where: { profileEmployeeId },
|
where: { profileEmployeeId },
|
||||||
order: { lastUpdatedAt: "DESC" },
|
order: { lastUpdatedAt: "DESC" },
|
||||||
});
|
});
|
||||||
|
|
@ -141,30 +106,10 @@ export class ProfileFamilyFatherEmployeeController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{profileEmployeeId}")
|
@Get("history/{profileEmployeeId}")
|
||||||
@Example({
|
public async familyFatherHistory(
|
||||||
status: 200,
|
@Path() profileEmployeeId: string,
|
||||||
message: "สำเร็จ",
|
@Request() req: RequestWithUser,
|
||||||
result: [
|
) {
|
||||||
{
|
|
||||||
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
|
|
||||||
createdAt: "2024-03-19T11:00:29.769Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-19T11:00:29.769Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
fatherPrefix: "string",
|
|
||||||
fatherFirstName: "string",
|
|
||||||
fatherLastName: "string",
|
|
||||||
fatherCareer: "string",
|
|
||||||
fatherCitizenId: "string",
|
|
||||||
fatherLive: true,
|
|
||||||
profileFamilyFatherId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async familyFatherHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
||||||
const profile = await this.profileRepo.findOne({
|
const profile = await this.profileRepo.findOne({
|
||||||
where: { id: profileEmployeeId },
|
where: { id: profileEmployeeId },
|
||||||
|
|
@ -221,6 +166,8 @@ export class ProfileFamilyFatherEmployeeController extends Controller {
|
||||||
familyFather.createdFullName = req.user.name;
|
familyFather.createdFullName = req.user.name;
|
||||||
familyFather.lastUpdateUserId = req.user.sub;
|
familyFather.lastUpdateUserId = req.user.sub;
|
||||||
familyFather.lastUpdateFullName = req.user.name;
|
familyFather.lastUpdateFullName = req.user.name;
|
||||||
|
familyFather.createdAt = new Date();
|
||||||
|
familyFather.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
const history = new ProfileFamilyFatherHistory();
|
const history = new ProfileFamilyFatherHistory();
|
||||||
Object.assign(history, { ...familyFather, id: undefined });
|
Object.assign(history, { ...familyFather, id: undefined });
|
||||||
|
|
@ -252,10 +199,13 @@ export class ProfileFamilyFatherEmployeeController extends Controller {
|
||||||
history.profileFamilyFatherId = familyFather.id;
|
history.profileFamilyFatherId = familyFather.id;
|
||||||
familyFather.lastUpdateUserId = req.user.sub;
|
familyFather.lastUpdateUserId = req.user.sub;
|
||||||
familyFather.lastUpdateFullName = req.user.name;
|
familyFather.lastUpdateFullName = req.user.name;
|
||||||
|
familyFather.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.ProfileFamilyFather.save(familyFather),
|
this.ProfileFamilyFather.save(familyFather),
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import {
|
import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
|
||||||
Example,
|
Example,
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
|
|
@ -41,16 +40,6 @@ export class ProfileFamilyFatherEmployeeTempController extends Controller {
|
||||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||||
}
|
}
|
||||||
const familyFather = await this.ProfileFamilyFather.findOne({
|
const familyFather = await this.ProfileFamilyFather.findOne({
|
||||||
select: [
|
|
||||||
"id",
|
|
||||||
"fatherPrefix",
|
|
||||||
"fatherFirstName",
|
|
||||||
"fatherLastName",
|
|
||||||
"fatherCareer",
|
|
||||||
"fatherCitizenId",
|
|
||||||
"fatherLive",
|
|
||||||
"profileId",
|
|
||||||
],
|
|
||||||
where: { profileEmployeeId: profile.id },
|
where: { profileEmployeeId: profile.id },
|
||||||
order: { lastUpdatedAt: "DESC" },
|
order: { lastUpdatedAt: "DESC" },
|
||||||
});
|
});
|
||||||
|
|
@ -59,20 +48,6 @@ export class ProfileFamilyFatherEmployeeTempController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileEmployeeId}")
|
@Get("{profileEmployeeId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: {
|
|
||||||
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
|
|
||||||
fatherPrefix: "string",
|
|
||||||
fatherFirstName: "string",
|
|
||||||
fatherLastName: "string",
|
|
||||||
fatherCareer: "string",
|
|
||||||
fatherCitizenId: "string",
|
|
||||||
fatherLive: true,
|
|
||||||
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
public async getFamilyFather(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
public async getFamilyFather(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||||
const profile = await this.profileRepo.findOne({
|
const profile = await this.profileRepo.findOne({
|
||||||
|
|
@ -83,16 +58,6 @@ export class ProfileFamilyFatherEmployeeTempController extends Controller {
|
||||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||||
}
|
}
|
||||||
const familyFather = await this.ProfileFamilyFather.findOne({
|
const familyFather = await this.ProfileFamilyFather.findOne({
|
||||||
select: [
|
|
||||||
"id",
|
|
||||||
"fatherPrefix",
|
|
||||||
"fatherFirstName",
|
|
||||||
"fatherLastName",
|
|
||||||
"fatherCareer",
|
|
||||||
"fatherCitizenId",
|
|
||||||
"fatherLive",
|
|
||||||
"profileEmployeeId",
|
|
||||||
],
|
|
||||||
where: { profileEmployeeId },
|
where: { profileEmployeeId },
|
||||||
order: { lastUpdatedAt: "DESC" },
|
order: { lastUpdatedAt: "DESC" },
|
||||||
});
|
});
|
||||||
|
|
@ -142,30 +107,10 @@ export class ProfileFamilyFatherEmployeeTempController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{profileEmployeeId}")
|
@Get("history/{profileEmployeeId}")
|
||||||
@Example({
|
public async familyFatherHistory(
|
||||||
status: 200,
|
@Path() profileEmployeeId: string,
|
||||||
message: "สำเร็จ",
|
@Request() req: RequestWithUser,
|
||||||
result: [
|
) {
|
||||||
{
|
|
||||||
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
|
|
||||||
createdAt: "2024-03-19T11:00:29.769Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-19T11:00:29.769Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
fatherPrefix: "string",
|
|
||||||
fatherFirstName: "string",
|
|
||||||
fatherLastName: "string",
|
|
||||||
fatherCareer: "string",
|
|
||||||
fatherCitizenId: "string",
|
|
||||||
fatherLive: true,
|
|
||||||
profileFamilyFatherId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async familyFatherHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
|
||||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||||
const profile = await this.profileRepo.findOne({
|
const profile = await this.profileRepo.findOne({
|
||||||
where: { id: profileEmployeeId },
|
where: { id: profileEmployeeId },
|
||||||
|
|
@ -222,6 +167,8 @@ export class ProfileFamilyFatherEmployeeTempController extends Controller {
|
||||||
familyFather.createdFullName = req.user.name;
|
familyFather.createdFullName = req.user.name;
|
||||||
familyFather.lastUpdateUserId = req.user.sub;
|
familyFather.lastUpdateUserId = req.user.sub;
|
||||||
familyFather.lastUpdateFullName = req.user.name;
|
familyFather.lastUpdateFullName = req.user.name;
|
||||||
|
familyFather.createdAt = new Date();
|
||||||
|
familyFather.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
const history = new ProfileFamilyFatherHistory();
|
const history = new ProfileFamilyFatherHistory();
|
||||||
Object.assign(history, { ...familyFather, id: undefined });
|
Object.assign(history, { ...familyFather, id: undefined });
|
||||||
|
|
@ -253,10 +200,13 @@ export class ProfileFamilyFatherEmployeeTempController extends Controller {
|
||||||
history.profileFamilyFatherId = familyFather.id;
|
history.profileFamilyFatherId = familyFather.id;
|
||||||
familyFather.lastUpdateUserId = req.user.sub;
|
familyFather.lastUpdateUserId = req.user.sub;
|
||||||
familyFather.lastUpdateFullName = req.user.name;
|
familyFather.lastUpdateFullName = req.user.name;
|
||||||
|
familyFather.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.ProfileFamilyFather.save(familyFather),
|
this.ProfileFamilyFather.save(familyFather),
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import {
|
import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
|
||||||
Example,
|
Example,
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
|
|
@ -41,16 +40,6 @@ export class ProfileFamilyMotherController extends Controller {
|
||||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||||
}
|
}
|
||||||
const familyMother = await this.ProfileFamilyMother.findOne({
|
const familyMother = await this.ProfileFamilyMother.findOne({
|
||||||
select: [
|
|
||||||
"id",
|
|
||||||
"motherPrefix",
|
|
||||||
"motherFirstName",
|
|
||||||
"motherLastName",
|
|
||||||
"motherCareer",
|
|
||||||
"motherCitizenId",
|
|
||||||
"motherLive",
|
|
||||||
"profileId",
|
|
||||||
],
|
|
||||||
where: { profileId: profile.id },
|
where: { profileId: profile.id },
|
||||||
order: { lastUpdatedAt: "DESC" },
|
order: { lastUpdatedAt: "DESC" },
|
||||||
});
|
});
|
||||||
|
|
@ -59,20 +48,6 @@ export class ProfileFamilyMotherController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileId}")
|
@Get("{profileId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: {
|
|
||||||
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
|
|
||||||
motherPrefix: "string",
|
|
||||||
motherFirstName: "string",
|
|
||||||
motherLastName: "string",
|
|
||||||
motherCareer: "string",
|
|
||||||
motherCitizenId: "string",
|
|
||||||
motherLive: true,
|
|
||||||
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
public async getFamilyMother(@Path() profileId: string, @Request() req: RequestWithUser) {
|
public async getFamilyMother(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||||
const profile = await this.profileRepo.findOne({
|
const profile = await this.profileRepo.findOne({
|
||||||
|
|
@ -83,16 +58,6 @@ export class ProfileFamilyMotherController extends Controller {
|
||||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||||
}
|
}
|
||||||
const familyMother = await this.ProfileFamilyMother.findOne({
|
const familyMother = await this.ProfileFamilyMother.findOne({
|
||||||
select: [
|
|
||||||
"id",
|
|
||||||
"motherPrefix",
|
|
||||||
"motherFirstName",
|
|
||||||
"motherLastName",
|
|
||||||
"motherCareer",
|
|
||||||
"motherCitizenId",
|
|
||||||
"motherLive",
|
|
||||||
"profileId",
|
|
||||||
],
|
|
||||||
where: { profileId },
|
where: { profileId },
|
||||||
order: { lastUpdatedAt: "DESC" },
|
order: { lastUpdatedAt: "DESC" },
|
||||||
});
|
});
|
||||||
|
|
@ -142,29 +107,6 @@ export class ProfileFamilyMotherController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{profileId}")
|
@Get("history/{profileId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
|
|
||||||
createdAt: "2024-03-19T11:00:29.769Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-19T11:00:29.769Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
motherPrefix: "string",
|
|
||||||
motherFirstName: "string",
|
|
||||||
motherLastName: "string",
|
|
||||||
motherCareer: "string",
|
|
||||||
motherCitizenId: "string",
|
|
||||||
motherLive: true,
|
|
||||||
profileFamilyMotherId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async familyMotherHistory(@Path() profileId: string, @Request() req: RequestWithUser) {
|
public async familyMotherHistory(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||||
const profile = await this.profileRepo.findOne({
|
const profile = await this.profileRepo.findOne({
|
||||||
|
|
@ -221,6 +163,8 @@ export class ProfileFamilyMotherController extends Controller {
|
||||||
familyMother.createdFullName = req.user.name;
|
familyMother.createdFullName = req.user.name;
|
||||||
familyMother.lastUpdateUserId = req.user.sub;
|
familyMother.lastUpdateUserId = req.user.sub;
|
||||||
familyMother.lastUpdateFullName = req.user.name;
|
familyMother.lastUpdateFullName = req.user.name;
|
||||||
|
familyMother.createdAt = new Date();
|
||||||
|
familyMother.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
const history = new ProfileFamilyMotherHistory();
|
const history = new ProfileFamilyMotherHistory();
|
||||||
Object.assign(history, { ...familyMother, id: undefined });
|
Object.assign(history, { ...familyMother, id: undefined });
|
||||||
|
|
@ -250,10 +194,13 @@ export class ProfileFamilyMotherController extends Controller {
|
||||||
history.profileFamilyMotherId = familyMother.id;
|
history.profileFamilyMotherId = familyMother.id;
|
||||||
familyMother.lastUpdateUserId = req.user.sub;
|
familyMother.lastUpdateUserId = req.user.sub;
|
||||||
familyMother.lastUpdateFullName = req.user.name;
|
familyMother.lastUpdateFullName = req.user.name;
|
||||||
|
familyMother.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.ProfileFamilyMother.save(familyMother),
|
this.ProfileFamilyMother.save(familyMother),
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import {
|
import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
|
||||||
Example,
|
Example,
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
|
|
@ -41,16 +40,6 @@ export class ProfileFamilyMotherEmployeeController extends Controller {
|
||||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||||
}
|
}
|
||||||
const familyMother = await this.ProfileFamilyMother.findOne({
|
const familyMother = await this.ProfileFamilyMother.findOne({
|
||||||
select: [
|
|
||||||
"id",
|
|
||||||
"motherPrefix",
|
|
||||||
"motherFirstName",
|
|
||||||
"motherLastName",
|
|
||||||
"motherCareer",
|
|
||||||
"motherCitizenId",
|
|
||||||
"motherLive",
|
|
||||||
"profileId",
|
|
||||||
],
|
|
||||||
where: { profileEmployeeId: profile.id },
|
where: { profileEmployeeId: profile.id },
|
||||||
order: { lastUpdatedAt: "DESC" },
|
order: { lastUpdatedAt: "DESC" },
|
||||||
});
|
});
|
||||||
|
|
@ -59,20 +48,6 @@ export class ProfileFamilyMotherEmployeeController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileEmployeeId}")
|
@Get("{profileEmployeeId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: {
|
|
||||||
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
|
|
||||||
motherPrefix: "string",
|
|
||||||
motherFirstName: "string",
|
|
||||||
motherLastName: "string",
|
|
||||||
motherCareer: "string",
|
|
||||||
motherCitizenId: "string",
|
|
||||||
motherLive: true,
|
|
||||||
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
public async getFamilyMother(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
public async getFamilyMother(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
||||||
const profile = await this.profileRepo.findOne({
|
const profile = await this.profileRepo.findOne({
|
||||||
|
|
@ -83,16 +58,6 @@ export class ProfileFamilyMotherEmployeeController extends Controller {
|
||||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||||
}
|
}
|
||||||
const familyMother = await this.ProfileFamilyMother.findOne({
|
const familyMother = await this.ProfileFamilyMother.findOne({
|
||||||
select: [
|
|
||||||
"id",
|
|
||||||
"motherPrefix",
|
|
||||||
"motherFirstName",
|
|
||||||
"motherLastName",
|
|
||||||
"motherCareer",
|
|
||||||
"motherCitizenId",
|
|
||||||
"motherLive",
|
|
||||||
"profileEmployeeId",
|
|
||||||
],
|
|
||||||
where: { profileEmployeeId },
|
where: { profileEmployeeId },
|
||||||
order: { lastUpdatedAt: "DESC" },
|
order: { lastUpdatedAt: "DESC" },
|
||||||
});
|
});
|
||||||
|
|
@ -142,30 +107,10 @@ export class ProfileFamilyMotherEmployeeController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{profileEmployeeId}")
|
@Get("history/{profileEmployeeId}")
|
||||||
@Example({
|
public async familyMotherHistory(
|
||||||
status: 200,
|
@Path() profileEmployeeId: string,
|
||||||
message: "สำเร็จ",
|
@Request() req: RequestWithUser,
|
||||||
result: [
|
) {
|
||||||
{
|
|
||||||
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
|
|
||||||
createdAt: "2024-03-19T11:00:29.769Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-19T11:00:29.769Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
motherPrefix: "string",
|
|
||||||
motherFirstName: "string",
|
|
||||||
motherLastName: "string",
|
|
||||||
motherCareer: "string",
|
|
||||||
motherCitizenId: "string",
|
|
||||||
motherLive: true,
|
|
||||||
profileFamilyMotherId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async familyMotherHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
||||||
const profile = await this.profileRepo.findOne({
|
const profile = await this.profileRepo.findOne({
|
||||||
where: { id: profileEmployeeId },
|
where: { id: profileEmployeeId },
|
||||||
|
|
@ -221,6 +166,8 @@ export class ProfileFamilyMotherEmployeeController extends Controller {
|
||||||
familyMother.createdFullName = req.user.name;
|
familyMother.createdFullName = req.user.name;
|
||||||
familyMother.lastUpdateUserId = req.user.sub;
|
familyMother.lastUpdateUserId = req.user.sub;
|
||||||
familyMother.lastUpdateFullName = req.user.name;
|
familyMother.lastUpdateFullName = req.user.name;
|
||||||
|
familyMother.createdAt = new Date();
|
||||||
|
familyMother.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
const history = new ProfileFamilyMotherHistory();
|
const history = new ProfileFamilyMotherHistory();
|
||||||
Object.assign(history, { ...familyMother, id: undefined });
|
Object.assign(history, { ...familyMother, id: undefined });
|
||||||
|
|
@ -252,10 +199,13 @@ export class ProfileFamilyMotherEmployeeController extends Controller {
|
||||||
history.profileFamilyMotherId = familyMother.id;
|
history.profileFamilyMotherId = familyMother.id;
|
||||||
familyMother.lastUpdateUserId = req.user.sub;
|
familyMother.lastUpdateUserId = req.user.sub;
|
||||||
familyMother.lastUpdateFullName = req.user.name;
|
familyMother.lastUpdateFullName = req.user.name;
|
||||||
|
familyMother.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.ProfileFamilyMother.save(familyMother),
|
this.ProfileFamilyMother.save(familyMother),
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import {
|
import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
|
||||||
Example,
|
Example,
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
|
|
@ -41,16 +40,6 @@ export class ProfileFamilyMotherEmployeeTempController extends Controller {
|
||||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||||
}
|
}
|
||||||
const familyMother = await this.ProfileFamilyMother.findOne({
|
const familyMother = await this.ProfileFamilyMother.findOne({
|
||||||
select: [
|
|
||||||
"id",
|
|
||||||
"motherPrefix",
|
|
||||||
"motherFirstName",
|
|
||||||
"motherLastName",
|
|
||||||
"motherCareer",
|
|
||||||
"motherCitizenId",
|
|
||||||
"motherLive",
|
|
||||||
"profileId",
|
|
||||||
],
|
|
||||||
where: { profileEmployeeId: profile.id },
|
where: { profileEmployeeId: profile.id },
|
||||||
order: { lastUpdatedAt: "DESC" },
|
order: { lastUpdatedAt: "DESC" },
|
||||||
});
|
});
|
||||||
|
|
@ -59,20 +48,6 @@ export class ProfileFamilyMotherEmployeeTempController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileEmployeeId}")
|
@Get("{profileEmployeeId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: {
|
|
||||||
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
|
|
||||||
motherPrefix: "string",
|
|
||||||
motherFirstName: "string",
|
|
||||||
motherLastName: "string",
|
|
||||||
motherCareer: "string",
|
|
||||||
motherCitizenId: "string",
|
|
||||||
motherLive: true,
|
|
||||||
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
public async getFamilyMother(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
public async getFamilyMother(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||||
const profile = await this.profileRepo.findOne({
|
const profile = await this.profileRepo.findOne({
|
||||||
|
|
@ -83,16 +58,6 @@ export class ProfileFamilyMotherEmployeeTempController extends Controller {
|
||||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||||
}
|
}
|
||||||
const familyMother = await this.ProfileFamilyMother.findOne({
|
const familyMother = await this.ProfileFamilyMother.findOne({
|
||||||
select: [
|
|
||||||
"id",
|
|
||||||
"motherPrefix",
|
|
||||||
"motherFirstName",
|
|
||||||
"motherLastName",
|
|
||||||
"motherCareer",
|
|
||||||
"motherCitizenId",
|
|
||||||
"motherLive",
|
|
||||||
"profileEmployeeId",
|
|
||||||
],
|
|
||||||
where: { profileEmployeeId },
|
where: { profileEmployeeId },
|
||||||
order: { lastUpdatedAt: "DESC" },
|
order: { lastUpdatedAt: "DESC" },
|
||||||
});
|
});
|
||||||
|
|
@ -142,30 +107,10 @@ export class ProfileFamilyMotherEmployeeTempController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{profileEmployeeId}")
|
@Get("history/{profileEmployeeId}")
|
||||||
@Example({
|
public async familyMotherHistory(
|
||||||
status: 200,
|
@Path() profileEmployeeId: string,
|
||||||
message: "สำเร็จ",
|
@Request() req: RequestWithUser,
|
||||||
result: [
|
) {
|
||||||
{
|
|
||||||
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
|
|
||||||
createdAt: "2024-03-19T11:00:29.769Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-19T11:00:29.769Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
motherPrefix: "string",
|
|
||||||
motherFirstName: "string",
|
|
||||||
motherLastName: "string",
|
|
||||||
motherCareer: "string",
|
|
||||||
motherCitizenId: "string",
|
|
||||||
motherLive: true,
|
|
||||||
profileFamilyMotherId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async familyMotherHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
|
||||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||||
const profile = await this.profileRepo.findOne({
|
const profile = await this.profileRepo.findOne({
|
||||||
where: { id: profileEmployeeId },
|
where: { id: profileEmployeeId },
|
||||||
|
|
@ -222,6 +167,8 @@ export class ProfileFamilyMotherEmployeeTempController extends Controller {
|
||||||
familyMother.createdFullName = req.user.name;
|
familyMother.createdFullName = req.user.name;
|
||||||
familyMother.lastUpdateUserId = req.user.sub;
|
familyMother.lastUpdateUserId = req.user.sub;
|
||||||
familyMother.lastUpdateFullName = req.user.name;
|
familyMother.lastUpdateFullName = req.user.name;
|
||||||
|
familyMother.createdAt = new Date();
|
||||||
|
familyMother.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
const history = new ProfileFamilyMotherHistory();
|
const history = new ProfileFamilyMotherHistory();
|
||||||
Object.assign(history, { ...familyMother, id: undefined });
|
Object.assign(history, { ...familyMother, id: undefined });
|
||||||
|
|
@ -253,10 +200,13 @@ export class ProfileFamilyMotherEmployeeTempController extends Controller {
|
||||||
history.profileFamilyMotherId = familyMother.id;
|
history.profileFamilyMotherId = familyMother.id;
|
||||||
familyMother.lastUpdateUserId = req.user.sub;
|
familyMother.lastUpdateUserId = req.user.sub;
|
||||||
familyMother.lastUpdateFullName = req.user.name;
|
familyMother.lastUpdateFullName = req.user.name;
|
||||||
|
familyMother.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.ProfileFamilyMother.save(familyMother),
|
this.ProfileFamilyMother.save(familyMother),
|
||||||
|
|
|
||||||
|
|
@ -389,15 +389,18 @@ export class ProfileGovernmentHistoryController extends Controller {
|
||||||
const history = new ProfileGovernment();
|
const history = new ProfileGovernment();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileId = profileId;
|
history.profileId = profileId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([this.profileRepo.save(record), this.govRepo.save(history)]);
|
await Promise.all([this.profileRepo.save(record), this.govRepo.save(history)]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -343,7 +343,7 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
||||||
@Get("history/{profileEmployeeId}")
|
@Get("history/{profileEmployeeId}")
|
||||||
@Example({})
|
@Example({})
|
||||||
public async govHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
public async govHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId)
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
||||||
const record = await this.govRepo.find({
|
const record = await this.govRepo.find({
|
||||||
order: { lastUpdatedAt: "DESC" },
|
order: { lastUpdatedAt: "DESC" },
|
||||||
where: { profileEmployeeId: profileEmployeeId },
|
where: { profileEmployeeId: profileEmployeeId },
|
||||||
|
|
@ -362,7 +362,7 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
||||||
@Body() body: UpdateProfileGovernment,
|
@Body() body: UpdateProfileGovernment,
|
||||||
@Path() profileEmployeeId: string,
|
@Path() profileEmployeeId: string,
|
||||||
) {
|
) {
|
||||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profileEmployeeId)
|
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
||||||
const record = await this.profileEmployeeRepo.findOne({
|
const record = await this.profileEmployeeRepo.findOne({
|
||||||
where: { id: profileEmployeeId },
|
where: { id: profileEmployeeId },
|
||||||
});
|
});
|
||||||
|
|
@ -371,15 +371,18 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
||||||
const history = new ProfileGovernment();
|
const history = new ProfileGovernment();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileEmployeeId = profileEmployeeId;
|
history.profileEmployeeId = profileEmployeeId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([this.profileEmployeeRepo.save(record), this.govRepo.save(history)]);
|
await Promise.all([this.profileEmployeeRepo.save(record), this.govRepo.save(history)]);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
|
|
|
||||||
|
|
@ -372,15 +372,18 @@ export class ProfileGovernmentEmployeeTempController extends Controller {
|
||||||
const history = new ProfileGovernment();
|
const history = new ProfileGovernment();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileEmployeeId = profileEmployeeId;
|
history.profileEmployeeId = profileEmployeeId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([this.profileEmployeeRepo.save(record), this.govRepo.save(history)]);
|
await Promise.all([this.profileEmployeeRepo.save(record), this.govRepo.save(history)]);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
Example,
|
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
Path,
|
Path,
|
||||||
|
|
@ -37,36 +36,18 @@ export class ProfileHonorController extends Controller {
|
||||||
}
|
}
|
||||||
const record = await this.honorRepo.find({
|
const record = await this.honorRepo.find({
|
||||||
where: { profileId: profile.id },
|
where: { profileId: profile.id },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileId}")
|
@Get("{profileId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
|
||||||
createdAt: "2024-03-12T03:10:05.594Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-12T03:10:05.594Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
detail: "string",
|
|
||||||
issueDate: "2024-03-12T10:09:47.000Z",
|
|
||||||
issuer: "string",
|
|
||||||
refCommandDate: "2024-03-12T10:09:47.000Z",
|
|
||||||
refCommandNo: "string",
|
|
||||||
isDate: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async getHonor(@Path() profileId: string, @Request() req: RequestWithUser) {
|
public async getHonor(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||||
const record = await this.honorRepo.findBy({ profileId });
|
const record = await this.honorRepo.find({
|
||||||
|
where: { profileId: profileId },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -87,56 +68,22 @@ export class ProfileHonorController extends Controller {
|
||||||
profileId: profile.id,
|
profileId: profile.id,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{honorId}")
|
@Get("history/{honorId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "3bedb365-4a41-4df5-8f47-b6e143221d2c",
|
|
||||||
createdAt: "2024-03-12T03:11:01.395Z",
|
|
||||||
createdUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
lastUpdatedAt: "2024-03-12T03:11:01.395Z",
|
|
||||||
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
createdFullName: "string",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
detail: "detail",
|
|
||||||
issueDate: "2024-03-12T10:10:31.000Z",
|
|
||||||
issuer: "issuer",
|
|
||||||
refCommandDate: "2024-03-12T10:10:31.000Z",
|
|
||||||
refCommandNo: "refCommandNo",
|
|
||||||
isDate: true,
|
|
||||||
profileHonorId: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "ba0e2f82-014e-46c6-8b82-a7c28eb5325f",
|
|
||||||
createdAt: "2024-03-12T03:10:05.657Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-12T03:10:05.657Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
detail: "string",
|
|
||||||
issueDate: "2024-03-12T10:09:47.000Z",
|
|
||||||
issuer: "string",
|
|
||||||
refCommandDate: "2024-03-12T10:09:47.000Z",
|
|
||||||
refCommandNo: "string",
|
|
||||||
isDate: true,
|
|
||||||
profileHonorId: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async honorHistory(@Path() honorId: string, @Request() req: RequestWithUser) {
|
public async honorHistory(@Path() honorId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.honorRepo.findOneBy({ id: honorId });
|
const _record = await this.honorRepo.findOneBy({ id: honorId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
||||||
}
|
}
|
||||||
const record = await this.honorHistoryRepo.findBy({
|
const record = await this.honorHistoryRepo.find({
|
||||||
|
where: {
|
||||||
profileHonorId: honorId,
|
profileHonorId: honorId,
|
||||||
|
},
|
||||||
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
@ -161,6 +108,8 @@ export class ProfileHonorController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -187,15 +136,18 @@ export class ProfileHonorController extends Controller {
|
||||||
const history = new ProfileHonorHistory();
|
const history = new ProfileHonorHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileHonorId = honorId;
|
history.profileHonorId = honorId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([this.honorRepo.save(record), this.honorHistoryRepo.save(history)]);
|
await Promise.all([this.honorRepo.save(record), this.honorHistoryRepo.save(history)]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
Example,
|
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
Path,
|
Path,
|
||||||
|
|
@ -41,36 +40,18 @@ export class ProfileHonorEmployeeController extends Controller {
|
||||||
}
|
}
|
||||||
const record = await this.honorRepo.find({
|
const record = await this.honorRepo.find({
|
||||||
where: { profileEmployeeId: profile.id },
|
where: { profileEmployeeId: profile.id },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileEmployeeId}")
|
@Get("{profileEmployeeId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
|
||||||
createdAt: "2024-03-12T03:10:05.594Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-12T03:10:05.594Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
detail: "string",
|
|
||||||
issueDate: "2024-03-12T10:09:47.000Z",
|
|
||||||
issuer: "string",
|
|
||||||
refCommandDate: "2024-03-12T10:09:47.000Z",
|
|
||||||
refCommandNo: "string",
|
|
||||||
isDate: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async getHonor(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
public async getHonor(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
||||||
const record = await this.honorRepo.findBy({ profileEmployeeId });
|
const record = await this.honorRepo.find({
|
||||||
|
where: { profileEmployeeId: profileEmployeeId },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -91,57 +72,27 @@ export class ProfileHonorEmployeeController extends Controller {
|
||||||
profileEmployeeId: profile.id,
|
profileEmployeeId: profile.id,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{honorId}")
|
@Get("history/{honorId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "3bedb365-4a41-4df5-8f47-b6e143221d2c",
|
|
||||||
createdAt: "2024-03-12T03:11:01.395Z",
|
|
||||||
createdUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
lastUpdatedAt: "2024-03-12T03:11:01.395Z",
|
|
||||||
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
createdFullName: "string",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
detail: "detail",
|
|
||||||
issueDate: "2024-03-12T10:10:31.000Z",
|
|
||||||
issuer: "issuer",
|
|
||||||
refCommandDate: "2024-03-12T10:10:31.000Z",
|
|
||||||
refCommandNo: "refCommandNo",
|
|
||||||
isDate: true,
|
|
||||||
profileHonorId: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "ba0e2f82-014e-46c6-8b82-a7c28eb5325f",
|
|
||||||
createdAt: "2024-03-12T03:10:05.657Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-12T03:10:05.657Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
detail: "string",
|
|
||||||
issueDate: "2024-03-12T10:09:47.000Z",
|
|
||||||
issuer: "string",
|
|
||||||
refCommandDate: "2024-03-12T10:09:47.000Z",
|
|
||||||
refCommandNo: "string",
|
|
||||||
isDate: true,
|
|
||||||
profileHonorId: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async honorHistory(@Path() honorId: string, @Request() req: RequestWithUser) {
|
public async honorHistory(@Path() honorId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.honorRepo.findOneBy({ id: honorId });
|
const _record = await this.honorRepo.findOneBy({ id: honorId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
|
await new permission().PermissionOrgUserGet(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
_record.profileEmployeeId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const record = await this.honorHistoryRepo.findBy({
|
const record = await this.honorHistoryRepo.find({
|
||||||
|
where: {
|
||||||
profileHonorId: honorId,
|
profileHonorId: honorId,
|
||||||
|
},
|
||||||
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
@ -165,6 +116,8 @@ export class ProfileHonorEmployeeController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -186,20 +139,27 @@ export class ProfileHonorEmployeeController extends Controller {
|
||||||
) {
|
) {
|
||||||
const record = await this.honorRepo.findOneBy({ id: honorId });
|
const record = await this.honorRepo.findOneBy({ id: honorId });
|
||||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId)
|
await new permission().PermissionOrgUserUpdate(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
record.profileEmployeeId,
|
||||||
|
);
|
||||||
|
|
||||||
const history = new ProfileHonorHistory();
|
const history = new ProfileHonorHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileHonorId = honorId;
|
history.profileHonorId = honorId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([this.honorRepo.save(record), this.honorHistoryRepo.save(history)]);
|
await Promise.all([this.honorRepo.save(record), this.honorHistoryRepo.save(history)]);
|
||||||
|
|
||||||
|
|
@ -210,7 +170,11 @@ export class ProfileHonorEmployeeController extends Controller {
|
||||||
public async deleteTraning(@Path() honorId: string, @Request() req: RequestWithUser) {
|
public async deleteTraning(@Path() honorId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.honorRepo.findOneBy({ id: honorId });
|
const _record = await this.honorRepo.findOneBy({ id: honorId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
|
await new permission().PermissionOrgUserDelete(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
_record.profileEmployeeId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.honorHistoryRepo.delete({
|
await this.honorHistoryRepo.delete({
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
Example,
|
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
Path,
|
Path,
|
||||||
|
|
@ -41,36 +40,18 @@ export class ProfileHonorEmployeeTempController extends Controller {
|
||||||
}
|
}
|
||||||
const record = await this.honorRepo.find({
|
const record = await this.honorRepo.find({
|
||||||
where: { profileEmployeeId: profile.id },
|
where: { profileEmployeeId: profile.id },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileEmployeeId}")
|
@Get("{profileEmployeeId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
|
||||||
createdAt: "2024-03-12T03:10:05.594Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-12T03:10:05.594Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
detail: "string",
|
|
||||||
issueDate: "2024-03-12T10:09:47.000Z",
|
|
||||||
issuer: "string",
|
|
||||||
refCommandDate: "2024-03-12T10:09:47.000Z",
|
|
||||||
refCommandNo: "string",
|
|
||||||
isDate: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async getHonor(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
public async getHonor(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||||
const record = await this.honorRepo.findBy({ profileEmployeeId });
|
const record = await this.honorRepo.find({
|
||||||
|
where: { profileEmployeeId: profileEmployeeId },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -91,53 +72,19 @@ export class ProfileHonorEmployeeTempController extends Controller {
|
||||||
profileEmployeeId: profile.id,
|
profileEmployeeId: profile.id,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{honorId}")
|
@Get("history/{honorId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "3bedb365-4a41-4df5-8f47-b6e143221d2c",
|
|
||||||
createdAt: "2024-03-12T03:11:01.395Z",
|
|
||||||
createdUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
lastUpdatedAt: "2024-03-12T03:11:01.395Z",
|
|
||||||
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
createdFullName: "string",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
detail: "detail",
|
|
||||||
issueDate: "2024-03-12T10:10:31.000Z",
|
|
||||||
issuer: "issuer",
|
|
||||||
refCommandDate: "2024-03-12T10:10:31.000Z",
|
|
||||||
refCommandNo: "refCommandNo",
|
|
||||||
isDate: true,
|
|
||||||
profileHonorId: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "ba0e2f82-014e-46c6-8b82-a7c28eb5325f",
|
|
||||||
createdAt: "2024-03-12T03:10:05.657Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-12T03:10:05.657Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
detail: "string",
|
|
||||||
issueDate: "2024-03-12T10:09:47.000Z",
|
|
||||||
issuer: "string",
|
|
||||||
refCommandDate: "2024-03-12T10:09:47.000Z",
|
|
||||||
refCommandNo: "string",
|
|
||||||
isDate: true,
|
|
||||||
profileHonorId: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async honorHistory(@Path() honorId: string, @Request() req: RequestWithUser) {
|
public async honorHistory(@Path() honorId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||||
const record = await this.honorHistoryRepo.findBy({
|
const record = await this.honorHistoryRepo.find({
|
||||||
|
where: {
|
||||||
profileHonorId: honorId,
|
profileHonorId: honorId,
|
||||||
|
},
|
||||||
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
@ -162,6 +109,8 @@ export class ProfileHonorEmployeeTempController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -189,15 +138,18 @@ export class ProfileHonorEmployeeTempController extends Controller {
|
||||||
const history = new ProfileHonorHistory();
|
const history = new ProfileHonorHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileHonorId = honorId;
|
history.profileHonorId = honorId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([this.honorRepo.save(record), this.honorHistoryRepo.save(history)]);
|
await Promise.all([this.honorRepo.save(record), this.honorHistoryRepo.save(history)]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
Example,
|
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
Path,
|
Path,
|
||||||
|
|
@ -48,41 +47,12 @@ export class ProfileInsigniaController extends Controller {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
where: { profileId: profile.id },
|
where: { profileId: profile.id },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileId}")
|
@Get("{profileId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "c9d4dd52-25f5-491a-852d-28bfe00d66cb",
|
|
||||||
createdAt: "2024-03-12T03:05:09.393Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-12T03:05:09.393Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
year: 0,
|
|
||||||
no: "string",
|
|
||||||
volume: "string",
|
|
||||||
section: "string",
|
|
||||||
page: "string",
|
|
||||||
receiveDate: "2024-03-12T10:05:02.000Z",
|
|
||||||
insigniaId: "string",
|
|
||||||
insigniaType: "string",
|
|
||||||
dateAnnounce: "2024-03-12T10:05:02.000Z",
|
|
||||||
issue: "string",
|
|
||||||
volumeNo: "string",
|
|
||||||
refCommandDate: "2024-03-12T10:05:02.000Z",
|
|
||||||
refCommandNo: "string",
|
|
||||||
note: "string",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async getInsignia(@Path() profileId: string, @Request() req: RequestWithUser) {
|
public async getInsignia(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||||
const record = await this.insigniaRepo.find({
|
const record = await this.insigniaRepo.find({
|
||||||
|
|
@ -92,65 +62,12 @@ export class ProfileInsigniaController extends Controller {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
where: { profileId },
|
where: { profileId },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{InsigniaId}")
|
@Get("history/{InsigniaId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "c363d13c-88bd-4954-adf5-70d3f5ca9c30",
|
|
||||||
createdAt: "2024-03-12T03:06:31.062Z",
|
|
||||||
createdUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
lastUpdatedAt: "2024-03-12T03:06:31.062Z",
|
|
||||||
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
createdFullName: "string",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
year: 0,
|
|
||||||
no: "no",
|
|
||||||
volume: "volume",
|
|
||||||
section: "section",
|
|
||||||
page: "page",
|
|
||||||
receiveDate: "2024-03-12T10:05:44.000Z",
|
|
||||||
insigniaId: "insigniaId",
|
|
||||||
insigniaType: "insigniaType",
|
|
||||||
dateAnnounce: "2024-03-12T10:05:44.000Z",
|
|
||||||
issue: "string",
|
|
||||||
volumeNo: "volumeNo",
|
|
||||||
refCommandDate: "2024-03-12T10:05:44.000Z",
|
|
||||||
refCommandNo: "refCommandNo",
|
|
||||||
note: "string",
|
|
||||||
profileInsigniaId: "c9d4dd52-25f5-491a-852d-28bfe00d66cb",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "c9d4dd52-25f5-491a-852d-28bfe00d66cb",
|
|
||||||
createdAt: "2024-03-12T03:05:09.393Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-12T03:09:04.905Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
year: 0,
|
|
||||||
no: "string",
|
|
||||||
volume: "string",
|
|
||||||
section: "string",
|
|
||||||
page: "string",
|
|
||||||
receiveDate: "2024-03-12T10:05:02.000Z",
|
|
||||||
insigniaId: "string",
|
|
||||||
insigniaType: "string",
|
|
||||||
dateAnnounce: "2024-03-12T10:05:02.000Z",
|
|
||||||
issue: "string",
|
|
||||||
volumeNo: "string",
|
|
||||||
refCommandDate: "2024-03-12T10:05:02.000Z",
|
|
||||||
refCommandNo: "string",
|
|
||||||
note: "string",
|
|
||||||
profileInsigniaId: "c9d4dd52-25f5-491a-852d-28bfe00d66cb",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async getInsigniaHistory(@Path() InsigniaId: string, @Request() req: RequestWithUser) {
|
public async getInsigniaHistory(@Path() InsigniaId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.insigniaRepo.findOneBy({ id: InsigniaId });
|
const _record = await this.insigniaRepo.findOneBy({ id: InsigniaId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
|
|
@ -165,6 +82,7 @@ export class ProfileInsigniaController extends Controller {
|
||||||
where: {
|
where: {
|
||||||
profileInsigniaId: InsigniaId,
|
profileInsigniaId: InsigniaId,
|
||||||
},
|
},
|
||||||
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
@ -195,6 +113,8 @@ export class ProfileInsigniaController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -228,15 +148,18 @@ export class ProfileInsigniaController extends Controller {
|
||||||
const history = new ProfileInsigniaHistory();
|
const history = new ProfileInsigniaHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileInsigniaId = insigniaId;
|
history.profileInsigniaId = insigniaId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([this.insigniaRepo.save(record), this.insigniaHistoryRepo.save(history)]);
|
await Promise.all([this.insigniaRepo.save(record), this.insigniaHistoryRepo.save(history)]);
|
||||||
|
|
||||||
|
|
@ -247,7 +170,11 @@ export class ProfileInsigniaController extends Controller {
|
||||||
public async deleteInsignia(@Path() insigniaId: string, @Request() req: RequestWithUser) {
|
public async deleteInsignia(@Path() insigniaId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.insigniaRepo.findOneBy({ id: insigniaId });
|
const _record = await this.insigniaRepo.findOneBy({ id: insigniaId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
await new permission().PermissionOrgUserDelete(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_OFFICER",
|
||||||
|
_record.profileId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
await this.insigniaHistoryRepo.delete({
|
await this.insigniaHistoryRepo.delete({
|
||||||
profileInsigniaId: insigniaId,
|
profileInsigniaId: insigniaId,
|
||||||
|
|
@ -291,6 +218,8 @@ export class ProfileInsigniaController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
Example,
|
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
Path,
|
Path,
|
||||||
|
|
@ -48,41 +47,12 @@ export class ProfileInsigniaEmployeeController extends Controller {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
where: { profileEmployeeId: profile.id },
|
where: { profileEmployeeId: profile.id },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileEmployeeId}")
|
@Get("{profileEmployeeId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "c9d4dd52-25f5-491a-852d-28bfe00d66cb",
|
|
||||||
createdAt: "2024-03-12T03:05:09.393Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-12T03:05:09.393Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
year: 0,
|
|
||||||
no: "string",
|
|
||||||
volume: "string",
|
|
||||||
section: "string",
|
|
||||||
page: "string",
|
|
||||||
receiveDate: "2024-03-12T10:05:02.000Z",
|
|
||||||
insigniaId: "string",
|
|
||||||
insigniaType: "string",
|
|
||||||
dateAnnounce: "2024-03-12T10:05:02.000Z",
|
|
||||||
issue: "string",
|
|
||||||
volumeNo: "string",
|
|
||||||
refCommandDate: "2024-03-12T10:05:02.000Z",
|
|
||||||
refCommandNo: "string",
|
|
||||||
note: "string",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async getInsignia(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
public async getInsignia(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
||||||
const record = await this.insigniaRepo.find({
|
const record = await this.insigniaRepo.find({
|
||||||
|
|
@ -92,69 +62,20 @@ export class ProfileInsigniaEmployeeController extends Controller {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
where: { profileEmployeeId },
|
where: { profileEmployeeId },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{InsigniaId}")
|
@Get("history/{InsigniaId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "c363d13c-88bd-4954-adf5-70d3f5ca9c30",
|
|
||||||
createdAt: "2024-03-12T03:06:31.062Z",
|
|
||||||
createdUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
lastUpdatedAt: "2024-03-12T03:06:31.062Z",
|
|
||||||
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
createdFullName: "string",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
year: 0,
|
|
||||||
no: "no",
|
|
||||||
volume: "volume",
|
|
||||||
section: "section",
|
|
||||||
page: "page",
|
|
||||||
receiveDate: "2024-03-12T10:05:44.000Z",
|
|
||||||
insigniaId: "insigniaId",
|
|
||||||
insigniaType: "insigniaType",
|
|
||||||
dateAnnounce: "2024-03-12T10:05:44.000Z",
|
|
||||||
issue: "string",
|
|
||||||
volumeNo: "volumeNo",
|
|
||||||
refCommandDate: "2024-03-12T10:05:44.000Z",
|
|
||||||
refCommandNo: "refCommandNo",
|
|
||||||
note: "string",
|
|
||||||
profileInsigniaId: "c9d4dd52-25f5-491a-852d-28bfe00d66cb",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "c9d4dd52-25f5-491a-852d-28bfe00d66cb",
|
|
||||||
createdAt: "2024-03-12T03:05:09.393Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-12T03:09:04.905Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
year: 0,
|
|
||||||
no: "string",
|
|
||||||
volume: "string",
|
|
||||||
section: "string",
|
|
||||||
page: "string",
|
|
||||||
receiveDate: "2024-03-12T10:05:02.000Z",
|
|
||||||
insigniaId: "string",
|
|
||||||
insigniaType: "string",
|
|
||||||
dateAnnounce: "2024-03-12T10:05:02.000Z",
|
|
||||||
issue: "string",
|
|
||||||
volumeNo: "string",
|
|
||||||
refCommandDate: "2024-03-12T10:05:02.000Z",
|
|
||||||
refCommandNo: "string",
|
|
||||||
note: "string",
|
|
||||||
profileInsigniaId: "c9d4dd52-25f5-491a-852d-28bfe00d66cb",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async getInsigniaHistory(@Path() InsigniaId: string, @Request() req: RequestWithUser) {
|
public async getInsigniaHistory(@Path() InsigniaId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.insigniaRepo.findOneBy({ id: InsigniaId });
|
const _record = await this.insigniaRepo.findOneBy({ id: InsigniaId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
|
await new permission().PermissionOrgUserGet(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
_record.profileEmployeeId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
const record = await this.insigniaHistoryRepo.find({
|
const record = await this.insigniaHistoryRepo.find({
|
||||||
relations: {
|
relations: {
|
||||||
|
|
@ -165,6 +86,7 @@ export class ProfileInsigniaEmployeeController extends Controller {
|
||||||
where: {
|
where: {
|
||||||
profileInsigniaId: InsigniaId,
|
profileInsigniaId: InsigniaId,
|
||||||
},
|
},
|
||||||
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
@ -182,7 +104,7 @@ export class ProfileInsigniaEmployeeController extends Controller {
|
||||||
if (!profile) {
|
if (!profile) {
|
||||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||||
}
|
}
|
||||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profile.id)
|
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profile.id);
|
||||||
|
|
||||||
const insignia = await this.insigniaMetaRepo.findOne({
|
const insignia = await this.insigniaMetaRepo.findOne({
|
||||||
where: { id: body.insigniaId },
|
where: { id: body.insigniaId },
|
||||||
|
|
@ -198,6 +120,8 @@ export class ProfileInsigniaEmployeeController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -219,7 +143,11 @@ export class ProfileInsigniaEmployeeController extends Controller {
|
||||||
) {
|
) {
|
||||||
const record = await this.insigniaRepo.findOneBy({ id: insigniaId });
|
const record = await this.insigniaRepo.findOneBy({ id: insigniaId });
|
||||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId)
|
await new permission().PermissionOrgUserUpdate(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
record.profileEmployeeId,
|
||||||
|
);
|
||||||
|
|
||||||
const insignia = await this.insigniaMetaRepo.findOne({
|
const insignia = await this.insigniaMetaRepo.findOne({
|
||||||
where: { id: body.insigniaId },
|
where: { id: body.insigniaId },
|
||||||
|
|
@ -231,15 +159,18 @@ export class ProfileInsigniaEmployeeController extends Controller {
|
||||||
const history = new ProfileInsigniaHistory();
|
const history = new ProfileInsigniaHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileInsigniaId = insigniaId;
|
history.profileInsigniaId = insigniaId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([this.insigniaRepo.save(record), this.insigniaHistoryRepo.save(history)]);
|
await Promise.all([this.insigniaRepo.save(record), this.insigniaHistoryRepo.save(history)]);
|
||||||
|
|
||||||
|
|
@ -250,7 +181,11 @@ export class ProfileInsigniaEmployeeController extends Controller {
|
||||||
public async deleteInsignia(@Path() insigniaId: string, @Request() req: RequestWithUser) {
|
public async deleteInsignia(@Path() insigniaId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.insigniaRepo.findOneBy({ id: insigniaId });
|
const _record = await this.insigniaRepo.findOneBy({ id: insigniaId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
|
await new permission().PermissionOrgUserDelete(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
_record.profileEmployeeId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.insigniaHistoryRepo.delete({
|
await this.insigniaHistoryRepo.delete({
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
Example,
|
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
Path,
|
Path,
|
||||||
|
|
@ -48,41 +47,12 @@ export class ProfileInsigniaEmployeeTempController extends Controller {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
where: { profileEmployeeId: profile.id },
|
where: { profileEmployeeId: profile.id },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileEmployeeId}")
|
@Get("{profileEmployeeId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "c9d4dd52-25f5-491a-852d-28bfe00d66cb",
|
|
||||||
createdAt: "2024-03-12T03:05:09.393Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-12T03:05:09.393Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
year: 0,
|
|
||||||
no: "string",
|
|
||||||
volume: "string",
|
|
||||||
section: "string",
|
|
||||||
page: "string",
|
|
||||||
receiveDate: "2024-03-12T10:05:02.000Z",
|
|
||||||
insigniaId: "string",
|
|
||||||
insigniaType: "string",
|
|
||||||
dateAnnounce: "2024-03-12T10:05:02.000Z",
|
|
||||||
issue: "string",
|
|
||||||
volumeNo: "string",
|
|
||||||
refCommandDate: "2024-03-12T10:05:02.000Z",
|
|
||||||
refCommandNo: "string",
|
|
||||||
note: "string",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async getInsignia(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
public async getInsignia(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||||
const record = await this.insigniaRepo.find({
|
const record = await this.insigniaRepo.find({
|
||||||
|
|
@ -92,65 +62,12 @@ export class ProfileInsigniaEmployeeTempController extends Controller {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
where: { profileEmployeeId },
|
where: { profileEmployeeId },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{InsigniaId}")
|
@Get("history/{InsigniaId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "c363d13c-88bd-4954-adf5-70d3f5ca9c30",
|
|
||||||
createdAt: "2024-03-12T03:06:31.062Z",
|
|
||||||
createdUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
lastUpdatedAt: "2024-03-12T03:06:31.062Z",
|
|
||||||
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
createdFullName: "string",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
year: 0,
|
|
||||||
no: "no",
|
|
||||||
volume: "volume",
|
|
||||||
section: "section",
|
|
||||||
page: "page",
|
|
||||||
receiveDate: "2024-03-12T10:05:44.000Z",
|
|
||||||
insigniaId: "insigniaId",
|
|
||||||
insigniaType: "insigniaType",
|
|
||||||
dateAnnounce: "2024-03-12T10:05:44.000Z",
|
|
||||||
issue: "string",
|
|
||||||
volumeNo: "volumeNo",
|
|
||||||
refCommandDate: "2024-03-12T10:05:44.000Z",
|
|
||||||
refCommandNo: "refCommandNo",
|
|
||||||
note: "string",
|
|
||||||
profileInsigniaId: "c9d4dd52-25f5-491a-852d-28bfe00d66cb",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "c9d4dd52-25f5-491a-852d-28bfe00d66cb",
|
|
||||||
createdAt: "2024-03-12T03:05:09.393Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-12T03:09:04.905Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
year: 0,
|
|
||||||
no: "string",
|
|
||||||
volume: "string",
|
|
||||||
section: "string",
|
|
||||||
page: "string",
|
|
||||||
receiveDate: "2024-03-12T10:05:02.000Z",
|
|
||||||
insigniaId: "string",
|
|
||||||
insigniaType: "string",
|
|
||||||
dateAnnounce: "2024-03-12T10:05:02.000Z",
|
|
||||||
issue: "string",
|
|
||||||
volumeNo: "string",
|
|
||||||
refCommandDate: "2024-03-12T10:05:02.000Z",
|
|
||||||
refCommandNo: "string",
|
|
||||||
note: "string",
|
|
||||||
profileInsigniaId: "c9d4dd52-25f5-491a-852d-28bfe00d66cb",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async getInsigniaHistory(@Path() InsigniaId: string, @Request() req: RequestWithUser) {
|
public async getInsigniaHistory(@Path() InsigniaId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||||
const record = await this.insigniaHistoryRepo.find({
|
const record = await this.insigniaHistoryRepo.find({
|
||||||
|
|
@ -162,6 +79,7 @@ export class ProfileInsigniaEmployeeTempController extends Controller {
|
||||||
where: {
|
where: {
|
||||||
profileInsigniaId: InsigniaId,
|
profileInsigniaId: InsigniaId,
|
||||||
},
|
},
|
||||||
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
@ -196,6 +114,8 @@ export class ProfileInsigniaEmployeeTempController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -230,15 +150,18 @@ export class ProfileInsigniaEmployeeTempController extends Controller {
|
||||||
const history = new ProfileInsigniaHistory();
|
const history = new ProfileInsigniaHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileInsigniaId = insigniaId;
|
history.profileInsigniaId = insigniaId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([this.insigniaRepo.save(record), this.insigniaHistoryRepo.save(history)]);
|
await Promise.all([this.insigniaRepo.save(record), this.insigniaHistoryRepo.save(history)]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
Example,
|
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
Path,
|
Path,
|
||||||
|
|
@ -25,7 +24,6 @@ import HttpError from "../interfaces/http-error";
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
import { RequestWithUser } from "../middlewares/user";
|
||||||
import { Profile } from "../entities/Profile";
|
import { Profile } from "../entities/Profile";
|
||||||
import { LeaveType } from "../entities/LeaveType";
|
import { LeaveType } from "../entities/LeaveType";
|
||||||
import { Brackets } from "typeorm";
|
|
||||||
import permission from "../interfaces/permission";
|
import permission from "../interfaces/permission";
|
||||||
@Route("api/v1/org/profile/leave")
|
@Route("api/v1/org/profile/leave")
|
||||||
@Tags("ProfileLeave")
|
@Tags("ProfileLeave")
|
||||||
|
|
@ -121,50 +119,18 @@ export class ProfileLeaveController extends Controller {
|
||||||
const record = await this.leaveRepo.find({
|
const record = await this.leaveRepo.find({
|
||||||
relations: { leaveType: true },
|
relations: { leaveType: true },
|
||||||
where: { profileId: profile.id },
|
where: { profileId: profile.id },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileId}")
|
@Get("{profileId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: {
|
|
||||||
id: "adbb08a6-d2f4-41b0-a9c1-49e883ca96bc",
|
|
||||||
createdAt: "2024-03-20T23:35:45.230Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-20T23:40:06.000Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
leaveTypeId: "8dc5e672-b416-4323-b086-06dde8c4353c",
|
|
||||||
dateLeaveStart: "2024-03-21T06:39:46.000Z",
|
|
||||||
dateLeaveEnd: "2024-03-21T06:39:46.000Z",
|
|
||||||
leaveDays: 0,
|
|
||||||
leaveCount: null,
|
|
||||||
totalLeave: 0,
|
|
||||||
status: "string",
|
|
||||||
reason: "string",
|
|
||||||
leaveType: {
|
|
||||||
id: "8dc5e672-b416-4323-b086-06dde8c4353c",
|
|
||||||
createdAt: "2024-02-04T21:28:40.536Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-02-04T21:28:40.536Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
name: "ลาป่วย",
|
|
||||||
code: "CM-002",
|
|
||||||
limit: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
public async getLeave(@Path() profileId: string, @Request() req: RequestWithUser) {
|
public async getLeave(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||||
const record = await this.leaveRepo.find({
|
const record = await this.leaveRepo.find({
|
||||||
relations: { leaveType: true },
|
relations: { leaveType: true },
|
||||||
where: { profileId },
|
where: { profileId },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
@ -175,79 +141,12 @@ export class ProfileLeaveController extends Controller {
|
||||||
const record = await this.leaveRepo.find({
|
const record = await this.leaveRepo.find({
|
||||||
relations: { leaveType: true },
|
relations: { leaveType: true },
|
||||||
where: { profileId },
|
where: { profileId },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{leaveId}")
|
@Get("history/{leaveId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "7eed2e72-d71c-4b3b-a90b-e1b7abdaa838",
|
|
||||||
createdAt: "2024-03-20T23:35:45.230Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-20T23:40:06.000Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
leaveTypeId: "8dc5e672-b416-4323-b086-06dde8c4353c",
|
|
||||||
dateLeaveStart: "2024-03-21T06:39:46.000Z",
|
|
||||||
dateLeaveEnd: "2024-03-21T06:39:46.000Z",
|
|
||||||
leaveDays: 0,
|
|
||||||
leaveCount: null,
|
|
||||||
totalLeave: 0,
|
|
||||||
status: "string",
|
|
||||||
reason: "string",
|
|
||||||
leaveType: {
|
|
||||||
id: "8dc5e672-b416-4323-b086-06dde8c4353c",
|
|
||||||
createdAt: "2024-02-04T21:28:40.536Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-02-04T21:28:40.536Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
name: "ลาป่วย",
|
|
||||||
code: "CM-002",
|
|
||||||
limit: 1,
|
|
||||||
},
|
|
||||||
profileLeaveId: "adbb08a6-d2f4-41b0-a9c1-49e883ca96bc",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "b1b9c291-9c96-4cbb-9309-6ff5a2a6e0e8",
|
|
||||||
createdAt: "2024-03-20T23:35:45.230Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-20T23:35:45.230Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
leaveTypeId: "7dc4e314-b456-4323-b086-06dde8c4353c",
|
|
||||||
dateLeaveStart: "2024-03-21T06:34:49.000Z",
|
|
||||||
dateLeaveEnd: "2024-03-21T06:34:49.000Z",
|
|
||||||
leaveDays: 2,
|
|
||||||
leaveCount: null,
|
|
||||||
totalLeave: 200,
|
|
||||||
status: "ไม่ผ่าน",
|
|
||||||
reason: "ติดงานสำคัญ",
|
|
||||||
leaveType: {
|
|
||||||
id: "7dc4e314-b456-4323-b086-06dde8c4353c",
|
|
||||||
createdAt: "2024-02-04T21:28:40.536Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-02-04T21:28:40.536Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
name: "ลาพักร้อน",
|
|
||||||
code: "CM-001",
|
|
||||||
limit: 356,
|
|
||||||
},
|
|
||||||
profileLeaveId: "adbb08a6-d2f4-41b0-a9c1-49e883ca96bc",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async leaveHistory(@Path() leaveId: string, @Request() req: RequestWithUser) {
|
public async leaveHistory(@Path() leaveId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.leaveRepo.findOneBy({ id: leaveId });
|
const _record = await this.leaveRepo.findOneBy({ id: leaveId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
|
|
@ -256,6 +155,7 @@ export class ProfileLeaveController extends Controller {
|
||||||
const record = await this.leaveHistoryRepo.find({
|
const record = await this.leaveHistoryRepo.find({
|
||||||
relations: { leaveType: true },
|
relations: { leaveType: true },
|
||||||
where: { profileLeaveId: leaveId },
|
where: { profileLeaveId: leaveId },
|
||||||
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
@ -286,6 +186,8 @@ export class ProfileLeaveController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -319,15 +221,18 @@ export class ProfileLeaveController extends Controller {
|
||||||
const history = new ProfileLeaveHistory();
|
const history = new ProfileLeaveHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileLeaveId = leaveId;
|
history.profileLeaveId = leaveId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([this.leaveRepo.save(record), this.leaveHistoryRepo.save(history)]);
|
await Promise.all([this.leaveRepo.save(record), this.leaveHistoryRepo.save(history)]);
|
||||||
|
|
||||||
|
|
@ -338,7 +243,11 @@ export class ProfileLeaveController extends Controller {
|
||||||
public async deleteLeave(@Path() leaveId: string, @Request() req: RequestWithUser) {
|
public async deleteLeave(@Path() leaveId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.leaveRepo.findOneBy({ id: leaveId });
|
const _record = await this.leaveRepo.findOneBy({ id: leaveId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
await new permission().PermissionOrgUserDelete(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_OFFICER",
|
||||||
|
_record.profileId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
await this.leaveHistoryRepo.delete({
|
await this.leaveHistoryRepo.delete({
|
||||||
profileLeaveId: leaveId,
|
profileLeaveId: leaveId,
|
||||||
|
|
@ -378,6 +287,8 @@ export class ProfileLeaveController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
Example,
|
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
Path,
|
Path,
|
||||||
|
|
@ -44,6 +43,7 @@ export class ProfileLeaveEmployeeController extends Controller {
|
||||||
const record = await this.leaveRepo.find({
|
const record = await this.leaveRepo.find({
|
||||||
relations: { leaveType: true },
|
relations: { leaveType: true },
|
||||||
where: { profileEmployeeId: profile.id },
|
where: { profileEmployeeId: profile.id },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
@ -54,6 +54,7 @@ export class ProfileLeaveEmployeeController extends Controller {
|
||||||
const record = await this.leaveRepo.find({
|
const record = await this.leaveRepo.find({
|
||||||
relations: { leaveType: true },
|
relations: { leaveType: true },
|
||||||
where: { profileEmployeeId: profileId },
|
where: { profileEmployeeId: profileId },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
@ -64,6 +65,7 @@ export class ProfileLeaveEmployeeController extends Controller {
|
||||||
const record = await this.leaveRepo.find({
|
const record = await this.leaveRepo.find({
|
||||||
relations: { leaveType: true },
|
relations: { leaveType: true },
|
||||||
where: { profileEmployeeId: profileId },
|
where: { profileEmployeeId: profileId },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
@ -72,18 +74,22 @@ export class ProfileLeaveEmployeeController extends Controller {
|
||||||
public async leaveHistory(@Path() leaveId: string, @Request() req: RequestWithUser) {
|
public async leaveHistory(@Path() leaveId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.leaveRepo.findOneBy({ id: leaveId });
|
const _record = await this.leaveRepo.findOneBy({ id: leaveId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
|
await new permission().PermissionOrgUserGet(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
_record.profileEmployeeId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
const record = await this.leaveHistoryRepo.find({
|
const record = await this.leaveHistoryRepo.find({
|
||||||
relations: { leaveType: true },
|
relations: { leaveType: true },
|
||||||
where: { profileLeaveId: leaveId },
|
where: { profileLeaveId: leaveId },
|
||||||
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post()
|
@Post()
|
||||||
public async newLeave(@Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeLeave) {
|
public async newLeave(@Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeLeave) {
|
||||||
|
|
||||||
if (!body.profileEmployeeId) {
|
if (!body.profileEmployeeId) {
|
||||||
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
|
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
|
||||||
}
|
}
|
||||||
|
|
@ -108,6 +114,8 @@ export class ProfileLeaveEmployeeController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -129,7 +137,11 @@ export class ProfileLeaveEmployeeController extends Controller {
|
||||||
) {
|
) {
|
||||||
const record = await this.leaveRepo.findOneBy({ id: leaveId });
|
const record = await this.leaveRepo.findOneBy({ id: leaveId });
|
||||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId)
|
await new permission().PermissionOrgUserUpdate(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
record.profileEmployeeId,
|
||||||
|
);
|
||||||
|
|
||||||
const leaveType = await this.leaveTypeRepository.findOne({
|
const leaveType = await this.leaveTypeRepository.findOne({
|
||||||
where: { id: body.leaveTypeId },
|
where: { id: body.leaveTypeId },
|
||||||
|
|
@ -141,15 +153,18 @@ export class ProfileLeaveEmployeeController extends Controller {
|
||||||
const history = new ProfileLeaveHistory();
|
const history = new ProfileLeaveHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileLeaveId = leaveId;
|
history.profileLeaveId = leaveId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([this.leaveRepo.save(record), this.leaveHistoryRepo.save(history)]);
|
await Promise.all([this.leaveRepo.save(record), this.leaveHistoryRepo.save(history)]);
|
||||||
|
|
||||||
|
|
@ -160,7 +175,11 @@ export class ProfileLeaveEmployeeController extends Controller {
|
||||||
public async deleteLeave(@Path() leaveId: string, @Request() req: RequestWithUser) {
|
public async deleteLeave(@Path() leaveId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.leaveRepo.findOneBy({ id: leaveId });
|
const _record = await this.leaveRepo.findOneBy({ id: leaveId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
|
await new permission().PermissionOrgUserDelete(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
_record.profileEmployeeId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.leaveHistoryRepo.delete({
|
await this.leaveHistoryRepo.delete({
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
Example,
|
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
Path,
|
Path,
|
||||||
|
|
@ -44,6 +43,7 @@ export class ProfileLeaveEmployeeTempController extends Controller {
|
||||||
const record = await this.leaveRepo.find({
|
const record = await this.leaveRepo.find({
|
||||||
relations: { leaveType: true },
|
relations: { leaveType: true },
|
||||||
where: { profileEmployeeId: profile.id },
|
where: { profileEmployeeId: profile.id },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
@ -54,6 +54,7 @@ export class ProfileLeaveEmployeeTempController extends Controller {
|
||||||
const record = await this.leaveRepo.find({
|
const record = await this.leaveRepo.find({
|
||||||
relations: { leaveType: true },
|
relations: { leaveType: true },
|
||||||
where: { profileEmployeeId: profileId },
|
where: { profileEmployeeId: profileId },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
@ -64,6 +65,7 @@ export class ProfileLeaveEmployeeTempController extends Controller {
|
||||||
const record = await this.leaveRepo.find({
|
const record = await this.leaveRepo.find({
|
||||||
relations: { leaveType: true },
|
relations: { leaveType: true },
|
||||||
where: { profileEmployeeId: profileId },
|
where: { profileEmployeeId: profileId },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
@ -74,6 +76,7 @@ export class ProfileLeaveEmployeeTempController extends Controller {
|
||||||
const record = await this.leaveHistoryRepo.find({
|
const record = await this.leaveHistoryRepo.find({
|
||||||
relations: { leaveType: true },
|
relations: { leaveType: true },
|
||||||
where: { profileLeaveId: leaveId },
|
where: { profileLeaveId: leaveId },
|
||||||
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
@ -104,6 +107,8 @@ export class ProfileLeaveEmployeeTempController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -138,15 +143,18 @@ export class ProfileLeaveEmployeeTempController extends Controller {
|
||||||
const history = new ProfileLeaveHistory();
|
const history = new ProfileLeaveHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileLeaveId = leaveId;
|
history.profileLeaveId = leaveId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([this.leaveRepo.save(record), this.leaveHistoryRepo.save(history)]);
|
await Promise.all([this.leaveRepo.save(record), this.leaveHistoryRepo.save(history)]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
Example,
|
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
Path,
|
Path,
|
||||||
|
|
@ -37,61 +36,27 @@ export class ProfileNopaidController extends Controller {
|
||||||
}
|
}
|
||||||
const lists = await this.nopaidRepository.find({
|
const lists = await this.nopaidRepository.find({
|
||||||
where: { profileId: profile.id },
|
where: { profileId: profile.id },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileId}")
|
@Get("{profileId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
|
||||||
date: "2024-03-12T10:09:47.000Z",
|
|
||||||
reference: "string",
|
|
||||||
detail: "string",
|
|
||||||
refCommandNo: "string",
|
|
||||||
refCommandDate: "2024-03-12T10:09:47.000Z",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async getNopaid(@Path() profileId: string, @Request() req: RequestWithUser) {
|
public async getNopaid(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||||
const lists = await this.nopaidRepository.find({
|
const lists = await this.nopaidRepository.find({
|
||||||
where: { profileId },
|
where: { profileId },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{nopaidId}")
|
@Get("history/{nopaidId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
|
||||||
date: "2024-03-12T10:09:47.000Z",
|
|
||||||
reference: "string",
|
|
||||||
detail: "string",
|
|
||||||
refCommandNo: "string",
|
|
||||||
refCommandDate: "2024-03-12T10:09:47.000Z",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
|
||||||
date: "2024-03-12T10:09:47.000Z",
|
|
||||||
reference: "string",
|
|
||||||
detail: "string",
|
|
||||||
refCommandNo: "string",
|
|
||||||
refCommandDate: "2024-03-12T10:09:47.000Z",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async nopaidHistory(@Path() nopaidId: string, @Request() req: RequestWithUser) {
|
public async nopaidHistory(@Path() nopaidId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.nopaidRepository.findOneBy({ id: nopaidId });
|
const _record = await this.nopaidRepository.findOneBy({ id: nopaidId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
||||||
};
|
}
|
||||||
const record = await this.nopaidHistoryRepository.find({
|
const record = await this.nopaidHistoryRepository.find({
|
||||||
where: { profileNopaidId: nopaidId },
|
where: { profileNopaidId: nopaidId },
|
||||||
order: { createdAt: "DESC" },
|
order: { createdAt: "DESC" },
|
||||||
|
|
@ -118,6 +83,8 @@ export class ProfileNopaidController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -144,15 +111,18 @@ export class ProfileNopaidController extends Controller {
|
||||||
const history = new ProfileNopaidHistory();
|
const history = new ProfileNopaidHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileNopaidId = nopaidId;
|
history.profileNopaidId = nopaidId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.nopaidRepository.save(record),
|
this.nopaidRepository.save(record),
|
||||||
|
|
@ -166,7 +136,11 @@ export class ProfileNopaidController extends Controller {
|
||||||
public async deleteNopaid(@Path() nopaidId: string, @Request() req: RequestWithUser) {
|
public async deleteNopaid(@Path() nopaidId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.nopaidRepository.findOneBy({ id: nopaidId });
|
const _record = await this.nopaidRepository.findOneBy({ id: nopaidId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
await new permission().PermissionOrgUserDelete(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_OFFICER",
|
||||||
|
_record.profileId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
await this.nopaidHistoryRepository.delete({
|
await this.nopaidHistoryRepository.delete({
|
||||||
profileNopaidId: nopaidId,
|
profileNopaidId: nopaidId,
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
Example,
|
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
Path,
|
Path,
|
||||||
|
|
@ -41,20 +40,24 @@ export class ProfileNopaidEmployeeController extends Controller {
|
||||||
}
|
}
|
||||||
const lists = await this.nopaidRepository.find({
|
const lists = await this.nopaidRepository.find({
|
||||||
where: { profileEmployeeId: profile.id },
|
where: { profileEmployeeId: profile.id },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileId}")
|
@Get("{profileId}")
|
||||||
public async getNopaid(@Path() profileId: string) {
|
public async getNopaid(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||||
|
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||||
const lists = await this.nopaidRepository.find({
|
const lists = await this.nopaidRepository.find({
|
||||||
where: { profileEmployeeId: profileId },
|
where: { profileEmployeeId: profileId },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{nopaidId}")
|
@Get("history/{nopaidId}")
|
||||||
public async nopaidHistory(@Path() nopaidId: string) {
|
public async nopaidHistory(@Path() nopaidId: string, @Request() req: RequestWithUser) {
|
||||||
|
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||||
const record = await this.nopaidHistoryRepository.find({
|
const record = await this.nopaidHistoryRepository.find({
|
||||||
where: { profileNopaidId: nopaidId },
|
where: { profileNopaidId: nopaidId },
|
||||||
order: { createdAt: "DESC" },
|
order: { createdAt: "DESC" },
|
||||||
|
|
@ -67,7 +70,6 @@ export class ProfileNopaidEmployeeController extends Controller {
|
||||||
@Request() req: RequestWithUser,
|
@Request() req: RequestWithUser,
|
||||||
@Body() body: CreateProfileEmployeeNopaid,
|
@Body() body: CreateProfileEmployeeNopaid,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
if (!body.profileEmployeeId) {
|
if (!body.profileEmployeeId) {
|
||||||
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
|
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
|
||||||
}
|
}
|
||||||
|
|
@ -85,6 +87,8 @@ export class ProfileNopaidEmployeeController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -106,20 +110,27 @@ export class ProfileNopaidEmployeeController extends Controller {
|
||||||
) {
|
) {
|
||||||
const record = await this.nopaidRepository.findOneBy({ id: nopaidId });
|
const record = await this.nopaidRepository.findOneBy({ id: nopaidId });
|
||||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId)
|
await new permission().PermissionOrgUserUpdate(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
record.profileEmployeeId,
|
||||||
|
);
|
||||||
|
|
||||||
const history = new ProfileNopaidHistory();
|
const history = new ProfileNopaidHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileNopaidId = nopaidId;
|
history.profileNopaidId = nopaidId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.nopaidRepository.save(record),
|
this.nopaidRepository.save(record),
|
||||||
|
|
@ -133,7 +144,11 @@ export class ProfileNopaidEmployeeController extends Controller {
|
||||||
public async deleteNopaid(@Path() nopaidId: string, @Request() req: RequestWithUser) {
|
public async deleteNopaid(@Path() nopaidId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.nopaidRepository.findOneBy({ id: nopaidId });
|
const _record = await this.nopaidRepository.findOneBy({ id: nopaidId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
|
await new permission().PermissionOrgUserDelete(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
_record.profileEmployeeId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.nopaidHistoryRepository.delete({
|
await this.nopaidHistoryRepository.delete({
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
Example,
|
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
Path,
|
Path,
|
||||||
|
|
@ -41,6 +40,7 @@ export class ProfileNopaidEmployeeTempController extends Controller {
|
||||||
}
|
}
|
||||||
const lists = await this.nopaidRepository.find({
|
const lists = await this.nopaidRepository.find({
|
||||||
where: { profileEmployeeId: profile.id },
|
where: { profileEmployeeId: profile.id },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
@ -50,6 +50,7 @@ export class ProfileNopaidEmployeeTempController extends Controller {
|
||||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||||
const lists = await this.nopaidRepository.find({
|
const lists = await this.nopaidRepository.find({
|
||||||
where: { profileEmployeeId: profileId },
|
where: { profileEmployeeId: profileId },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
@ -87,6 +88,8 @@ export class ProfileNopaidEmployeeTempController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -114,15 +117,18 @@ export class ProfileNopaidEmployeeTempController extends Controller {
|
||||||
const history = new ProfileNopaidHistory();
|
const history = new ProfileNopaidHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileNopaidId = nopaidId;
|
history.profileNopaidId = nopaidId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.nopaidRepository.save(record),
|
this.nopaidRepository.save(record),
|
||||||
|
|
|
||||||
|
|
@ -37,53 +37,22 @@ export class ProfileOtherController extends Controller {
|
||||||
}
|
}
|
||||||
const lists = await this.otherRepository.find({
|
const lists = await this.otherRepository.find({
|
||||||
where: { profileId: profile.id },
|
where: { profileId: profile.id },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileId}")
|
@Get("{profileId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
|
||||||
isActive: true,
|
|
||||||
date: "2024-03-12T10:09:47.000Z",
|
|
||||||
reference: "string",
|
|
||||||
detail: "string",
|
|
||||||
refCommandNo: "string",
|
|
||||||
refCommandDate: "2024-03-12T10:09:47.000Z",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async getOther(@Path() profileId: string, @Request() req: RequestWithUser) {
|
public async getOther(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||||
const lists = await this.otherRepository.find({
|
const lists = await this.otherRepository.find({
|
||||||
where: { profileId: profileId },
|
where: { profileId: profileId },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{otherId}")
|
@Get("history/{otherId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
|
||||||
isActive: true,
|
|
||||||
date: "2024-03-12T10:09:47.000Z",
|
|
||||||
detail: "string",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
|
||||||
isActive: true,
|
|
||||||
date: "2024-03-12T10:09:47.000Z",
|
|
||||||
detail: "string",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async otherHistory(@Path() otherId: string, @Request() req: RequestWithUser) {
|
public async otherHistory(@Path() otherId: string, @Request() req: RequestWithUser) {
|
||||||
// const _record = await this.otherRepository.findOneBy({ id: otherId });
|
// const _record = await this.otherRepository.findOneBy({ id: otherId });
|
||||||
// if (_record) {
|
// if (_record) {
|
||||||
|
|
@ -115,6 +84,8 @@ export class ProfileOtherController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -141,15 +112,18 @@ export class ProfileOtherController extends Controller {
|
||||||
const history = new ProfileOtherHistory();
|
const history = new ProfileOtherHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileOtherId = otherId;
|
history.profileOtherId = otherId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.otherRepository.save(record),
|
this.otherRepository.save(record),
|
||||||
|
|
@ -163,7 +137,11 @@ export class ProfileOtherController extends Controller {
|
||||||
public async deleteOther(@Path() otherId: string, @Request() req: RequestWithUser) {
|
public async deleteOther(@Path() otherId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.otherRepository.findOneBy({ id: otherId });
|
const _record = await this.otherRepository.findOneBy({ id: otherId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
await new permission().PermissionOrgUserDelete(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_OFFICER",
|
||||||
|
_record.profileId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
await this.otherHistoryRepository.delete({
|
await this.otherHistoryRepository.delete({
|
||||||
profileOtherId: otherId,
|
profileOtherId: otherId,
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
Example,
|
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
Path,
|
Path,
|
||||||
|
|
@ -41,6 +40,7 @@ export class ProfileOtherEmployeeController extends Controller {
|
||||||
}
|
}
|
||||||
const lists = await this.otherRepository.find({
|
const lists = await this.otherRepository.find({
|
||||||
where: { profileEmployeeId: profile.id },
|
where: { profileEmployeeId: profile.id },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
@ -50,6 +50,7 @@ export class ProfileOtherEmployeeController extends Controller {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId);
|
||||||
const lists = await this.otherRepository.find({
|
const lists = await this.otherRepository.find({
|
||||||
where: { profileEmployeeId: profileId },
|
where: { profileEmployeeId: profileId },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
@ -58,7 +59,11 @@ export class ProfileOtherEmployeeController extends Controller {
|
||||||
public async otherHistory(@Path() otherId: string, @Request() req: RequestWithUser) {
|
public async otherHistory(@Path() otherId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.otherRepository.findOneBy({ id: otherId });
|
const _record = await this.otherRepository.findOneBy({ id: otherId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
|
await new permission().PermissionOrgUserGet(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
_record.profileEmployeeId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
const record = await this.otherHistoryRepository.find({
|
const record = await this.otherHistoryRepository.find({
|
||||||
where: { profileOtherId: otherId },
|
where: { profileOtherId: otherId },
|
||||||
|
|
@ -86,6 +91,8 @@ export class ProfileOtherEmployeeController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -105,23 +112,29 @@ export class ProfileOtherEmployeeController extends Controller {
|
||||||
@Body() body: UpdateProfileOther,
|
@Body() body: UpdateProfileOther,
|
||||||
@Path() otherId: string,
|
@Path() otherId: string,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
const record = await this.otherRepository.findOneBy({ id: otherId });
|
const record = await this.otherRepository.findOneBy({ id: otherId });
|
||||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId)
|
await new permission().PermissionOrgUserUpdate(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
record.profileEmployeeId,
|
||||||
|
);
|
||||||
|
|
||||||
const history = new ProfileOtherHistory();
|
const history = new ProfileOtherHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileOtherId = otherId;
|
history.profileOtherId = otherId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.otherRepository.save(record),
|
this.otherRepository.save(record),
|
||||||
|
|
@ -135,7 +148,11 @@ export class ProfileOtherEmployeeController extends Controller {
|
||||||
public async deleteOther(@Path() otherId: string, @Request() req: RequestWithUser) {
|
public async deleteOther(@Path() otherId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.otherRepository.findOneBy({ id: otherId });
|
const _record = await this.otherRepository.findOneBy({ id: otherId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
|
await new permission().PermissionOrgUserDelete(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
_record.profileEmployeeId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.otherHistoryRepository.delete({
|
await this.otherHistoryRepository.delete({
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ export class ProfileOtherEmployeeTempController extends Controller {
|
||||||
}
|
}
|
||||||
const lists = await this.otherRepository.find({
|
const lists = await this.otherRepository.find({
|
||||||
where: { profileEmployeeId: profile.id },
|
where: { profileEmployeeId: profile.id },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
@ -50,6 +51,7 @@ export class ProfileOtherEmployeeTempController extends Controller {
|
||||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||||
const lists = await this.otherRepository.find({
|
const lists = await this.otherRepository.find({
|
||||||
where: { profileEmployeeId: profileId },
|
where: { profileEmployeeId: profileId },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(lists);
|
||||||
}
|
}
|
||||||
|
|
@ -84,6 +86,8 @@ export class ProfileOtherEmployeeTempController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -111,15 +115,18 @@ export class ProfileOtherEmployeeTempController extends Controller {
|
||||||
const history = new ProfileOtherHistory();
|
const history = new ProfileOtherHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileOtherId = otherId;
|
history.profileOtherId = otherId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.otherRepository.save(record),
|
this.otherRepository.save(record),
|
||||||
|
|
|
||||||
|
|
@ -44,34 +44,6 @@ export class ProfileSalaryController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileId}")
|
@Get("{profileId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "3cf02fb7-2f0c-471b-b641-51d557375c0a",
|
|
||||||
createdAt: "2024-03-12T02:55:56.915Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-12T02:55:56.915Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
isActive: true,
|
|
||||||
startDate: "2024-03-12T09:55:23.000Z",
|
|
||||||
endDate: "2024-03-12T09:55:23.000Z",
|
|
||||||
numberOrder: "string",
|
|
||||||
topic: "string",
|
|
||||||
place: "string",
|
|
||||||
dateOrder: "2024-03-12T09:55:23.000Z",
|
|
||||||
department: "string",
|
|
||||||
duration: "string",
|
|
||||||
name: "string",
|
|
||||||
yearly: 0,
|
|
||||||
isDate: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async getSalary(@Path() profileId: string, @Request() req: RequestWithUser) {
|
public async getSalary(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||||
const record = await this.salaryRepo.find({
|
const record = await this.salaryRepo.find({
|
||||||
|
|
@ -92,63 +64,16 @@ export class ProfileSalaryController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{salaryId}")
|
@Get("history/{salaryId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "6d4e9dbe-8697-4546-9651-0a1c3ea0a82d",
|
|
||||||
createdAt: "2024-03-12T02:55:56.971Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-12T02:55:56.971Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
isActive: true,
|
|
||||||
startDate: "2024-03-12T09:55:23.000Z",
|
|
||||||
endDate: "2024-03-12T09:55:23.000Z",
|
|
||||||
numberOrder: "string",
|
|
||||||
topic: "string",
|
|
||||||
place: "string",
|
|
||||||
dateOrder: "2024-03-12T09:55:23.000Z",
|
|
||||||
department: "string",
|
|
||||||
duration: "string",
|
|
||||||
name: "string",
|
|
||||||
yearly: 0,
|
|
||||||
isDate: true,
|
|
||||||
profileSalaryId: "3cf02fb7-2f0c-471b-b641-51d557375c0a",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "a251c176-3dac-4d09-9813-38c8db1127e3",
|
|
||||||
createdAt: "2024-03-12T02:58:17.917Z",
|
|
||||||
createdUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
lastUpdatedAt: "2024-03-12T02:58:17.917Z",
|
|
||||||
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
createdFullName: "string",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
isActive: true,
|
|
||||||
startDate: "2024-03-12T09:57:44.000Z",
|
|
||||||
endDate: "2024-03-12T09:57:44.000Z",
|
|
||||||
numberOrder: "string",
|
|
||||||
topic: "topic",
|
|
||||||
place: "place",
|
|
||||||
dateOrder: "2024-03-12T09:57:44.000Z",
|
|
||||||
department: "department",
|
|
||||||
duration: "string",
|
|
||||||
name: "name",
|
|
||||||
yearly: 0,
|
|
||||||
isDate: true,
|
|
||||||
profileSalaryId: "3cf02fb7-2f0c-471b-b641-51d557375c0a",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async salaryHistory(@Path() salaryId: string, @Request() req: RequestWithUser) {
|
public async salaryHistory(@Path() salaryId: string, @Request() req: RequestWithUser) {
|
||||||
// const _record = await this.salaryRepo.findOneBy({ id: salaryId });
|
// const _record = await this.salaryRepo.findOneBy({ id: salaryId });
|
||||||
// if (_record) {
|
// if (_record) {
|
||||||
// await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
// await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
||||||
// }
|
// }
|
||||||
const record = await this.salaryHistoryRepo.findBy({
|
const record = await this.salaryHistoryRepo.find({
|
||||||
|
where: {
|
||||||
profileSalaryId: salaryId,
|
profileSalaryId: salaryId,
|
||||||
|
},
|
||||||
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
@ -178,6 +103,8 @@ export class ProfileSalaryController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -204,15 +131,18 @@ export class ProfileSalaryController extends Controller {
|
||||||
const history = new ProfileSalaryHistory();
|
const history = new ProfileSalaryHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileSalaryId = salaryId;
|
history.profileSalaryId = salaryId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([this.salaryRepo.save(record), this.salaryHistoryRepo.save(history)]);
|
await Promise.all([this.salaryRepo.save(record), this.salaryHistoryRepo.save(history)]);
|
||||||
|
|
||||||
|
|
@ -223,7 +153,11 @@ export class ProfileSalaryController extends Controller {
|
||||||
public async deleteSalary(@Path() salaryId: string, @Request() req: RequestWithUser) {
|
public async deleteSalary(@Path() salaryId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.salaryRepo.findOneBy({ id: salaryId });
|
const _record = await this.salaryRepo.findOneBy({ id: salaryId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
await new permission().PermissionOrgUserDelete(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_OFFICER",
|
||||||
|
_record.profileId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
await this.salaryHistoryRepo.delete({
|
await this.salaryHistoryRepo.delete({
|
||||||
profileSalaryId: salaryId,
|
profileSalaryId: salaryId,
|
||||||
|
|
@ -239,7 +173,11 @@ export class ProfileSalaryController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("swap/{direction}/{salaryId}")
|
@Get("swap/{direction}/{salaryId}")
|
||||||
public async swapSalary(@Path() direction: string, salaryId: string, @Request() req: RequestWithUser) {
|
public async swapSalary(
|
||||||
|
@Path() direction: string,
|
||||||
|
salaryId: string,
|
||||||
|
@Request() req: RequestWithUser,
|
||||||
|
) {
|
||||||
const source_item = await this.salaryRepo.findOne({ where: { id: salaryId } });
|
const source_item = await this.salaryRepo.findOne({ where: { id: salaryId } });
|
||||||
// if (source_item) {
|
// if (source_item) {
|
||||||
// await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", source_item.profileId);//ไม่แน่ใจOFFปิดไว้ก่อน
|
// await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", source_item.profileId);//ไม่แน่ใจOFFปิดไว้ก่อน
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
Example,
|
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
Path,
|
Path,
|
||||||
|
|
@ -49,10 +48,7 @@ export class ProfileSalaryEmployeeController extends Controller {
|
||||||
|
|
||||||
@Get("{profileId}")
|
@Get("{profileId}")
|
||||||
public async getSalaryEmployee(@Path() profileId: string, @Request() req: RequestWithUser) {
|
public async getSalaryEmployee(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||||
// const _record = await this.salaryRepo.findOneBy({ id: profileId });
|
|
||||||
// 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({
|
const record = await this.salaryRepo.find({
|
||||||
where: { profileEmployeeId: profileId },
|
where: { profileEmployeeId: profileId },
|
||||||
order: { order: "ASC" },
|
order: { order: "ASC" },
|
||||||
|
|
@ -63,10 +59,6 @@ export class ProfileSalaryEmployeeController extends Controller {
|
||||||
@Get("admin/{profileId}")
|
@Get("admin/{profileId}")
|
||||||
public async getSalaryEmployeeAdmin(@Path() profileId: string, @Request() req: RequestWithUser) {
|
public async getSalaryEmployeeAdmin(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionGet(req, "SYS_WAGE");
|
await new permission().PermissionGet(req, "SYS_WAGE");
|
||||||
// const _record = await this.salaryRepo.findOneBy({ id: profileId });
|
|
||||||
// if (_record) {
|
|
||||||
// await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId);
|
|
||||||
// }
|
|
||||||
const record = await this.salaryRepo.find({
|
const record = await this.salaryRepo.find({
|
||||||
where: { profileEmployeeId: profileId },
|
where: { profileEmployeeId: profileId },
|
||||||
order: { order: "ASC" },
|
order: { order: "ASC" },
|
||||||
|
|
@ -78,10 +70,17 @@ export class ProfileSalaryEmployeeController extends Controller {
|
||||||
public async salaryHistory(@Path() salaryId: string, @Request() req: RequestWithUser) {
|
public async salaryHistory(@Path() salaryId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.salaryRepo.findOneBy({ id: salaryId });
|
const _record = await this.salaryRepo.findOneBy({ id: salaryId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
|
await new permission().PermissionOrgUserGet(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
_record.profileEmployeeId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
const record = await this.salaryHistoryRepo.findBy({
|
const record = await this.salaryHistoryRepo.find({
|
||||||
|
where: {
|
||||||
profileSalaryId: salaryId,
|
profileSalaryId: salaryId,
|
||||||
|
},
|
||||||
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
@ -114,6 +113,8 @@ export class ProfileSalaryEmployeeController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -133,23 +134,29 @@ export class ProfileSalaryEmployeeController extends Controller {
|
||||||
@Body() body: UpdateProfileSalaryEmployee,
|
@Body() body: UpdateProfileSalaryEmployee,
|
||||||
@Path() salaryId: string,
|
@Path() salaryId: string,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
const record = await this.salaryRepo.findOneBy({ id: salaryId });
|
const record = await this.salaryRepo.findOneBy({ id: salaryId });
|
||||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId)
|
await new permission().PermissionOrgUserUpdate(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
record.profileEmployeeId,
|
||||||
|
);
|
||||||
|
|
||||||
const history = new ProfileSalaryHistory();
|
const history = new ProfileSalaryHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileSalaryId = salaryId;
|
history.profileSalaryId = salaryId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([this.salaryRepo.save(record), this.salaryHistoryRepo.save(history)]);
|
await Promise.all([this.salaryRepo.save(record), this.salaryHistoryRepo.save(history)]);
|
||||||
|
|
||||||
|
|
@ -160,7 +167,11 @@ export class ProfileSalaryEmployeeController extends Controller {
|
||||||
public async deleteSalaryEmployee(@Path() salaryId: string, @Request() req: RequestWithUser) {
|
public async deleteSalaryEmployee(@Path() salaryId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.salaryRepo.findOneBy({ id: salaryId });
|
const _record = await this.salaryRepo.findOneBy({ id: salaryId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
|
await new permission().PermissionOrgUserDelete(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
_record.profileEmployeeId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.salaryHistoryRepo.delete({
|
await this.salaryHistoryRepo.delete({
|
||||||
|
|
@ -177,10 +188,18 @@ export class ProfileSalaryEmployeeController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("swap/{direction}/{salaryId}")
|
@Get("swap/{direction}/{salaryId}")
|
||||||
public async swapSalaryEmployee(@Path() direction: string, salaryId: string, @Request() req: RequestWithUser) {
|
public async swapSalaryEmployee(
|
||||||
|
@Path() direction: string,
|
||||||
|
salaryId: string,
|
||||||
|
@Request() req: RequestWithUser,
|
||||||
|
) {
|
||||||
const _record = await this.salaryRepo.findOneBy({ id: salaryId });
|
const _record = await this.salaryRepo.findOneBy({ id: salaryId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
|
await new permission().PermissionOrgUserGet(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
_record.profileEmployeeId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
const source_item = await this.salaryRepo.findOne({ where: { id: salaryId } });
|
const source_item = await this.salaryRepo.findOne({ where: { id: salaryId } });
|
||||||
if (source_item == null) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (source_item == null) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
Example,
|
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
Path,
|
Path,
|
||||||
|
|
@ -70,8 +69,11 @@ export class ProfileSalaryEmployeeTempController extends Controller {
|
||||||
@Get("history/{salaryId}")
|
@Get("history/{salaryId}")
|
||||||
public async salaryHistory(@Path() salaryId: string, @Request() req: RequestWithUser) {
|
public async salaryHistory(@Path() salaryId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||||
const record = await this.salaryHistoryRepo.findBy({
|
const record = await this.salaryHistoryRepo.find({
|
||||||
|
where: {
|
||||||
profileSalaryId: salaryId,
|
profileSalaryId: salaryId,
|
||||||
|
},
|
||||||
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
@ -105,6 +107,8 @@ export class ProfileSalaryEmployeeTempController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -132,15 +136,18 @@ export class ProfileSalaryEmployeeTempController extends Controller {
|
||||||
const history = new ProfileSalaryHistory();
|
const history = new ProfileSalaryHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileSalaryId = salaryId;
|
history.profileSalaryId = salaryId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([this.salaryRepo.save(record), this.salaryHistoryRepo.save(history)]);
|
await Promise.all([this.salaryRepo.save(record), this.salaryHistoryRepo.save(history)]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
Example,
|
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
Path,
|
Path,
|
||||||
|
|
@ -41,103 +40,32 @@ export class ProfileTrainingController extends Controller {
|
||||||
}
|
}
|
||||||
const record = await this.trainingRepo.find({
|
const record = await this.trainingRepo.find({
|
||||||
where: { profileId: profile.id },
|
where: { profileId: profile.id },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileId}")
|
@Get("{profileId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "3cf02fb7-2f0c-471b-b641-51d557375c0a",
|
|
||||||
createdAt: "2024-03-12T02:55:56.915Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-12T02:55:56.915Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
isActive: true,
|
|
||||||
startDate: "2024-03-12T09:55:23.000Z",
|
|
||||||
endDate: "2024-03-12T09:55:23.000Z",
|
|
||||||
numberOrder: "string",
|
|
||||||
topic: "string",
|
|
||||||
place: "string",
|
|
||||||
dateOrder: "2024-03-12T09:55:23.000Z",
|
|
||||||
department: "string",
|
|
||||||
duration: "string",
|
|
||||||
name: "string",
|
|
||||||
yearly: 0,
|
|
||||||
isDate: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async getTraining(@Path() profileId: string, @Request() req: RequestWithUser) {
|
public async getTraining(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||||
const record = await this.trainingRepo.findBy({ profileId });
|
const record = await this.trainingRepo.find({
|
||||||
|
where: { profileId },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{trainingId}")
|
@Get("history/{trainingId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "6d4e9dbe-8697-4546-9651-0a1c3ea0a82d",
|
|
||||||
createdAt: "2024-03-12T02:55:56.971Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-12T02:55:56.971Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
isActive: true,
|
|
||||||
startDate: "2024-03-12T09:55:23.000Z",
|
|
||||||
endDate: "2024-03-12T09:55:23.000Z",
|
|
||||||
numberOrder: "string",
|
|
||||||
topic: "string",
|
|
||||||
place: "string",
|
|
||||||
dateOrder: "2024-03-12T09:55:23.000Z",
|
|
||||||
department: "string",
|
|
||||||
duration: "string",
|
|
||||||
name: "string",
|
|
||||||
yearly: 0,
|
|
||||||
isDate: true,
|
|
||||||
profileTrainingId: "3cf02fb7-2f0c-471b-b641-51d557375c0a",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "a251c176-3dac-4d09-9813-38c8db1127e3",
|
|
||||||
createdAt: "2024-03-12T02:58:17.917Z",
|
|
||||||
createdUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
lastUpdatedAt: "2024-03-12T02:58:17.917Z",
|
|
||||||
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
createdFullName: "string",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
isActive: true,
|
|
||||||
startDate: "2024-03-12T09:57:44.000Z",
|
|
||||||
endDate: "2024-03-12T09:57:44.000Z",
|
|
||||||
numberOrder: "string",
|
|
||||||
topic: "topic",
|
|
||||||
place: "place",
|
|
||||||
dateOrder: "2024-03-12T09:57:44.000Z",
|
|
||||||
department: "department",
|
|
||||||
duration: "string",
|
|
||||||
name: "name",
|
|
||||||
yearly: 0,
|
|
||||||
isDate: true,
|
|
||||||
profileTrainingId: "3cf02fb7-2f0c-471b-b641-51d557375c0a",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async trainingHistory(@Path() trainingId: string, @Request() req: RequestWithUser) {
|
public async trainingHistory(@Path() trainingId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.trainingRepo.findOneBy({ id: trainingId });
|
const _record = await this.trainingRepo.findOneBy({ id: trainingId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
||||||
}
|
}
|
||||||
const record = await this.trainingHistoryRepo.findBy({
|
const record = await this.trainingHistoryRepo.find({
|
||||||
|
where: {
|
||||||
profileTrainingId: trainingId,
|
profileTrainingId: trainingId,
|
||||||
|
},
|
||||||
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
@ -161,6 +89,8 @@ export class ProfileTrainingController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -187,15 +117,18 @@ export class ProfileTrainingController extends Controller {
|
||||||
const history = new ProfileTrainingHistory();
|
const history = new ProfileTrainingHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileTrainingId = trainingId;
|
history.profileTrainingId = trainingId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([this.trainingRepo.save(record), this.trainingHistoryRepo.save(history)]);
|
await Promise.all([this.trainingRepo.save(record), this.trainingHistoryRepo.save(history)]);
|
||||||
|
|
||||||
|
|
@ -206,7 +139,11 @@ export class ProfileTrainingController extends Controller {
|
||||||
public async deleteTraining(@Path() trainingId: string, @Request() req: RequestWithUser) {
|
public async deleteTraining(@Path() trainingId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.trainingRepo.findOneBy({ id: trainingId });
|
const _record = await this.trainingRepo.findOneBy({ id: trainingId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
await new permission().PermissionOrgUserDelete(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_OFFICER",
|
||||||
|
_record.profileId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
await this.trainingHistoryRepo.delete({
|
await this.trainingHistoryRepo.delete({
|
||||||
profileTrainingId: trainingId,
|
profileTrainingId: trainingId,
|
||||||
|
|
|
||||||
|
|
@ -41,104 +41,37 @@ export class ProfileTrainingEmployeeController extends Controller {
|
||||||
}
|
}
|
||||||
const record = await this.trainingRepo.find({
|
const record = await this.trainingRepo.find({
|
||||||
where: { profileEmployeeId: profile.id },
|
where: { profileEmployeeId: profile.id },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileEmployeeId}")
|
@Get("{profileEmployeeId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "3cf02fb7-2f0c-471b-b641-51d557375c0a",
|
|
||||||
createdAt: "2024-03-12T02:55:56.915Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-12T02:55:56.915Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
isActive: true,
|
|
||||||
startDate: "2024-03-12T09:55:23.000Z",
|
|
||||||
endDate: "2024-03-12T09:55:23.000Z",
|
|
||||||
numberOrder: "string",
|
|
||||||
topic: "string",
|
|
||||||
place: "string",
|
|
||||||
dateOrder: "2024-03-12T09:55:23.000Z",
|
|
||||||
department: "string",
|
|
||||||
duration: "string",
|
|
||||||
name: "string",
|
|
||||||
yearly: 0,
|
|
||||||
isDate: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async getTraining(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
public async getTraining(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
||||||
const record = await this.trainingRepo.findBy({ profileEmployeeId });
|
const record = await this.trainingRepo.find({
|
||||||
|
where: { profileEmployeeId },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{trainingId}")
|
@Get("history/{trainingId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "6d4e9dbe-8697-4546-9651-0a1c3ea0a82d",
|
|
||||||
createdAt: "2024-03-12T02:55:56.971Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-12T02:55:56.971Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
isActive: true,
|
|
||||||
startDate: "2024-03-12T09:55:23.000Z",
|
|
||||||
endDate: "2024-03-12T09:55:23.000Z",
|
|
||||||
numberOrder: "string",
|
|
||||||
topic: "string",
|
|
||||||
place: "string",
|
|
||||||
dateOrder: "2024-03-12T09:55:23.000Z",
|
|
||||||
department: "string",
|
|
||||||
duration: "string",
|
|
||||||
name: "string",
|
|
||||||
yearly: 0,
|
|
||||||
isDate: true,
|
|
||||||
profileTrainingId: "3cf02fb7-2f0c-471b-b641-51d557375c0a",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "a251c176-3dac-4d09-9813-38c8db1127e3",
|
|
||||||
createdAt: "2024-03-12T02:58:17.917Z",
|
|
||||||
createdUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
lastUpdatedAt: "2024-03-12T02:58:17.917Z",
|
|
||||||
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
createdFullName: "string",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
isActive: true,
|
|
||||||
startDate: "2024-03-12T09:57:44.000Z",
|
|
||||||
endDate: "2024-03-12T09:57:44.000Z",
|
|
||||||
numberOrder: "string",
|
|
||||||
topic: "topic",
|
|
||||||
place: "place",
|
|
||||||
dateOrder: "2024-03-12T09:57:44.000Z",
|
|
||||||
department: "department",
|
|
||||||
duration: "string",
|
|
||||||
name: "name",
|
|
||||||
yearly: 0,
|
|
||||||
isDate: true,
|
|
||||||
profileTrainingId: "3cf02fb7-2f0c-471b-b641-51d557375c0a",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async trainingHistory(@Path() trainingId: string, @Request() req: RequestWithUser) {
|
public async trainingHistory(@Path() trainingId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.trainingRepo.findOneBy({ id: trainingId });
|
const _record = await this.trainingRepo.findOneBy({ id: trainingId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
|
await new permission().PermissionOrgUserGet(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
_record.profileEmployeeId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const record = await this.trainingHistoryRepo.findBy({
|
const record = await this.trainingHistoryRepo.find({
|
||||||
|
where: {
|
||||||
profileTrainingId: trainingId,
|
profileTrainingId: trainingId,
|
||||||
|
},
|
||||||
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
@ -158,7 +91,6 @@ export class ProfileTrainingEmployeeController extends Controller {
|
||||||
}
|
}
|
||||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profile.id);
|
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profile.id);
|
||||||
|
|
||||||
|
|
||||||
const data = new ProfileTraining();
|
const data = new ProfileTraining();
|
||||||
|
|
||||||
const meta = {
|
const meta = {
|
||||||
|
|
@ -166,6 +98,8 @@ export class ProfileTrainingEmployeeController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -187,20 +121,27 @@ export class ProfileTrainingEmployeeController extends Controller {
|
||||||
) {
|
) {
|
||||||
const record = await this.trainingRepo.findOneBy({ id: trainingId });
|
const record = await this.trainingRepo.findOneBy({ id: trainingId });
|
||||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId)
|
await new permission().PermissionOrgUserUpdate(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
record.profileEmployeeId,
|
||||||
|
);
|
||||||
|
|
||||||
const history = new ProfileTrainingHistory();
|
const history = new ProfileTrainingHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileTrainingId = trainingId;
|
history.profileTrainingId = trainingId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([this.trainingRepo.save(record), this.trainingHistoryRepo.save(history)]);
|
await Promise.all([this.trainingRepo.save(record), this.trainingHistoryRepo.save(history)]);
|
||||||
|
|
||||||
|
|
@ -211,7 +152,11 @@ export class ProfileTrainingEmployeeController extends Controller {
|
||||||
public async deleteTraining(@Path() trainingId: string, @Request() req: RequestWithUser) {
|
public async deleteTraining(@Path() trainingId: string, @Request() req: RequestWithUser) {
|
||||||
const _record = await this.trainingRepo.findOneBy({ id: trainingId });
|
const _record = await this.trainingRepo.findOneBy({ id: trainingId });
|
||||||
if (_record) {
|
if (_record) {
|
||||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
|
await new permission().PermissionOrgUserDelete(
|
||||||
|
req,
|
||||||
|
"SYS_REGISTRY_EMP",
|
||||||
|
_record.profileEmployeeId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.trainingHistoryRepo.delete({
|
await this.trainingHistoryRepo.delete({
|
||||||
|
|
|
||||||
|
|
@ -41,100 +41,29 @@ export class ProfileTrainingEmployeeTempController extends Controller {
|
||||||
}
|
}
|
||||||
const record = await this.trainingRepo.find({
|
const record = await this.trainingRepo.find({
|
||||||
where: { profileEmployeeId: profile.id },
|
where: { profileEmployeeId: profile.id },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("{profileEmployeeId}")
|
@Get("{profileEmployeeId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "3cf02fb7-2f0c-471b-b641-51d557375c0a",
|
|
||||||
createdAt: "2024-03-12T02:55:56.915Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-12T02:55:56.915Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
|
||||||
isActive: true,
|
|
||||||
startDate: "2024-03-12T09:55:23.000Z",
|
|
||||||
endDate: "2024-03-12T09:55:23.000Z",
|
|
||||||
numberOrder: "string",
|
|
||||||
topic: "string",
|
|
||||||
place: "string",
|
|
||||||
dateOrder: "2024-03-12T09:55:23.000Z",
|
|
||||||
department: "string",
|
|
||||||
duration: "string",
|
|
||||||
name: "string",
|
|
||||||
yearly: 0,
|
|
||||||
isDate: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async getTraining(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
public async getTraining(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||||
const record = await this.trainingRepo.findBy({ profileEmployeeId });
|
const record = await this.trainingRepo.find({
|
||||||
|
where: { profileEmployeeId },
|
||||||
|
order: { createdAt: "ASC" },
|
||||||
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("history/{trainingId}")
|
@Get("history/{trainingId}")
|
||||||
@Example({
|
|
||||||
status: 200,
|
|
||||||
message: "สำเร็จ",
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
id: "6d4e9dbe-8697-4546-9651-0a1c3ea0a82d",
|
|
||||||
createdAt: "2024-03-12T02:55:56.971Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-03-12T02:55:56.971Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
isActive: true,
|
|
||||||
startDate: "2024-03-12T09:55:23.000Z",
|
|
||||||
endDate: "2024-03-12T09:55:23.000Z",
|
|
||||||
numberOrder: "string",
|
|
||||||
topic: "string",
|
|
||||||
place: "string",
|
|
||||||
dateOrder: "2024-03-12T09:55:23.000Z",
|
|
||||||
department: "string",
|
|
||||||
duration: "string",
|
|
||||||
name: "string",
|
|
||||||
yearly: 0,
|
|
||||||
isDate: true,
|
|
||||||
profileTrainingId: "3cf02fb7-2f0c-471b-b641-51d557375c0a",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "a251c176-3dac-4d09-9813-38c8db1127e3",
|
|
||||||
createdAt: "2024-03-12T02:58:17.917Z",
|
|
||||||
createdUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
lastUpdatedAt: "2024-03-12T02:58:17.917Z",
|
|
||||||
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
|
|
||||||
createdFullName: "string",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
isActive: true,
|
|
||||||
startDate: "2024-03-12T09:57:44.000Z",
|
|
||||||
endDate: "2024-03-12T09:57:44.000Z",
|
|
||||||
numberOrder: "string",
|
|
||||||
topic: "topic",
|
|
||||||
place: "place",
|
|
||||||
dateOrder: "2024-03-12T09:57:44.000Z",
|
|
||||||
department: "department",
|
|
||||||
duration: "string",
|
|
||||||
name: "name",
|
|
||||||
yearly: 0,
|
|
||||||
isDate: true,
|
|
||||||
profileTrainingId: "3cf02fb7-2f0c-471b-b641-51d557375c0a",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
public async trainingHistory(@Path() trainingId: string, @Request() req: RequestWithUser) {
|
public async trainingHistory(@Path() trainingId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||||
const record = await this.trainingHistoryRepo.findBy({
|
const record = await this.trainingHistoryRepo.find({
|
||||||
|
where: {
|
||||||
profileTrainingId: trainingId,
|
profileTrainingId: trainingId,
|
||||||
|
},
|
||||||
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
@ -162,6 +91,8 @@ export class ProfileTrainingEmployeeTempController extends Controller {
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
@ -189,15 +120,18 @@ export class ProfileTrainingEmployeeTempController extends Controller {
|
||||||
const history = new ProfileTrainingHistory();
|
const history = new ProfileTrainingHistory();
|
||||||
|
|
||||||
Object.assign(record, body);
|
Object.assign(record, body);
|
||||||
Object.assign(history, body);
|
Object.assign(history, { ...record, id: undefined });
|
||||||
|
|
||||||
history.profileTrainingId = trainingId;
|
history.profileTrainingId = trainingId;
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
history.lastUpdateUserId = req.user.sub;
|
||||||
history.lastUpdateFullName = req.user.name;
|
history.lastUpdateFullName = req.user.name;
|
||||||
history.createdUserId = req.user.sub;
|
history.createdUserId = req.user.sub;
|
||||||
history.createdFullName = req.user.name;
|
history.createdFullName = req.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
await Promise.all([this.trainingRepo.save(record), this.trainingHistoryRepo.save(history)]);
|
await Promise.all([this.trainingRepo.save(record), this.trainingHistoryRepo.save(history)]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,8 @@ export class ProvinceController extends Controller {
|
||||||
_province.createdFullName = request.user.name;
|
_province.createdFullName = request.user.name;
|
||||||
_province.lastUpdateUserId = request.user.sub;
|
_province.lastUpdateUserId = request.user.sub;
|
||||||
_province.lastUpdateFullName = request.user.name;
|
_province.lastUpdateFullName = request.user.name;
|
||||||
|
_province.createdAt = new Date();
|
||||||
|
_province.lastUpdatedAt = new Date();
|
||||||
await this.provinceRepository.save(_province);
|
await this.provinceRepository.save(_province);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
@ -127,6 +129,7 @@ export class ProvinceController extends Controller {
|
||||||
|
|
||||||
_province.lastUpdateUserId = request.user.sub;
|
_province.lastUpdateUserId = request.user.sub;
|
||||||
_province.lastUpdateFullName = request.user.name;
|
_province.lastUpdateFullName = request.user.name;
|
||||||
|
_province.lastUpdatedAt = new Date();
|
||||||
this.provinceRepository.merge(_province, requestBody);
|
this.provinceRepository.merge(_province, requestBody);
|
||||||
await this.provinceRepository.save(_province);
|
await this.provinceRepository.save(_province);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,8 @@ export class RankController extends Controller {
|
||||||
rank.createdFullName = request.user.name;
|
rank.createdFullName = request.user.name;
|
||||||
rank.lastUpdateUserId = request.user.sub;
|
rank.lastUpdateUserId = request.user.sub;
|
||||||
rank.lastUpdateFullName = request.user.name;
|
rank.lastUpdateFullName = request.user.name;
|
||||||
|
rank.createdAt = new Date();
|
||||||
|
rank.lastUpdatedAt = new Date();
|
||||||
await this.rankRepository.save(rank);
|
await this.rankRepository.save(rank);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
@ -88,6 +90,7 @@ export class RankController extends Controller {
|
||||||
|
|
||||||
rank.lastUpdateUserId = request.user.sub;
|
rank.lastUpdateUserId = request.user.sub;
|
||||||
rank.lastUpdateFullName = request.user.name;
|
rank.lastUpdateFullName = request.user.name;
|
||||||
|
rank.lastUpdatedAt = new Date();
|
||||||
this.rankRepository.merge(rank, requestBody);
|
this.rankRepository.merge(rank, requestBody);
|
||||||
await this.rankRepository.save(rank);
|
await this.rankRepository.save(rank);
|
||||||
return new HttpSuccess();
|
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