|
@@ -1,8 +1,6 @@
|
|
|
-import { Entity, PrimaryGeneratedColumn, Column, Index, ManyToOne, JoinColumn } from 'typeorm';
|
|
|
|
|
-import { z } from '@hono/zod-openapi';
|
|
|
|
|
|
|
+import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, JoinColumn } from 'typeorm';
|
|
|
import { UserEntity } from '@/server/modules/users/user.entity';
|
|
import { UserEntity } from '@/server/modules/users/user.entity';
|
|
|
import process from 'node:process';
|
|
import process from 'node:process';
|
|
|
-import { UserSchema } from '../users/user.schema';
|
|
|
|
|
|
|
|
|
|
@Entity('file')
|
|
@Entity('file')
|
|
|
export class File {
|
|
export class File {
|
|
@@ -56,120 +54,4 @@ export class File {
|
|
|
onUpdate: 'CURRENT_TIMESTAMP'
|
|
onUpdate: 'CURRENT_TIMESTAMP'
|
|
|
})
|
|
})
|
|
|
updatedAt!: Date;
|
|
updatedAt!: Date;
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-export const FileSchema = z.object({
|
|
|
|
|
- id: z.number().int().positive().openapi({
|
|
|
|
|
- description: '文件ID',
|
|
|
|
|
- example: 1
|
|
|
|
|
- }),
|
|
|
|
|
- name: z.string().max(255).openapi({
|
|
|
|
|
- description: '文件名称',
|
|
|
|
|
- example: '项目计划书.pdf'
|
|
|
|
|
- }),
|
|
|
|
|
- type: z.string().max(50).nullable().openapi({
|
|
|
|
|
- description: '文件类型',
|
|
|
|
|
- example: 'application/pdf'
|
|
|
|
|
- }),
|
|
|
|
|
- size: z.number().int().positive().nullable().openapi({
|
|
|
|
|
- description: '文件大小,单位字节',
|
|
|
|
|
- example: 102400
|
|
|
|
|
- }),
|
|
|
|
|
- path: z.string().max(512).openapi({
|
|
|
|
|
- description: '文件存储路径',
|
|
|
|
|
- example: '/uploads/documents/2023/project-plan.pdf'
|
|
|
|
|
- }),
|
|
|
|
|
- fullUrl: z.string().url().openapi({
|
|
|
|
|
- description: '完整文件访问URL',
|
|
|
|
|
- example: 'https://minio.example.com/d8dai/uploads/documents/2023/project-plan.pdf'
|
|
|
|
|
- }),
|
|
|
|
|
- description: z.string().nullable().openapi({
|
|
|
|
|
- description: '文件描述',
|
|
|
|
|
- example: '2023年度项目计划书'
|
|
|
|
|
- }),
|
|
|
|
|
- uploadUserId: z.number().int().positive().openapi({
|
|
|
|
|
- description: '上传用户ID',
|
|
|
|
|
- example: 1
|
|
|
|
|
- }),
|
|
|
|
|
- uploadUser: UserSchema,
|
|
|
|
|
- uploadTime: z.date().openapi({
|
|
|
|
|
- description: '上传时间',
|
|
|
|
|
- example: '2023-01-15T10:30:00Z'
|
|
|
|
|
- }),
|
|
|
|
|
- lastUpdated: z.date().nullable().openapi({
|
|
|
|
|
- description: '最后更新时间',
|
|
|
|
|
- example: '2023-01-16T14:20:00Z'
|
|
|
|
|
- }),
|
|
|
|
|
- createdAt: z.date().openapi({
|
|
|
|
|
- description: '创建时间',
|
|
|
|
|
- example: '2023-01-15T10:30:00Z'
|
|
|
|
|
- }),
|
|
|
|
|
- updatedAt: z.date().openapi({
|
|
|
|
|
- description: '更新时间',
|
|
|
|
|
- example: '2023-01-16T14:20:00Z'
|
|
|
|
|
- })
|
|
|
|
|
-});
|
|
|
|
|
-
|
|
|
|
|
-export const CreateFileDto = z.object({
|
|
|
|
|
- name: z.string().max(255).openapi({
|
|
|
|
|
- description: '文件名称',
|
|
|
|
|
- example: '项目计划书.pdf'
|
|
|
|
|
- }),
|
|
|
|
|
- type: z.string().max(50).nullable().optional().openapi({
|
|
|
|
|
- description: '文件类型',
|
|
|
|
|
- example: 'application/pdf'
|
|
|
|
|
- }),
|
|
|
|
|
- size: z.coerce.number().int().positive().nullable().optional().openapi({
|
|
|
|
|
- description: '文件大小,单位字节',
|
|
|
|
|
- example: 102400
|
|
|
|
|
- }),
|
|
|
|
|
- path: z.string().max(512).openapi({
|
|
|
|
|
- description: '文件存储路径',
|
|
|
|
|
- example: '/uploads/documents/2023/project-plan.pdf'
|
|
|
|
|
- }),
|
|
|
|
|
- description: z.string().nullable().optional().openapi({
|
|
|
|
|
- description: '文件描述',
|
|
|
|
|
- example: '2023年度项目计划书'
|
|
|
|
|
- }),
|
|
|
|
|
- lastUpdated: z.coerce.date().nullable().optional().openapi({
|
|
|
|
|
- description: '最后更新时间',
|
|
|
|
|
- example: '2023-01-16T14:20:00Z'
|
|
|
|
|
- })
|
|
|
|
|
-});
|
|
|
|
|
-
|
|
|
|
|
-export const UpdateFileDto = z.object({
|
|
|
|
|
- name: z.string().max(255).optional().openapi({
|
|
|
|
|
- description: '文件名称',
|
|
|
|
|
- example: '项目计划书_v2.pdf'
|
|
|
|
|
- }),
|
|
|
|
|
- type: z.string().max(50).nullable().optional().openapi({
|
|
|
|
|
- description: '文件类型',
|
|
|
|
|
- example: 'application/pdf'
|
|
|
|
|
- }),
|
|
|
|
|
- size: z.coerce.number().int().positive().nullable().optional().openapi({
|
|
|
|
|
- description: '文件大小,单位字节',
|
|
|
|
|
- example: 153600
|
|
|
|
|
- }),
|
|
|
|
|
- path: z.string().max(512).optional().openapi({
|
|
|
|
|
- description: '文件存储路径',
|
|
|
|
|
- example: '/uploads/documents/2023/project-plan_v2.pdf'
|
|
|
|
|
- }),
|
|
|
|
|
- description: z.string().nullable().optional().openapi({
|
|
|
|
|
- description: '文件描述',
|
|
|
|
|
- example: '2023年度项目计划书(修订版)'
|
|
|
|
|
- }),
|
|
|
|
|
- uploadUserId: z.number().int().positive().optional().openapi({
|
|
|
|
|
- description: '上传用户ID',
|
|
|
|
|
- example: 1
|
|
|
|
|
- }),
|
|
|
|
|
- uploadTime: z.coerce.date().optional().openapi({
|
|
|
|
|
- description: '上传时间',
|
|
|
|
|
- example: '2023-01-15T10:30:00Z'
|
|
|
|
|
- }),
|
|
|
|
|
- lastUpdated: z.coerce.date().nullable().optional().openapi({
|
|
|
|
|
- description: '最后更新时间',
|
|
|
|
|
- example: '2023-01-16T14:20:00Z'
|
|
|
|
|
- })
|
|
|
|
|
-});
|
|
|
|
|
-
|
|
|
|
|
-export type FileType = z.infer<typeof FileSchema>
|
|
|
|
|
|
|
+}
|