Config.interface.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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_Config {
  12. constructor(data: object) {
  13. dealVO(this, data);
  14. }
  15. @ApiProperty({ description: '数据id' })
  16. _id: string = undefined;
  17. @ApiProperty({ description: 'logo' })
  18. 'logo_url': Array<any> = undefined;
  19. @ApiProperty({ description: '男头像' })
  20. 'boy_url': Array<any> = undefined;
  21. @ApiProperty({ description: '女头像' })
  22. 'girl_url': Array<any> = undefined;
  23. }
  24. export class QDTO_Config extends SearchBase {
  25. constructor() {
  26. const like_prop = [];
  27. const props = [];
  28. const mapping = [];
  29. super({ like_prop, props, mapping });
  30. }
  31. }
  32. export class QVO_Config extends FVO_Config {
  33. constructor(data: object) {
  34. super(data);
  35. dealVO(this, data);
  36. }
  37. }
  38. export class CDTO_Config {
  39. @ApiProperty({ description: 'logo' })
  40. @Rule(RuleType['array']().empty(''))
  41. 'logo_url': Array<any> = undefined;
  42. @ApiProperty({ description: '男头像' })
  43. @Rule(RuleType['array']().empty(''))
  44. 'boy_url': Array<any> = undefined;
  45. @ApiProperty({ description: '女头像' })
  46. @Rule(RuleType['array']().empty(''))
  47. 'girl_url': Array<any> = undefined;
  48. }
  49. export class CVO_Config extends FVO_Config {
  50. constructor(data: object) {
  51. super(data);
  52. dealVO(this, data);
  53. }
  54. }
  55. export class UDTO_Config extends CDTO_Config {
  56. @ApiProperty({ description: '数据id' })
  57. @Rule(RuleType['string']().empty(''))
  58. _id: string = undefined;
  59. }
  60. export class UVAO_Config extends FVO_Config {
  61. constructor(data: object) {
  62. super(data);
  63. dealVO(this, data);
  64. }
  65. }