|
|
@@ -1,5 +1,6 @@
|
|
|
-import { Entity, PrimaryGeneratedColumn, Column, Index } from 'typeorm';
|
|
|
+import { Entity, PrimaryGeneratedColumn, Column, Index, ManyToOne, JoinColumn } from 'typeorm';
|
|
|
import { z } from '@hono/zod-openapi';
|
|
|
+import { UserEntity } from '@/server/modules/users/user.entity';
|
|
|
|
|
|
@Entity('file')
|
|
|
export class File {
|
|
|
@@ -21,8 +22,12 @@ export class File {
|
|
|
@Column({ name: 'description', type: 'text', nullable: true })
|
|
|
description?: string;
|
|
|
|
|
|
- @Column({ name: 'upload_user_id', type: 'varchar', length: 50 })
|
|
|
- uploadUserId!: string;
|
|
|
+ @Column({ name: 'upload_user_id', type: 'int', unsigned: true })
|
|
|
+ uploadUserId!: number;
|
|
|
+
|
|
|
+ @ManyToOne(() => UserEntity)
|
|
|
+ @JoinColumn({ name: 'upload_user_id', referencedColumnName: 'id' })
|
|
|
+ uploadUser!: UserEntity;
|
|
|
|
|
|
@Column({ name: 'upload_time', type: 'datetime' })
|
|
|
uploadTime!: Date;
|
|
|
@@ -67,9 +72,9 @@ export const FileSchema = z.object({
|
|
|
description: '文件描述',
|
|
|
example: '2023年度项目计划书'
|
|
|
}),
|
|
|
- uploadUserId: z.string().max(50).openapi({
|
|
|
+ uploadUserId: z.number().int().positive().openapi({
|
|
|
description: '上传用户ID',
|
|
|
- example: 'U1001'
|
|
|
+ example: 1
|
|
|
}),
|
|
|
uploadTime: z.date().openapi({
|
|
|
description: '上传时间',
|
|
|
@@ -110,9 +115,9 @@ export const CreateFileDto = z.object({
|
|
|
description: '文件描述',
|
|
|
example: '2023年度项目计划书'
|
|
|
}),
|
|
|
- uploadUserId: z.string().max(50).openapi({
|
|
|
+ uploadUserId: z.number().int().positive().openapi({
|
|
|
description: '上传用户ID',
|
|
|
- example: 'U1001'
|
|
|
+ example: 1
|
|
|
}),
|
|
|
lastUpdated: z.coerce.date().nullable().optional().openapi({
|
|
|
description: '最后更新时间',
|
|
|
@@ -141,9 +146,9 @@ export const UpdateFileDto = z.object({
|
|
|
description: '文件描述',
|
|
|
example: '2023年度项目计划书(修订版)'
|
|
|
}),
|
|
|
- uploadUserId: z.string().max(50).optional().openapi({
|
|
|
+ uploadUserId: z.number().int().positive().optional().openapi({
|
|
|
description: '上传用户ID',
|
|
|
- example: 'U1001'
|
|
|
+ example: 1
|
|
|
}),
|
|
|
uploadTime: z.coerce.date().optional().openapi({
|
|
|
description: '上传时间',
|