import { Rule, RuleType } from '@midwayjs/validate'; import { ApiProperty } from '@midwayjs/swagger'; import { SearchBase } from 'free-midway-component'; import get = require('lodash/get'); const dealVO = (cla, data) => { for (const key in cla) { const val = get(data, key); if (val || val === 0) cla[key] = val; } }; export class FVO_User { constructor(data: object) { dealVO(this, data); } @ApiProperty({ description: '数据id' }) _id: string = undefined; @ApiProperty({ description: '姓名' }) 'name': string = undefined; @ApiProperty({ description: '联系电话' }) 'tel': string = undefined; @ApiProperty({ description: '密码' }) 'password': string = undefined; @ApiProperty({ description: '性别' }) 'gender': string = undefined; @ApiProperty({ description: '角色' }) 'role': string = undefined; @ApiProperty({ description: '所属街道' }) 'street': string = undefined; @ApiProperty({ description: '所属社区' }) 'community': string = undefined; @ApiProperty({ description: '创建时间' }) 'create_time': string = undefined; @ApiProperty({ description: '微信id' }) 'openid': string = undefined; @ApiProperty({ description: '状态' }) 'status': string = undefined; } export class QDTO_User extends SearchBase { constructor() { const like_prop = ['name']; const props = [ 'name', 'tel', 'gender', 'role', 'street', 'community', 'openid', 'create_time', 'status', ]; const mapping = []; super({ like_prop, props, mapping }); } @ApiProperty({ description: '姓名' }) 'name': string = undefined; @ApiProperty({ description: '联系电话' }) 'tel': string = undefined; @ApiProperty({ description: '性别' }) 'gender': string = undefined; @ApiProperty({ description: '角色' }) 'role': string = undefined; @ApiProperty({ description: '所属街道' }) 'street': string = undefined; @ApiProperty({ description: '所属社区' }) 'community': string = undefined; @ApiProperty({ description: '微信id' }) 'openid': string = undefined; @ApiProperty({ description: '创建时间' }) 'create_time': string = undefined; @ApiProperty({ description: '状态' }) 'status': string = undefined; } export class QVO_User extends FVO_User { constructor(data: object) { super(data); dealVO(this, data); } } export class CDTO_User { @ApiProperty({ description: '姓名' }) @Rule(RuleType['string']().empty('')) 'name': string = undefined; @ApiProperty({ description: '联系电话' }) @Rule(RuleType['string']().empty('')) 'tel': string = undefined; @ApiProperty({ description: '密码' }) @Rule(RuleType['string']().empty('')) 'password': string = undefined; @ApiProperty({ description: '性别' }) @Rule(RuleType['string']().empty('')) 'gender': string = undefined; @ApiProperty({ description: '角色' }) @Rule(RuleType['string']().empty('')) 'role': string = undefined; @ApiProperty({ description: '所属街道' }) @Rule(RuleType['string']().empty('')) 'street': string = undefined; @ApiProperty({ description: '所属社区' }) @Rule(RuleType['string']().empty('')) 'community': string = undefined; @ApiProperty({ description: '创建时间' }) @Rule(RuleType['string']().empty('')) 'create_time': string = undefined; @ApiProperty({ description: '微信id' }) @Rule(RuleType['string']().empty('')) 'openid': string = undefined; @ApiProperty({ description: '状态' }) @Rule(RuleType['string']().empty('')) 'status': string = undefined; } export class CVO_User extends FVO_User { constructor(data: object) { super(data); dealVO(this, data); } } export class UDTO_User extends CDTO_User { @ApiProperty({ description: '数据id' }) @Rule(RuleType['string']().empty('')) _id: string = undefined; } export class UVAO_User extends FVO_User { constructor(data: object) { super(data); dealVO(this, data); } } export class LoginVO { constructor(data: object) { for (const key of Object.keys(this)) { this[key] = get(data, key); } } @ApiProperty({ description: '数据id' }) _id: string = undefined; @ApiProperty({ description: '姓名' }) 'name': string = undefined; @ApiProperty({ description: '联系电话' }) 'tel': string = undefined; @ApiProperty({ description: '性别' }) 'gender': string = undefined; @ApiProperty({ description: '角色' }) 'role': string = undefined; @ApiProperty({ description: '所属街道' }) 'street': string = undefined; @ApiProperty({ description: '所属社区' }) 'community': string = undefined; @ApiProperty({ description: '微信id' }) 'openid': string = undefined; @ApiProperty({ description: '状态' }) 'status': string = undefined; } export class LoginDTO { @ApiProperty({ description: '电话号', example: '18843520013' }) @Rule(RuleType['string']().empty('')) 'tel': string = undefined; @ApiProperty({ description: '密码', example: '111111' }) @Rule(RuleType['string']().empty('')) 'password': string = undefined; } export class ResetPasswordDTO { @ApiProperty({ description: '用户id', example: '' }) @Rule(RuleType['string']().required()) '_id': string = undefined; @ApiProperty({ description: '密码', example: '123456' }) @Rule(RuleType['string']().required()) 'password': string = undefined; }