|
|
@@ -1,4 +1,5 @@
|
|
|
-import { Entity, PrimaryColumn, Column, Index } from 'typeorm';
|
|
|
+import { Entity, PrimaryColumn, Column, Index, ForeignKey } from 'typeorm';
|
|
|
+import { Client } from '../clients/client.entity';
|
|
|
import { z } from '@hono/zod-openapi';
|
|
|
|
|
|
@Entity('hetong')
|
|
|
@@ -12,8 +13,9 @@ export class Hetong {
|
|
|
@Column({ name: 'user_id', type: 'varchar', length: 50 })
|
|
|
userId!: string;
|
|
|
|
|
|
- @Column({ name: 'client_id', type: 'varchar', length: 50 })
|
|
|
- clientId!: string;
|
|
|
+ @Column({ name: 'client_id', type: 'int', unsigned: true })
|
|
|
+ @ForeignKey(() => Client)
|
|
|
+ clientId!: number;
|
|
|
|
|
|
@Column({ name: 'project_id', type: 'varchar', length: 50, nullable: true })
|
|
|
projectId?: string;
|
|
|
@@ -76,9 +78,9 @@ export const HetongSchema = z.object({
|
|
|
description: '关联用户ID',
|
|
|
example: 'U1001'
|
|
|
}),
|
|
|
- clientId: z.string().max(50).openapi({
|
|
|
+ clientId: z.number().int().positive().openapi({
|
|
|
description: '客户ID',
|
|
|
- example: 'C2001'
|
|
|
+ example: 2001
|
|
|
}),
|
|
|
projectId: z.string().max(50).nullable().openapi({
|
|
|
description: '项目ID',
|
|
|
@@ -151,9 +153,9 @@ export const CreateHetongDto = z.object({
|
|
|
description: '关联用户ID',
|
|
|
example: 'U1001'
|
|
|
}),
|
|
|
- clientId: z.string().max(50).openapi({
|
|
|
+ clientId: z.coerce.number().int().positive().openapi({
|
|
|
description: '客户ID',
|
|
|
- example: 'C2001'
|
|
|
+ example: 2001
|
|
|
}),
|
|
|
projectId: z.string().max(50).nullable().optional().openapi({
|
|
|
description: '项目ID',
|
|
|
@@ -214,9 +216,9 @@ export const UpdateHetongDto = z.object({
|
|
|
description: '关联用户ID',
|
|
|
example: 'U1001'
|
|
|
}),
|
|
|
- clientId: z.string().max(50).optional().openapi({
|
|
|
+ clientId: z.coerce.number().int().positive().optional().openapi({
|
|
|
description: '客户ID',
|
|
|
- example: 'C2001'
|
|
|
+ example: 2001
|
|
|
}),
|
|
|
projectId: z.string().max(50).nullable().optional().openapi({
|
|
|
description: '项目ID',
|