import { Entity, Column, PrimaryGeneratedColumn, ManyToOne, OneToOne, JoinColumn, CreateDateColumn, UpdateDateColumn, } from 'typeorm'; import { PDepart } from './p-depart'; import { PUserType } from './p-user-type.entity'; import { ApiProperty } from '@nestjs/swagger'; import { PAccessory } from 'kkk-lib/auth/entity/p-accessory.entity'; @Entity() export class PUser { @ApiProperty({ description: '主键id', type: 'int' }) @PrimaryGeneratedColumn() id?: number; @ApiProperty({ description: '关键key,可以为空,但不能重复', nullable: true, type: 'string', }) @Column({ unique: true, nullable: true }) key?: string; @ApiProperty({ description: '登录名', type: 'string' }) @Column() username?: string; @ApiProperty({ description: '真实姓名', type: 'string' }) @Column({ name: 'real_name' }) realName?: string; @ApiProperty({ description: '密码', type: 'string' }) @Column() password?: string; @ApiProperty({ description: '用户Sn', type: 'string' }) @Column({ nullable: true }) userSn?: string; @ApiProperty({ description: '用户类型', type: 'PUserType' }) @ManyToOne((userType) => PUserType, { eager: true }) userType?: PUserType; @ApiProperty({ description: '用户部门', type: 'PDepart' }) @ManyToOne((depart) => PDepart, { eager: true }) depart?: PDepart; @ApiProperty({ description: '头像图', nullable: true, type: 'PAccessory' }) @OneToOne((type) => PAccessory, { eager: true }) @JoinColumn() avatar?: PAccessory; @ApiProperty({ description: '基本信息 JSON字符串格式', nullable: true, type: 'string', }) @Column('longtext', { nullable: true }) baseInfo?: string; @ApiProperty({ description: '邮箱', nullable: true, type: 'string' }) @Column({ nullable: true }) email?: string; @ApiProperty({ description: '创建时间,更新时候不用处理,系统自动更新', nullable: true, type: 'Date', }) @CreateDateColumn({ type: 'timestamp' }) createdTime?: Date; @ApiProperty({ description: '更新时间,更新时候不用处理,系统自动更新', nullable: true, type: 'Date', }) @UpdateDateColumn({ type: 'timestamp' }) updatedTime?: Date; }