questionnaire.interface.ts 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import { Rule, RuleType } from '@midwayjs/validate';
  2. import { ApiProperty } from '@midwayjs/swagger';
  3. import { SearchBase } from 'free-midway-component';
  4. import get = require('lodash/get');
  5. const dealVO = (cla, data) => {
  6. for (const key in cla) {
  7. const val = get(data, key);
  8. if (val || val === 0) cla[key] = val;
  9. }
  10. };
  11. export class FVO_questionnaire {
  12. constructor(data: object) {
  13. dealVO(this, data);
  14. }
  15. @ApiProperty({ description: '数据id' })
  16. _id: string = undefined;
  17. @ApiProperty({ description: '类型' })
  18. 'type': string = undefined;
  19. @ApiProperty({ description: '标题' })
  20. 'title': string = undefined;
  21. @ApiProperty({ description: '发布时间' })
  22. 'create_date': string = undefined;
  23. @ApiProperty({ description: '简介' })
  24. 'brief': string = undefined;
  25. @ApiProperty({ description: '问卷题库' })
  26. 'questions': Array<any> = undefined;
  27. @ApiProperty({ description: '是否启用' })
  28. 'is_use': string = undefined;
  29. }
  30. export class QDTO_questionnaire extends SearchBase {
  31. constructor() {
  32. const like_prop = [];
  33. const props = ['type', 'title', 'create_date', 'is_use'];
  34. const mapping = [];
  35. super({ like_prop, props, mapping });
  36. }
  37. @ApiProperty({ description: '类型' })
  38. 'type': string = undefined;
  39. @ApiProperty({ description: '标题' })
  40. 'title': string = undefined;
  41. @ApiProperty({ description: '发布时间' })
  42. 'create_date': string = undefined;
  43. @ApiProperty({ description: '是否启用' })
  44. 'is_use': string = undefined;
  45. }
  46. export class QVO_questionnaire extends FVO_questionnaire {
  47. constructor(data: object) {
  48. super(data);
  49. dealVO(this, data);
  50. }
  51. }
  52. export class CDTO_questionnaire {
  53. @ApiProperty({ description: '类型' })
  54. @Rule(RuleType['string']().empty(''))
  55. 'type': string = undefined;
  56. @ApiProperty({ description: '标题' })
  57. @Rule(RuleType['string']().empty(''))
  58. 'title': string = undefined;
  59. @ApiProperty({ description: '发布时间' })
  60. @Rule(RuleType['string']().empty(''))
  61. 'create_date': string = undefined;
  62. @ApiProperty({ description: '简介' })
  63. @Rule(RuleType['string']().empty(''))
  64. 'brief': string = undefined;
  65. @ApiProperty({ description: '问卷题库' })
  66. @Rule(RuleType['array']().empty(''))
  67. 'questions': Array<any> = undefined;
  68. @ApiProperty({ description: '是否启用' })
  69. @Rule(RuleType['string']().empty(''))
  70. 'is_use': string = undefined;
  71. }
  72. export class CVO_questionnaire extends FVO_questionnaire {
  73. constructor(data: object) {
  74. super(data);
  75. dealVO(this, data);
  76. }
  77. }
  78. export class UDTO_questionnaire extends CDTO_questionnaire {
  79. @ApiProperty({ description: '数据id' })
  80. @Rule(RuleType['string']().empty(''))
  81. _id: string = undefined;
  82. }
  83. export class UVAO_questionnaire extends FVO_questionnaire {
  84. constructor(data: object) {
  85. super(data);
  86. dealVO(this, data);
  87. }
  88. }