Merge branch 'develop' into adiDev
This commit is contained in:
commit
8eae807a64
8 changed files with 2296 additions and 46 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -21,6 +21,7 @@ import { PosMasterAct } from "../entities/PosMasterAct";
|
||||||
import { getAllJSDocTagsOfKind } from "typescript";
|
import { getAllJSDocTagsOfKind } from "typescript";
|
||||||
import { viewDirectorActing } from "../entities/view/viewDirectorActing";
|
import { viewDirectorActing } from "../entities/view/viewDirectorActing";
|
||||||
import { viewDirector } from "../entities/view/viewDirector";
|
import { viewDirector } from "../entities/view/viewDirector";
|
||||||
|
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||||
|
|
||||||
@Route("api/v1/org/workflow")
|
@Route("api/v1/org/workflow")
|
||||||
@Tags("Workflow")
|
@Tags("Workflow")
|
||||||
|
|
@ -32,6 +33,7 @@ export class WorkflowController extends Controller {
|
||||||
private stateOperatorUserRepo = AppDataSource.getRepository(StateOperatorUser);
|
private stateOperatorUserRepo = AppDataSource.getRepository(StateOperatorUser);
|
||||||
private stateUserCommentRepo = AppDataSource.getRepository(StateUserComment);
|
private stateUserCommentRepo = AppDataSource.getRepository(StateUserComment);
|
||||||
private profileRepo = AppDataSource.getRepository(Profile);
|
private profileRepo = AppDataSource.getRepository(Profile);
|
||||||
|
private profileEmployeeRepo = AppDataSource.getRepository(ProfileEmployee);
|
||||||
|
|
||||||
private metaWorkflowRepo = AppDataSource.getRepository(MetaWorkflow);
|
private metaWorkflowRepo = AppDataSource.getRepository(MetaWorkflow);
|
||||||
private metaStateRepo = AppDataSource.getRepository(MetaState);
|
private metaStateRepo = AppDataSource.getRepository(MetaState);
|
||||||
|
|
@ -51,12 +53,21 @@ export class WorkflowController extends Controller {
|
||||||
posTypeName: string;
|
posTypeName: string;
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
const profile = await this.profileRepo.findOne({
|
let profileType = "OFFICER";
|
||||||
|
let profile: any = await this.profileRepo.findOne({
|
||||||
where: {
|
where: {
|
||||||
keycloak: req.user.sub,
|
keycloak: req.user.sub,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลผู้ใช้งาน");
|
if (!profile) {
|
||||||
|
profileType = "EMPLOYEE";
|
||||||
|
profile = await this.profileEmployeeRepo.findOne({
|
||||||
|
where: {
|
||||||
|
keycloak: req.user.sub,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลผู้ใช้งาน");
|
||||||
|
}
|
||||||
|
|
||||||
const metaWorkflow = await this.metaWorkflowRepo.findOne({
|
const metaWorkflow = await this.metaWorkflowRepo.findOne({
|
||||||
where: {
|
where: {
|
||||||
|
|
@ -81,6 +92,7 @@ export class WorkflowController extends Controller {
|
||||||
id: undefined,
|
id: undefined,
|
||||||
...meta,
|
...meta,
|
||||||
...body,
|
...body,
|
||||||
|
profileType: profileType,
|
||||||
system: body.sysName,
|
system: body.sysName,
|
||||||
});
|
});
|
||||||
await this.workflowRepo.save(workflow);
|
await this.workflowRepo.save(workflow);
|
||||||
|
|
@ -117,7 +129,9 @@ export class WorkflowController extends Controller {
|
||||||
|
|
||||||
const stateOperatorUser = new StateOperatorUser();
|
const stateOperatorUser = new StateOperatorUser();
|
||||||
Object.assign(stateOperatorUser, {
|
Object.assign(stateOperatorUser, {
|
||||||
profileId: profile.id,
|
profileId: profileType == "OFFICER" ? profile.id : null,
|
||||||
|
profileEmployeeId: profileType != "OFFICER" ? profile.id : null,
|
||||||
|
profileType: profileType,
|
||||||
operator: "Owner",
|
operator: "Owner",
|
||||||
order: 1,
|
order: 1,
|
||||||
workflowId: workflow.id,
|
workflowId: workflow.id,
|
||||||
|
|
@ -205,14 +219,22 @@ export class WorkflowController extends Controller {
|
||||||
action: string;
|
action: string;
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
const stateOperatorUser = await this.stateOperatorUserRepo.findOne({
|
let stateOperatorUser = await this.stateOperatorUserRepo.findOne({
|
||||||
where: {
|
where: {
|
||||||
profileId: body.profileId,
|
profileId: body.profileId,
|
||||||
workflowId: body.workflowId,
|
workflowId: body.workflowId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!stateOperatorUser)
|
if (!stateOperatorUser) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ผู้ใช้งานนี้ไม่มีหน้าที่ในกระบวนการนี้");
|
stateOperatorUser = await this.stateOperatorUserRepo.findOne({
|
||||||
|
where: {
|
||||||
|
profileEmployeeId: body.profileId,
|
||||||
|
workflowId: body.workflowId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (!stateOperatorUser)
|
||||||
|
throw new HttpError(HttpStatus.NOT_FOUND, "ผู้ใช้งานนี้ไม่มีหน้าที่ในกระบวนการนี้");
|
||||||
|
}
|
||||||
|
|
||||||
const operator = await this.stateOperatorRepo.findOne({
|
const operator = await this.stateOperatorRepo.findOne({
|
||||||
where: {
|
where: {
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ import { ProfileEdit } from "./ProfileEdit";
|
||||||
import { ProfileDevelopment } from "./ProfileDevelopment";
|
import { ProfileDevelopment } from "./ProfileDevelopment";
|
||||||
import { DevelopmentRequest } from "./DevelopmentRequest";
|
import { DevelopmentRequest } from "./DevelopmentRequest";
|
||||||
import { RoleKeycloak } from "./RoleKeycloak";
|
import { RoleKeycloak } from "./RoleKeycloak";
|
||||||
|
import { StateOperatorUser } from "./StateOperatorUser";
|
||||||
|
|
||||||
@Entity("profileEmployee")
|
@Entity("profileEmployee")
|
||||||
export class ProfileEmployee extends EntityBase {
|
export class ProfileEmployee extends EntityBase {
|
||||||
|
|
@ -695,6 +696,9 @@ export class ProfileEmployee extends EntityBase {
|
||||||
@OneToMany(() => ProfileFamilyCouple, (v) => v.profile)
|
@OneToMany(() => ProfileFamilyCouple, (v) => v.profile)
|
||||||
profileFamilyCouple: ProfileFamilyCouple[];
|
profileFamilyCouple: ProfileFamilyCouple[];
|
||||||
|
|
||||||
|
@OneToMany(() => StateOperatorUser, (v) => v.profile)
|
||||||
|
stateOperatorUsers: StateOperatorUser[];
|
||||||
|
|
||||||
//ที่อยู่
|
//ที่อยู่
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,14 @@ export class RoleKeycloak extends EntityBase {
|
||||||
})
|
})
|
||||||
name: string;
|
name: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "คำอธิบาย",
|
||||||
|
length: 255,
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
description: string;
|
||||||
|
|
||||||
@ManyToMany(() => Profile, (profile) => profile.roleKeycloaks)
|
@ManyToMany(() => Profile, (profile) => profile.roleKeycloaks)
|
||||||
profiles: Profile[];
|
profiles: Profile[];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
|
||||||
import { EntityBase } from "./base/Base";
|
import { EntityBase } from "./base/Base";
|
||||||
import { Workflow } from "./Workflow";
|
import { Workflow } from "./Workflow";
|
||||||
import { Profile } from "./Profile";
|
import { Profile } from "./Profile";
|
||||||
|
import { ProfileEmployee } from "./ProfileEmployee";
|
||||||
|
|
||||||
@Entity("stateOperatorUser")
|
@Entity("stateOperatorUser")
|
||||||
export class StateOperatorUser extends EntityBase {
|
export class StateOperatorUser extends EntityBase {
|
||||||
|
|
@ -13,6 +14,14 @@ export class StateOperatorUser extends EntityBase {
|
||||||
})
|
})
|
||||||
operator: string;
|
operator: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "ผู้ใช้งาน",
|
||||||
|
length: 255,
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
profileType: string;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
comment: "ลำดับ",
|
comment: "ลำดับ",
|
||||||
|
|
@ -44,4 +53,17 @@ export class StateOperatorUser extends EntityBase {
|
||||||
@ManyToOne(() => Profile, (profile) => profile.stateOperatorUsers)
|
@ManyToOne(() => Profile, (profile) => profile.stateOperatorUsers)
|
||||||
@JoinColumn({ name: "profileId" })
|
@JoinColumn({ name: "profileId" })
|
||||||
profile: Profile;
|
profile: Profile;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
length: 40,
|
||||||
|
comment: "คีย์นอก(FK)ของตาราง profileEmployee",
|
||||||
|
type: "uuid",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
profileEmployeeId: string;
|
||||||
|
|
||||||
|
@ManyToOne(() => ProfileEmployee, (profileEmployee) => profileEmployee.stateOperatorUsers)
|
||||||
|
@JoinColumn({ name: "profileEmployeeId" })
|
||||||
|
profileEmployee: ProfileEmployee;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,14 @@ export class Workflow extends EntityBase {
|
||||||
})
|
})
|
||||||
refId: string;
|
refId: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "ผู้ใช้งาน",
|
||||||
|
length: 255,
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
profileType: string;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
comment: "ชื่อ flow",
|
comment: "ชื่อ flow",
|
||||||
|
|
|
||||||
20
src/migration/1731941837869-updata_workflow_add_rmployee.ts
Normal file
20
src/migration/1731941837869-updata_workflow_add_rmployee.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class UpdataWorkflowAddRmployee1731941837869 implements MigrationInterface {
|
||||||
|
name = 'UpdataWorkflowAddRmployee1731941837869'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`workflow\` ADD \`profileType\` varchar(255) NULL COMMENT 'ผู้ใช้งาน'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`stateOperatorUser\` ADD \`profileType\` varchar(255) NULL COMMENT 'ผู้ใช้งาน'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`stateOperatorUser\` ADD \`profileEmployeeId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง profileEmployee'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`stateOperatorUser\` ADD CONSTRAINT \`FK_7039ce6f8c316e5bbdc879e801b\` FOREIGN KEY (\`profileEmployeeId\`) REFERENCES \`profileEmployee\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`stateOperatorUser\` DROP FOREIGN KEY \`FK_7039ce6f8c316e5bbdc879e801b\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`stateOperatorUser\` DROP COLUMN \`profileEmployeeId\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`stateOperatorUser\` DROP COLUMN \`profileType\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`workflow\` DROP COLUMN \`profileType\``);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
14
src/migration/1731987222018-updata_workflow_add_rmployee1.ts
Normal file
14
src/migration/1731987222018-updata_workflow_add_rmployee1.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class UpdataWorkflowAddRmployee11731987222018 implements MigrationInterface {
|
||||||
|
name = 'UpdataWorkflowAddRmployee11731987222018'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`roleKeycloak\` ADD \`description\` varchar(255) NULL COMMENT 'คำอธิบาย'`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`roleKeycloak\` DROP COLUMN \`description\``);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue