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_address { constructor(data: object) { dealVO(this, data); } @ApiProperty({ description: '数据id' }) _id: string = undefined; @ApiProperty({ description: '用户' }) 'user': string = undefined; @ApiProperty({ description: '收货人' }) 'name': string = undefined; @ApiProperty({ description: '收货人联系电话' }) 'phone': string = undefined; @ApiProperty({ description: '省份' }) 'province': string = undefined; @ApiProperty({ description: '城市' }) 'city': string = undefined; @ApiProperty({ description: '区' }) 'area': string = undefined; @ApiProperty({ description: '详细地址' }) 'address': string = undefined; @ApiProperty({ description: '是否默认' }) 'is_default': string = undefined; } export class QDTO_address extends SearchBase { constructor() { const like_prop = []; const props = []; const mapping = []; super({ like_prop, props, mapping }); } } export class QVO_address extends FVO_address { constructor(data: object) { super(data); dealVO(this, data); } } export class CDTO_address { @ApiProperty({ description: '用户' }) @Rule(RuleType['string']().empty('')) 'user': string = undefined; @ApiProperty({ description: '收货人' }) @Rule(RuleType['string']().empty('')) 'name': string = undefined; @ApiProperty({ description: '收货人联系电话' }) @Rule(RuleType['string']().empty('')) 'phone': string = undefined; @ApiProperty({ description: '省份' }) @Rule(RuleType['string']().empty('')) 'province': string = undefined; @ApiProperty({ description: '城市' }) @Rule(RuleType['string']().empty('')) 'city': string = undefined; @ApiProperty({ description: '区' }) @Rule(RuleType['string']().empty('')) 'area': string = undefined; @ApiProperty({ description: '详细地址' }) @Rule(RuleType['string']().empty('')) 'address': string = undefined; @ApiProperty({ description: '是否默认' }) @Rule(RuleType['string']().empty('')) 'is_default': string = undefined; } export class CVO_address extends FVO_address { constructor(data: object) { super(data); dealVO(this, data); } } export class UDTO_address extends CDTO_address { @ApiProperty({ description: '数据id' }) @Rule(RuleType['string']().empty('')) _id: string = undefined; } export class UVAO_address extends FVO_address { constructor(data: object) { super(data); dealVO(this, data); } }