User.interface.ts 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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. 'name': string = undefined;
  19. @ApiProperty({ description: '联系电话' })
  20. 'tel': string = undefined;
  21. @ApiProperty({ description: '密码' })
  22. 'password': string = undefined;
  23. @ApiProperty({ description: '性别' })
  24. 'gender': string = undefined;
  25. @ApiProperty({ description: '角色' })
  26. 'role': string = undefined;
  27. @ApiProperty({ description: '所属街道' })
  28. 'street': string = undefined;
  29. @ApiProperty({ description: '所属社区' })
  30. 'community': string = undefined;
  31. @ApiProperty({ description: '创建时间' })
  32. 'create_time': string = undefined;
  33. @ApiProperty({ description: '微信id' })
  34. 'openid': string = undefined;
  35. @ApiProperty({ description: '状态' })
  36. 'status': string = undefined;
  37. }
  38. export class QDTO_User extends SearchBase {
  39. constructor() {
  40. const like_prop = ['name'];
  41. const props = [
  42. 'name',
  43. 'tel',
  44. 'gender',
  45. 'role',
  46. 'street',
  47. 'community',
  48. 'openid',
  49. 'create_time',
  50. 'status',
  51. ];
  52. const mapping = [];
  53. super({ like_prop, props, mapping });
  54. }
  55. @ApiProperty({ description: '姓名' })
  56. 'name': string = undefined;
  57. @ApiProperty({ description: '联系电话' })
  58. 'tel': string = undefined;
  59. @ApiProperty({ description: '性别' })
  60. 'gender': string = undefined;
  61. @ApiProperty({ description: '角色' })
  62. 'role': string = undefined;
  63. @ApiProperty({ description: '所属街道' })
  64. 'street': string = undefined;
  65. @ApiProperty({ description: '所属社区' })
  66. 'community': string = undefined;
  67. @ApiProperty({ description: '微信id' })
  68. 'openid': string = undefined;
  69. @ApiProperty({ description: '创建时间' })
  70. 'create_time': string = undefined;
  71. @ApiProperty({ description: '状态' })
  72. 'status': string = undefined;
  73. }
  74. export class QVO_User extends FVO_User {
  75. constructor(data: object) {
  76. super(data);
  77. dealVO(this, data);
  78. }
  79. }
  80. export class CDTO_User {
  81. @ApiProperty({ description: '姓名' })
  82. @Rule(RuleType['string']().empty(''))
  83. 'name': string = undefined;
  84. @ApiProperty({ description: '联系电话' })
  85. @Rule(RuleType['string']().empty(''))
  86. 'tel': string = undefined;
  87. @ApiProperty({ description: '密码' })
  88. @Rule(RuleType['string']().empty(''))
  89. 'password': string = undefined;
  90. @ApiProperty({ description: '性别' })
  91. @Rule(RuleType['string']().empty(''))
  92. 'gender': string = undefined;
  93. @ApiProperty({ description: '角色' })
  94. @Rule(RuleType['string']().empty(''))
  95. 'role': string = undefined;
  96. @ApiProperty({ description: '所属街道' })
  97. @Rule(RuleType['string']().empty(''))
  98. 'street': string = undefined;
  99. @ApiProperty({ description: '所属社区' })
  100. @Rule(RuleType['string']().empty(''))
  101. 'community': string = undefined;
  102. @ApiProperty({ description: '创建时间' })
  103. @Rule(RuleType['string']().empty(''))
  104. 'create_time': string = undefined;
  105. @ApiProperty({ description: '微信id' })
  106. @Rule(RuleType['string']().empty(''))
  107. 'openid': string = undefined;
  108. @ApiProperty({ description: '状态' })
  109. @Rule(RuleType['string']().empty(''))
  110. 'status': string = undefined;
  111. }
  112. export class CVO_User extends FVO_User {
  113. constructor(data: object) {
  114. super(data);
  115. dealVO(this, data);
  116. }
  117. }
  118. export class UDTO_User extends CDTO_User {
  119. @ApiProperty({ description: '数据id' })
  120. @Rule(RuleType['string']().empty(''))
  121. _id: string = undefined;
  122. }
  123. export class UVAO_User extends FVO_User {
  124. constructor(data: object) {
  125. super(data);
  126. dealVO(this, data);
  127. }
  128. }
  129. export class LoginVO {
  130. constructor(data: object) {
  131. for (const key of Object.keys(this)) {
  132. this[key] = get(data, key);
  133. }
  134. }
  135. @ApiProperty({ description: '数据id' })
  136. _id: string = undefined;
  137. @ApiProperty({ description: '姓名' })
  138. 'name': string = undefined;
  139. @ApiProperty({ description: '联系电话' })
  140. 'tel': string = undefined;
  141. @ApiProperty({ description: '性别' })
  142. 'gender': string = undefined;
  143. @ApiProperty({ description: '角色' })
  144. 'role': string = undefined;
  145. @ApiProperty({ description: '所属街道' })
  146. 'street': string = undefined;
  147. @ApiProperty({ description: '所属社区' })
  148. 'community': string = undefined;
  149. @ApiProperty({ description: '微信id' })
  150. 'openid': string = undefined;
  151. @ApiProperty({ description: '状态' })
  152. 'status': string = undefined;
  153. }
  154. export class LoginDTO {
  155. @ApiProperty({ description: '电话号', example: '18843520013' })
  156. @Rule(RuleType['string']().empty(''))
  157. 'tel': string = undefined;
  158. @ApiProperty({ description: '密码', example: '111111' })
  159. @Rule(RuleType['string']().empty(''))
  160. 'password': string = undefined;
  161. }
  162. export class ResetPasswordDTO {
  163. @ApiProperty({ description: '用户id', example: '' })
  164. @Rule(RuleType['string']().required())
  165. '_id': string = undefined;
  166. @ApiProperty({ description: '密码', example: '123456' })
  167. @Rule(RuleType['string']().required())
  168. 'password': string = undefined;
  169. }