|
|
@@ -1,54 +1,42 @@
|
|
|
-import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, JoinColumn } from 'typeorm';
|
|
|
+import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, JoinColumn, CreateDateColumn, UpdateDateColumn } from 'typeorm';
|
|
|
import { File } from '@/server/modules/files/file.entity';
|
|
|
|
|
|
@Entity('templates')
|
|
|
export class Template {
|
|
|
- @PrimaryGeneratedColumn({ unsigned: true })
|
|
|
+ @PrimaryGeneratedColumn({ unsigned: true, comment: '模板ID,主键自增' })
|
|
|
id!: number;
|
|
|
|
|
|
- @Column({ name: 'title', type: 'varchar', length: 255 })
|
|
|
+ @Column({ name: 'title', type: 'varchar', length: 255, comment: '模板标题' })
|
|
|
title!: string;
|
|
|
|
|
|
- @Column({ name: 'description', type: 'text', nullable: true })
|
|
|
+ @Column({ name: 'description', type: 'text', nullable: true, comment: '模板描述' })
|
|
|
description!: string | null;
|
|
|
|
|
|
- @Column({ name: 'file_id', type: 'int', unsigned: true })
|
|
|
+ @Column({ name: 'file_id', type: 'int', unsigned: true, comment: '关联文件ID' })
|
|
|
fileId!: number;
|
|
|
|
|
|
@ManyToOne(() => File)
|
|
|
@JoinColumn({ name: 'file_id', referencedColumnName: 'id' })
|
|
|
file!: File;
|
|
|
|
|
|
- @Column({ name: 'preview_url', type: 'varchar', length: 500, nullable: true })
|
|
|
- previewUrl!: string | null;
|
|
|
-
|
|
|
- @Column({ name: 'category', type: 'varchar', length: 100 })
|
|
|
+ @Column({ name: 'category', type: 'varchar', length: 100, comment: '模板分类' })
|
|
|
category!: string;
|
|
|
|
|
|
- @Column({ name: 'is_free', type: 'tinyint', default: 0 })
|
|
|
+ @Column({ name: 'is_free', type: 'tinyint', default: 0, comment: '是否免费:0-收费,1-免费' })
|
|
|
isFree!: number;
|
|
|
|
|
|
- @Column({ name: 'download_count', type: 'int', unsigned: true, default: 0 })
|
|
|
+ @Column({ name: 'download_count', type: 'int', unsigned: true, default: 0, comment: '下载次数' })
|
|
|
downloadCount!: number;
|
|
|
|
|
|
- @Column({ name: 'is_disabled', type: 'tinyint', default: 0 })
|
|
|
+ @Column({ name: 'is_disabled', type: 'tinyint', default: 0, comment: '是否禁用:0-启用,1-禁用' })
|
|
|
isDisabled!: number;
|
|
|
|
|
|
- @Column({ name: 'is_deleted', type: 'tinyint', default: 0 })
|
|
|
+ @Column({ name: 'is_deleted', type: 'tinyint', default: 0, comment: '是否删除:0-未删除,1-已删除' })
|
|
|
isDeleted!: number;
|
|
|
|
|
|
- @Column({
|
|
|
- name: 'created_at',
|
|
|
- type: 'timestamp',
|
|
|
- default: () => 'CURRENT_TIMESTAMP'
|
|
|
- })
|
|
|
+ @CreateDateColumn({ name: 'created_at', comment: '创建时间' })
|
|
|
createdAt!: Date;
|
|
|
|
|
|
- @Column({
|
|
|
- name: 'updated_at',
|
|
|
- type: 'timestamp',
|
|
|
- default: () => 'CURRENT_TIMESTAMP',
|
|
|
- onUpdate: 'CURRENT_TIMESTAMP'
|
|
|
- })
|
|
|
+ @UpdateDateColumn({ name: 'updated_at', comment: '更新时间' })
|
|
|
updatedAt!: Date;
|
|
|
}
|