Merge branch 'develop' into develop-Bright

This commit is contained in:
Bright 2024-11-27 10:21:19 +07:00
commit b4b49b7378
2 changed files with 14 additions and 10 deletions

View file

@ -1439,7 +1439,7 @@ export class ProfileEmployeeController extends Controller {
.leftJoinAndSelect("current_holders.orgChild2", "orgChild2")
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
.where("current_holders.orgRevisionId = :orgRevisionId", {orgRevisionId: findRevision.id})
.where("current_holders.orgRevisionId = :orgRevisionId", { orgRevisionId: findRevision.id })
.andWhere(
_data.root != undefined && _data.root != null
? _data.root[0] != null
@ -3759,6 +3759,7 @@ export class ProfileEmployeeController extends Controller {
where: {
keycloak: IsNull(),
citizenId: Like(`%${body.keyword}%`),
employeeClass: "PREM",
},
relations: ["posType", "posLevel", "current_holders", "profileSalary"],
skip,
@ -3771,6 +3772,7 @@ export class ProfileEmployeeController extends Controller {
where: {
keycloak: IsNull(),
firstName: Like(`%${body.keyword}%`),
employeeClass: "PREM",
},
relations: ["posType", "posLevel", "current_holders", "profileSalary"],
skip,
@ -3783,6 +3785,7 @@ export class ProfileEmployeeController extends Controller {
where: {
keycloak: IsNull(),
lastName: Like(`%${body.keyword}%`),
employeeClass: "PREM",
},
relations: ["posType", "posLevel", "current_holders", "profileSalary"],
skip,
@ -3794,6 +3797,7 @@ export class ProfileEmployeeController extends Controller {
[findProfile, total] = await this.profileRepo.findAndCount({
where: {
keycloak: IsNull(),
employeeClass: "PREM",
},
relations: ["posType", "posLevel", "current_holders", "profileSalary"],
skip,

View file

@ -212,6 +212,7 @@ export class KeycloakController extends Controller {
const profileEmp = await this.profileEmpRepo.findOne({
where: {
keycloak: userId,
employeeClass: "PREM",
},
relations: ["roleKeycloaks"],
});
@ -245,7 +246,6 @@ export class KeycloakController extends Controller {
@Post("{userId}/role")
async addRole(@Path() userId: string, @Body() body: { role: string[] }) {
const list = await getRoles();
if (!Array.isArray(list)) throw new Error("Failed. Cannot get role(s) data from the server.");
const result = await addUserRoles(
@ -255,7 +255,7 @@ export class KeycloakController extends Controller {
if (!result) {
throw new Error("Failed. Cannot set user's role.");
}
}
const roleKeycloak = await this.roleKeycloakRepo.find({
where: { id: In(body.role) },
@ -266,18 +266,17 @@ export class KeycloakController extends Controller {
});
if (!profile) {
const profileEmp = await this.profileEmpRepo.findOne({
where: { keycloak: userId },
where: { keycloak: userId, employeeClass: "PREM" },
relations: ["roleKeycloaks"],
});
// if (!profileEmp) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
if(profileEmp) {
if (profileEmp) {
profileEmp.roleKeycloaks = Array.from(
new Set([...profileEmp.roleKeycloaks, ...roleKeycloak]),
);
this.profileEmpRepo.save(profileEmp);
}
}
else {
} else {
profile.roleKeycloaks = Array.from(new Set([...profile.roleKeycloaks, ...roleKeycloak]));
this.profileRepo.save(profile);
}
@ -293,7 +292,7 @@ export class KeycloakController extends Controller {
});
if (!profile) {
const profileEmp = await this.profileEmpRepo.findOne({
where: { keycloak: userId },
where: { keycloak: userId, employeeClass: "PREM" },
relations: ["roleKeycloaks"],
});
if (!profileEmp) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -532,6 +531,7 @@ export class KeycloakController extends Controller {
.leftJoinAndSelect("profileEmployee.current_holders", "current_holders")
.where("profileEmployee.keycloak IS NOT NULL AND profileEmployee.keycloak != ''")
.andWhere(condition)
.andWhere({ employeeClass: "PREM" })
.andWhere(
new Brackets((qb) => {
qb.orWhere(
@ -647,7 +647,7 @@ export class KeycloakController extends Controller {
});
if (!profile) {
const profileEmp = await this.profileEmpRepo.findOne({
where: { keycloak: id },
where: { keycloak: id, employeeClass: "PREM" },
relations: ["roleKeycloaks"],
});
if (!profileEmp) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -667,7 +667,7 @@ export class KeycloakController extends Controller {
});
if (!profile) {
const profileEmp = await this.profileEmpRepo.findOne({
where: { keycloak: userId },
where: { keycloak: userId, employeeClass: "PREM" },
});
if (!profileEmp) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
profileEmp.isActive = status;