dictData.interface.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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_dictData {
  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. 'label': string = undefined;
  21. @ApiProperty({ description: '键值' })
  22. 'value': string = undefined;
  23. @ApiProperty({ description: '排序' })
  24. 'sort': number = undefined;
  25. @ApiProperty({ description: '是否使用' })
  26. 'is_use': string = undefined;
  27. @ApiProperty({ description: '字数据' })
  28. 'children': Array<any> = undefined;
  29. }
  30. export class QDTO_dictData extends SearchBase {
  31. constructor() {
  32. const like_prop = [];
  33. const props = ['type', 'label', 'value', 'sort', 'is_use'];
  34. const mapping = [];
  35. super({ like_prop, props, mapping });
  36. }
  37. @ApiProperty({ description: '类型' })
  38. 'type': string = undefined;
  39. @ApiProperty({ description: '标签' })
  40. 'label': string = undefined;
  41. @ApiProperty({ description: '键值' })
  42. 'value': string = undefined;
  43. @ApiProperty({ description: '排序' })
  44. 'sort': number = undefined;
  45. @ApiProperty({ description: '是否使用' })
  46. 'is_use': string = undefined;
  47. }
  48. export class QVO_dictData extends FVO_dictData {
  49. constructor(data: object) {
  50. super(data);
  51. dealVO(this, data);
  52. }
  53. }
  54. export class CDTO_dictData {
  55. @ApiProperty({ description: '类型' })
  56. @Rule(RuleType['string']().empty(''))
  57. 'type': string = undefined;
  58. @ApiProperty({ description: '标签' })
  59. @Rule(RuleType['string']().empty(''))
  60. 'label': string = undefined;
  61. @ApiProperty({ description: '键值' })
  62. @Rule(RuleType['string']().empty(''))
  63. 'value': string = undefined;
  64. @ApiProperty({ description: '排序' })
  65. @Rule(RuleType['number']().empty(''))
  66. 'sort': number = undefined;
  67. @ApiProperty({ description: '是否使用' })
  68. @Rule(RuleType['string']().empty(''))
  69. 'is_use': string = undefined;
  70. @ApiProperty({ description: '字数据' })
  71. @Rule(RuleType['array']().empty(''))
  72. 'children': Array<any> = undefined;
  73. }
  74. export class CVO_dictData extends FVO_dictData {
  75. constructor(data: object) {
  76. super(data);
  77. dealVO(this, data);
  78. }
  79. }
  80. export class UDTO_dictData extends CDTO_dictData {
  81. @ApiProperty({ description: '数据id' })
  82. @Rule(RuleType['string']().empty(''))
  83. _id: string = undefined;
  84. }
  85. export class UVAO_dictData extends FVO_dictData {
  86. constructor(data: object) {
  87. super(data);
  88. dealVO(this, data);
  89. }
  90. }