user.interface.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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_user {
  12. constructor(data: object) {
  13. dealVO(this, data);
  14. }
  15. @ApiProperty({ description: '数据id' })
  16. _id: string = undefined;
  17. @ApiProperty({ description: '账号' })
  18. 'account': string = undefined;
  19. @ApiProperty({ description: '密码' })
  20. 'password': string = undefined;
  21. @ApiProperty({ description: '昵称' })
  22. 'nick_name': string = undefined;
  23. @ApiProperty({ description: '性别' })
  24. 'gender': string = undefined;
  25. @ApiProperty({ description: '手机号' })
  26. 'phone': string = undefined;
  27. @ApiProperty({ description: '角色' })
  28. 'role': Array<any> = undefined;
  29. @ApiProperty({ description: '状态' })
  30. 'status': string = undefined;
  31. }
  32. export class QDTO_user extends SearchBase {
  33. constructor() {
  34. const like_prop = [];
  35. const props = ['account', 'nick_name', 'phone', 'status'];
  36. const mapping = [];
  37. super({ like_prop, props, mapping });
  38. }
  39. @ApiProperty({ description: '账号' })
  40. 'account': string = undefined;
  41. @ApiProperty({ description: '昵称' })
  42. 'nick_name': string = undefined;
  43. @ApiProperty({ description: '手机号' })
  44. 'phone': string = undefined;
  45. @ApiProperty({ description: '状态' })
  46. 'status': string = undefined;
  47. }
  48. export class QVO_user extends FVO_user {
  49. constructor(data: object) {
  50. super(data);
  51. dealVO(this, data);
  52. }
  53. }
  54. export class CDTO_user {
  55. @ApiProperty({ description: '账号' })
  56. @Rule(RuleType['string']().empty(''))
  57. 'account': string = undefined;
  58. @ApiProperty({ description: '密码' })
  59. @Rule(RuleType['string']().empty(''))
  60. 'password': string = undefined;
  61. @ApiProperty({ description: '昵称' })
  62. @Rule(RuleType['string']().empty(''))
  63. 'nick_name': string = undefined;
  64. @ApiProperty({ description: '性别' })
  65. @Rule(RuleType['string']().empty(''))
  66. 'gender': string = undefined;
  67. @ApiProperty({ description: '手机号' })
  68. @Rule(RuleType['string']().empty(''))
  69. 'phone': string = undefined;
  70. @ApiProperty({ description: '角色' })
  71. @Rule(RuleType['array']().empty(''))
  72. 'role': Array<any> = undefined;
  73. @ApiProperty({ description: '状态' })
  74. @Rule(RuleType['string']().empty(''))
  75. 'status': string = undefined;
  76. }
  77. export class CVO_user extends FVO_user {
  78. constructor(data: object) {
  79. super(data);
  80. dealVO(this, data);
  81. }
  82. }
  83. export class UDTO_user extends CDTO_user {
  84. @ApiProperty({ description: '数据id' })
  85. @Rule(RuleType['string']().empty(''))
  86. _id: string = undefined;
  87. }
  88. export class UVAO_user extends FVO_user {
  89. constructor(data: object) {
  90. super(data);
  91. dealVO(this, data);
  92. }
  93. }