|
@@ -0,0 +1,81 @@
|
|
|
+import {
|
|
|
+ Column,
|
|
|
+ CreateDateColumn,
|
|
|
+ Entity,
|
|
|
+ JoinColumn,
|
|
|
+ JoinTable,
|
|
|
+ ManyToMany,
|
|
|
+ ManyToOne,
|
|
|
+ OneToMany,
|
|
|
+ OneToOne,
|
|
|
+ PrimaryGeneratedColumn,
|
|
|
+ UpdateDateColumn,
|
|
|
+} from 'typeorm';
|
|
|
+import { Category } from '../category/category.entity';
|
|
|
+import { User } from '../user/user.entity';
|
|
|
+
|
|
|
+@Entity()
|
|
|
+export class Menu {
|
|
|
+ @PrimaryGeneratedColumn()
|
|
|
+ id: number;
|
|
|
+
|
|
|
+ @Column({ unique: false, default: '', length: 200 })
|
|
|
+ title: string;
|
|
|
+
|
|
|
+ @Column({ default: true })
|
|
|
+ enable: boolean;
|
|
|
+
|
|
|
+ @Column({ default: 0 })
|
|
|
+ level: number;
|
|
|
+
|
|
|
+ @Column({ default: '' })
|
|
|
+ cover: string;
|
|
|
+
|
|
|
+ @Column({ default: false })
|
|
|
+ isPublish: boolean;
|
|
|
+
|
|
|
+ @Column({ type: 'longtext', nullable: true })
|
|
|
+ content: string;
|
|
|
+
|
|
|
+ @Column({ default: '' })
|
|
|
+ remark: string;
|
|
|
+
|
|
|
+ @OneToOne(() => Category, {
|
|
|
+ cascade: true,
|
|
|
+ onDelete: 'CASCADE',
|
|
|
+ createForeignKeyConstraints: false,
|
|
|
+ })
|
|
|
+ @JoinColumn()
|
|
|
+ category: Category;
|
|
|
+
|
|
|
+ @Column({ nullable: true })
|
|
|
+ categoryId: number;
|
|
|
+
|
|
|
+ @OneToOne(() => User, {
|
|
|
+ cascade: true,
|
|
|
+ })
|
|
|
+ @JoinColumn()
|
|
|
+ user: User;
|
|
|
+
|
|
|
+ @Column({ nullable: true })
|
|
|
+ userId: number;
|
|
|
+
|
|
|
+ @CreateDateColumn()
|
|
|
+ createTime: Date;
|
|
|
+
|
|
|
+ @UpdateDateColumn()
|
|
|
+ updateTime: Date;
|
|
|
+
|
|
|
+ @ManyToOne(() => Menu, (menu) => menu.children, {
|
|
|
+ createForeignKeyConstraints: false,
|
|
|
+ })
|
|
|
+ parent: Menu;
|
|
|
+
|
|
|
+ @OneToMany(() => Menu, (menu) => menu.parent, {
|
|
|
+ createForeignKeyConstraints: false,
|
|
|
+ })
|
|
|
+ children: Menu[];
|
|
|
+
|
|
|
+ @Column({ nullable: true })
|
|
|
+ parentId: number;
|
|
|
+}
|