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

@ -3759,6 +3759,7 @@ export class ProfileEmployeeController extends Controller {
where: { where: {
keycloak: IsNull(), keycloak: IsNull(),
citizenId: Like(`%${body.keyword}%`), citizenId: Like(`%${body.keyword}%`),
employeeClass: "PREM",
}, },
relations: ["posType", "posLevel", "current_holders", "profileSalary"], relations: ["posType", "posLevel", "current_holders", "profileSalary"],
skip, skip,
@ -3771,6 +3772,7 @@ export class ProfileEmployeeController extends Controller {
where: { where: {
keycloak: IsNull(), keycloak: IsNull(),
firstName: Like(`%${body.keyword}%`), firstName: Like(`%${body.keyword}%`),
employeeClass: "PREM",
}, },
relations: ["posType", "posLevel", "current_holders", "profileSalary"], relations: ["posType", "posLevel", "current_holders", "profileSalary"],
skip, skip,
@ -3783,6 +3785,7 @@ export class ProfileEmployeeController extends Controller {
where: { where: {
keycloak: IsNull(), keycloak: IsNull(),
lastName: Like(`%${body.keyword}%`), lastName: Like(`%${body.keyword}%`),
employeeClass: "PREM",
}, },
relations: ["posType", "posLevel", "current_holders", "profileSalary"], relations: ["posType", "posLevel", "current_holders", "profileSalary"],
skip, skip,
@ -3794,6 +3797,7 @@ export class ProfileEmployeeController extends Controller {
[findProfile, total] = await this.profileRepo.findAndCount({ [findProfile, total] = await this.profileRepo.findAndCount({
where: { where: {
keycloak: IsNull(), keycloak: IsNull(),
employeeClass: "PREM",
}, },
relations: ["posType", "posLevel", "current_holders", "profileSalary"], relations: ["posType", "posLevel", "current_holders", "profileSalary"],
skip, skip,

View file

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