import { IProCptItem } from './compilation';

// 实体类型
export enum EntityType {
  // 个人
  PERSON = 1,
  // 企业
  ENTERPRISE = 2,
}

// 登录类型（与实体类型有语义上的区别）
export enum LoginType {
  PERSON = 'person',
  ENTERPRISE = 'enterprise',
}

// 登录方式（使用密码还是短信进行登录，与登录类型是不同概念）
export enum LoginMode {
  PASSWORD = 'password',
  SMS = 'sms',
}

export enum UserType {
  NORMAL = 'normal',
  PROFESSIONAL = 'professional',
}

export interface IUsedCptItem {
  // 编办 ID
  compilationID: string;
  // 第一次使用的时间
  firstUseTime: number;
}

export interface IContactItem {
  // 用户 ID
  userID: string;
  // 第一成为联系人的时间
  firstContactTime: number;
}

export interface IEverydayOnlineTimeItem {
  // 日期
  date: number;
  // 在线时长
  onlineTime: number;
}

export interface ISummary {
  // 最后登录时间
  lastLoginTime: number;
  // 上次使用的编办
  lastUsedCpt: string;
  // 总共在线时长
  totalOnlineTime: number;
  // 今天目前的在线时长
  todayOnlineTime: number;
  // 每天的在线时长
  everydayOnlineTime: IEverydayOnlineTimeItem[];
}

export interface IUserArea {
  province: string; // 省份
  municipality: string; // 城市
}

export interface IUser {
  ID: string;
  ssoID: string;
  mobile: string;
  realName: string;
  createTime: number;
  proCptList: IProCptItem[];
  usedCptList: IUsedCptItem[];
  specifyCpt: string;
  contacts: IContactItem[];
  onlySMSLogin: boolean;
  abnormalLoginAlert: boolean;
  defaultEnterprise: string;
  summaryInfo: ISummary;
  institutionName: string; // 用户输入的机构名称
  area: IUserArea; // 用户选择的省份、城市、地区
}

export interface IAPInstitution {
  ID: string;
  name: string;
}
export interface IAPOrganizationalStructure {
  ID: string;
  name: string;
}

export interface IAPUser {
  ID: string;
  createdTime: number;
  gender: string;
  accountType: string;
  account: string;
  name: string;
  phone: string;
  contactMobile: string;
  officePhone: string;
  email: string;
  institution: IAPInstitution;
  organizationalStructure: IAPOrganizationalStructure;
  dataID: string;
  created: string;
  createdID: string; // 创建人ID
  isCreated?: boolean; // 是否可创建，字段由后台定义
  roleIDs?: string[]; // 角色ID列表
  enable?: boolean;
  projectLimit?: number; // 创建项目数量的限制
  failLoginCount?: number; // 登陆失败的次数
  lastTryLoginTime?: number; // 上次尝试登陆的时间
  passwordModifyTime?: number; // 密码修改时间
  phrases: string[]; // 常用语
  idCode: string; // 身份证号码
  isIdAuth: boolean; // 身份证是否经过实名认证
  registere: string; // 注册审批状态
  reason: string; // 注册审批备注
  qualifications: IQualifications[];
  certificate: ICertificate[];
  employmentCertificateName: String;
}

export interface IQualifications {
  ID: string;
  school: string;
  professional: string;
  qualifications: string;
  certificateNo: string;
  validTime: string;
  filePath: string;
}

export interface ICertificate {
  ID: string;
  name: string[];
  professional: string;
  lv: string;
  certificateNo: string;
  validTime: string;
  filePath: string;
}


// 最近联系人
export interface IRecentUser extends IUser {
  recentDate: number;
}

// 正在查看项目的用户
export interface IViewingProjectUser {
  projectID: string;
  userID: string;
  userName: string;
  mobile: string;
  enterpriseID: string;
  enterpriseName: string;
}

// 安全策略配置
export interface ISecurityConfiguration {
  ID: string;
  loginTimes: number;
  accountLockTimes: number;
  passwordVerification: number;
  passwordValidity: number;
  logReserveDay: number;
}

export enum ERegisterStatus {
  PENDING = 'pending', // 审批中
  PASS = 'pass', // 审批通过
  RETURN = 'return', // 驳回
}
