import { BaseEntity } from '../../base/entity/base';
import { Column, Entity, Index,BeforeInsert } from 'typeorm';

/**
 * 用户信息
 */
@Entity('t_school_user_info')
export class UserInfoEntity extends BaseEntity {
  @Index({ unique: true })
  @Column({ comment: '登录唯一ID', nullable: true })
  unionid: string;

  @Column({ comment: '头像', nullable: true })
  avatarUrl: string;

  @Column({ comment: '昵称', nullable: true })
  nickName: string;

  @Index({ unique: true })
  @Column({ comment: '手机号', nullable: true })
  phone: string;

  @Column({ comment: '生日', type: 'date', nullable: true })
  birthday: Date;

  @Column({ comment: '性别', dict: ['未知', '男', '女'], default: 0 })
  gender: number;

  @Index()
  @Column({ comment: '角色', dict: ['老师', '学生', '其他'], default: '学生' })
  role: string;

  @Index()
  @Column({ comment: '学校ID' })   // 使用归属部门，这里建议选顶层学校
  departmentId: number;

  departmentName: string;

  @Index()
  @Column({ comment: '碳积分', default: 0 })
  carbonBalance: number;

  @Index()
  @Column({ comment: '学院ID', nullable: true })
  collegeId: number;

  @Column({ comment: '学院名称', nullable: true })
  collegeName: string;

  @Index()
  @Column({ comment: '专业ID', nullable: true })
  majorId: number;

  @Column({ comment: '专业名称', nullable: true })
  majorName: string;

  @Index()
  @Column({ comment: '班级ID', nullable: true })
  classId: number;

  @Column({ comment: '班级名称', nullable: true })
  className: string;

  @Column({ comment: '状态', dict: ['禁用', '正常', '已注销'], default: 1 })
  status: number;

  @Column({ comment: '登录方式', dict: ['小程序', '公众号', 'H5'], default: 0 })
  loginType: number;

  @Column({ comment: '密码', nullable: true })
  password: string;

  @Column({ comment: '介绍', type: 'text', nullable: true })
  description: string;

}
