@opentiny/tiny-toolkit-pro
Version:
TinyPro Vue:开箱即用、前后端分离的 Vue 后台管理模板
66 lines (63 loc) • 1.71 kB
text/typescript
import {
BeforeInsert,
Column,
CreateDateColumn,
DeleteDateColumn,
Entity,
JoinTable,
ManyToMany,
PrimaryColumn,
PrimaryGeneratedColumn,
UpdateDateColumn,
} from 'typeorm';
import { Role } from './role';
import * as crypto from 'crypto';
export const encry = (value: string, salt: string) =>
crypto.pbkdf2Sync(value, salt, 1000, 18, 'sha256').toString('hex');
('user')
export class User {
()
id: number;
()
name: string;
()
email: string;
()
password: string;
(() => Role)
({ name: 'user_role' })
role: Role[];
({ nullable: true })
department: string;
({ nullable: true })
employeeType: string;
({ type: 'timestamp', nullable: true })
probationStart: string;
({ type: 'timestamp', nullable: true })
probationEnd: string;
({ nullable: true })
probationDuration: string;
({ type: 'timestamp', nullable: true })
protocolStart: string;
({ type: 'timestamp', nullable: true })
protocolEnd: string;
({ nullable: true })
address: string;
({ nullable: true })
status: number;
()
createTime: Date;
()
updateTime: Date;
({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
create_time: Date;
({ nullable: true })
salt: string;
({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
update_time: Date;
()
beforeInsert() {
this.salt = crypto.randomBytes(4).toString('base64');
this.password = encry(this.password, this.salt);
}
}