import { ApiProperty } from '@midwayjs/swagger';
import { Rule, RuleType } from '@midwayjs/validate';
import { get } from 'lodash';
export enum LoginType {
  Admin = 'Admin',
  User = 'User',
}

export class LoginDTO {
  @ApiProperty({ description: '账号' })
  @Rule(RuleType['string']().required())
  account: string = undefined;
  @ApiProperty({ description: '密码' })
  @Rule(RuleType['string']().required())
  password: string = undefined;
}

export class UPwdDTO {
  @ApiProperty({ description: '用户数据id' })
  @Rule(RuleType['number']().required())
  id: number = undefined;
  @ApiProperty({ description: '密码' })
  @Rule(RuleType['string']().required())
  password: string = undefined;
}

export class LoginVO {
  constructor(data: object) {
    this.id = get(data, 'id');
    this.nick_name = get(data, 'nick_name');
    this.dept = get(data, 'dept');
    this.openid = get(data, 'openid');
    this.role = get(data, 'role');
    this.is_super = get(data, 'is_super');
    this.account = get(data, 'account');
  }
  id: string;
  nick_name: string;
  openid: string;
  role: Array<any>;
  is_super: number;
  @ApiProperty({ description: '登录标识' })
  'login_code': string = undefined;
  dept?: string;
  account?: string;
}
