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_course { constructor(data: object) { dealVO(this, data); } @ApiProperty({ description: '数据id' }) _id: string = undefined; @ApiProperty({ description: '年度' }) 'year': string = undefined; @ApiProperty({ description: '标题' }) 'title': string = undefined; @ApiProperty({ description: '类型' }) 'type': string = undefined; @ApiProperty({ description: '课程类型' }) 'brand': string = undefined; @ApiProperty({ description: '发布时间' }) 'time': string = undefined; @ApiProperty({ description: '封面' }) 'logo': Array = undefined; @ApiProperty({ description: '总学时' }) 'hour': string = undefined; @ApiProperty({ description: '简介' }) 'brief': string = undefined; @ApiProperty({ description: '内容' }) 'content': string = undefined; @ApiProperty({ description: '是否使用' }) 'is_use': string = undefined; @ApiProperty({ description: '状态' }) 'status': string = undefined; } export class QDTO_course extends SearchBase { constructor() { const like_prop = ['title']; const props = ['year', 'type', 'brand', 'title', 'time', 'is_use', 'status']; const mapping = []; super({ like_prop, props, mapping }); } @ApiProperty({ description: '年度' }) 'year': string = undefined; @ApiProperty({ description: '标题' }) 'title': string = undefined; @ApiProperty({ description: '类型' }) 'type': string = undefined; @ApiProperty({ description: '发布时间' }) 'time': string = undefined; @ApiProperty({ description: '课程类型' }) 'brand': string = undefined; @ApiProperty({ description: '是否使用' }) 'is_use': string = undefined; @ApiProperty({ description: '状态' }) 'status': string = undefined; } export class QVO_course extends FVO_course { constructor(data: object) { super(data); dealVO(this, data); } } export class CDTO_course { @ApiProperty({ description: '年度' }) @Rule(RuleType['string']().empty('')) 'year': string = undefined; @ApiProperty({ description: '标题' }) @Rule(RuleType['string']().empty('')) 'title': string = undefined; @ApiProperty({ description: '类型' }) @Rule(RuleType['string']().empty('')) 'type': string = undefined; @ApiProperty({ description: '发布时间' }) @Rule(RuleType['string']().empty('')) 'time': string = undefined; @ApiProperty({ description: '课程类型' }) @Rule(RuleType['string']().empty('')) 'brand': string = undefined; @ApiProperty({ description: '封面' }) @Rule(RuleType['array']().empty('')) 'logo': Array = undefined; @ApiProperty({ description: '总学时' }) @Rule(RuleType['string']().empty('')) 'hour': string = undefined; @ApiProperty({ description: '简介' }) @Rule(RuleType['string']().empty('')) 'brief': string = undefined; @ApiProperty({ description: '内容' }) @Rule(RuleType['string']().empty('')) 'content': string = undefined; @ApiProperty({ description: '是否使用' }) @Rule(RuleType['string']().empty('')) 'is_use': string = undefined; @ApiProperty({ description: '状态' }) @Rule(RuleType['string']().empty('')) 'status': string = undefined; } export class CVO_course extends FVO_course { constructor(data: object) { super(data); dealVO(this, data); } } export class UDTO_course extends CDTO_course { @ApiProperty({ description: '数据id' }) @Rule(RuleType['string']().empty('')) _id: string = undefined; } export class UVAO_course extends FVO_course { constructor(data: object) { super(data); dealVO(this, data); } }