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_questionnaire { constructor(data: object) { dealVO(this, data); } @ApiProperty({ description: '数据id' }) _id: string = undefined; @ApiProperty({ description: '类型' }) 'type': string = undefined; @ApiProperty({ description: '标题' }) 'title': string = undefined; @ApiProperty({ description: '发布时间' }) 'create_date': string = undefined; @ApiProperty({ description: '简介' }) 'brief': string = undefined; @ApiProperty({ description: '问卷题库' }) 'questions': Array = undefined; @ApiProperty({ description: '是否启用' }) 'is_use': string = undefined; } export class QDTO_questionnaire extends SearchBase { constructor() { const like_prop = []; const props = ['type', 'title', 'create_date', 'is_use']; const mapping = []; super({ like_prop, props, mapping }); } @ApiProperty({ description: '类型' }) 'type': string = undefined; @ApiProperty({ description: '标题' }) 'title': string = undefined; @ApiProperty({ description: '发布时间' }) 'create_date': string = undefined; @ApiProperty({ description: '是否启用' }) 'is_use': string = undefined; } export class QVO_questionnaire extends FVO_questionnaire { constructor(data: object) { super(data); dealVO(this, data); } } export class CDTO_questionnaire { @ApiProperty({ description: '类型' }) @Rule(RuleType['string']().empty('')) 'type': string = undefined; @ApiProperty({ description: '标题' }) @Rule(RuleType['string']().empty('')) 'title': string = undefined; @ApiProperty({ description: '发布时间' }) @Rule(RuleType['string']().empty('')) 'create_date': string = undefined; @ApiProperty({ description: '简介' }) @Rule(RuleType['string']().empty('')) 'brief': string = undefined; @ApiProperty({ description: '问卷题库' }) @Rule(RuleType['array']().empty('')) 'questions': Array = undefined; @ApiProperty({ description: '是否启用' }) @Rule(RuleType['string']().empty('')) 'is_use': string = undefined; } export class CVO_questionnaire extends FVO_questionnaire { constructor(data: object) { super(data); dealVO(this, data); } } export class UDTO_questionnaire extends CDTO_questionnaire { @ApiProperty({ description: '数据id' }) @Rule(RuleType['string']().empty('')) _id: string = undefined; } export class UVAO_questionnaire extends FVO_questionnaire { constructor(data: object) { super(data); dealVO(this, data); } }