|
|
@@ -1,5 +1,6 @@
|
|
|
-import { Entity, PrimaryGeneratedColumn, Column, Index } from 'typeorm';
|
|
|
+import { Entity, PrimaryGeneratedColumn, Column, Index, JoinColumn, ManyToOne } from 'typeorm';
|
|
|
import { z } from '@hono/zod-openapi';
|
|
|
+import { UserEntity } from '@/server/modules/users/user.entity';
|
|
|
|
|
|
@Entity('client')
|
|
|
export class Client {
|
|
|
@@ -63,6 +64,24 @@ export class Client {
|
|
|
@Column({ name: 'responsible_user_id', type: 'int', unsigned: true, nullable: true })
|
|
|
responsibleUserId?: number;
|
|
|
|
|
|
+ @ManyToOne(() => UserEntity, { nullable: true })
|
|
|
+ @JoinColumn({ name: 'responsible_user_id', referencedColumnName: 'id' })
|
|
|
+ responsibleUser?: UserEntity;
|
|
|
+
|
|
|
+ @Column({ name: 'sales_person_id', type: 'int', unsigned: true, nullable: true })
|
|
|
+ salesPersonId?: number;
|
|
|
+
|
|
|
+ @ManyToOne(() => UserEntity, { nullable: true })
|
|
|
+ @JoinColumn({ name: 'sales_person_id', referencedColumnName: 'id' })
|
|
|
+ salesPerson?: UserEntity;
|
|
|
+
|
|
|
+ @Column({ name: 'operator_id', type: 'int', unsigned: true, nullable: true })
|
|
|
+ operatorId?: number;
|
|
|
+
|
|
|
+ @ManyToOne(() => UserEntity, { nullable: true })
|
|
|
+ @JoinColumn({ name: 'operator_id', referencedColumnName: 'id' })
|
|
|
+ operator?: UserEntity;
|
|
|
+
|
|
|
@Column({ name: 'group_id', type: 'int', unsigned: true, nullable: true })
|
|
|
groupId?: number;
|
|
|
|
|
|
@@ -198,6 +217,14 @@ export const ClientSchema = z.object({
|
|
|
description: '负责人用户ID',
|
|
|
example: 1
|
|
|
}),
|
|
|
+ salesPersonId: z.number().int().positive().nullable().openapi({
|
|
|
+ description: '业务员用户ID',
|
|
|
+ example: 2
|
|
|
+ }),
|
|
|
+ operatorId: z.number().int().positive().nullable().openapi({
|
|
|
+ description: '操作员用户ID',
|
|
|
+ example: 3
|
|
|
+ }),
|
|
|
groupId: z.number().int().positive().nullable().openapi({
|
|
|
description: '客户所属群组ID',
|
|
|
example: 1
|
|
|
@@ -252,15 +279,34 @@ export const ClientSchema = z.object({
|
|
|
}),
|
|
|
auditStatus: z.number().int().min(0).max(2).openapi({
|
|
|
description: '审核状态:0-待审核,1-已审核,2-已拒绝',
|
|
|
- example: 1
|
|
|
- }),
|
|
|
- createdAt: z.date().openapi({
|
|
|
- description: '创建时间',
|
|
|
- example: '2023-01-01T00:00:00Z'
|
|
|
+ example: 0
|
|
|
}),
|
|
|
- updatedAt: z.date().openapi({
|
|
|
- description: '更新时间',
|
|
|
- example: '2023-01-01T00:00:00Z'
|
|
|
+ responsibleUser: z.object({
|
|
|
+ id: z.number(),
|
|
|
+ username: z.string(),
|
|
|
+ name: z.string().nullable(),
|
|
|
+ email: z.string().nullable(),
|
|
|
+ phone: z.string().nullable()
|
|
|
+ }).nullable().optional().openapi({
|
|
|
+ description: '负责人用户信息'
|
|
|
+ }),
|
|
|
+ salesPerson: z.object({
|
|
|
+ id: z.number(),
|
|
|
+ username: z.string(),
|
|
|
+ name: z.string().nullable(),
|
|
|
+ email: z.string().nullable(),
|
|
|
+ phone: z.string().nullable()
|
|
|
+ }).nullable().optional().openapi({
|
|
|
+ description: '业务员用户信息'
|
|
|
+ }),
|
|
|
+ operator: z.object({
|
|
|
+ id: z.number(),
|
|
|
+ username: z.string(),
|
|
|
+ name: z.string().nullable(),
|
|
|
+ email: z.string().nullable(),
|
|
|
+ phone: z.string().nullable()
|
|
|
+ }).nullable().optional().openapi({
|
|
|
+ description: '操作员用户信息'
|
|
|
})
|
|
|
});
|
|
|
|
|
|
@@ -269,7 +315,7 @@ export const CreateClientDto = z.object({
|
|
|
description: '客户公司名称',
|
|
|
example: '北京科技有限公司'
|
|
|
}),
|
|
|
- areaId: z.number().int().positive().nullable().openapi({
|
|
|
+ areaId: z.number().int().positive().nullable().optional().openapi({
|
|
|
description: '所在区域ID,关联area_data表',
|
|
|
example: 1
|
|
|
}),
|
|
|
@@ -341,6 +387,14 @@ export const CreateClientDto = z.object({
|
|
|
description: '负责人用户ID',
|
|
|
example: 1
|
|
|
}),
|
|
|
+ salesPersonId: z.number().int().positive().nullable().optional().openapi({
|
|
|
+ description: '业务员用户ID',
|
|
|
+ example: 2
|
|
|
+ }),
|
|
|
+ operatorId: z.number().int().positive().nullable().optional().openapi({
|
|
|
+ description: '操作员用户ID',
|
|
|
+ example: 3
|
|
|
+ }),
|
|
|
groupId: z.number().int().positive().nullable().optional().openapi({
|
|
|
description: '客户所属群组ID',
|
|
|
example: 1
|
|
|
@@ -476,6 +530,14 @@ export const UpdateClientDto = z.object({
|
|
|
description: '负责人用户ID',
|
|
|
example: 1
|
|
|
}),
|
|
|
+ salesPersonId: z.number().int().positive().nullable().optional().openapi({
|
|
|
+ description: '业务员用户ID',
|
|
|
+ example: 2
|
|
|
+ }),
|
|
|
+ operatorId: z.number().int().positive().nullable().optional().openapi({
|
|
|
+ description: '操作员用户ID',
|
|
|
+ example: 3
|
|
|
+ }),
|
|
|
groupId: z.number().int().positive().nullable().optional().openapi({
|
|
|
description: '客户所属群组ID',
|
|
|
example: 1
|