user.interface.ts 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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: 'openid' })
  18. 'openid': string = undefined;
  19. @ApiProperty({ description: '类别' })
  20. 'type': string = undefined;
  21. @ApiProperty({ description: '名称' })
  22. 'name': string = undefined;
  23. @ApiProperty({ description: '账号' })
  24. 'account': string = undefined;
  25. @ApiProperty({ description: '密码' })
  26. 'password': string = undefined;
  27. @ApiProperty({ description: '手机号' })
  28. 'phone': string = undefined;
  29. @ApiProperty({ description: '邮箱' })
  30. 'email': string = undefined;
  31. @ApiProperty({ description: '性别' })
  32. 'gender': string = undefined;
  33. @ApiProperty({ description: '头像' })
  34. 'icon': Array<any> = undefined;
  35. @ApiProperty({ description: '年龄' })
  36. 'age': string = undefined;
  37. @ApiProperty({ description: '状态' })
  38. 'status': string = undefined;
  39. @ApiProperty({ description: '工作单位' })
  40. 'work': string = undefined;
  41. }
  42. export class QDTO_user extends SearchBase {
  43. constructor() {
  44. const like_prop = ['name'];
  45. const props = [
  46. 'openid',
  47. 'type',
  48. 'name',
  49. 'account',
  50. 'phone',
  51. 'age',
  52. 'status',
  53. ];
  54. const mapping = [];
  55. super({ like_prop, props, mapping });
  56. }
  57. @ApiProperty({ description: 'openid' })
  58. 'openid': string = undefined;
  59. @ApiProperty({ description: '类别' })
  60. 'type': string = undefined;
  61. @ApiProperty({ description: '名称' })
  62. 'name': string = undefined;
  63. @ApiProperty({ description: '账号' })
  64. 'account': string = undefined;
  65. @ApiProperty({ description: '手机号' })
  66. 'phone': string = undefined;
  67. @ApiProperty({ description: '年龄' })
  68. 'age': string = undefined;
  69. @ApiProperty({ description: '状态' })
  70. 'status': string = undefined;
  71. }
  72. export class QVO_user extends FVO_user {
  73. constructor(data: object) {
  74. super(data);
  75. dealVO(this, data);
  76. }
  77. }
  78. export class CDTO_user {
  79. @ApiProperty({ description: 'openid' })
  80. @Rule(RuleType['string']().empty(''))
  81. 'openid': string = undefined;
  82. @ApiProperty({ description: '类别' })
  83. @Rule(RuleType['string']().empty(''))
  84. 'type': string = undefined;
  85. @ApiProperty({ description: '名称' })
  86. @Rule(RuleType['string']().empty(''))
  87. 'name': string = undefined;
  88. @ApiProperty({ description: '账号' })
  89. @Rule(RuleType['string']().empty(''))
  90. 'account': string = undefined;
  91. @ApiProperty({ description: '密码' })
  92. @Rule(RuleType['string']().empty(''))
  93. 'password': string = undefined;
  94. @ApiProperty({ description: '手机号' })
  95. @Rule(RuleType['string']().empty(''))
  96. 'phone': string = undefined;
  97. @ApiProperty({ description: '邮箱' })
  98. @Rule(RuleType['string']().empty(''))
  99. 'email': string = undefined;
  100. @ApiProperty({ description: '性别' })
  101. @Rule(RuleType['string']().empty(''))
  102. 'gender': string = undefined;
  103. @ApiProperty({ description: '头像' })
  104. @Rule(RuleType['array']().empty(''))
  105. 'icon': Array<any> = undefined;
  106. @ApiProperty({ description: '年龄' })
  107. @Rule(RuleType['string']().empty(''))
  108. 'age': string = undefined;
  109. @ApiProperty({ description: '状态' })
  110. @Rule(RuleType['string']().empty(''))
  111. 'status': string = undefined;
  112. @ApiProperty({ description: '工作单位' })
  113. @Rule(RuleType['string']().empty(''))
  114. 'work': string = undefined;
  115. }
  116. export class CVO_user extends FVO_user {
  117. constructor(data: object) {
  118. super(data);
  119. dealVO(this, data);
  120. }
  121. }
  122. export class UDTO_user extends CDTO_user {
  123. @ApiProperty({ description: '数据id' })
  124. @Rule(RuleType['string']().empty(''))
  125. _id: string = undefined;
  126. }
  127. export class UVAO_user extends FVO_user {
  128. constructor(data: object) {
  129. super(data);
  130. dealVO(this, data);
  131. }
  132. }
  133. export class LoginVO {
  134. constructor(data: object) {
  135. for (const key of Object.keys(this)) {
  136. this[key] = get(data, key);
  137. }
  138. }
  139. @ApiProperty({ description: '数据id' })
  140. _id: string = undefined;
  141. @ApiProperty({ description: 'openid' })
  142. 'openid': string = undefined;
  143. @ApiProperty({ description: '类别' })
  144. 'type': string = undefined;
  145. @ApiProperty({ description: '名称' })
  146. 'name': string = undefined;
  147. @ApiProperty({ description: '账号' })
  148. 'account': string = undefined;
  149. @ApiProperty({ description: '手机号' })
  150. 'phone': string = undefined;
  151. @ApiProperty({ description: '邮箱' })
  152. 'email': string = undefined;
  153. @ApiProperty({ description: '性别' })
  154. 'gender': string = undefined;
  155. @ApiProperty({ description: '头像' })
  156. 'icon': Array<any> = undefined;
  157. @ApiProperty({ description: '年龄' })
  158. 'age': string = undefined;
  159. @ApiProperty({ description: '状态' })
  160. 'status': string = undefined;
  161. @ApiProperty({ description: '工作单位' })
  162. 'work': string = undefined;
  163. }
  164. export class LoginDTO {
  165. @ApiProperty({ description: '账号', example: 'test' })
  166. @Rule(RuleType['string']().empty(''))
  167. 'account': string = undefined;
  168. @ApiProperty({ description: '密码', example: '111111' })
  169. @Rule(RuleType['string']().empty(''))
  170. 'password': string = undefined;
  171. }
  172. export class ResetPasswordDTO {
  173. @ApiProperty({ description: '用户id', example: '' })
  174. @Rule(RuleType['string']().required())
  175. '_id': string = undefined;
  176. @ApiProperty({ description: '密码', example: '123456' })
  177. @Rule(RuleType['string']().required())
  178. 'password': string = undefined;
  179. }