forked from yoone/API
1
0
Fork 0
API/src/entity/user.entity.ts

32 lines
759 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// src/entity/user.entity.ts
import { Exclude } from 'class-transformer';
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
@Entity('user')
export class User {
@PrimaryGeneratedColumn()
id: number;
@Column({ unique: true })
username: string;
@Column()
@Exclude()
password: string;
// @Column() // 默认角色为管理员
// roleId: number; // 角色 (如admin, editor, viewer)
@Column({ type: 'simple-array', nullable: true })
permissions: string[]; // 自定义权限 (如:['user:add', 'user:edit'])
@Column({ default: false })
isSuper: boolean; // 超级管理员
@Column({ default: false })
isAdmin: boolean; // 管理员
@Column({ default: true })
isActive: boolean; // 用户是否启用
}