From f67dab02a0cec0fb76ce5158099b061e0c56db6c Mon Sep 17 00:00:00 2001 From: kittapath Date: Wed, 16 Oct 2024 12:00:22 +0700 Subject: [PATCH] no message --- src/controllers/WorkflowController.ts | 46 +++++++++++++++++---------- src/entities/Workflow.ts | 16 ++++++++++ 2 files changed, 46 insertions(+), 16 deletions(-) diff --git a/src/controllers/WorkflowController.ts b/src/controllers/WorkflowController.ts index ca1d3f03..48e4bf6f 100644 --- a/src/controllers/WorkflowController.ts +++ b/src/controllers/WorkflowController.ts @@ -132,12 +132,14 @@ export class WorkflowController extends Controller { @Request() req: RequestWithUser, @Body() body: { - workflowId: string; + refId: string; + system: string; }, ) { const workflow = await this.workflowRepo.findOne({ where: { - id: body.workflowId, + refId: body.refId, + system: body.system, }, relations: ["stateOperatorUsers"], }); @@ -162,7 +164,8 @@ export class WorkflowController extends Controller { @Request() req: RequestWithUser, @Body() body: { - workflowId: string; + refId: string; + system: string; }, ) { const profile = await this.profileRepo.findOne({ @@ -171,22 +174,22 @@ export class WorkflowController extends Controller { }, }); if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลผู้ใช้งาน"); + const workflow = await this.workflowRepo.findOne({ + where: { + refId: body.refId, + system: body.system, + }, + relations: ["stateOperatorUsers"], + }); + if (!workflow) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่สามารถดำเนินการกระบวนการนี้ได้"); const stateOperatorUser = await this.stateOperatorUserRepo.findOne({ where: { - profileId: profile.id, - workflowId: body.workflowId, + workflowId: workflow.id, }, }); if (!stateOperatorUser) throw new HttpError(HttpStatus.NOT_FOUND, "ผู้ใช้งานนี้ไม่มีหน้าที่ในกระบวนการนี้"); - const workflow = await this.workflowRepo.findOne({ - where: { - id: body.workflowId, - }, - }); - if (!workflow) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่สามารถดำเนินการกระบวนการนี้ได้"); - const operator = await this.stateOperatorRepo.findOne({ where: { operator: stateOperatorUser.operator, @@ -215,12 +218,21 @@ export class WorkflowController extends Controller { @Request() req: RequestWithUser, @Body() body: { - workflowId: string; + refId: string; + system: string; }, ) { + const workflow = await this.workflowRepo.findOne({ + where: { + refId: body.refId, + system: body.system, + }, + relations: ["stateOperatorUsers"], + }); + if (!workflow) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่สามารถดำเนินการกระบวนการนี้ได้"); const state = await this.stateRepo.find({ where: { - workflowId: body.workflowId, + workflowId: workflow.id, }, order: { stateUserComments: { order: "ASC" } }, relations: ["stateUserComments"], @@ -239,12 +251,14 @@ export class WorkflowController extends Controller { @Request() req: RequestWithUser, @Body() body: { - workflowId: string; + refId: string; + system: string; }, ) { const workflow = await this.workflowRepo.findOne({ where: { - id: body.workflowId, + refId: body.refId, + system: body.system, }, relations: ["stateOperatorUsers"], }); diff --git a/src/entities/Workflow.ts b/src/entities/Workflow.ts index fd66bdd1..0c6090d6 100644 --- a/src/entities/Workflow.ts +++ b/src/entities/Workflow.ts @@ -5,6 +5,22 @@ import { StateOperatorUser } from "./StateOperatorUser"; @Entity("workflow") export class Workflow extends EntityBase { + @Column({ + nullable: true, + comment: "refIdw", + length: 255, + default: null, + }) + refId: string; + + @Column({ + nullable: true, + comment: "system", + length: 255, + default: null, + }) + system: string; + @Column({ nullable: true, comment: "ชื่อ flow",