feat: add update status flow
This commit is contained in:
parent
7413b2a8f8
commit
52c97134cb
3 changed files with 35 additions and 9 deletions
|
|
@ -0,0 +1,2 @@
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "RequestData" ADD COLUMN "flow" JSONB;
|
||||||
|
|
@ -1202,6 +1202,8 @@ model RequestData {
|
||||||
quotation Quotation @relation(fields: [quotationId], references: [id])
|
quotation Quotation @relation(fields: [quotationId], references: [id])
|
||||||
quotationId String
|
quotationId String
|
||||||
|
|
||||||
|
flow Json?
|
||||||
|
|
||||||
requestWork RequestWork[]
|
requestWork RequestWork[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,19 @@
|
||||||
import { Controller, Delete, Get, Path, Put, Query, Request, Route, Security, Tags } from "tsoa";
|
import {
|
||||||
|
Body,
|
||||||
|
Controller,
|
||||||
|
Delete,
|
||||||
|
Get,
|
||||||
|
Path,
|
||||||
|
Put,
|
||||||
|
Query,
|
||||||
|
Request,
|
||||||
|
Route,
|
||||||
|
Security,
|
||||||
|
Tags,
|
||||||
|
} from "tsoa";
|
||||||
import { RequestWithUser } from "../interfaces/user";
|
import { RequestWithUser } from "../interfaces/user";
|
||||||
import prisma from "../db";
|
import prisma from "../db";
|
||||||
import { Prisma } from "@prisma/client";
|
import { Prisma, RequestWorkStatus } from "@prisma/client";
|
||||||
import { createPermCheck, createPermCondition } from "../services/permission";
|
import { createPermCheck, createPermCondition } from "../services/permission";
|
||||||
|
|
||||||
// User in company can see.
|
// User in company can see.
|
||||||
|
|
@ -80,14 +92,24 @@ export class RequestListController extends Controller {
|
||||||
|
|
||||||
/** @todo */
|
/** @todo */
|
||||||
@Put("{requestId}")
|
@Put("{requestId}")
|
||||||
async updateRequestById(@Request() req: RequestWithUser, @Path() requestId: string) {
|
async updateRequestById(
|
||||||
return {};
|
@Request() req: RequestWithUser,
|
||||||
}
|
@Path() requestId: string,
|
||||||
|
@Body() payload: { status: RequestWorkStatus; attributes: Record<string, any> },
|
||||||
|
) {
|
||||||
|
const record = await prisma.requestWork.update({
|
||||||
|
where: { id: requestId },
|
||||||
|
data: {
|
||||||
|
workStatus: payload.status,
|
||||||
|
request: {
|
||||||
|
update: {
|
||||||
|
flow: payload.attributes,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
/** @todo */
|
return record;
|
||||||
@Delete("{requestId}")
|
|
||||||
async deleteRequestById(@Request() req: RequestWithUser, @Path() requestId: string) {
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue