12345678910111213141516171819202122232425262728293031323334 |
- import { Column, Entity } from 'typeorm';
- import { BaseModel } from '../../frame/BaseModel';
- import * as bcrypt from 'bcryptjs';
- // 管理员
- @Entity('admin')
- export class Admin extends BaseModel {
- @Column({ type: 'character varying', nullable: true, comment: '管理员名称' })
- nick_name: string;
- @Column({ type: 'character varying', comment: '账号', unique: true })
- account: string;
- @Column({
- type: 'character varying',
- select: false,
- comment: '密码',
- transformer: {
- from: value => value,
- // to:进入数据库,需要加密
- to: value => {
- const salt = bcrypt.genSaltSync(10);
- const hash = bcrypt.hashSync(value, salt);
- return hash;
- },
- },
- })
- password: string; //TODO:需要重新加密
- @Column({ type: 'jsonb', nullable: true, comment: '角色id数组' })
- role: string[];
- @Column({ type: 'integer', nullable: true, comment: '部门id' })
- dept: number;
- @Column({ type: 'character varying', default: '0', comment: '是否使用: 0:使用;1:禁用' })
- is_use: string;
- @Column({ type: 'character varying', default: '1', comment: '是否是超级管理员: 0:是;1否' })
- is_super: string;
- }
|