/** * @description 字典项 * @author ZKS * @date 2025-11-27 */ import { Dict } from './dict.entity'; import { Product } from './product.entity'; import { Column, CreateDateColumn, Entity, Index, JoinColumn, ManyToMany, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn, } from 'typeorm'; @Entity() @Index(['name', 'dict'], { unique: true }) export class DictItem { // 主键 @PrimaryGeneratedColumn() id: number; // 字典项名称 @Column({ comment: '字典项显示名称' }) title: string; // 目前没有单独做国际化, 所以这里先添加 titleCN 用来标注 @Column({ comment: '字典项中文名称', nullable: true }) titleCN: string; // 唯一标识 @Column({ comment: '字典唯一标识名称' }) name: string; @Column({ nullable: true, comment: '简称' }) shortName: string; @Column({ nullable: true, comment: '字典项描述' }) description?: string // 字典项值 @Column({ nullable: true, comment: '字典项值' }) value?: string; @Column({ nullable: true, comment: '图片' }) image: string; // 排序 @Column({ default: 0, comment: '排序' }) sort: number; // 属于哪个字典 @ManyToOne(() => Dict, dict => dict.items) @JoinColumn({ name: 'dict_id' }) dict: Dict; // 关联的产品 @ManyToMany(() => Product, product => product.attributes) products: Product[]; // 创建时间 @CreateDateColumn() createdAt: Date; // 更新时间 @UpdateDateColumn() updatedAt: Date; }