| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269 |
- import { Entity, PrimaryColumn, Column, Index } from 'typeorm';
- import { z } from '@hono/zod-openapi';
- @Entity('hetong')
- export class Hetong {
- @PrimaryColumn({ name: 'id', type: 'varchar', length: 50 })
- id!: string;
- @Column({ name: 'contract_date', type: 'date' })
- contractDate!: Date;
- @Column({ name: 'user_id', type: 'varchar', length: 50 })
- userId!: string;
- @Column({ name: 'client_id', type: 'varchar', length: 50 })
- clientId!: string;
- @Column({ name: 'project_id', type: 'varchar', length: 50, nullable: true })
- projectId?: string;
- @Column({ name: 'amount', type: 'decimal', precision: 15, scale: 2 })
- amount!: number;
- @Column({ name: 'type', type: 'varchar', length: 50 })
- type!: string;
- @Column({ name: 'status', type: 'varchar', length: 50 })
- status!: string;
- @Column({ name: 'start_date', type: 'date' })
- startDate!: Date;
- @Column({ name: 'end_date', type: 'date' })
- endDate!: Date;
- @Column({ name: 'description', type: 'text', nullable: true })
- description?: string;
- @Column({ name: 'contract_number', type: 'varchar', length: 100 })
- contractNumber!: string;
- @Column({ name: 'currency', type: 'varchar', length: 20, default: 'CNY' })
- currency!: string;
- @Column({ name: 'exchange_rate', type: 'decimal', precision: 10, scale: 4, default: 1 })
- exchangeRate!: number;
- @Column({ name: 'foreign_amount', type: 'decimal', precision: 15, scale: 2, nullable: true })
- foreignAmount?: number;
- @Column({ name: 'file_path', type: 'varchar', length: 512, nullable: true })
- filePath?: string;
- @Column({ name: 'created_at', type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
- createdAt!: Date;
- @Column({
- name: 'updated_at',
- type: 'timestamp',
- default: () => 'CURRENT_TIMESTAMP',
- onUpdate: 'CURRENT_TIMESTAMP'
- })
- updatedAt!: Date;
- }
- export const HetongSchema = z.object({
- id: z.string().max(50).openapi({
- description: '合同ID',
- example: 'HT20230001'
- }),
- contractDate: z.date().openapi({
- description: '合同日期',
- example: '2023-01-15'
- }),
- userId: z.string().max(50).openapi({
- description: '关联用户ID',
- example: 'U1001'
- }),
- clientId: z.string().max(50).openapi({
- description: '客户ID',
- example: 'C2001'
- }),
- projectId: z.string().max(50).nullable().openapi({
- description: '项目ID',
- example: 'P3001'
- }),
- amount: z.number().multipleOf(0.01).openapi({
- description: '合同金额',
- example: 150000.00
- }),
- type: z.string().max(50).openapi({
- description: '合同类型',
- example: '服务合同'
- }),
- status: z.string().max(50).openapi({
- description: '合同状态:如生效中、已结束等',
- example: '生效中'
- }),
- startDate: z.date().openapi({
- description: '开始日期',
- example: '2023-02-01'
- }),
- endDate: z.date().openapi({
- description: '结束日期',
- example: '2024-01-31'
- }),
- description: z.string().nullable().openapi({
- description: '合同描述',
- example: '年度技术服务合同'
- }),
- contractNumber: z.string().max(100).openapi({
- description: '合同编号',
- example: 'HT-2023-0001'
- }),
- currency: z.string().max(20).openapi({
- description: '货币类型',
- example: 'CNY'
- }),
- exchangeRate: z.number().multipleOf(0.0001).openapi({
- description: '汇率',
- example: 1.0000
- }),
- foreignAmount: z.number().multipleOf(0.01).nullable().openapi({
- description: '外币金额',
- example: null
- }),
- filePath: z.string().max(512).nullable().openapi({
- description: '合同文件路径',
- example: '/uploads/contracts/2023/HT-2023-0001.pdf'
- }),
- createdAt: z.date().openapi({
- description: '创建时间',
- example: '2023-01-15T00:00:00Z'
- }),
- updatedAt: z.date().openapi({
- description: '更新时间',
- example: '2023-01-15T00:00:00Z'
- })
- });
- export const CreateHetongDto = z.object({
- id: z.string().max(50).openapi({
- description: '合同ID',
- example: 'HT20230001'
- }),
- contractDate: z.coerce.date().openapi({
- description: '合同日期',
- example: '2023-01-15'
- }),
- userId: z.string().max(50).openapi({
- description: '关联用户ID',
- example: 'U1001'
- }),
- clientId: z.string().max(50).openapi({
- description: '客户ID',
- example: 'C2001'
- }),
- projectId: z.string().max(50).nullable().optional().openapi({
- description: '项目ID',
- example: 'P3001'
- }),
- amount: z.coerce.number().multipleOf(0.01).openapi({
- description: '合同金额',
- example: 150000.00
- }),
- type: z.string().max(50).openapi({
- description: '合同类型',
- example: '服务合同'
- }),
- status: z.string().max(50).openapi({
- description: '合同状态:如生效中、已结束等',
- example: '生效中'
- }),
- startDate: z.coerce.date().openapi({
- description: '开始日期',
- example: '2023-02-01'
- }),
- endDate: z.coerce.date().openapi({
- description: '结束日期',
- example: '2024-01-31'
- }),
- description: z.string().nullable().optional().openapi({
- description: '合同描述',
- example: '年度技术服务合同'
- }),
- contractNumber: z.string().max(100).openapi({
- description: '合同编号',
- example: 'HT-2023-0001'
- }),
- currency: z.string().max(20).default('CNY').openapi({
- description: '货币类型',
- example: 'CNY'
- }),
- exchangeRate: z.coerce.number().multipleOf(0.0001).default(1).openapi({
- description: '汇率',
- example: 1.0000
- }),
- foreignAmount: z.coerce.number().multipleOf(0.01).nullable().optional().openapi({
- description: '外币金额',
- example: null
- }),
- filePath: z.string().max(512).nullable().optional().openapi({
- description: '合同文件路径',
- example: '/uploads/contracts/2023/HT-2023-0001.pdf'
- })
- });
- export const UpdateHetongDto = z.object({
- contractDate: z.coerce.date().optional().openapi({
- description: '合同日期',
- example: '2023-01-15'
- }),
- userId: z.string().max(50).optional().openapi({
- description: '关联用户ID',
- example: 'U1001'
- }),
- clientId: z.string().max(50).optional().openapi({
- description: '客户ID',
- example: 'C2001'
- }),
- projectId: z.string().max(50).nullable().optional().openapi({
- description: '项目ID',
- example: 'P3001'
- }),
- amount: z.coerce.number().multipleOf(0.01).optional().openapi({
- description: '合同金额',
- example: 150000.00
- }),
- type: z.string().max(50).optional().openapi({
- description: '合同类型',
- example: '服务合同'
- }),
- status: z.string().max(50).optional().openapi({
- description: '合同状态:如生效中、已结束等',
- example: '生效中'
- }),
- startDate: z.coerce.date().optional().openapi({
- description: '开始日期',
- example: '2023-02-01'
- }),
- endDate: z.coerce.date().optional().openapi({
- description: '结束日期',
- example: '2024-01-31'
- }),
- description: z.string().nullable().optional().openapi({
- description: '合同描述',
- example: '年度技术服务合同'
- }),
- contractNumber: z.string().max(100).optional().openapi({
- description: '合同编号',
- example: 'HT-2023-0001'
- }),
- currency: z.string().max(20).optional().openapi({
- description: '货币类型',
- example: 'CNY'
- }),
- exchangeRate: z.coerce.number().multipleOf(0.0001).optional().openapi({
- description: '汇率',
- example: 1.0000
- }),
- foreignAmount: z.coerce.number().multipleOf(0.01).nullable().optional().openapi({
- description: '外币金额',
- example: null
- }),
- filePath: z.string().max(512).nullable().optional().openapi({
- description: '合同文件路径',
- example: '/uploads/contracts/2023/HT-2023-0001.pdf'
- })
- });
|