import { Column, CreateDateColumn, Entity, PrimaryGeneratedColumn, UpdateDateColumn, } from 'typeorm'; /** * 使用手册表 manual * - 自引用 parentId 实现多级树形结构 * - type=0 为目录节点(无 content),type=1 为文档节点(有 content) */ @Entity('manual') export class Manual { /** 主键ID */ @PrimaryGeneratedColumn({ type: 'int', unsigned: true }) id: number; /** 父节点ID,NULL 表示根节点 */ @Column({ name: 'parent_id', type: 'int', unsigned: true, nullable: true, comment: '父节点ID,NULL=根节点', }) parentId: number | null; /** 标题 */ @Column({ type: 'varchar', length: 200, comment: '标题' }) title: string; /** 节点类型:0=目录 1=文档 */ @Column({ type: 'tinyint', default: 1, comment: '类型:0=目录节点 1=文档节点', }) type: number; /** 文档正文(富文本 HTML 或 Markdown;目录节点为 null) */ @Column({ type: 'longtext', nullable: true, comment: '文档正文(目录节点为空)', }) content: string | null; /** 正文格式:html=富文本 markdown=Markdown */ @Column({ name: 'content_format', type: 'varchar', length: 10, default: 'html', comment: '正文格式:html=富文本 markdown=Markdown', }) contentFormat: 'html' | 'markdown'; /** 排序值,越小越靠前 */ @Column({ type: 'int', default: 0, comment: '排序值' }) sort: number; /** 是否显示:1显示 0隐藏 */ @Column({ name: 'is_show', type: 'tinyint', default: 1, comment: '是否显示 1是0否', }) isShow: number; @CreateDateColumn({ name: 'created_at', type: 'datetime' }) createdAt: Date; @UpdateDateColumn({ name: 'updated_at', type: 'datetime' }) updatedAt: Date; }