Merge branch 'develop' into nice
This commit is contained in:
commit
d012e9a9d9
16 changed files with 6296 additions and 1872 deletions
|
|
@ -1,23 +1,21 @@
|
|||
# Build Stage
|
||||
FROM node:lts-alpine AS build-stage
|
||||
FROM node:20.19.4-alpine AS build-stage
|
||||
|
||||
# Create app directory
|
||||
WORKDIR /app
|
||||
|
||||
# Install app dependencies
|
||||
COPY package*.json ./
|
||||
|
||||
RUN npm ci
|
||||
#RUN npm ci
|
||||
RUN npm install
|
||||
|
||||
# Copy source files and build the app
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
# Production Stage
|
||||
FROM node:lts-alpine
|
||||
|
||||
ENV NODE_ENV production
|
||||
USER node
|
||||
FROM node:20.19.4-alpine
|
||||
ENV NODE_ENV=production
|
||||
|
||||
# Create app directory
|
||||
WORKDIR /app
|
||||
|
|
@ -27,7 +25,9 @@ COPY --from=build-stage /app/dist ./dist
|
|||
|
||||
# Install only production dependencies
|
||||
COPY package*.json ./
|
||||
RUN npm ci --production
|
||||
#RUN npm ci --production
|
||||
RUN npm install
|
||||
USER node
|
||||
|
||||
# Define the entrypoint and default command
|
||||
# If you have a custom entrypoint script
|
||||
|
|
|
|||
53
package-lock.json
generated
53
package-lock.json
generated
|
|
@ -5072,39 +5072,6 @@
|
|||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/typeorm-cli/node_modules/iconv-lite": {
|
||||
"version": "0.6.3",
|
||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
|
||||
"integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"safer-buffer": ">= 2.1.2 < 3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/typeorm-cli/node_modules/long": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz",
|
||||
"integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==",
|
||||
"optional": true,
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/typeorm-cli/node_modules/lru-cache": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
|
||||
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"yallist": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/typeorm-cli/node_modules/mkdirp": {
|
||||
"version": "0.5.6",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz",
|
||||
|
|
@ -5121,26 +5088,6 @@
|
|||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
|
||||
},
|
||||
"node_modules/typeorm-cli/node_modules/mysql2": {
|
||||
"version": "2.3.3",
|
||||
"resolved": "https://registry.npmjs.org/mysql2/-/mysql2-2.3.3.tgz",
|
||||
"integrity": "sha512-wxJUev6LgMSgACDkb/InIFxDprRa6T95+VEoR+xPvtngtccNH2dGjEB/fVZ8yg1gWv1510c9CvXuJHi5zUm0ZA==",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"denque": "^2.0.1",
|
||||
"generate-function": "^2.3.1",
|
||||
"iconv-lite": "^0.6.3",
|
||||
"long": "^4.0.0",
|
||||
"lru-cache": "^6.0.0",
|
||||
"named-placeholders": "^1.1.2",
|
||||
"seq-queue": "^0.0.5",
|
||||
"sqlstring": "^2.3.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/typeorm-cli/node_modules/reflect-metadata": {
|
||||
"version": "0.1.14",
|
||||
"resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.14.tgz",
|
||||
|
|
|
|||
|
|
@ -160,6 +160,8 @@ export class CommandController extends Controller {
|
|||
@Get("list")
|
||||
async GetResult(
|
||||
@Request() request: RequestWithUser,
|
||||
@Query("sortBy") sortBy?: string,
|
||||
@Query("descending") descending?: boolean,
|
||||
@Query("page") page: number = 1,
|
||||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query() keyword: string = "",
|
||||
|
|
@ -262,14 +264,9 @@ export class CommandController extends Controller {
|
|||
yearKeyword = match[1].trim();
|
||||
}
|
||||
let yearInBC = yearKeyword ? parseInt(yearKeyword) - 543 : null;
|
||||
//
|
||||
|
||||
// console.log("k>>",keyword);
|
||||
// console.log("bk>>",baseKeyword);
|
||||
// console.log("yk>>",yearKeyword);
|
||||
// console.log("yi>>",yearInBC);
|
||||
|
||||
const [commands, total] = await this.commandRepository
|
||||
|
||||
// const [commands, total] = await this.commandRepository
|
||||
let query = await this.commandRepository
|
||||
.createQueryBuilder("command")
|
||||
.leftJoinAndSelect("command.commandType", "commandType")
|
||||
.andWhere(
|
||||
|
|
@ -339,6 +336,15 @@ export class CommandController extends Controller {
|
|||
}),
|
||||
)
|
||||
.orderBy("command.createdAt", "DESC")
|
||||
|
||||
if (sortBy) {
|
||||
query = query.orderBy(
|
||||
`command.${sortBy}`,
|
||||
descending ? "DESC" : "ASC"
|
||||
);
|
||||
}
|
||||
|
||||
let [commands, total] = await query
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
|
@ -1559,6 +1565,12 @@ export class CommandController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Get("cornjob/cronjobUpdateRetirementStatus")
|
||||
async runCronjobUpdateRetirementStatus() {
|
||||
await this.cronjobUpdateRetirementStatus();
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API รายละเอียดรายการคำสั่ง tab4 คำสั่ง
|
||||
*
|
||||
|
|
@ -3006,6 +3018,38 @@ export class CommandController extends Controller {
|
|||
return new HttpSuccess(_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* API อัพเดทสถานะ CANCEL คำสั่งยกเลิกการลาออก, คำสั่งยกเลิกการลาออกลูกจ้าง
|
||||
*
|
||||
* @summary API อัพเดทสถานะ CANCEL คำสั่งยกเลิกการลาออก, คำสั่งยกเลิกการลาออกลูกจ้าง
|
||||
*
|
||||
*/
|
||||
@Post("cancel-resign")
|
||||
public async command41Excecute(
|
||||
@Request() req: RequestWithUser,
|
||||
@Body()
|
||||
body: {
|
||||
resignId: string[];
|
||||
},
|
||||
) {
|
||||
const _refId = Array.from(new Set(body.resignId));
|
||||
// 1. ดึง commandRecive ที่ refId ตรงกับ resignId
|
||||
const commandRecives = await this.commandReciveRepository.find({
|
||||
select: ["commandId"],
|
||||
where: { refId: In(_refId) },
|
||||
});
|
||||
// 2. ดึง commandId ที่ไม่ซ้ำ
|
||||
const commandIds = Array.from(new Set(commandRecives.map(x => x.commandId).filter(Boolean)));
|
||||
// 3. อัปเดต status ของ command
|
||||
if (commandIds.length > 0) {
|
||||
await this.commandRepository.update(
|
||||
{ id: In(commandIds) },
|
||||
{ status: "CANCEL" }
|
||||
);
|
||||
}
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Post("excexute/salary-current")
|
||||
public async newSalaryAndUpdateCurrent(
|
||||
@Request() req: RequestWithUser,
|
||||
|
|
@ -3437,6 +3481,7 @@ export class CommandController extends Controller {
|
|||
orgChild2New?: string | null;
|
||||
orgChild3New?: string | null;
|
||||
orgChild4New?: string | null;
|
||||
resignId?: string | null;
|
||||
}[];
|
||||
},
|
||||
) {
|
||||
|
|
@ -3501,6 +3546,19 @@ export class CommandController extends Controller {
|
|||
if (code && ["C-PM-08", "C-PM-17", "C-PM-18"].includes(code)) {
|
||||
removePostMasterAct(profile.id);
|
||||
}
|
||||
//ออกคำสั่งยกเลิกลาออกต้องอัพเดทสถานะคำสั่งลาออกเป็น CANCEL
|
||||
else if (item.resignId && code && ["C-PM-41"].includes(code)) {
|
||||
const commandRecive = await this.commandReciveRepository.findOne({
|
||||
select: ["commandId"],
|
||||
where: { refId: item.resignId },
|
||||
});
|
||||
if (commandRecive && commandRecive.commandId) {
|
||||
await this.commandRepository.update(
|
||||
{ id: commandRecive?.commandId },
|
||||
{ status: "CANCEL" }
|
||||
);
|
||||
}
|
||||
}
|
||||
let _commandYear = item.commandYear;
|
||||
if (item.commandYear) {
|
||||
_commandYear = item.commandYear > 2500 ? item.commandYear : item.commandYear + 543;
|
||||
|
|
@ -3541,19 +3599,19 @@ export class CommandController extends Controller {
|
|||
profile.lastUpdateFullName = req.user.name;
|
||||
profile.lastUpdatedAt = new Date();
|
||||
const clearProfile = await checkCommandType(String(item.commandId));
|
||||
|
||||
|
||||
//ปั๊มประวัติก่อนลบตำแหน่ง
|
||||
const curRevision = await this.orgRevisionRepo.findOne({
|
||||
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false }
|
||||
})
|
||||
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
||||
});
|
||||
|
||||
if(curRevision){
|
||||
if (curRevision) {
|
||||
const curPosMaster = await this.posMasterRepository.findOne({
|
||||
where:{
|
||||
where: {
|
||||
current_holderId: profile.id,
|
||||
orgRevisionId: curRevision.id
|
||||
}
|
||||
})
|
||||
orgRevisionId: curRevision.id,
|
||||
},
|
||||
});
|
||||
if (curPosMaster && clearProfile.LeaveType != "RETIRE_OUT_EMP") {
|
||||
await CreatePosMasterHistoryOfficer(curPosMaster.id, req, "DELETE");
|
||||
}
|
||||
|
|
@ -3767,6 +3825,7 @@ export class CommandController extends Controller {
|
|||
commandCode?: string | null;
|
||||
commandName?: string | null;
|
||||
remark: string | null;
|
||||
resignId: string | null;
|
||||
}[];
|
||||
},
|
||||
) {
|
||||
|
|
@ -3822,6 +3881,20 @@ export class CommandController extends Controller {
|
|||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const code = _command?.commandType?.code;
|
||||
//ออกคำสั่งยกเลิกลาออกต้องอัพเดทสถานะคำสั่งลาออกเป็น CANCEL
|
||||
if (item.resignId && code && ["C-PM-42"].includes(code)) {
|
||||
const commandRecive = await this.commandReciveRepository.findOne({
|
||||
select: ["commandId"],
|
||||
where: { refId: item.resignId },
|
||||
});
|
||||
if (commandRecive && commandRecive.commandId) {
|
||||
await this.commandRepository.update(
|
||||
{ id: commandRecive?.commandId },
|
||||
{ status: "CANCEL" }
|
||||
);
|
||||
}
|
||||
}
|
||||
let _commandYear = item.commandYear;
|
||||
if (item.commandYear) {
|
||||
_commandYear = item.commandYear > 2500 ? item.commandYear : item.commandYear + 543;
|
||||
|
|
|
|||
|
|
@ -127,6 +127,8 @@ export class DevelopmentRequestController extends Controller {
|
|||
@Query("keyword") keyword: string = "",
|
||||
@Query("page") page: number = 1,
|
||||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query("sortBy") sortBy?: string,
|
||||
@Query("descending") descending?: boolean,
|
||||
) {
|
||||
let data = await new permission().PermissionOrgList(request, "SYS_REGISTRY_OFFICER");
|
||||
const orgRevisionPublish = await this.orgRevisionRepository
|
||||
|
|
@ -134,7 +136,7 @@ export class DevelopmentRequestController extends Controller {
|
|||
.where("orgRevision.orgRevisionIsDraft = false")
|
||||
.andWhere("orgRevision.orgRevisionIsCurrent = true")
|
||||
.getOne();
|
||||
const [lists, total] = await AppDataSource.getRepository(DevelopmentRequest)
|
||||
let query = await AppDataSource.getRepository(DevelopmentRequest)
|
||||
.createQueryBuilder("developmentRequest")
|
||||
.leftJoinAndSelect("developmentRequest.profile", "profile")
|
||||
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
||||
|
|
@ -249,9 +251,20 @@ export class DevelopmentRequestController extends Controller {
|
|||
}),
|
||||
)
|
||||
.orderBy("developmentRequest.createdAt", "DESC")
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
|
||||
if (sortBy) {
|
||||
query = query.orderBy(
|
||||
`developmentRequest.${sortBy}`,
|
||||
descending ? "DESC" : "ASC"
|
||||
);
|
||||
}
|
||||
|
||||
const [lists, total] = await query
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
const _data = lists.map((item) => ({ ...item, profile: null }));
|
||||
return new HttpSuccess({ data: _data, total });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import { checkQueueInProgress, setLogDataDiff } from "../interfaces/utils";
|
|||
import { sendToQueueOrg, sendToQueueOrgDraft } from "../services/rabbitmq";
|
||||
import { PosType } from "../entities/PosType";
|
||||
import { PosLevel } from "../entities/PosLevel";
|
||||
import { PermissionOrg } from "../entities/PermissionOrg";
|
||||
|
||||
@Route("api/v1/org")
|
||||
@Tags("Organization")
|
||||
|
|
@ -49,6 +50,7 @@ export class OrganizationController extends Controller {
|
|||
private profileRepo = AppDataSource.getRepository(Profile);
|
||||
private posTypeRepository = AppDataSource.getRepository(PosType);
|
||||
private posLevelRepository = AppDataSource.getRepository(PosLevel);
|
||||
private permissionOrgRepository = AppDataSource.getRepository(PermissionOrg);
|
||||
|
||||
/**
|
||||
* API ล้างข้อมูล
|
||||
|
|
@ -7869,4 +7871,48 @@ export class OrganizationController extends Controller {
|
|||
posLevelNameOrder: posLevel.map((x) => x.posLevelName),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* API เพิ่มสิทธิ์โครงสร้าง
|
||||
*
|
||||
* @summary - เพิ่มสิทธิ์โครงสร้าง (ADMIN)
|
||||
*
|
||||
*/
|
||||
@Get("root/add/permission/{child1Id}")
|
||||
async addRootPermission(@Path() child1Id: string, @Request() request: RequestWithUser) {
|
||||
const profiles = await this.profileRepo.find({
|
||||
where: {
|
||||
keycloak: Not(IsNull()),
|
||||
current_holders: {
|
||||
orgChild1Id: child1Id,
|
||||
},
|
||||
},
|
||||
});
|
||||
const orgRoots = await this.orgRootRepository.find({
|
||||
where: {
|
||||
orgRevision: {
|
||||
orgRevisionIsDraft: true,
|
||||
orgRevisionIsCurrent: false,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
for await (const root of orgRoots) {
|
||||
const _permissionOrg = profiles.map((profile) => {
|
||||
const permission = new PermissionOrg();
|
||||
permission.orgRootId = root.id;
|
||||
permission.profileId = profile.id;
|
||||
permission.createdUserId = request.user.sub;
|
||||
permission.createdFullName = request.user.name;
|
||||
permission.lastUpdateUserId = request.user.sub;
|
||||
permission.lastUpdateFullName = request.user.name;
|
||||
permission.createdAt = new Date();
|
||||
permission.lastUpdatedAt = new Date();
|
||||
return permission;
|
||||
});
|
||||
await this.permissionOrgRepository.save(_permissionOrg);
|
||||
}
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2355,6 +2355,7 @@ export class PositionController extends Controller {
|
|||
.addOrderBy("orgChild3.orgChild3Order", "ASC")
|
||||
.addOrderBy("orgChild4.orgChild4Order", "ASC")
|
||||
.addOrderBy("posMaster.posMasterOrder", "ASC")
|
||||
.addOrderBy("posMaster.posMasterCreatedAt", "ASC")
|
||||
.skip((body.page - 1) * body.pageSize)
|
||||
.take(body.pageSize)
|
||||
.getManyAndCount();
|
||||
|
|
|
|||
|
|
@ -2585,6 +2585,8 @@ export class ProfileController extends Controller {
|
|||
keyword: string;
|
||||
page: number;
|
||||
pageSize: number;
|
||||
sortBy?: string;
|
||||
descending?: boolean;
|
||||
},
|
||||
) {
|
||||
let posMaster = await this.posMasterRepo.findOne({
|
||||
|
|
@ -2672,7 +2674,7 @@ export class ProfileController extends Controller {
|
|||
// condition.isDirector = true;
|
||||
// // conditionNow.isDirector = true;
|
||||
// }
|
||||
const [lists, total] = await AppDataSource.getRepository(viewDirectorActing)
|
||||
let query = await AppDataSource.getRepository(viewDirectorActing)
|
||||
.createQueryBuilder("viewDirectorActing")
|
||||
// .andWhere(condition)
|
||||
.andWhere(
|
||||
|
|
@ -2724,9 +2726,19 @@ export class ProfileController extends Controller {
|
|||
);
|
||||
}),
|
||||
)
|
||||
.skip((body.page - 1) * body.pageSize)
|
||||
.take(body.pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
if (body.sortBy) {
|
||||
query = query.orderBy(
|
||||
`viewDirectorActing.${body.sortBy}`,
|
||||
body.descending ? "DESC" : "ASC"
|
||||
);
|
||||
}
|
||||
|
||||
const [lists, total] = await query
|
||||
.skip((body.page - 1) * body.pageSize)
|
||||
.take(body.pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
return new HttpSuccess({ data: lists, total });
|
||||
} else {
|
||||
// const posMaster = await this.posMasterRepo.findOne({
|
||||
|
|
@ -2764,7 +2776,7 @@ export class ProfileController extends Controller {
|
|||
// condition.isDirector = true;
|
||||
// // conditionNow.isDirector = true;
|
||||
// }
|
||||
const [lists, total] = await AppDataSource.getRepository(viewDirector)
|
||||
let query = await AppDataSource.getRepository(viewDirector)
|
||||
.createQueryBuilder("viewDirector")
|
||||
// .andWhere(condition)
|
||||
.andWhere(
|
||||
|
|
@ -2816,9 +2828,19 @@ export class ProfileController extends Controller {
|
|||
);
|
||||
}),
|
||||
)
|
||||
|
||||
if (body.sortBy) {
|
||||
query = query.orderBy(
|
||||
`viewDirector.${body.sortBy}`,
|
||||
body.descending ? "DESC" : "ASC"
|
||||
);
|
||||
}
|
||||
|
||||
const [lists, total] = await query
|
||||
.skip((body.page - 1) * body.pageSize)
|
||||
.take(body.pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
return new HttpSuccess({ data: lists, total });
|
||||
}
|
||||
}
|
||||
|
|
@ -8545,6 +8567,8 @@ export class ProfileController extends Controller {
|
|||
keyword?: string;
|
||||
system?: string;
|
||||
},
|
||||
@Query("sortBy") sortBy?: string,
|
||||
@Query("descending") descending?: boolean
|
||||
) {
|
||||
// ค้นหารายชื่อถ้าไม่ส่ง system มาให้ default ตามทะเบียนประวัติ
|
||||
let _system: string = "SYS_REGISTRY_OFFICER";
|
||||
|
|
@ -8616,7 +8640,7 @@ export class ProfileController extends Controller {
|
|||
break;
|
||||
}
|
||||
|
||||
const [findProfile, total] = await this.profileRepo
|
||||
let query = await this.profileRepo
|
||||
.createQueryBuilder("profile")
|
||||
.leftJoinAndSelect("profile.posType", "posType")
|
||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||
|
|
@ -8672,6 +8696,27 @@ export class ProfileController extends Controller {
|
|||
qb.orWhere(body.keyword ? queryLike : "1=1", { keyword: `%${body.keyword}%` });
|
||||
}),
|
||||
)
|
||||
|
||||
if (sortBy) {
|
||||
if(sortBy === "name"){
|
||||
query = query
|
||||
.orderBy(`profile.prefix`,descending ? "DESC" : "ASC")
|
||||
.addOrderBy(`profile.firstName`,descending ? "DESC" : "ASC")
|
||||
.addOrderBy(`profile.lastName`,descending ? "DESC" : "ASC")
|
||||
}else if(sortBy === "organization"){
|
||||
query = query.orderBy(
|
||||
`orgRoot.orgRootName`,
|
||||
descending ? "DESC" : "ASC"
|
||||
);
|
||||
}else{
|
||||
query = query.orderBy(
|
||||
`profile.${sortBy}`,
|
||||
descending ? "DESC" : "ASC"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const [findProfile, total] = await query
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
|
@ -9103,6 +9148,8 @@ export class ProfileController extends Controller {
|
|||
page: number;
|
||||
pageSize: number;
|
||||
keyword?: string;
|
||||
sortBy?: string;
|
||||
descending?: boolean;
|
||||
},
|
||||
) {
|
||||
let _data: any = {
|
||||
|
|
@ -9116,7 +9163,7 @@ export class ProfileController extends Controller {
|
|||
if (!request.user.role.includes("SUPER_ADMIN")) {
|
||||
_data = await new permission().PermissionOrgCreate(request, "SYS_PROBATION");
|
||||
}
|
||||
const [findProfile, total] = await AppDataSource.getRepository(Profile)
|
||||
let query = await AppDataSource.getRepository(Profile)
|
||||
.createQueryBuilder("profile")
|
||||
.leftJoinAndSelect("profile.profileSalary", "profileSalary")
|
||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||
|
|
@ -9230,7 +9277,39 @@ export class ProfileController extends Controller {
|
|||
);
|
||||
}),
|
||||
)
|
||||
.orderBy("profile.citizenId", "ASC")
|
||||
|
||||
if (body.sortBy) {
|
||||
if(body.sortBy === "posLevelName"){
|
||||
query = query.orderBy(
|
||||
`posLevel.posLevelName`,
|
||||
body.descending ? "DESC" : "ASC"
|
||||
);
|
||||
}else if(body.sortBy === "posTypeName"){
|
||||
query = query.orderBy(
|
||||
`posType.posTypeName`,
|
||||
body.descending ? "DESC" : "ASC"
|
||||
);
|
||||
}else if(body.sortBy === "commandNo"){
|
||||
query = query.orderBy(
|
||||
`profileSalary.commandNo`,
|
||||
body.descending ? "DESC" : "ASC"
|
||||
);
|
||||
}else if(body.sortBy === "orgRootName"){
|
||||
query = query.orderBy(
|
||||
`orgRoot.orgRootName`,
|
||||
body.descending ? "DESC" : "ASC"
|
||||
);
|
||||
}else{
|
||||
query = query.orderBy(
|
||||
`profile.${body.sortBy}`,
|
||||
body.descending ? "DESC" : "ASC"
|
||||
);
|
||||
}
|
||||
}else{
|
||||
query = query.orderBy("profile.citizenId", "ASC")
|
||||
}
|
||||
|
||||
const [findProfile, total] = await query
|
||||
.skip((body.page - 1) * body.pageSize)
|
||||
.take(body.pageSize)
|
||||
.getManyAndCount();
|
||||
|
|
|
|||
|
|
@ -58,11 +58,13 @@ export class ProfileDevelopmentController extends Controller {
|
|||
@Query("page") page: number = 1,
|
||||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query() searchKeyword: string = "",
|
||||
@Query("sortBy") sortBy?: string,
|
||||
@Query("descending") descending?: boolean,
|
||||
) {
|
||||
let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_OFFICER");
|
||||
if (_workflow == false)
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||
const [profileDevelopment, total] = await AppDataSource.getRepository(ProfileDevelopment)
|
||||
let query = await AppDataSource.getRepository(ProfileDevelopment)
|
||||
.createQueryBuilder("profileDevelopment")
|
||||
.where({ profileId: profileId })
|
||||
.andWhere(
|
||||
|
|
@ -102,9 +104,19 @@ export class ProfileDevelopmentController extends Controller {
|
|||
}),
|
||||
)
|
||||
.orderBy("profileDevelopment.createdAt", "ASC")
|
||||
|
||||
if (sortBy) {
|
||||
query = query.orderBy(
|
||||
`profileDevelopment.${sortBy}`,
|
||||
descending ? "DESC" : "ASC"
|
||||
);
|
||||
}
|
||||
|
||||
const [profileDevelopment, total] = await query
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
return new HttpSuccess({ data: profileDevelopment, total });
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,11 +56,14 @@ export class ProfileDevelopmentEmployeeController extends Controller {
|
|||
@Query("page") page: number = 1,
|
||||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query() searchKeyword: string = "",
|
||||
@Query("sortBy") sortBy?: string,
|
||||
@Query("descending") descending?: boolean,
|
||||
) {
|
||||
let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_EMP");
|
||||
if (_workflow == false)
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId);
|
||||
const [profileDevelopment, total] = await AppDataSource.getRepository(ProfileDevelopment)
|
||||
|
||||
let query = await AppDataSource.getRepository(ProfileDevelopment)
|
||||
.createQueryBuilder("profileDevelopment")
|
||||
.where({ profileEmployeeId: profileId })
|
||||
.andWhere(
|
||||
|
|
@ -100,9 +103,19 @@ export class ProfileDevelopmentEmployeeController extends Controller {
|
|||
}),
|
||||
)
|
||||
.orderBy("profileDevelopment.createdAt", "ASC")
|
||||
|
||||
if (sortBy) {
|
||||
query = query.orderBy(
|
||||
`profileDevelopment.${sortBy}`,
|
||||
descending ? "DESC" : "ASC"
|
||||
);
|
||||
}
|
||||
|
||||
const [profileDevelopment, total] = await query
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
return new HttpSuccess({ data: profileDevelopment, total });
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -116,6 +116,8 @@ export class ProfileEditController extends Controller {
|
|||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query("keyword") keyword: string = "",
|
||||
@Query("status") status: string = "",
|
||||
@Query("sortBy") sortBy?: string,
|
||||
@Query("descending") descending?: boolean,
|
||||
) {
|
||||
let data = await new permission().PermissionOrgList(request, "SYS_REGISTRY_OFFICER");
|
||||
const orgRevisionPublish = await this.orgRevisionRepository
|
||||
|
|
@ -123,7 +125,7 @@ export class ProfileEditController extends Controller {
|
|||
.where("orgRevision.orgRevisionIsDraft = false")
|
||||
.andWhere("orgRevision.orgRevisionIsCurrent = true")
|
||||
.getOne();
|
||||
let [getProfileEdit, total] = await AppDataSource.getRepository(ProfileEdit)
|
||||
let query = await AppDataSource.getRepository(ProfileEdit)
|
||||
.createQueryBuilder("ProfileEdit")
|
||||
.leftJoinAndSelect("ProfileEdit.profile", "profile")
|
||||
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
||||
|
|
@ -214,10 +216,27 @@ export class ProfileEditController extends Controller {
|
|||
);
|
||||
}),
|
||||
)
|
||||
.orderBy("ProfileEdit.createdAt", "DESC")
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
.orderBy("ProfileEdit.createdAt", "DESC")
|
||||
|
||||
if (sortBy) {
|
||||
if(sortBy == "fullname"){
|
||||
query = query.orderBy(
|
||||
`profile.firstName`,
|
||||
descending ? "DESC" : "ASC"
|
||||
);
|
||||
}else{
|
||||
query = query.orderBy(
|
||||
`ProfileEdit.${sortBy}`,
|
||||
descending ? "DESC" : "ASC"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const [getProfileEdit, total] = await query
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
const _data = getProfileEdit.map((item) => ({
|
||||
id: item.id,
|
||||
idcard: item.profile.citizenId,
|
||||
|
|
|
|||
|
|
@ -110,6 +110,8 @@ export class ProfileEditEmployeeController extends Controller {
|
|||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query("keyword") keyword: string = "",
|
||||
@Query("status") status: string = "",
|
||||
@Query("sortBy") sortBy?: string,
|
||||
@Query("descending") descending?: boolean,
|
||||
) {
|
||||
let data = await new permission().PermissionOrgList(request, "SYS_REGISTRY_EMP");
|
||||
const orgRevisionPublish = await this.orgRevisionRepository
|
||||
|
|
@ -117,7 +119,8 @@ export class ProfileEditEmployeeController extends Controller {
|
|||
.where("orgRevision.orgRevisionIsDraft = false")
|
||||
.andWhere("orgRevision.orgRevisionIsCurrent = true")
|
||||
.getOne();
|
||||
let [getProfileEdit, total] = await AppDataSource.getRepository(ProfileEdit)
|
||||
|
||||
let query = await AppDataSource.getRepository(ProfileEdit)
|
||||
.createQueryBuilder("ProfileEdit")
|
||||
.leftJoinAndSelect("ProfileEdit.profileEmployee", "profileEmployee")
|
||||
.leftJoinAndSelect("profileEmployee.current_holders", "current_holders")
|
||||
|
|
@ -209,9 +212,25 @@ export class ProfileEditEmployeeController extends Controller {
|
|||
}),
|
||||
)
|
||||
.orderBy("ProfileEdit.createdAt", "DESC")
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
if (sortBy) {
|
||||
if(sortBy == "fullname"){
|
||||
query = query.orderBy(
|
||||
`profileEmployee.firstName`,
|
||||
descending ? "DESC" : "ASC"
|
||||
);
|
||||
}else{
|
||||
query = query.orderBy(
|
||||
`ProfileEdit.${sortBy}`,
|
||||
descending ? "DESC" : "ASC"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let [getProfileEdit, total] = await query
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
const _data = getProfileEdit.map((item) => ({
|
||||
id: item.id,
|
||||
|
|
|
|||
|
|
@ -1504,6 +1504,8 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
@Query() isProbation?: boolean,
|
||||
@Query() isRetire?: boolean,
|
||||
@Query() type?: string,
|
||||
@Query("sortBy") sortBy?: string,
|
||||
@Query("descending") descending?: boolean,
|
||||
) {
|
||||
let _data = await new permission().PermissionOrgList(request, "SYS_REGISTRY_TEMP");
|
||||
let queryLike =
|
||||
|
|
@ -1525,7 +1527,8 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
if (!findRevision) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||
}
|
||||
const [record, total] = await this.profileRepo
|
||||
|
||||
let query = await this.profileRepo
|
||||
.createQueryBuilder("profileEmployee")
|
||||
.leftJoinAndSelect("profileEmployee.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("profileEmployee.posType", "posType")
|
||||
|
|
@ -1638,9 +1641,36 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
}
|
||||
}),
|
||||
)
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
if (sortBy) {
|
||||
if(sortBy == "posLevel"){
|
||||
query = query.orderBy(
|
||||
`posLevel.posLevelName`,
|
||||
descending ? "DESC" : "ASC"
|
||||
);
|
||||
}else if(sortBy == "posType"){
|
||||
query = query.orderBy(
|
||||
`posType.posTypeName`,
|
||||
descending ? "DESC" : "ASC"
|
||||
);
|
||||
}else if(sortBy == "govAge"){
|
||||
query = query.orderBy(
|
||||
`profileEmployee.dateAppoint`,
|
||||
descending ? "DESC" : "ASC"
|
||||
);
|
||||
}else{
|
||||
query = query.orderBy(
|
||||
`profileEmployee.${sortBy}`,
|
||||
descending ? "DESC" : "ASC"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const [record, total] = await query
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
const data = await Promise.all(
|
||||
record.map((_data) => {
|
||||
const shortName =
|
||||
|
|
|
|||
|
|
@ -64,6 +64,8 @@ export class ProfileSalaryTempController extends Controller {
|
|||
@Query() searchKeyword: string = "",
|
||||
@Query() statusCheckEdit?: string | null,
|
||||
@Query() rootId?: string,
|
||||
@Query("sortBy") sortBy?: string,
|
||||
@Query("descending") descending?: boolean,
|
||||
) {
|
||||
if (type.trim().toUpperCase() == "OFFICER") {
|
||||
let _data = await new permission().PermissionOrgList(request, "SYS_REGISTRY_OFFICER");
|
||||
|
|
@ -78,7 +80,7 @@ export class ProfileSalaryTempController extends Controller {
|
|||
if (!findRevision) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||
}
|
||||
const [record, total] = await this.profileRepo
|
||||
let query = await this.profileRepo
|
||||
.createQueryBuilder("profile")
|
||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("profile.posType", "posType")
|
||||
|
|
@ -321,17 +323,51 @@ export class ProfileSalaryTempController extends Controller {
|
|||
rootId: rootId,
|
||||
})
|
||||
.addSelect("CASE WHEN current_holders.posMasterNo IS NULL THEN 1 ELSE 0 END", "sort_order")
|
||||
.orderBy("sort_order", "ASC")
|
||||
// .orderBy(`${sortBy}`, sort)
|
||||
|
||||
if (sortBy) {
|
||||
if(sortBy == "posLevel"){
|
||||
query = query.orderBy(
|
||||
`posLevel.posLevelName`,
|
||||
descending ? "DESC" : "ASC"
|
||||
);
|
||||
}else if(sortBy == "posType"){
|
||||
query = query.orderBy(
|
||||
`posType.posTypeName`,
|
||||
descending ? "DESC" : "ASC"
|
||||
);
|
||||
}else if(sortBy == "posExecutive"){
|
||||
query = query.orderBy(
|
||||
`posExecutive.posExecutiveName`,
|
||||
descending ? "DESC" : "ASC"
|
||||
);
|
||||
}else if(sortBy == "posNo"){
|
||||
query = query.orderBy("orgChild4.orgChild4ShortName",descending ? "DESC" : "ASC")
|
||||
.addOrderBy("orgChild3.orgChild3ShortName",descending ? "DESC" : "ASC")
|
||||
.addOrderBy("orgChild2.orgChild2ShortName",descending ? "DESC" : "ASC")
|
||||
.addOrderBy("orgChild1.orgChild1ShortName",descending ? "DESC" : "ASC")
|
||||
.addOrderBy("orgRoot.orgRootShortName",descending ? "DESC" : "ASC")
|
||||
.addOrderBy("current_holders.posMasterNo",descending ? "DESC" : "ASC")
|
||||
}else{
|
||||
query = query.orderBy(
|
||||
`profile.${sortBy}`,
|
||||
descending ? "DESC" : "ASC"
|
||||
);
|
||||
}
|
||||
}else{
|
||||
query = query.orderBy("sort_order", "ASC")
|
||||
.addOrderBy("orgRoot.orgRootOrder", "ASC")
|
||||
.addOrderBy("orgChild1.orgChild1Order", "ASC")
|
||||
.addOrderBy("orgChild2.orgChild2Order", "ASC")
|
||||
.addOrderBy("orgChild3.orgChild3Order", "ASC")
|
||||
.addOrderBy("orgChild4.orgChild4Order", "ASC")
|
||||
.addOrderBy("current_holders.posMasterNo", "ASC")
|
||||
// .orderBy(`${sortBy}`, sort)
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
}
|
||||
|
||||
const [record, total] = await query
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
const data = await Promise.all(
|
||||
record.map((_data) => {
|
||||
|
|
@ -465,7 +501,7 @@ export class ProfileSalaryTempController extends Controller {
|
|||
if (!findRevision) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||
}
|
||||
const [record, total] = await this.profileEmployeeRepo
|
||||
let query = await this.profileEmployeeRepo
|
||||
.createQueryBuilder("profileEmployee")
|
||||
.leftJoinAndSelect("profileEmployee.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("profileEmployee.posType", "posType")
|
||||
|
|
@ -721,9 +757,35 @@ export class ProfileSalaryTempController extends Controller {
|
|||
})
|
||||
.orderBy("current_holders.posMasterNo", "ASC")
|
||||
// .orderBy(`${sortBy}`, sort)
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
if (sortBy) {
|
||||
if(sortBy == "posLevel"){
|
||||
query = query.orderBy(
|
||||
`posLevel.posLevelName`,
|
||||
descending ? "DESC" : "ASC"
|
||||
);
|
||||
}else if(sortBy == "posType"){
|
||||
query = query.orderBy(
|
||||
`posType.posTypeName`,
|
||||
descending ? "DESC" : "ASC"
|
||||
);
|
||||
}else if(sortBy == "posNo"){
|
||||
query = query.orderBy(
|
||||
`orgRoot.orgRootShortName`,
|
||||
descending ? "DESC" : "ASC"
|
||||
);
|
||||
}else{
|
||||
query = query.orderBy(
|
||||
`profileEmployee.${sortBy}`,
|
||||
descending ? "DESC" : "ASC"
|
||||
);
|
||||
}
|
||||
}
|
||||
const [record, total] = await query
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
const data = await Promise.all(
|
||||
record.map((_data) => {
|
||||
const shortName =
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -852,10 +852,15 @@ export class KeycloakController extends Controller {
|
|||
// _item.birthDate.toISOString().slice(5, 7) +
|
||||
// gregorianYear;
|
||||
// password = formattedDate;
|
||||
const _date = new Date(_item.birthDate.toDateString()).getDate().toString().padStart(2, "0");
|
||||
const _month = (new Date(_item.birthDate.toDateString()).getMonth()+1).toString().padStart(2, "0");
|
||||
const _year = (new Date(_item.birthDate.toDateString()).getFullYear()+543);
|
||||
password = `${_date}${_month}${_year}`
|
||||
const _date = new Date(_item.birthDate.toDateString())
|
||||
.getDate()
|
||||
.toString()
|
||||
.padStart(2, "0");
|
||||
const _month = (new Date(_item.birthDate.toDateString()).getMonth() + 1)
|
||||
.toString()
|
||||
.padStart(2, "0");
|
||||
const _year = new Date(_item.birthDate.toDateString()).getFullYear() + 543;
|
||||
password = `${_date}${_month}${_year}`;
|
||||
}
|
||||
const checkUser = await getUserByUsername(_item.citizenId);
|
||||
let userId: any = "";
|
||||
|
|
@ -918,10 +923,15 @@ export class KeycloakController extends Controller {
|
|||
// _item.birthDate.toISOString().slice(5, 7) +
|
||||
// gregorianYear;
|
||||
// password = formattedDate;
|
||||
const _date = new Date(_item.birthDate.toDateString()).getDate().toString().padStart(2, "0");
|
||||
const _month = (new Date(_item.birthDate.toDateString()).getMonth()+1).toString().padStart(2, "0");
|
||||
const _year = (new Date(_item.birthDate.toDateString()).getFullYear()+543);
|
||||
password = `${_date}${_month}${_year}`
|
||||
const _date = new Date(_item.birthDate.toDateString())
|
||||
.getDate()
|
||||
.toString()
|
||||
.padStart(2, "0");
|
||||
const _month = (new Date(_item.birthDate.toDateString()).getMonth() + 1)
|
||||
.toString()
|
||||
.padStart(2, "0");
|
||||
const _year = new Date(_item.birthDate.toDateString()).getFullYear() + 543;
|
||||
password = `${_date}${_month}${_year}`;
|
||||
}
|
||||
const checkUser = await getUserByUsername(_item.citizenId);
|
||||
let userId: any = "";
|
||||
|
|
@ -990,4 +1000,83 @@ export class KeycloakController extends Controller {
|
|||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@Post("add-role-staff/user/{child1Id}")
|
||||
@Security("bearerAuth", ["system", "admin"])
|
||||
async addroleStaffToUser(
|
||||
@Path() child1Id: string,
|
||||
@Request() request: { user: { sub: string; preferred_username: string } },
|
||||
) {
|
||||
const profiles = await this.profileRepo.find({
|
||||
where: {
|
||||
keycloak: Not(IsNull()),
|
||||
current_holders: {
|
||||
orgChild1Id: child1Id,
|
||||
},
|
||||
},
|
||||
relations: ["roleKeycloaks"],
|
||||
});
|
||||
// return profiles.length;
|
||||
|
||||
for await (const _item of profiles) {
|
||||
let password = _item.citizenId;
|
||||
if (_item.birthDate != null) {
|
||||
const _date = new Date(_item.birthDate.toDateString())
|
||||
.getDate()
|
||||
.toString()
|
||||
.padStart(2, "0");
|
||||
const _month = (new Date(_item.birthDate.toDateString()).getMonth() + 1)
|
||||
.toString()
|
||||
.padStart(2, "0");
|
||||
const _year = new Date(_item.birthDate.toDateString()).getFullYear() + 543;
|
||||
password = `${_date}${_month}${_year}`;
|
||||
}
|
||||
const checkUser = await getUserByUsername(_item.citizenId);
|
||||
let userId: any = "";
|
||||
if (checkUser.length == 0) {
|
||||
userId = await createUser(_item.citizenId, password, {
|
||||
firstName: _item.firstName,
|
||||
lastName: _item.lastName,
|
||||
});
|
||||
if (typeof userId !== "string") {
|
||||
throw new Error(userId.errorMessage);
|
||||
}
|
||||
} else {
|
||||
userId = checkUser[0].id;
|
||||
}
|
||||
|
||||
const list = await getRoles();
|
||||
if (!Array.isArray(list)) throw new Error("Failed. Cannot get role(s) data from the server.");
|
||||
const resultUser = await addUserRoles(
|
||||
userId,
|
||||
list.filter((v) => v.id == "8a1a0dc9-304c-4e5b-a90a-65f841048212"),
|
||||
);
|
||||
const resultStaff = await addUserRoles(
|
||||
userId,
|
||||
list.filter((v) => v.id == "f1fff8db-0795-47c1-9952-f3c18d5b6172"),
|
||||
);
|
||||
|
||||
// if (!resultUser) {
|
||||
// throw new Error("Failed. Cannot set user's role.");
|
||||
// }
|
||||
|
||||
// if (!resultStaff) {
|
||||
// throw new Error("Failed. Cannot set staff's role.");
|
||||
// }
|
||||
if (typeof userId === "string") {
|
||||
_item.keycloak = userId;
|
||||
}
|
||||
const roleKeycloakUser = await this.roleKeycloakRepo.find({
|
||||
where: { id: "8a1a0dc9-304c-4e5b-a90a-65f841048212" },
|
||||
});
|
||||
const roleKeycloakStaff = await this.roleKeycloakRepo.find({
|
||||
where: { id: "f1fff8db-0795-47c1-9952-f3c18d5b6172" },
|
||||
});
|
||||
if (_item) {
|
||||
_item.roleKeycloaks = Array.from(new Set([...roleKeycloakUser, ...roleKeycloakStaff]));
|
||||
this.profileRepo.save(_item);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { AppDataSource } from "../database/data-source";
|
||||
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
|
||||
import { EmployeeTempPosMaster } from "../entities/EmployeeTempPosMaster";
|
||||
import { OrgRevision } from "../entities/OrgRevision";
|
||||
import { PosMaster } from "../entities/PosMaster";
|
||||
import { PosMasterEmployeeHistory } from "../entities/PosMasterEmployeeHistory";
|
||||
import { PosMasterEmployeeTempHistory } from "../entities/PosMasterEmployeeTempHistory";
|
||||
|
|
@ -17,6 +18,7 @@ export async function CreatePosMasterHistoryOfficer(
|
|||
await AppDataSource.transaction(async (manager) => {
|
||||
const repoPosmaster = manager.getRepository(PosMaster);
|
||||
const repoHistory = manager.getRepository(PosMasterHistory);
|
||||
const repoOrgRevision = manager.getRepository(OrgRevision);
|
||||
|
||||
const pm = await repoPosmaster.findOne({
|
||||
where: { id: posMasterId },
|
||||
|
|
@ -31,11 +33,20 @@ export async function CreatePosMasterHistoryOfficer(
|
|||
"orgChild3",
|
||||
"orgChild4",
|
||||
"current_holder",
|
||||
"next_holder",
|
||||
],
|
||||
});
|
||||
|
||||
if (!pm) return false;
|
||||
if (!pm.ancestorDNA) return false;
|
||||
|
||||
const checkCurrentRevision = await repoOrgRevision.findOne({
|
||||
where:{
|
||||
id: pm.orgRevisionId,
|
||||
orgRevisionIsCurrent: true,
|
||||
orgRevisionIsDraft: false
|
||||
}
|
||||
})
|
||||
const _null: any = null;
|
||||
const h = new PosMasterHistory();
|
||||
const selectedPosition =
|
||||
|
|
@ -44,9 +55,15 @@ export async function CreatePosMasterHistoryOfficer(
|
|||
: null;
|
||||
h.ancestorDNA = pm.ancestorDNA ? pm.ancestorDNA : _null;
|
||||
if(!type || type != "DELETE"){
|
||||
h.prefix = pm.current_holder?.prefix || _null;
|
||||
h.firstName = pm.current_holder?.firstName || _null;
|
||||
h.lastName = pm.current_holder?.lastName || _null;
|
||||
if(checkCurrentRevision){
|
||||
h.prefix = pm.current_holder?.prefix || _null;
|
||||
h.firstName = pm.current_holder?.firstName || _null;
|
||||
h.lastName = pm.current_holder?.lastName || _null;
|
||||
}else{
|
||||
h.prefix = pm.next_holder?.prefix || _null;
|
||||
h.firstName = pm.next_holder?.firstName || _null;
|
||||
h.lastName = pm.next_holder?.lastName || _null;
|
||||
}
|
||||
h.position = selectedPosition?.positionName ?? _null;
|
||||
h.posType = selectedPosition?.posType?.posTypeName ?? _null;
|
||||
h.posLevel = selectedPosition?.posLevel?.posLevelName ?? _null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue