news.interface.ts 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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_news {
  12. constructor(data: object) {
  13. dealVO(this, data);
  14. }
  15. @ApiProperty({ description: '数据id' })
  16. _id: string = undefined;
  17. @ApiProperty({ description: '标题' })
  18. 'title': string = undefined;
  19. @ApiProperty({ description: '封面' })
  20. 'logo': Array<any> = undefined;
  21. @ApiProperty({ description: '发布人' })
  22. 'person': string = undefined;
  23. @ApiProperty({ description: '发布时间' })
  24. 'time': string = undefined;
  25. @ApiProperty({ description: '内容' })
  26. 'content': string = undefined;
  27. @ApiProperty({ description: '浏览次数' })
  28. 'number': number = undefined;
  29. @ApiProperty({ description: '类型' })
  30. 'type': string = undefined;
  31. @ApiProperty({ description: '是否使用' })
  32. 'is_use': string = undefined;
  33. @ApiProperty({ description: '状态' })
  34. 'status': string = undefined;
  35. }
  36. export class QDTO_news extends SearchBase {
  37. constructor() {
  38. const like_prop = ['title'];
  39. const props = ['title', 'person', 'time', 'type', 'is_use', 'status'];
  40. const mapping = [];
  41. super({ like_prop, props, mapping });
  42. }
  43. @ApiProperty({ description: '标题' })
  44. 'title': string = undefined;
  45. @ApiProperty({ description: '发布人' })
  46. 'person': string = undefined;
  47. @ApiProperty({ description: '发布时间' })
  48. 'time': string = undefined;
  49. @ApiProperty({ description: '类型' })
  50. 'type': string = undefined;
  51. @ApiProperty({ description: '是否使用' })
  52. 'is_use': string = undefined;
  53. @ApiProperty({ description: '状态' })
  54. 'status': string = undefined;
  55. }
  56. export class QVO_news extends FVO_news {
  57. constructor(data: object) {
  58. super(data);
  59. dealVO(this, data);
  60. }
  61. }
  62. export class CDTO_news {
  63. @ApiProperty({ description: '标题' })
  64. @Rule(RuleType['string']().empty(''))
  65. 'title': string = undefined;
  66. @ApiProperty({ description: '封面' })
  67. @Rule(RuleType['array']().empty(''))
  68. 'logo': Array<any> = undefined;
  69. @ApiProperty({ description: '发布人' })
  70. @Rule(RuleType['string']().empty(''))
  71. 'person': string = undefined;
  72. @ApiProperty({ description: '发布时间' })
  73. @Rule(RuleType['string']().empty(''))
  74. 'time': string = undefined;
  75. @ApiProperty({ description: '内容' })
  76. @Rule(RuleType['string']().empty(''))
  77. 'content': string = undefined;
  78. @ApiProperty({ description: '浏览次数' })
  79. @Rule(RuleType['number']().empty(''))
  80. 'number': number = undefined;
  81. @ApiProperty({ description: '类型' })
  82. @Rule(RuleType['string']().empty(''))
  83. 'type': string = undefined;
  84. @ApiProperty({ description: '是否使用' })
  85. @Rule(RuleType['string']().empty(''))
  86. 'is_use': string = undefined;
  87. @ApiProperty({ description: '状态' })
  88. @Rule(RuleType['string']().empty(''))
  89. 'status': string = undefined;
  90. }
  91. export class CVO_news extends FVO_news {
  92. constructor(data: object) {
  93. super(data);
  94. dealVO(this, data);
  95. }
  96. }
  97. export class UDTO_news extends CDTO_news {
  98. @ApiProperty({ description: '数据id' })
  99. @Rule(RuleType['string']().empty(''))
  100. _id: string = undefined;
  101. }
  102. export class UVAO_news extends FVO_news {
  103. constructor(data: object) {
  104. super(data);
  105. dealVO(this, data);
  106. }
  107. }