Merge branch 'develop' into adiDev

This commit is contained in:
AdisakKanthawilang 2024-11-14 09:45:51 +07:00
commit 4edf59ecd1
11 changed files with 189 additions and 465 deletions

View file

@ -876,9 +876,9 @@ export class CommandController extends Controller {
}
/**
* API
* API
*
* @summary API
* @summary API
*
* @param {string} id Id
*/
@ -2561,7 +2561,17 @@ export class CommandController extends Controller {
await Promise.all(
body.data.map(async (item) => {
const profile = await this.profileRepository.findOne({
relations: ["profileSalary","posType","posLevel"],
relations: [
"profileSalary",
"posType",
"posLevel",
"current_holders",
"current_holders.orgRoot",
"current_holders.orgChild1",
"current_holders.orgChild2",
"current_holders.orgChild3",
"current_holders.orgChild4",
],
where: { id: item.profileId },
order: {
profileSalary: {
@ -3037,6 +3047,16 @@ export class CommandController extends Controller {
statusReport: "REPORT",
}));
await this.posMasterRepository.save(data);
if (posMasters && posMasters.length > 0) {
const orgRevision = await this.orgRevisionRepo.findOne({
where: { id: posMasters[0].orgRevisionId }
});
if (orgRevision != null && orgRevision.isLock == false) {
await this.orgRevisionRepo.update(orgRevision.id, {
isLock: true,
});
}
}
return new HttpSuccess();
}
@ -3531,6 +3551,20 @@ export class CommandController extends Controller {
statusReport: "PENDING",
}));
await this.posMasterRepository.save(data);
if (data && data.length > 0) {
const revisionId = data[0].orgRevisionId;
const orgRevision = await this.orgRevisionRepo.findOne({
where: { id: revisionId },
relations: ["posMasters"]
});
if (orgRevision != null && !["REPORT"].includes(
orgRevision.posMasters.find(x => x.statusReport === "REPORT")?.statusReport || "")
) {
await this.orgRevisionRepo.update(orgRevision.id, {
isLock: false,
});
}
}
return new HttpSuccess();
}

View file

@ -668,6 +668,28 @@ export class OrganizationController extends Controller {
return new HttpSuccess(revision);
}
/**
* API
*
* @summary API
*
* @param {string} id Id OrgRevison
*/
@Get("lock/{id}")
async GetById(
@Request() request: RequestWithUser,
@Path() id: string,
) {
//add check permission
const orgRevision = await this.orgRevisionRepository.findOne({
where: { id: id }
});
if (!orgRevision) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงสร้าง");
}
return new HttpSuccess(orgRevision.isLock);
}
/**
* API
*
@ -5520,6 +5542,27 @@ export class OrganizationController extends Controller {
return new HttpSuccess(data.map((x) => x.id));
}
/**
* API
*
* @summary
*
*/
@Get("active/root/all")
async GetActiveRootAll() {
const orgRevisionActive = await this.orgRevisionRepository.findOne({
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
});
if (!orgRevisionActive) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบโครงสร้างที่เผยแพร่อยู่ตอนนี้");
}
const data = await this.orgRootRepository.find({
where: { orgRevisionId: orgRevisionActive.id },
});
return new HttpSuccess(data);
}
/**
* API
*

View file

@ -3112,6 +3112,8 @@ export class PositionController extends Controller {
await this.posMasterRepository.update(id, {
isSit: false,
next_holderId: null,
current_holderId: null,
statusReport: "PENDING",
});
dataMaster.positions.forEach(async (position) => {

View file

@ -4428,6 +4428,10 @@ export class ProfileController extends Controller {
"posType",
"current_holders",
"current_holders.orgRoot",
"current_holders.orgChild1",
"current_holders.orgChild2",
"current_holders.orgChild3",
"current_holders.orgChild4",
"profileSalary",
],
order: {
@ -4444,6 +4448,10 @@ export class ProfileController extends Controller {
"posType",
"current_holders",
"current_holders.orgRoot",
"current_holders.orgChild1",
"current_holders.orgChild2",
"current_holders.orgChild3",
"current_holders.orgChild4",
"profileSalary",
],
order: {
@ -5287,6 +5295,10 @@ export class ProfileController extends Controller {
"posType",
"current_holders",
"current_holders.orgRoot",
"current_holders.orgChild1",
"current_holders.orgChild2",
"current_holders.orgChild3",
"current_holders.orgChild4",
"profileSalary",
"profileEducations",
],
@ -5672,7 +5684,16 @@ export class ProfileController extends Controller {
//await new permission().PermissionOrgUserGet(request, "SYS_REGISTRY_OFFICER", id); //ไม่แน่ใจOFFปิดไว้ก่อน
const profile = await this.profileEmpRepo.findOne({
where: { id: id },
relations: ["posLevel", "posType", "current_holders", "current_holders.orgRoot"],
relations: [
"posLevel",
"posType",
"current_holders",
"current_holders.orgRoot",
"current_holders.orgChild1",
"current_holders.orgChild2",
"current_holders.orgChild3",
"current_holders.orgChild4",
],
});
if (!profile) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ");
@ -7000,7 +7021,16 @@ export class ProfileController extends Controller {
) {
const profile = await this.profileRepo.findOne({
where: { keycloak: request.user.sub },
relations: ["posLevel", "posType", "current_holders", "current_holders.orgRoot"],
relations: [
"posLevel",
"posType",
"current_holders",
"current_holders.orgRoot",
"current_holders.orgChild1",
"current_holders.orgChild2",
"current_holders.orgChild3",
"current_holders.orgChild4",
],
});
if (!profile) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ");

View file

@ -1856,6 +1856,10 @@ export class ProfileEmployeeController extends Controller {
"posType",
"current_holders",
"current_holders.orgRoot",
"current_holders.orgChild1",
"current_holders.orgChild2",
"current_holders.orgChild3",
"current_holders.orgChild4",
"profileSalary",
],
order: {
@ -2983,7 +2987,16 @@ export class ProfileEmployeeController extends Controller {
) {
const profile = await this.profileRepo.findOne({
where: { keycloak: request.user.sub },
relations: ["posLevel", "posType", "current_holders", "current_holders.orgRoot"],
relations: [
"posLevel",
"posType",
"current_holders",
"current_holders.orgRoot",
"current_holders.orgChild1",
"current_holders.orgChild2",
"current_holders.orgChild3",
"current_holders.orgChild4",
],
});
if (!profile) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ");
@ -3838,6 +3851,10 @@ export class ProfileEmployeeController extends Controller {
"posType",
"current_holders",
"current_holders.orgRoot",
"current_holders.orgChild1",
"current_holders.orgChild2",
"current_holders.orgChild3",
"current_holders.orgChild4",
"profileSalary",
"profileEducations"
],

View file

@ -1563,6 +1563,10 @@ export class ProfileEmployeeTempController extends Controller {
"posType",
"current_holders",
"current_holders.orgRoot",
"current_holders.orgChild1",
"current_holders.orgChild2",
"current_holders.orgChild3",
"current_holders.orgChild4",
"profileSalary",
],
order: {
@ -2614,7 +2618,16 @@ export class ProfileEmployeeTempController extends Controller {
) {
const profile = await this.profileRepo.findOne({
where: { keycloak: request.user.sub },
relations: ["posLevel", "posType", "current_holders", "current_holders.orgRoot"],
relations: [
"posLevel",
"posType",
"current_holders",
"current_holders.orgRoot",
"current_holders.orgChild1",
"current_holders.orgChild2",
"current_holders.orgChild3",
"current_holders.orgChild4",
],
});
if (!profile) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ");
@ -3431,7 +3444,17 @@ export class ProfileEmployeeTempController extends Controller {
// await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMPปิดไว้ก่อน
const profile = await this.profileRepo.findOne({
where: { id: id },
relations: ["posLevel", "posType", "current_holders", "current_holders.orgRoot", "profileEducations"],
relations: [
"posLevel",
"posType",
"current_holders",
"current_holders.orgRoot",
"current_holders.orgChild1",
"current_holders.orgChild2",
"current_holders.orgChild3",
"current_holders.orgChild4",
"profileEducations"
],
order: {
profileEducations: {
createdAt: "DESC"

View file

@ -145,10 +145,6 @@ export class KeycloakController extends Controller {
// });
// io.getInstance()?.emit("FolderCreate", folderData);
const _roles = {
role: body.roles || [],
};
const addRole = await this.addRole(userId, _roles);
const profile = await this.profileRepo.findOne({
where: {
@ -157,8 +153,25 @@ export class KeycloakController extends Controller {
});
if (profile) {
let _null: any = null;
profile.keycloak = userId;
profile.email = body.email == null ? _null : body.email;
await this.profileRepo.save(profile);
if (body.roles != null && body.roles.length > 0) {
const roleKeycloak = await this.roleKeycloakRepo.find({
where: { id: In(body.roles) },
});
const _profile = await this.profileRepo.findOne({
where: { keycloak: userId },
relations: ["roleKeycloaks"],
});
if (_profile) {
_profile.roleKeycloaks = Array.from(
new Set([..._profile.roleKeycloaks, ...roleKeycloak]),
);
this.profileRepo.save(_profile);
}
}
}
return userId;
}
@ -185,7 +198,6 @@ export class KeycloakController extends Controller {
// const _rolesUpdate = {
// role: body.roles || [],
// };
// const addRole = await this.addRole(userId, _rolesUpdate);
return chkUpdate;
}
@ -560,13 +572,14 @@ export class KeycloakController extends Controller {
const result = await createGroup(body.name);
if (!result) throw new Error("Failed. Cannot create group.");
}
@Post("log/sso")
async addLogSSO(
@Request() req: RequestWithUser,
@Body() body: {
text: string,
}
@Body()
body: {
text: string;
},
) {
try {
addLogSequence(req, {