|
@@ -0,0 +1,156 @@
|
|
|
+import { Rule, RuleType } from '@midwayjs/validate';
|
|
|
+import { ApiProperty } from '@midwayjs/swagger';
|
|
|
+import {
|
|
|
+ FrameworkErrorEnum,
|
|
|
+ SearchBase,
|
|
|
+ ServiceError,
|
|
|
+} from 'free-midway-component';
|
|
|
+import get = require('lodash/get');
|
|
|
+const dealVO = (cla, data) => {
|
|
|
+ for (const key in cla) {
|
|
|
+ const val = get(data, key);
|
|
|
+ if (val || val === 0) cla[key] = val;
|
|
|
+ }
|
|
|
+};
|
|
|
+export class FVO_User {
|
|
|
+ constructor(data: object) {
|
|
|
+ dealVO(this, data);
|
|
|
+ }
|
|
|
+ @ApiProperty({ description: '数据id' })
|
|
|
+ _id: string = undefined;
|
|
|
+ @ApiProperty({ description: '姓名' })
|
|
|
+ 'name': string = undefined;
|
|
|
+ @ApiProperty({ description: '联系电话' })
|
|
|
+ 'tel': string = undefined;
|
|
|
+ @ApiProperty({ description: '密码' })
|
|
|
+ 'password': string = undefined;
|
|
|
+ @ApiProperty({ description: '性别' })
|
|
|
+ 'gender': number = undefined;
|
|
|
+ @ApiProperty({ description: '角色' })
|
|
|
+ 'role': string = undefined;
|
|
|
+ @ApiProperty({ description: '所属' })
|
|
|
+ 'belong': string = undefined;
|
|
|
+ @ApiProperty({ description: '微信id' })
|
|
|
+ 'openid': string = undefined;
|
|
|
+ @ApiProperty({ description: '状态' })
|
|
|
+ 'status': string = undefined;
|
|
|
+}
|
|
|
+
|
|
|
+export class QDTO_User extends SearchBase {
|
|
|
+ constructor() {
|
|
|
+ const like_prop = [];
|
|
|
+ const props = ['name', 'openid', 'status'];
|
|
|
+ const mapping = [];
|
|
|
+ super({ like_prop, props, mapping });
|
|
|
+ }
|
|
|
+ @ApiProperty({ description: '姓名' })
|
|
|
+ 'name': string = undefined;
|
|
|
+ @ApiProperty({ description: '微信id' })
|
|
|
+ 'openid': string = undefined;
|
|
|
+ @ApiProperty({ description: '状态' })
|
|
|
+ 'status': string = undefined;
|
|
|
+}
|
|
|
+
|
|
|
+export class QVO_User extends FVO_User {
|
|
|
+ constructor(data: object) {
|
|
|
+ super(data);
|
|
|
+ dealVO(this, data);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+export class CDTO_User {
|
|
|
+ @ApiProperty({ description: '姓名' })
|
|
|
+ @Rule(
|
|
|
+ RuleType['string']()
|
|
|
+ .required()
|
|
|
+ .error(new ServiceError('缺少姓名', FrameworkErrorEnum.NEED_BODY))
|
|
|
+ )
|
|
|
+ 'name': string = undefined;
|
|
|
+ @ApiProperty({ description: '联系电话' })
|
|
|
+ @Rule(
|
|
|
+ RuleType['string']()
|
|
|
+ .required()
|
|
|
+ .error(new ServiceError('缺少联系电话', FrameworkErrorEnum.NEED_BODY))
|
|
|
+ )
|
|
|
+ 'tel': string = undefined;
|
|
|
+ @ApiProperty({ description: '密码' })
|
|
|
+ @Rule(RuleType['string']().empty(''))
|
|
|
+ 'password': string = undefined;
|
|
|
+ @ApiProperty({ description: '性别' })
|
|
|
+ @Rule(RuleType['number']().empty(''))
|
|
|
+ 'gender': number = undefined;
|
|
|
+ @ApiProperty({ description: '角色' })
|
|
|
+ @Rule(RuleType['string']().empty(''))
|
|
|
+ 'role': string = undefined;
|
|
|
+ @ApiProperty({ description: '所属' })
|
|
|
+ @Rule(RuleType['string']().empty(''))
|
|
|
+ 'belong': string = undefined;
|
|
|
+ @ApiProperty({ description: '微信id' })
|
|
|
+ @Rule(RuleType['string']().empty(''))
|
|
|
+ 'openid': string = undefined;
|
|
|
+ @ApiProperty({ description: '状态' })
|
|
|
+ @Rule(RuleType['string']().empty(''))
|
|
|
+ 'status': string = undefined;
|
|
|
+}
|
|
|
+
|
|
|
+export class CVO_User extends FVO_User {
|
|
|
+ constructor(data: object) {
|
|
|
+ super(data);
|
|
|
+ dealVO(this, data);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+export class UDTO_User extends CDTO_User {
|
|
|
+ @ApiProperty({ description: '数据id' })
|
|
|
+ @Rule(RuleType['string']().empty(''))
|
|
|
+ _id: string = undefined;
|
|
|
+}
|
|
|
+
|
|
|
+export class UVAO_User extends FVO_User {
|
|
|
+ constructor(data: object) {
|
|
|
+ super(data);
|
|
|
+ dealVO(this, data);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+export class LoginVO {
|
|
|
+ constructor(data: object) {
|
|
|
+ for (const key of Object.keys(this)) {
|
|
|
+ this[key] = get(data, key);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ @ApiProperty({ description: '数据id' })
|
|
|
+ _id: string = undefined;
|
|
|
+ @ApiProperty({ description: '姓名' })
|
|
|
+ 'name': string = undefined;
|
|
|
+ @ApiProperty({ description: '联系电话' })
|
|
|
+ 'tel': string = undefined;
|
|
|
+ @ApiProperty({ description: '性别' })
|
|
|
+ 'gender': number = undefined;
|
|
|
+ @ApiProperty({ description: '角色' })
|
|
|
+ 'role': string = undefined;
|
|
|
+ @ApiProperty({ description: '所属' })
|
|
|
+ 'belong': string = undefined;
|
|
|
+ @ApiProperty({ description: '微信id' })
|
|
|
+ 'openid': string = undefined;
|
|
|
+ @ApiProperty({ description: '状态' })
|
|
|
+ 'status': string = undefined;
|
|
|
+}
|
|
|
+
|
|
|
+export class LoginDTO {
|
|
|
+ @ApiProperty({ description: '电话号', example: '18843520013' })
|
|
|
+ @Rule(RuleType['string']().empty(''))
|
|
|
+ 'tel': string = undefined;
|
|
|
+ @ApiProperty({ description: '密码', example: '111111' })
|
|
|
+ @Rule(RuleType['string']().empty(''))
|
|
|
+ 'password': string = undefined;
|
|
|
+}
|
|
|
+
|
|
|
+export class ResetPasswordDTO {
|
|
|
+ @ApiProperty({ description: '用户id', example: '' })
|
|
|
+ @Rule(RuleType['string']().required())
|
|
|
+ '_id': string = undefined;
|
|
|
+ @ApiProperty({ description: '密码', example: '123456' })
|
|
|
+ @Rule(RuleType['string']().required())
|
|
|
+ 'password': string = undefined;
|
|
|
+}
|