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: '微信小程序id' }) 'openid': string = undefined; @ApiProperty({ description: '昵称' }) 'nick_name': string = undefined; @ApiProperty({ description: '电话' }) 'tel': string = undefined; @ApiProperty({ description: '部门' }) 'dept': string = undefined; } export class QDTO_user extends SearchBase { constructor() { const like_prop = []; const props = []; const mapping = []; super({ like_prop, props, mapping }); } } export class QVO_user extends FVO_user { constructor(data: object) { super(data); dealVO(this, data); } } export class CDTO_user { @ApiProperty({ description: '微信小程序id' }) @Rule(RuleType['string']().empty('')) 'openid': string = undefined; @ApiProperty({ description: '昵称' }) @Rule(RuleType['string']().empty('')) 'nick_name': string = undefined; @ApiProperty({ description: '电话' }) @Rule(RuleType['string']().empty('')) 'tel': string = undefined; @ApiProperty({ description: '部门' }) @Rule(RuleType['string']().empty('')) 'dept': 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); } }