|
|
@@ -0,0 +1,98 @@
|
|
|
+import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm';
|
|
|
+import { z } from '@hono/zod-openapi';
|
|
|
+
|
|
|
+@Entity('excel_templates')
|
|
|
+export class ExcelTemplate {
|
|
|
+ @PrimaryGeneratedColumn({ unsigned: true })
|
|
|
+ id!: number;
|
|
|
+
|
|
|
+ @Column({
|
|
|
+ name: 'template_name',
|
|
|
+ type: 'varchar',
|
|
|
+ length: 255,
|
|
|
+ nullable: false,
|
|
|
+ comment: '模板名称'
|
|
|
+ })
|
|
|
+ templateName!: string;
|
|
|
+
|
|
|
+ @Column({
|
|
|
+ name: 'template_key',
|
|
|
+ type: 'varchar',
|
|
|
+ length: 50,
|
|
|
+ nullable: false,
|
|
|
+ comment: '模板唯一标识键'
|
|
|
+ })
|
|
|
+ templateKey!: string;
|
|
|
+
|
|
|
+ @Column({
|
|
|
+ name: 'template_config',
|
|
|
+ type: 'json',
|
|
|
+ nullable: false,
|
|
|
+ comment: 'Excel模板配置(存储header配置、字段映射规则等)'
|
|
|
+ })
|
|
|
+ templateConfig!: Record<string, any>;
|
|
|
+
|
|
|
+ @Column({
|
|
|
+ name: 'created_by',
|
|
|
+ type: 'int',
|
|
|
+ nullable: false,
|
|
|
+ comment: '创建人ID(关联member_auth_users.id)'
|
|
|
+ })
|
|
|
+ createdBy!: number;
|
|
|
+
|
|
|
+ @Column({
|
|
|
+ name: 'is_deleted',
|
|
|
+ type: 'tinyint',
|
|
|
+ default: 0,
|
|
|
+ comment: '是否删除 0-正常 1-删除'
|
|
|
+ })
|
|
|
+ isDeleted!: number;
|
|
|
+
|
|
|
+ @Column({
|
|
|
+ name: 'created_at',
|
|
|
+ type: 'timestamp',
|
|
|
+ default: () => 'CURRENT_TIMESTAMP',
|
|
|
+ comment: '创建时间'
|
|
|
+ })
|
|
|
+ createdAt!: Date;
|
|
|
+
|
|
|
+ @Column({
|
|
|
+ name: 'updated_at',
|
|
|
+ type: 'timestamp',
|
|
|
+ default: () => 'CURRENT_TIMESTAMP',
|
|
|
+ onUpdate: 'CURRENT_TIMESTAMP',
|
|
|
+ comment: '更新时间'
|
|
|
+ })
|
|
|
+ updatedAt!: Date;
|
|
|
+}
|
|
|
+
|
|
|
+export const ExcelTemplateSchema = z.object({
|
|
|
+ id: z.number().int().positive().openapi({
|
|
|
+ description: 'ID'
|
|
|
+ }),
|
|
|
+ templateName: z.string().max(255).openapi({
|
|
|
+ description: '模板名称',
|
|
|
+ example: '默认Excel模板'
|
|
|
+ }),
|
|
|
+ templateKey: z.string().max(50).openapi({
|
|
|
+ description: '模板唯一标识键',
|
|
|
+ example: 'default_template'
|
|
|
+ }),
|
|
|
+ templateConfig: z.record(z.any()).openapi({
|
|
|
+ description: 'Excel模板配置'
|
|
|
+ }),
|
|
|
+ createdBy: z.number().int().openapi({
|
|
|
+ description: '创建人ID',
|
|
|
+ example: 1
|
|
|
+ }),
|
|
|
+ isDeleted: z.number().int().min(0).max(1).default(0).openapi({
|
|
|
+ description: '是否删除 0-正常 1-删除',
|
|
|
+ example: 0
|
|
|
+ }),
|
|
|
+ createdAt: z.date().openapi({
|
|
|
+ description: '创建时间'
|
|
|
+ }),
|
|
|
+ updatedAt: z.date().openapi({
|
|
|
+ description: '更新时间'
|
|
|
+ })
|
|
|
+});
|