1234567891011121314151617181920212223242526272829303132333435363738 |
- import { Column, Entity } from 'typeorm';
- import { BaseModel } from '../../frame/BaseModel';
- import * as bcrypt from 'bcryptjs';
- @Entity('user')
- export class User 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: 'character varying', comment: '性别' })
- gender: string;
- @Column({ type: 'character varying', nullable: true, comment: '手机号' })
- phone: string;
- @Column({ type: 'character varying', nullable: true, comment: '电子邮箱' })
- email: string;
- @Column({ type: 'jsonb', nullable: true, comment: '角色id数组' })
- role: number[];
- @Column({ type: 'character varying', default: '1', comment: '状态: 0:未审核;1:已审核' })
- status: string;
- }
|