dictData.interface.ts 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. 'code': 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. }
  28. export class QDTO_dictData extends SearchBase {
  29. constructor() {
  30. const like_prop = [];
  31. const props = ['code', 'is_use'];
  32. const mapping = [];
  33. super({ like_prop, props, mapping });
  34. }
  35. @ApiProperty({ description: '字典类型编码' })
  36. 'code': string = undefined;
  37. @ApiProperty({ description: '是否使用' })
  38. 'is_use': string = undefined;
  39. }
  40. export class QVO_dictData extends FVO_dictData {
  41. constructor(data: object) {
  42. super(data);
  43. dealVO(this, data);
  44. }
  45. }
  46. export class CDTO_dictData {
  47. @ApiProperty({ description: '字典类型编码' })
  48. @Rule(RuleType['string']().empty(''))
  49. 'code': string = undefined;
  50. @ApiProperty({ description: '数据显示值' })
  51. @Rule(RuleType['string']().empty(''))
  52. 'label': string = undefined;
  53. @ApiProperty({ description: '数据选择值' })
  54. @Rule(RuleType['string']().empty(''))
  55. 'value': string = undefined;
  56. @ApiProperty({ description: '排序' })
  57. @Rule(RuleType['number']().empty(''))
  58. 'sort': number = undefined;
  59. @ApiProperty({ description: '是否使用' })
  60. @Rule(RuleType['string']().empty(''))
  61. 'is_use': string = undefined;
  62. }
  63. export class CVO_dictData extends FVO_dictData {
  64. constructor(data: object) {
  65. super(data);
  66. dealVO(this, data);
  67. }
  68. }
  69. export class UDTO_dictData extends CDTO_dictData {
  70. @ApiProperty({ description: '数据id' })
  71. @Rule(RuleType['string']().empty(''))
  72. _id: string = undefined;
  73. }
  74. export class UVAO_dictData extends FVO_dictData {
  75. constructor(data: object) {
  76. super(data);
  77. dealVO(this, data);
  78. }
  79. }