Merge branch 'develop' into adiDev
This commit is contained in:
commit
4edf59ecd1
11 changed files with 189 additions and 465 deletions
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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) => {
|
||||
|
|
|
|||
|
|
@ -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, "ไม่พบข้อมูลบุคคลนี้ในระบบ");
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
],
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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, {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue