|
@@ -1,13 +1,18 @@
|
|
|
-import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm';
|
|
|
|
|
|
|
+import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, JoinColumn } from 'typeorm';
|
|
|
import { z } from '@hono/zod-openapi';
|
|
import { z } from '@hono/zod-openapi';
|
|
|
|
|
+import { Client } from '@/server/modules/clients/client.entity';
|
|
|
|
|
|
|
|
@Entity('follow_up_record')
|
|
@Entity('follow_up_record')
|
|
|
export class FollowUpRecord {
|
|
export class FollowUpRecord {
|
|
|
@PrimaryGeneratedColumn({ unsigned: true })
|
|
@PrimaryGeneratedColumn({ unsigned: true })
|
|
|
id!: number;
|
|
id!: number;
|
|
|
|
|
|
|
|
- @Column({ name: 'serial_number', type: 'varchar', length: 50, comment: '编号' })
|
|
|
|
|
- serialNumber!: string;
|
|
|
|
|
|
|
+ @Column({ name: 'client_id', type: 'int', unsigned: true, nullable: false, comment: '客户ID' })
|
|
|
|
|
+ clientId!: number;
|
|
|
|
|
+
|
|
|
|
|
+ @ManyToOne(() => Client, { nullable: false })
|
|
|
|
|
+ @JoinColumn({ name: 'client_id', referencedColumnName: 'id' })
|
|
|
|
|
+ client!: Client;
|
|
|
|
|
|
|
|
@Column({ name: 'resource_name', type: 'varchar', length: 255, comment: '收录资源' })
|
|
@Column({ name: 'resource_name', type: 'varchar', length: 255, comment: '收录资源' })
|
|
|
resourceName!: string;
|
|
resourceName!: string;
|
|
@@ -26,23 +31,38 @@ export class FollowUpRecord {
|
|
|
|
|
|
|
|
@Column({ name: 'updated_at', type: 'timestamp', default: () => 'CURRENT_TIMESTAMP', onUpdate: 'CURRENT_TIMESTAMP', comment: '更新时间' })
|
|
@Column({ name: 'updated_at', type: 'timestamp', default: () => 'CURRENT_TIMESTAMP', onUpdate: 'CURRENT_TIMESTAMP', comment: '更新时间' })
|
|
|
updatedAt!: Date;
|
|
updatedAt!: Date;
|
|
|
|
|
+
|
|
|
|
|
+ @Column({ name: 'created_by', type: 'int', unsigned: true, nullable: true, comment: '创建用户ID' })
|
|
|
|
|
+ createdBy?: number;
|
|
|
|
|
+
|
|
|
|
|
+ @Column({ name: 'updated_by', type: 'int', unsigned: true, nullable: true, comment: '更新用户ID' })
|
|
|
|
|
+ updatedBy?: number;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 基础Schema
|
|
// 基础Schema
|
|
|
export const FollowUpRecordSchema = z.object({
|
|
export const FollowUpRecordSchema = z.object({
|
|
|
id: z.number().int().positive().openapi({ description: '主键ID' }),
|
|
id: z.number().int().positive().openapi({ description: '主键ID' }),
|
|
|
- serialNumber: z.string().max(50).openapi({ description: '编号', example: 'FUP202407150001' }),
|
|
|
|
|
|
|
+ clientId: z.number().int().positive().openapi({ description: '客户ID', example: 1 }),
|
|
|
resourceName: z.string().max(255).openapi({ description: '收录资源', example: '某科技公司合作项目' }),
|
|
resourceName: z.string().max(255).openapi({ description: '收录资源', example: '某科技公司合作项目' }),
|
|
|
nextContactTime: z.string().datetime().nullable().openapi({ description: '下次联系时间', example: '2024-07-20 14:30:00' }),
|
|
nextContactTime: z.string().datetime().nullable().openapi({ description: '下次联系时间', example: '2024-07-20 14:30:00' }),
|
|
|
details: z.string().nullable().optional().openapi({ description: '详细备注', example: '客户对产品功能有特殊要求,需要单独沟通' }),
|
|
details: z.string().nullable().optional().openapi({ description: '详细备注', example: '客户对产品功能有特殊要求,需要单独沟通' }),
|
|
|
isDeleted: z.coerce.number().int().min(0).max(1).default(0).openapi({ description: '删除状态', example: 0 }),
|
|
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' }),
|
|
createdAt: z.string().datetime().openapi({ description: '录入时间', example: '2024-07-15T12:00:00Z' }),
|
|
|
- updatedAt: z.string().datetime().openapi({ description: '更新时间', example: '2024-07-15T12:00:00Z' })
|
|
|
|
|
|
|
+ updatedAt: z.string().datetime().openapi({ description: '更新时间', example: '2024-07-15T12:00:00Z' }),
|
|
|
|
|
+ createdBy: z.number().int().positive().nullable().openapi({ description: '创建用户ID', example: 1 }),
|
|
|
|
|
+ updatedBy: z.number().int().positive().nullable().openapi({ description: '更新用户ID', example: 1 }),
|
|
|
|
|
+ client: z.object({
|
|
|
|
|
+ id: z.number(),
|
|
|
|
|
+ companyName: z.string(),
|
|
|
|
|
+ contactPerson: z.string().nullable()
|
|
|
|
|
+ }).nullable().optional().openapi({
|
|
|
|
|
+ description: '关联客户信息'
|
|
|
|
|
+ })
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
// 创建DTO
|
|
// 创建DTO
|
|
|
export const CreateFollowUpRecordDto = z.object({
|
|
export const CreateFollowUpRecordDto = z.object({
|
|
|
- serialNumber: z.string().max(50).openapi({ description: '编号', example: 'FUP202407150001' }),
|
|
|
|
|
|
|
+ clientId: z.coerce.number().int().positive().openapi({ description: '客户ID', example: 1 }),
|
|
|
resourceName: z.string().max(255).openapi({ description: '收录资源', example: '某科技公司合作项目' }),
|
|
resourceName: z.string().max(255).openapi({ description: '收录资源', example: '某科技公司合作项目' }),
|
|
|
nextContactTime: z.coerce.date().nullable().optional().openapi({ description: '下次联系时间', example: '2024-07-20 14:30:00' }),
|
|
nextContactTime: z.coerce.date().nullable().optional().openapi({ description: '下次联系时间', example: '2024-07-20 14:30:00' }),
|
|
|
details: z.string().nullable().optional().openapi({ description: '详细备注', example: '客户对产品功能有特殊要求,需要单独沟通' })
|
|
details: z.string().nullable().optional().openapi({ description: '详细备注', example: '客户对产品功能有特殊要求,需要单独沟通' })
|
|
@@ -50,7 +70,7 @@ export const CreateFollowUpRecordDto = z.object({
|
|
|
|
|
|
|
|
// 更新DTO
|
|
// 更新DTO
|
|
|
export const UpdateFollowUpRecordDto = z.object({
|
|
export const UpdateFollowUpRecordDto = z.object({
|
|
|
- serialNumber: z.string().max(50).optional().openapi({ description: '编号', example: 'FUP202407150001' }),
|
|
|
|
|
|
|
+ clientId: z.coerce.number().int().positive().optional().openapi({ description: '客户ID', example: 1 }),
|
|
|
resourceName: z.string().max(255).optional().openapi({ description: '收录资源', example: '某科技公司合作项目' }),
|
|
resourceName: z.string().max(255).optional().openapi({ description: '收录资源', example: '某科技公司合作项目' }),
|
|
|
nextContactTime: z.coerce.date().nullable().optional().openapi({ description: '下次联系时间', example: '2024-07-20 14:30:00' }),
|
|
nextContactTime: z.coerce.date().nullable().optional().openapi({ description: '下次联系时间', example: '2024-07-20 14:30:00' }),
|
|
|
details: z.string().nullable().optional().openapi({ description: '详细备注', example: '客户对产品功能有特殊要求,需要单独沟通' })
|
|
details: z.string().nullable().optional().openapi({ description: '详细备注', example: '客户对产品功能有特殊要求,需要单独沟通' })
|