feat: add workflow step detail field
This commit is contained in:
parent
b758067e14
commit
4fc88b9872
3 changed files with 30 additions and 0 deletions
|
|
@ -0,0 +1,2 @@
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "WorkflowTemplateStep" ADD COLUMN "detail" TEXT;
|
||||||
|
|
@ -946,6 +946,7 @@ model WorkflowTemplateStep {
|
||||||
|
|
||||||
order Int
|
order Int
|
||||||
name String
|
name String
|
||||||
|
detail String?
|
||||||
type String?
|
type String?
|
||||||
value WorkflowTemplateStepValue[] // NOTE: For enum or options type
|
value WorkflowTemplateStepValue[] // NOTE: For enum or options type
|
||||||
responsiblePerson WorkflowTemplateStepUser[]
|
responsiblePerson WorkflowTemplateStepUser[]
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ type WorkflowPayload = {
|
||||||
step: {
|
step: {
|
||||||
id?: string;
|
id?: string;
|
||||||
name: string;
|
name: string;
|
||||||
|
detail?: string;
|
||||||
type?: string;
|
type?: string;
|
||||||
value?: string[];
|
value?: string[];
|
||||||
responsiblePersonId?: string[];
|
responsiblePersonId?: string[];
|
||||||
|
|
@ -112,6 +113,32 @@ export class FlowTemplateController extends Controller {
|
||||||
|
|
||||||
@Post()
|
@Post()
|
||||||
async createFlowTemplate(@Request() req: RequestWithUser, @Body() body: WorkflowPayload) {
|
async createFlowTemplate(@Request() req: RequestWithUser, @Body() body: WorkflowPayload) {
|
||||||
|
const where = {
|
||||||
|
OR: [
|
||||||
|
{ name: { contains: body.name } },
|
||||||
|
{
|
||||||
|
step: {
|
||||||
|
some: { name: { contains: body.name } },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
AND: {
|
||||||
|
registeredBranch: {
|
||||||
|
OR: permissionCondCompany(req.user),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
} satisfies Prisma.WorkflowTemplateWhereInput;
|
||||||
|
|
||||||
|
const exists = await prisma.workflowTemplate.findFirst({ where });
|
||||||
|
|
||||||
|
if (exists) {
|
||||||
|
throw new HttpError(
|
||||||
|
HttpStatus.BAD_REQUEST,
|
||||||
|
"Workflow template with this name already exists",
|
||||||
|
"sameNameExists",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const userAffiliatedBranch = await prisma.branch.findFirst({
|
const userAffiliatedBranch = await prisma.branch.findFirst({
|
||||||
include: branchRelationPermInclude(req.user),
|
include: branchRelationPermInclude(req.user),
|
||||||
where: body.registeredBranchId
|
where: body.registeredBranchId
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue