|
|
@@ -9,15 +9,9 @@ export class OrderRecord {
|
|
|
@PrimaryGeneratedColumn({ unsigned: true })
|
|
|
id!: number;
|
|
|
|
|
|
- @Column({ name: 'company_name', type: 'varchar', length: 255, comment: '公司名称' })
|
|
|
- companyName!: string;
|
|
|
-
|
|
|
@Column({ name: 'order_number', type: 'varchar', length: 50, comment: '订单编号' })
|
|
|
orderNumber!: string;
|
|
|
|
|
|
- @Column({ name: 'contact_person', type: 'varchar', length: 50, comment: '联系人' })
|
|
|
- contactPerson!: string;
|
|
|
-
|
|
|
@Column({ name: 'order_date', type: 'date', comment: '下单日期' })
|
|
|
orderDate!: Date;
|
|
|
|
|
|
@@ -33,9 +27,6 @@ export class OrderRecord {
|
|
|
@Column({ name: 'order_status', type: 'tinyint', default: 0, comment: '订单状态(0-未处理,1-已完成)' })
|
|
|
orderStatus!: number;
|
|
|
|
|
|
- @Column({ name: 'salesperson', type: 'varchar', length: 50, comment: '业务员' })
|
|
|
- salesperson!: string;
|
|
|
-
|
|
|
// 外键关系
|
|
|
@Column({ name: 'client_id', type: 'int', unsigned: true, nullable: true, comment: '客户ID' })
|
|
|
clientId?: number;
|
|
|
@@ -44,8 +35,8 @@ export class OrderRecord {
|
|
|
@JoinColumn({ name: 'client_id', referencedColumnName: 'id' })
|
|
|
client?: Client;
|
|
|
|
|
|
- @Column({ name: 'linkman_id', type: 'varchar', length: 50, nullable: true, comment: '联系人ID' })
|
|
|
- linkmanId?: string;
|
|
|
+ @Column({ name: 'linkman_id', type: 'int', unsigned: true, nullable: true, comment: '联系人ID' })
|
|
|
+ linkmanId?: number;
|
|
|
|
|
|
@ManyToOne(() => Linkman, { nullable: true })
|
|
|
@JoinColumn({ name: 'linkman_id', referencedColumnName: 'id' })
|
|
|
@@ -71,17 +62,14 @@ export class OrderRecord {
|
|
|
// 基础Schema
|
|
|
export const OrderRecordSchema = z.object({
|
|
|
id: z.number().int().positive().openapi({ description: '记录ID' }),
|
|
|
- companyName: z.string().max(255).openapi({ description: '公司名称', example: '测试科技有限公司' }),
|
|
|
orderNumber: z.string().max(50).openapi({ description: '订单编号', example: 'ORD202407150001' }),
|
|
|
- contactPerson: z.string().max(50).openapi({ description: '联系人', example: '张三' }),
|
|
|
orderDate: z.string().datetime().openapi({ description: '下单日期', example: '2024-07-15' }),
|
|
|
deliveryDate: z.string().datetime().nullable().openapi({ description: '交单日期', example: '2024-07-20' }),
|
|
|
advancePayment: z.coerce.number().multipleOf(0.01).openapi({ description: '预付款', example: 1000.00 }),
|
|
|
orderAmount: z.coerce.number().multipleOf(0.01).openapi({ description: '订单金额', example: 5000.00 }),
|
|
|
orderStatus: z.coerce.number().int().min(0).max(1).openapi({ description: '订单状态(0-未处理,1-已完成)', example: 0 }),
|
|
|
- salesperson: z.string().max(50).openapi({ description: '业务员', example: '李四' }),
|
|
|
clientId: z.number().int().positive().nullable().openapi({ description: '客户ID', example: 1 }),
|
|
|
- linkmanId: z.string().max(50).nullable().openapi({ description: '联系人ID', example: 'LM001' }),
|
|
|
+ linkmanId: z.number().int().positive().nullable().openapi({ description: '联系人ID', example: 1 }),
|
|
|
userId: z.number().int().positive().nullable().openapi({ description: '业务员用户ID', example: 1 }),
|
|
|
isDeleted: z.coerce.number().int().min(0).max(1).default(0).openapi({ description: '删除状态', example: 0 }),
|
|
|
createdAt: z.string().datetime().openapi({ description: '录入时间', example: '2024-07-15T12:00:00Z' }),
|
|
|
@@ -94,7 +82,7 @@ export const OrderRecordSchema = z.object({
|
|
|
description: '关联客户信息'
|
|
|
}),
|
|
|
linkman: z.object({
|
|
|
- id: z.string(),
|
|
|
+ id: z.number(),
|
|
|
name: z.string(),
|
|
|
mobile: z.string().nullable()
|
|
|
}).nullable().optional().openapi({
|
|
|
@@ -111,32 +99,26 @@ export const OrderRecordSchema = z.object({
|
|
|
|
|
|
// 创建DTO
|
|
|
export const CreateOrderRecordDto = z.object({
|
|
|
- companyName: z.string().max(255).openapi({ description: '公司名称', example: '测试科技有限公司' }),
|
|
|
orderNumber: z.string().max(50).openapi({ description: '订单编号', example: 'ORD202407150001' }),
|
|
|
- contactPerson: z.string().max(50).openapi({ description: '联系人', example: '张三' }),
|
|
|
orderDate: z.coerce.date().openapi({ description: '下单日期', example: '2024-07-15' }),
|
|
|
deliveryDate: z.coerce.date().nullable().optional().openapi({ description: '交单日期', example: '2024-07-20' }),
|
|
|
advancePayment: z.coerce.number().multipleOf(0.01).default(0).openapi({ description: '预付款', example: 1000.00 }),
|
|
|
orderAmount: z.coerce.number().multipleOf(0.01).default(0).openapi({ description: '订单金额', example: 5000.00 }),
|
|
|
orderStatus: z.coerce.number().int().min(0).max(1).default(0).openapi({ description: '订单状态', example: 0 }),
|
|
|
- salesperson: z.string().max(50).openapi({ description: '业务员', example: '李四' }),
|
|
|
clientId: z.coerce.number().int().positive().nullable().optional().openapi({ description: '客户ID', example: 1 }),
|
|
|
- linkmanId: z.string().max(50).nullable().optional().openapi({ description: '联系人ID', example: 'LM001' }),
|
|
|
+ linkmanId: z.coerce.number().int().positive().nullable().optional().openapi({ description: '联系人ID', example: 1 }),
|
|
|
userId: z.coerce.number().int().positive().nullable().optional().openapi({ description: '业务员用户ID', example: 1 })
|
|
|
});
|
|
|
|
|
|
// 更新DTO
|
|
|
export const UpdateOrderRecordDto = z.object({
|
|
|
- companyName: z.string().max(255).optional().openapi({ description: '公司名称', example: '测试科技有限公司' }),
|
|
|
orderNumber: z.string().max(50).optional().openapi({ description: '订单编号', example: 'ORD202407150001' }),
|
|
|
- contactPerson: z.string().max(50).optional().openapi({ description: '联系人', example: '张三' }),
|
|
|
orderDate: z.coerce.date().optional().openapi({ description: '下单日期', example: '2024-07-15' }),
|
|
|
deliveryDate: z.coerce.date().nullable().optional().openapi({ description: '交单日期', example: '2024-07-20' }),
|
|
|
advancePayment: z.coerce.number().multipleOf(0.01).optional().openapi({ description: '预付款', example: 1000.00 }),
|
|
|
orderAmount: z.coerce.number().multipleOf(0.01).optional().openapi({ description: '订单金额', example: 5000.00 }),
|
|
|
orderStatus: z.coerce.number().int().min(0).max(1).optional().openapi({ description: '订单状态', example: 0 }),
|
|
|
- salesperson: z.string().max(50).optional().openapi({ description: '业务员', example: '李四' }),
|
|
|
clientId: z.coerce.number().int().positive().nullable().optional().openapi({ description: '客户ID', example: 1 }),
|
|
|
- linkmanId: z.string().max(50).nullable().optional().openapi({ description: '联系人ID', example: 'LM001' }),
|
|
|
+ linkmanId: z.coerce.number().int().positive().nullable().optional().openapi({ description: '联系人ID', example: 1 }),
|
|
|
userId: z.coerce.number().int().positive().nullable().optional().openapi({ description: '业务员用户ID', example: 1 })
|
|
|
});
|