Spaces:
Sleeping
Sleeping
File size: 1,242 Bytes
73746a8 426f2a4 73746a8 f45e448 73746a8 426f2a4 73746a8 426f2a4 73746a8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | import {
Entity,
Column,
PrimaryGeneratedColumn,
CreateDateColumn,
UpdateDateColumn,
OneToMany,
} from 'typeorm';
import { Order } from './order.entity';
import { UserCourse } from './user-course.entity';
import { Comment } from './comment.entity';
export enum UserRole {
USER = 'user',
ADMIN = 'admin',
}
@Entity('users')
export class User {
@PrimaryGeneratedColumn()
id: number;
@Column({ type: 'varchar', length: 100, unique: true })
email: string;
@Column({ type: 'varchar', length: 255, name: 'password_hash' })
passwordHash: string;
@Column({ type: 'varchar', length: 50 })
nickname: string;
@Column({ type: 'varchar', length: 255, nullable: true })
avatar: string;
@Column({ type: 'boolean', default: false, name: 'is_vip' })
isVip: boolean;
@Column({ type: 'varchar', default: UserRole.USER })
role: UserRole;
@CreateDateColumn({ name: 'created_at' })
createdAt: Date;
@UpdateDateColumn({ name: 'updated_at' })
updatedAt: Date;
@OneToMany(() => Order, (order) => order.user)
orders: Order[];
@OneToMany(() => UserCourse, (userCourse) => userCourse.user)
userCourses: UserCourse[];
@OneToMany(() => Comment, (comment) => comment.user)
comments: Comment[];
}
|