109 lines
2.1 KiB
TypeScript
109 lines
2.1 KiB
TypeScript
|
|
import { PayCondition, Status } from "@prisma/client";
|
||
|
|
import {
|
||
|
|
Body,
|
||
|
|
Controller,
|
||
|
|
Delete,
|
||
|
|
Get,
|
||
|
|
Path,
|
||
|
|
Post,
|
||
|
|
Put,
|
||
|
|
Query,
|
||
|
|
Request,
|
||
|
|
Route,
|
||
|
|
Security,
|
||
|
|
Tags,
|
||
|
|
} from "tsoa";
|
||
|
|
import { RequestWithUser } from "../interfaces/user";
|
||
|
|
|
||
|
|
type QuotationCreate = {
|
||
|
|
status?: Status;
|
||
|
|
|
||
|
|
payCondition: PayCondition;
|
||
|
|
|
||
|
|
paySplitCount?: number;
|
||
|
|
paySplit?: Date[];
|
||
|
|
|
||
|
|
payBillDate?: number;
|
||
|
|
|
||
|
|
workerCount: number;
|
||
|
|
workerId: string[]; // EmployeeId
|
||
|
|
|
||
|
|
urgent?: boolean;
|
||
|
|
|
||
|
|
service: {
|
||
|
|
id: string;
|
||
|
|
// Other fields will come from original data
|
||
|
|
work?: {
|
||
|
|
// Name field will come from original data
|
||
|
|
product: {
|
||
|
|
id: string;
|
||
|
|
amount: number;
|
||
|
|
discount: number;
|
||
|
|
pricePerUnit: number;
|
||
|
|
}[];
|
||
|
|
}[];
|
||
|
|
};
|
||
|
|
};
|
||
|
|
|
||
|
|
type QuotationUpdate = {
|
||
|
|
status?: "ACTIVE" | "INACTIVE";
|
||
|
|
|
||
|
|
payCondition: PayCondition;
|
||
|
|
|
||
|
|
paySplitCount?: number;
|
||
|
|
paySplit?: Date[];
|
||
|
|
|
||
|
|
payBillDate?: number;
|
||
|
|
|
||
|
|
workerCount: number;
|
||
|
|
workerId: string[]; // EmployeeId
|
||
|
|
|
||
|
|
urgent?: boolean;
|
||
|
|
|
||
|
|
service: {
|
||
|
|
id: string;
|
||
|
|
// Other fields will come from original data
|
||
|
|
work?: {
|
||
|
|
// Name field will come from original data
|
||
|
|
product: {
|
||
|
|
id: string;
|
||
|
|
amount: number;
|
||
|
|
discount: number;
|
||
|
|
pricePerUnit: number;
|
||
|
|
}[];
|
||
|
|
}[];
|
||
|
|
};
|
||
|
|
};
|
||
|
|
|
||
|
|
@Route("/api/v1/quotation")
|
||
|
|
@Tags("Quotation")
|
||
|
|
export class QuotationController extends Controller {
|
||
|
|
@Get("{quotationId}")
|
||
|
|
@Security("keycloak")
|
||
|
|
async getQuotationById(
|
||
|
|
@Path() quotationId: string,
|
||
|
|
@Query() page: number = 1,
|
||
|
|
@Query() pageSize: number = 30,
|
||
|
|
) {}
|
||
|
|
|
||
|
|
@Get()
|
||
|
|
@Security("keycloak")
|
||
|
|
async getQuotationList(@Query() page: number = 1, @Query() pageSize: number = 30) {}
|
||
|
|
|
||
|
|
@Post()
|
||
|
|
@Security("keycloak")
|
||
|
|
async createQuotation(@Request() req: RequestWithUser, @Body() body: QuotationCreate) {}
|
||
|
|
|
||
|
|
@Put("{quotationId}")
|
||
|
|
@Security("keycloak")
|
||
|
|
async editQuotation(
|
||
|
|
@Request() req: RequestWithUser,
|
||
|
|
@Path() quotationId: string,
|
||
|
|
@Body() body: QuotationUpdate,
|
||
|
|
) {}
|
||
|
|
|
||
|
|
@Delete("{quotationId}")
|
||
|
|
@Security("keycloak")
|
||
|
|
async deleteQuotationById(@Request() req: RequestWithUser, @Path() quotationId: string) {}
|
||
|
|
}
|