diff --git a/.env.example b/.env.example index 9efa9164..2e7bc341 100644 --- a/.env.example +++ b/.env.example @@ -1,23 +1,34 @@ AUTH_REALM_URL=https://id.frappet.synology.me/realms/bma-ehr -AUTH_PUBLIC_KEY=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvYg0ZJvH6HgNOzyPp7PCvY3bJwD9WdsNn6gZbuvIfqJQZ8iSH1t0p3fgODO/fqwcj9UFeh1bVFOSjuW+JpnPehROqzt81KNl9zLLNXoN4LimReQHaMM3dU7DCbRylgVCouIDvObyjg8G+Cy5lZvFKWym/DPwGVpSdbvDZJ83qxq2dp7GJXS8PhOvA+MB1K009/jW5pBTUwNArLjoFccr+gIYIiOJDg2rYyIF3fDkwyWkuxr6xRt10+BRJytselwy/18kbDuJxVPaapdgTXI6wLzx7HWcDk30n5EvhJEumnIPpRst8gucqNYmB4MH+vsyoxV5WLuO3qmVRzFbtAppRQIDAQAB +AUTH_PUBLIC_KEY=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1/QAH75nWgiRzWCTrGJv8q2A7z0qggC2IQ9Sva/Ok1RxeGE/ED2m4ELbF5B9MtugyXYGMUBXaKhooMpTE3wyR1OwsUlv/GtYSmMuKUnsSEXklsP8nIq8gZkCvISOVdvIC4ng5aZ5nBcp9cQ3eVbz4dfZcbLzcqLIIkxQmFBK0m1eFL5IdNj8Ac7U4eH4ylOckOu174f35NnFH6wDva6Iic3EXapMcE2BnXXCTajk2dmlWAzH13ybQBgHDfrOtulrmn1CzQxe9WUJes4qX5z72N05KsHvtUObaeN6cb+mIeH36GdysqgAdd2hhKkgUFXwtLPzldtrEc7xVyf3OLEg1QIDAQAB AUTH_PREFERRED_MODE=online AUTH_ACCOUNT_SECRET=qsFwDb5anVoXKKwoeivrByIn9VYWQNRn + APP_HOST=0.0.0.0 -APP_PORT=13001 -DB_HOST=192.168.1.80 -DB_PORT=3306 +APP_PORT=3001 + +DB_HOST=192.168.1.81 +DB_PORT=4063 DB_USERNAME=root DB_PASSWORD=adminVM123 -DB_NAME=bma_ehr_organization_demo +DB_NAME=bma_ehr_organization + +# DB_HOST=192.168.1.81 +# DB_PORT=4063 +# DB_USERNAME=root +# DB_PASSWORD=adminVM123 +# DB_NAME=bma_ehr_organization + KC_URL=https://id.frappet.synology.me KC_REALM=bma-ehr KC_SERVICE_ACCOUNT_CLIENT_ID=bma-ehr-dev KC_SERVICE_ACCOUNT_SECRET=f2mp7Xj4nz6gbgITve9J7AHXZI8dRhOd API_URL=https://bma-ehr.frappet.synology.me/api/v1 -REDIS_HOST=192.168.1.81 -REDIS_PORT=6379 + ELASTICSEARCH_INDEX=bma-ehr-log-index ELASTICSEARCH_PROTOCOL=http -ELASTICSEARCH_HOST=192.168.1.40 +ELASTICSEARCH_HOST=192.168.1.90 ELASTICSEARCH_PORT=9200 + +REDIS_HOST=192.168.1.81 +REDIS_PORT=6379 API_KEY=fKRL16yyEgbyTEJdsMw2h64tGSCmkW685PRtM3CygzX1JOSdptT9UJtpgWwKM8FybRTJups3GTFwj27ZRvlPdIkv3XgCoVJaD5LmR06ozuEPvCCRSdp2WFthg08V5xHc56fTPfZLpr1VmXrhd6dvYhHIqKkQUJR02Rlkss11cLRWEQOssEFVA4xdu2J5DIRO1EM5m7wRRvEwcDB4mYRXD9HH52SMq6iYqUWEWsMwLdbk7QW9yYESUEuzMW5gWrb6vIeWZxJV5bTz1PcWUyR7eO9Fyw1F5DiQYc9JgzTC1mW7cv31fEtTtrfbJYKIb5EbWilqIEUKC6A0UKBDDek35ML0006cqRVm0pvdOH6jeq7VQyYrhdXe59dBEyhYGUIfozoVBvW7Up4QBuOMjyPjSqJPlMBKwaseptfrblxQV1AOOivSBpf1ZcQyOZ8JktRtKUDSuXsmG0lsXwFlI3JCeSHdpVdgZWFYcJPegqfrB6KotR02t9AVkpLs1ZWrixwz \ No newline at end of file diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 8f291634..33ef6533 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -19,7 +19,7 @@ import HttpSuccess from "../interfaces/http-success"; import HttpStatusCode from "../interfaces/http-status"; import HttpError from "../interfaces/http-error"; import { Command } from "../entities/Command"; -import { Brackets, LessThan, MoreThan, Double, In, Not ,Between } from "typeorm"; +import { Brackets, LessThan, MoreThan, Double, In, Not, Between } from "typeorm"; import { CommandType } from "../entities/CommandType"; import { CommandSend } from "../entities/CommandSend"; import { Profile, CreateProfileAllFields } from "../entities/Profile"; @@ -262,7 +262,7 @@ export class CommandController extends Controller { commandYear: _data.commandYear, commandAffectDate: _data.commandAffectDate, commandExcecuteDate: _data.commandExcecuteDate, - assignFullName: _data.createdFullName, + assignFullName: null, //xxxxxxxxxxxxxxx createdFullName: _data.createdFullName, status: _data.status, issue: _data.issue, @@ -1013,11 +1013,10 @@ export class CommandController extends Controller { if (command.commandExcecuteDate == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบวันที่คำสั่งมีผล"); - let profiles = command && command.commandRecives.length > 0 - ? command.commandRecives - .filter((x) => x.profileId != null) - .map((x) => x.profileId) - : []; + let profiles = + command && command.commandRecives.length > 0 + ? command.commandRecives.filter((x) => x.profileId != null).map((x) => x.profileId) + : []; await new CallAPI() .PostData(request, "/placement/noti/profiles", { @@ -1073,12 +1072,12 @@ export class CommandController extends Controller { const command = await this.commandRepository.find({ relations: ["commandType", "commandRecives"], - where:{ + where: { commandExcecuteDate: Between(today, tomorrow), - status: "WAITING" - } + status: "WAITING", + }, }); - + const data = { client_id: "gettoken", client_secret: process.env.AUTH_ACCOUNT_SECRET, @@ -1100,27 +1099,27 @@ export class CommandController extends Controller { ]); if (_data == null) { return new HttpError(HttpStatus.UNAUTHORIZED, "ชื่อผู้ใช้งานหรือรหัสผ่านไม่ถูกต้อง"); - } + } command.forEach(async (x) => { - const path = this.commandTypePath(x.commandType.code); - if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ"); - const msg = { - data: { - id: x.id, - status: "REPORTED", - lastUpdateUserId: "system", - lastUpdateFullName: "system", - // lastUpdateUserId: _data.user.sub, - // lastUpdateFullName: _data.user.name, - lastUpdatedAt: new Date(), - }, - user: _data.user, - token: _data.access_token, - }; - sendToQueue(msg); - }) - + const path = this.commandTypePath(x.commandType.code); + if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ"); + const msg = { + data: { + id: x.id, + status: "REPORTED", + lastUpdateUserId: "system", + lastUpdateFullName: "system", + // lastUpdateUserId: _data.user.sub, + // lastUpdateFullName: _data.user.name, + lastUpdatedAt: new Date(), + }, + user: _data.user, + token: _data.access_token, + }; + sendToQueue(msg); + }); + return new HttpSuccess(); } @@ -2286,7 +2285,7 @@ export class CommandController extends Controller { const userKeycloakId = await createUser(profile.citizenId, profile.citizenId, { firstName: profile.firstName, lastName: profile.lastName, - email: profile.email, + // email: profile.email, }); if (typeof userKeycloakId !== "string") { throw new Error(userKeycloakId.errorMessage); @@ -2305,6 +2304,7 @@ export class CommandController extends Controller { ); if (!result) throw new Error("Failed. Cannot set user's role."); profile.keycloak = userKeycloakId; + profile.email = item.bodyProfile.email; await this.profileRepository.save(profile); setLogDataDiff(req, { before, after: profile }); } @@ -2773,7 +2773,7 @@ export class CommandController extends Controller { case "C-PM-05": return "/placement/appointment/appoint/report"; case "C-PM-06": - return "/placement/appointment/slip/report"; + return "/placement/slip/report"; case "C-PM-07": return "/placement/appointment/move/report"; case "C-PM-08": @@ -2781,7 +2781,7 @@ export class CommandController extends Controller { case "C-PM-09": return "/retirement/other/out/report"; case "C-PM-10": - return "/xxxxxx"; + return "/probation/report/command10/officer/report"; case "C-PM-11": return "/probation/report/command11/officer/report"; case "C-PM-12": @@ -2839,7 +2839,7 @@ export class CommandController extends Controller { case "C-PM-38": return "/org/command/command38/officer/report"; case "C-PM-39": - return "/placement/slip/report"; + return "/placement/appointment/slip/report"; case "C-PM-40": return "/org/command/command40/officer/report"; case "C-PM-41": diff --git a/src/controllers/DPISController.ts b/src/controllers/DPISController.ts index 597a997b..1d3ad25f 100644 --- a/src/controllers/DPISController.ts +++ b/src/controllers/DPISController.ts @@ -3,13 +3,25 @@ import { Controller, Example, Get, Path, Response, Route, SuccessResponse, Tags import { DateTime } from "@elastic/elasticsearch/lib/api/types"; import { Double } from "typeorm"; import { AppDataSource } from "../database/data-source"; +import { OrgRevision } from "../entities/OrgRevision"; import { Profile } from "../entities/Profile"; import HttpError from "../interfaces/http-error"; import HttpStatus from "../interfaces/http-status"; interface DPISResponse { + /** + * สถานะ + */ status: number; + + /** + * ข้อความตอบกลับ + */ message: string; + + /** + * ผลลัพธ์การค้นหา + */ result?: DPISResult; } @@ -33,6 +45,7 @@ interface DPISResult { educations: ProfileEducationResult[]; leaves: ProfileLeaveResult[]; salaries: ProfileSalaryResult[]; + organization: ProfileOrgResult; } interface ProfileLeaveResult { @@ -42,6 +55,33 @@ interface ProfileLeaveResult { totalLeave: number; } +interface ProfileOrgResult { + /** + * ผลลัพธ์การค้นหา + */ + orgRootName: string; + + /** + * กองระดับ 1 + */ + orgChild1Name: string; + + /** + * กองระดับ 2 + */ + orgChild2Name: string; + + /** + * กองระดับ 3 + */ + orgChild3Name: string; + + /** + * กองระดับ 4 + */ + orgChild4Name: string; +} + interface ProfileEducationResult { country: string; degree: string; @@ -70,6 +110,7 @@ interface ProfileSalaryResult { @SuccessResponse(HttpStatus.OK, "สำเร็จ") export class DPISController extends Controller { private profileRepo = AppDataSource.getRepository(Profile); + private orgRevisionRepo = AppDataSource.getRepository(OrgRevision); /** * แสดงข้อมูลข้าราชการจากเลขประจำตัวประชาชน @@ -101,6 +142,13 @@ export class DPISController extends Controller { leaveReason: null, positionLevel: "ปฏิบัติงาน", positionType: "ทั่วไป", + organization: { + orgRootName: "", + orgChild1Name: "", + orgChild2Name: "", + orgChild3Name: "", + orgChild4Name: "", + }, educations: [], salaries: [ { @@ -144,8 +192,10 @@ export class DPISController extends Controller { profileSalary: true, profileEducations: true, profileLeaves: true, + current_holders: true, }, where: { citizenId: citizenId }, + //relations: ["current_holders", "current_holders.orgRoot"], order: { profileSalary: { date: "DESC", @@ -159,6 +209,10 @@ export class DPISController extends Controller { }, }); if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); + const findRevision = await this.orgRevisionRepo.findOne({ + where: { orgRevisionIsCurrent: true }, + }); + var current_holder = profile.current_holders?.find((x) => x.orgRevisionId == findRevision?.id); const mapProfile: DPISResult = { citizenId: profile.citizenId, @@ -178,6 +232,14 @@ export class DPISController extends Controller { positionLevel: profile.posLevel ? profile.posLevel.posLevelName : "", positionType: profile.posType ? profile.posType.posTypeName : "", + organization: { + orgRootName: current_holder?.orgRoot?.orgRootName || "", + orgChild1Name: current_holder?.orgChild1?.orgChild1Name || "", + orgChild2Name: current_holder?.orgChild2?.orgChild2Name || "", + orgChild3Name: current_holder?.orgChild3?.orgChild3Name || "", + orgChild4Name: current_holder?.orgChild4?.orgChild4Name || "", + }, + // educations educations: profile.profileEducations.map((item) => { return { diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 178f4584..2b4120ce 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -3514,10 +3514,10 @@ export class ProfileController extends Controller { }, relations: ["orgChild1"], }); - if (posMasters == null || posMasters.orgRoot == null) { + if (posMasters == null || posMasters.orgChild1 == null) { return new HttpSuccess(false); } - return new HttpSuccess(posMasters); + return new HttpSuccess(posMasters.orgChild1.isOfficer); } /** @@ -3978,12 +3978,18 @@ export class ProfileController extends Controller { // await new permission().PermissionOrgUserGet(request, "SYS_REGISTRY_OFFICER", id);//ไม่แน่ใจOFFปิดไว้ก่อน const profile = await this.profileRepo.findOne({ where: { id: id }, - relations: ["posLevel", "posType", "current_holders", "current_holders.orgRoot", "profileSalary"], + relations: [ + "posLevel", + "posType", + "current_holders", + "current_holders.orgRoot", + "profileSalary", + ], order: { profileSalary: { order: "DESC", - } - } + }, + }, }); if (!profile) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ"); diff --git a/src/controllers/WorkflowController.ts b/src/controllers/WorkflowController.ts index 5e5837aa..e92d8327 100644 --- a/src/controllers/WorkflowController.ts +++ b/src/controllers/WorkflowController.ts @@ -1,4 +1,4 @@ -import { Body, Controller, Post, Request, Route, Security, Tags } from "tsoa"; +import { Body, Controller, Get, Path, Post, Request, Route, Security, Tags } from "tsoa"; import { AppDataSource } from "../database/data-source"; import { RequestWithUser } from "../middlewares/user"; import HttpError from "../interfaces/http-error"; @@ -14,6 +14,8 @@ import { StateUserComment } from "../entities/StateUserComment"; import { MetaWorkflow } from "../entities/MetaWorkflow"; import { MetaState } from "../entities/MetaState"; import { MetaStateOperator } from "../entities/MetaStateOperator"; +import { PosMaster } from "../entities/PosMaster"; +import { IsNull, Not } from "typeorm"; @Route("api/v1/org/workflow") @Tags("Workflow") @@ -29,6 +31,7 @@ export class WorkflowController extends Controller { private metaWorkflowRepo = AppDataSource.getRepository(MetaWorkflow); private metaStateRepo = AppDataSource.getRepository(MetaState); private metaStateOperatorRepo = AppDataSource.getRepository(MetaStateOperator); + private posMasterRepo = AppDataSource.getRepository(PosMaster); @Post("add-workflow") public async checkWorkflow( @@ -66,12 +69,19 @@ export class WorkflowController extends Controller { lastUpdatedAt: new Date(), }; const workflow = new Workflow(); - Object.assign(workflow, { ...metaWorkflow, id: undefined, ...meta }); - this.workflowRepo.save(workflow); + Object.assign(workflow, { + ...metaWorkflow, + id: undefined, + ...meta, + ...body, + system: body.sysName, + }); + await this.workflowRepo.save(workflow); const metaState = await this.metaStateRepo.find({ where: { metaWorkflowId: metaWorkflow.id, }, + order: { order: "ASC" }, }); await Promise.all( @@ -79,15 +89,19 @@ export class WorkflowController extends Controller { const state = new State(); Object.assign(state, { ...item, id: undefined, workflowId: workflow.id, ...meta }); await this.stateRepo.save(state); + if (state.order == 1) { + workflow.stateId = state.id; + await this.workflowRepo.save(workflow); + } const metaStateOperator = await this.metaStateOperatorRepo.find({ where: { metaStateId: item.id, }, }); await Promise.all( - metaStateOperator.map(async (item) => { + metaStateOperator.map(async (item1) => { const stateOperator = new StateOperator(); - Object.assign(stateOperator, { ...item, id: undefined, stateId: state.id, ...meta }); + Object.assign(stateOperator, { ...item1, id: undefined, stateId: state.id, ...meta }); await this.stateOperatorRepo.save(stateOperator); }), ); @@ -97,12 +111,46 @@ export class WorkflowController extends Controller { const stateOperatorUser = new StateOperatorUser(); Object.assign(stateOperatorUser, { profileId: profile.id, - operator: "OWNER", + operator: "Owner", order: 1, workflowId: workflow.id, ...meta, }); await this.stateOperatorUserRepo.save(stateOperatorUser); + + const profileOfficer = await this.posMasterRepo.find({ + where: { + posMasterAssigns: { assignId: body.sysName }, + orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true }, + }, + relations: ["orgChild1"], + }); + await Promise.all( + profileOfficer.map(async (item, i) => { + if (item.orgChild1 == null || item.orgChild1.isOfficer == false) { + const stateOperatorUser = new StateOperatorUser(); + Object.assign(stateOperatorUser, { + profileId: item.current_holderId, + operator: "Officer", + order: i + 2, + workflowId: workflow.id, + ...meta, + }); + await this.stateOperatorUserRepo.save(stateOperatorUser); + } else { + const stateOperatorUser = new StateOperatorUser(); + Object.assign(stateOperatorUser, { + profileId: item.current_holderId, + operator: "PersonnelOfficer", + order: i + 2, + workflowId: workflow.id, + ...meta, + }); + await this.stateOperatorUserRepo.save(stateOperatorUser); + } + }), + ); + return new HttpSuccess(); } @@ -174,7 +222,7 @@ export class WorkflowController extends Controller { const workflow = await this.workflowRepo.findOne({ where: { refId: body.refId, - system: body.system, + sysName: body.system, }, relations: ["stateOperatorUsers"], }); @@ -207,7 +255,7 @@ export class WorkflowController extends Controller { where: { workflow: { refId: body.refId, - system: body.system, + sysName: body.system, }, profile: { keycloak: req.user.sub, @@ -217,7 +265,6 @@ export class WorkflowController extends Controller { }); if (!stateOperatorUser) throw new HttpError(HttpStatus.NOT_FOUND, "ผู้ใช้งานนี้ไม่มีหน้าที่ในกระบวนการนี้"); - const operator = await this.stateOperatorRepo.findOne({ where: { operator: stateOperatorUser.operator, @@ -225,8 +272,25 @@ export class WorkflowController extends Controller { }, relations: ["state"], }); - if (!operator) - throw new HttpError(HttpStatus.NOT_FOUND, "ผู้ใช้งานนี้ไม่มีหน้าที่ในขั้นตอนนี้"); + if (!operator) { + const state = await this.stateRepo.findOne({ + where: { + id: stateOperatorUser.workflow.stateId, + }, + }); + return new HttpSuccess({ + stateId: state?.id || null, + stateNo: state?.order || null, + stateName: state?.name || null, + operator: stateOperatorUser.operator, + can_view: false, + can_update: false, + can_operate: false, + can_change_state: false, + can_delete: false, + can_cancel: false, + }); + } return new HttpSuccess({ stateId: operator.state.id, stateNo: operator.state.order, @@ -254,17 +318,29 @@ export class WorkflowController extends Controller { where: { workflow: { refId: body.refId, - system: body.system, + sysName: body.system, }, }, order: { order: "ASC", stateUserComments: { order: "ASC" } }, - relations: ["stateUserComments"], + relations: ["stateUserComments", "stateUserComments.profile"], }); const _state = state.map((x) => ({ stateId: x.id, stateNo: x.order, stateName: x.name, - stateUserComments: x.stateUserComments, + stateUserComments: x.stateUserComments.map((x) => ({ + id: x.id, + prefix: x.profile.prefix, + firstName: x.profile.firstName, + lastName: x.profile.lastName, + profileId: x.profileId, + isAcceptSetting: x.isAcceptSetting, + isApproveSetting: x.isApproveSetting, + isReasonSetting: x.isReasonSetting, + isAccept: x.isAccept, + isApprove: x.isApprove, + reason: x.reason, + })), })); return new HttpSuccess(_state); } @@ -278,24 +354,35 @@ export class WorkflowController extends Controller { system: string; }, ) { - const stateOperatorUser = await this.stateOperatorUserRepo.findOne({ + const stateOperatorUserNow = await this.stateOperatorUserRepo.findOne({ where: { workflow: { refId: body.refId, - system: body.system, + sysName: body.system, }, profile: { keycloak: req.user.sub, }, }, }); - if (!stateOperatorUser) - throw new HttpError(HttpStatus.NOT_FOUND, "ผู้ใช้งานนี้ไม่มีหน้าที่ในกระบวนการนี้"); + const stateOperatorUser = await this.stateOperatorUserRepo.find({ + where: { + workflow: { + refId: body.refId, + sysName: body.system, + }, + profile: { + keycloak: Not(req.user.sub), + }, + operator: stateOperatorUserNow?.operator || "", + }, + }); + await this.stateOperatorUserRepo.remove(stateOperatorUser); const workflow = await this.workflowRepo.findOne({ where: { refId: body.refId, - system: body.system, + sysName: body.system, }, relations: ["stateOperatorUsers"], }); @@ -538,4 +625,71 @@ export class WorkflowController extends Controller { profileId: stateUserComment?.profileId || null, }); } + + /** + * + * + */ + @Get("commander") + async getProfilePlacement(@Request() req: RequestWithUser) { + const posMasterUser = await this.posMasterRepo.findOne({ + where: { + orgRevision: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false }, + current_holder: { keycloak: req.user.sub }, + }, + }); + if (!posMasterUser || !posMasterUser.orgRootId) + throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบตำแหน่งผู้ใช้งาน"); + + const posMasters = await this.posMasterRepo.find({ + where: { + orgRevision: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false }, + isDirector: true, + current_holderId: Not(IsNull()), + orgRootId: posMasterUser.orgRootId, + }, + relations: ["current_holder", "orgRoot"], + }); + + let _posMasters = posMasters.map((data) => ({ + id: data.current_holderId, + prefix: data.current_holder.prefix, + firstName: data.current_holder.firstName, + lastName: data.current_holder.lastName, + position: data.current_holder.position, + posLevel: data.current_holder.posLevel, + posType: data.current_holder.posType, + orgRoot: data.orgRoot.orgRootName, + })); + + return new HttpSuccess(_posMasters); + } + + /** + * API เช็ค สกจ + * + * @summary เช็ค สกจ + * + */ + @Get("keycloak/isofficer/{system}") + async getIsOfficerByKeycloak(@Path() system: string, @Request() req: RequestWithUser) { + const profile = await this.profileRepo.findOne({ + where: { + keycloak: req.user.sub, + }, + }); + if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลผู้ใช้งาน"); + + const profileOfficer = await this.posMasterRepo.findOne({ + where: { + posMasterAssigns: { assignId: system }, + orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true }, + current_holderId: profile.id, + }, + relations: ["orgChild1"], + }); + if (!profileOfficer) return new HttpSuccess({ isOfficer: false, isStaff: false }); + let isOfficer = profileOfficer.orgChild1 == null ? false : profileOfficer.orgChild1.isOfficer; + return new HttpSuccess({ isOfficer: isOfficer, isStaff: !isOfficer }); + } } diff --git a/src/entities/StateOperatorUser.ts b/src/entities/StateOperatorUser.ts index d9f2d6a8..2fb40199 100644 --- a/src/entities/StateOperatorUser.ts +++ b/src/entities/StateOperatorUser.ts @@ -1,6 +1,5 @@ -import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm"; +import { Entity, Column, ManyToOne, JoinColumn } from "typeorm"; import { EntityBase } from "./base/Base"; -import { StateOperator } from "./StateOperator"; import { Workflow } from "./Workflow"; import { Profile } from "./Profile"; @@ -21,14 +20,6 @@ export class StateOperatorUser extends EntityBase { }) order: number; - @Column({ - nullable: true, - comment: "ผู้ดำเนินการ", - length: 255, - default: null, - }) - refId: string; - @Column({ nullable: true, length: 40, diff --git a/src/entities/Workflow.ts b/src/entities/Workflow.ts index 0c6090d6..e6804bf2 100644 --- a/src/entities/Workflow.ts +++ b/src/entities/Workflow.ts @@ -13,14 +13,6 @@ export class Workflow extends EntityBase { }) refId: string; - @Column({ - nullable: true, - comment: "system", - length: 255, - default: null, - }) - system: string; - @Column({ nullable: true, comment: "ชื่อ flow", diff --git a/src/migration/1729073909711-add_table_workflow8.ts b/src/migration/1729073909711-add_table_workflow8.ts new file mode 100644 index 00000000..17efd713 --- /dev/null +++ b/src/migration/1729073909711-add_table_workflow8.ts @@ -0,0 +1,16 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class AddTableWorkflow81729073909711 implements MigrationInterface { + name = 'AddTableWorkflow81729073909711' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`workflow\` DROP COLUMN \`system\``); + await queryRunner.query(`ALTER TABLE \`stateOperatorUser\` DROP COLUMN \`refId\``); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`stateOperatorUser\` ADD \`refId\` varchar(255) NULL COMMENT 'ผู้ดำเนินการ'`); + await queryRunner.query(`ALTER TABLE \`workflow\` ADD \`system\` varchar(255) NULL COMMENT 'system'`); + } + +}