zs 2 years ago
parent
commit
cf7914f775

+ 55 - 2
src/controller/channel/channel.controller.ts

@@ -1,4 +1,5 @@
 import {
+  Config,
   Body,
   Controller,
   Del,
@@ -8,7 +9,11 @@ import {
   Post,
   Query,
 } from '@midwayjs/decorator';
-import { BaseController } from 'free-midway-component';
+import {
+  BaseController,
+  ServiceError,
+  FrameworkErrorEnum,
+} from 'free-midway-component';
 import { ChannelService } from '../../service/channel/channel.service';
 import {
   CDTO_channel,
@@ -18,15 +23,63 @@ import {
   QVO_channel,
   UDTO_channel,
   UVAO_channel,
+  LoginDTO,
+  LoginVO,
+  ResetPasswordDTO,
 } from '../../interface/channel/channel.interface';
-import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
+import {
+  ApiOperation,
+  ApiResponse,
+  ApiTags,
+  ApiQuery,
+} from '@midwayjs/swagger';
 import { Validate } from '@midwayjs/validate';
+import { JwtService } from '@midwayjs/jwt';
+import get = require('lodash/get');
 @ApiTags(['科技频道'])
 @Controller('/channel')
 export class ChannelController extends BaseController {
   @Inject()
   service: ChannelService;
 
+  @Inject()
+  jwtService: JwtService;
+
+  @Config('jwt.secret')
+  jwtSecret;
+
+  @Config('jwt.expiresIn')
+  jwtExpiresIn;
+
+  @Post('/login')
+  @Validate()
+  async login(@Body() body: LoginDTO) {
+    const data = await this.service.findUserToLogin(body);
+    let vo = new LoginVO(data);
+    vo = JSON.parse(JSON.stringify(vo));
+    const token = await this.jwtService.sign(vo, this.jwtSecret, {
+      expiresIn: this.jwtExpiresIn,
+    });
+    return token;
+  }
+
+  @Post('/rp')
+  @ApiOperation({ description: '修改密码' })
+  async resetPassword(@Body() body: ResetPasswordDTO) {
+    // 获取用户token中的登录信息
+    const user_id = get(this.ctx, 'user._id');
+    if (!user_id)
+      throw new ServiceError('未找到用户信息', FrameworkErrorEnum.NOT_LOGIN);
+    // 查询用户
+    const user = await this.service.fetch(user_id);
+    if (!user)
+      throw new ServiceError('未找到用户', FrameworkErrorEnum.NOT_FOUND_DATA);
+    // 修改密码
+    await this.service.updateOne(user_id, body);
+    // 返回结果
+    return 'ok';
+  }
+
   @Post('/')
   @Validate()
   @ApiResponse({ type: CVO_channel })

+ 1 - 12
src/controller/system/role.controller.ts

@@ -71,22 +71,11 @@ export class RoleController extends BaseController {
     const type = get(user, 'type');
     const user_id = get(this.ctx.user, '_id');
     let udata = {};
-    if (type === '1' || type === '2' || type === '3')
+    if (type === '0' || type === '1' || type === '2' || type === '3')
       udata = await this.adminService.fetch(user_id);
     else if (type === '4') udata = await this.personalService.fetch(user_id);
     else if (type === '5') udata = await this.companyService.fetch(user_id);
     else if (type === '6') udata = await this.expertService.fetch(user_id);
-    else if (type === '0') {
-      // 超级管理员
-      const f = new SearchBase({});
-      const modules = await this.moduleService.query(f);
-      const allMenus = {};
-      for (const i of modules) {
-        const menus = await this.menusService.queryMenu(get(i, '_id'));
-        allMenus[get(i, '_id')] = menus;
-      }
-      return allMenus;
-    }
     const menus = await this.service.getMenuByRoles(get(udata, 'role', []));
     return menus;
   }

+ 55 - 2
src/controller/technology/dock.controller.ts

@@ -1,4 +1,5 @@
 import {
+  Config,
   Body,
   Controller,
   Del,
@@ -8,7 +9,11 @@ import {
   Post,
   Query,
 } from '@midwayjs/decorator';
-import { BaseController } from 'free-midway-component';
+import {
+  BaseController,
+  ServiceError,
+  FrameworkErrorEnum,
+} from 'free-midway-component';
 import { DockService } from '../../service/technology/dock.service';
 import {
   CDTO_dock,
@@ -18,15 +23,63 @@ import {
   QVO_dock,
   UDTO_dock,
   UVAO_dock,
+  LoginDTO,
+  LoginVO,
+  ResetPasswordDTO,
 } from '../../interface/technology/dock.interface';
-import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
+import {
+  ApiOperation,
+  ApiResponse,
+  ApiTags,
+  ApiQuery,
+} from '@midwayjs/swagger';
 import { Validate } from '@midwayjs/validate';
+import { JwtService } from '@midwayjs/jwt';
+import get = require('lodash/get');
 @ApiTags(['科技成果'])
 @Controller('/dock')
 export class DockController extends BaseController {
   @Inject()
   service: DockService;
 
+  @Inject()
+  jwtService: JwtService;
+
+  @Config('jwt.secret')
+  jwtSecret;
+
+  @Config('jwt.expiresIn')
+  jwtExpiresIn;
+
+  @Post('/login')
+  @Validate()
+  async login(@Body() body: LoginDTO) {
+    const data = await this.service.findUserToLogin(body);
+    let vo = new LoginVO(data);
+    vo = JSON.parse(JSON.stringify(vo));
+    const token = await this.jwtService.sign(vo, this.jwtSecret, {
+      expiresIn: this.jwtExpiresIn,
+    });
+    return token;
+  }
+
+  @Post('/rp')
+  @ApiOperation({ description: '修改密码' })
+  async resetPassword(@Body() body: ResetPasswordDTO) {
+    // 获取用户token中的登录信息
+    const user_id = get(this.ctx, 'user._id');
+    if (!user_id)
+      throw new ServiceError('未找到用户信息', FrameworkErrorEnum.NOT_LOGIN);
+    // 查询用户
+    const user = await this.service.fetch(user_id);
+    if (!user)
+      throw new ServiceError('未找到用户', FrameworkErrorEnum.NOT_FOUND_DATA);
+    // 修改密码
+    await this.service.updateOne(user_id, body);
+    // 返回结果
+    return 'ok';
+  }
+
   @Post('/')
   @Validate()
   @ApiResponse({ type: CVO_dock })

+ 55 - 2
src/controller/train/train.controller.ts

@@ -1,4 +1,5 @@
 import {
+  Config,
   Body,
   Controller,
   Del,
@@ -8,7 +9,11 @@ import {
   Post,
   Query,
 } from '@midwayjs/decorator';
-import { BaseController } from 'free-midway-component';
+import {
+  BaseController,
+  ServiceError,
+  FrameworkErrorEnum,
+} from 'free-midway-component';
 import { TrainService } from '../../service/train/train.service';
 import {
   CDTO_train,
@@ -18,15 +23,63 @@ import {
   QVO_train,
   UDTO_train,
   UVAO_train,
+  LoginDTO,
+  LoginVO,
+  ResetPasswordDTO,
 } from '../../interface/train/train.interface';
-import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
+import {
+  ApiOperation,
+  ApiResponse,
+  ApiTags,
+  ApiQuery,
+} from '@midwayjs/swagger';
 import { Validate } from '@midwayjs/validate';
+import { JwtService } from '@midwayjs/jwt';
+import get = require('lodash/get');
 @ApiTags(['培训问诊'])
 @Controller('/train')
 export class TrainController extends BaseController {
   @Inject()
   service: TrainService;
 
+  @Inject()
+  jwtService: JwtService;
+
+  @Config('jwt.secret')
+  jwtSecret;
+
+  @Config('jwt.expiresIn')
+  jwtExpiresIn;
+
+  @Post('/login')
+  @Validate()
+  async login(@Body() body: LoginDTO) {
+    const data = await this.service.findUserToLogin(body);
+    let vo = new LoginVO(data);
+    vo = JSON.parse(JSON.stringify(vo));
+    const token = await this.jwtService.sign(vo, this.jwtSecret, {
+      expiresIn: this.jwtExpiresIn,
+    });
+    return token;
+  }
+
+  @Post('/rp')
+  @ApiOperation({ description: '修改密码' })
+  async resetPassword(@Body() body: ResetPasswordDTO) {
+    // 获取用户token中的登录信息
+    const user_id = get(this.ctx, 'user._id');
+    if (!user_id)
+      throw new ServiceError('未找到用户信息', FrameworkErrorEnum.NOT_LOGIN);
+    // 查询用户
+    const user = await this.service.fetch(user_id);
+    if (!user)
+      throw new ServiceError('未找到用户', FrameworkErrorEnum.NOT_FOUND_DATA);
+    // 修改密码
+    await this.service.updateOne(user_id, body);
+    // 返回结果
+    return 'ok';
+  }
+
   @Post('/')
   @Validate()
   @ApiResponse({ type: CVO_train })

+ 55 - 2
src/controller/train/trainUser.controller.ts

@@ -1,4 +1,5 @@
 import {
+  Config,
   Body,
   Controller,
   Del,
@@ -8,7 +9,11 @@ import {
   Post,
   Query,
 } from '@midwayjs/decorator';
-import { BaseController } from 'free-midway-component';
+import {
+  BaseController,
+  ServiceError,
+  FrameworkErrorEnum,
+} from 'free-midway-component';
 import { TrainUserService } from '../../service/train/trainUser.service';
 import {
   CDTO_trainUser,
@@ -18,15 +23,63 @@ import {
   QVO_trainUser,
   UDTO_trainUser,
   UVAO_trainUser,
+  LoginDTO,
+  LoginVO,
+  ResetPasswordDTO,
 } from '../../interface/train/trainUser.interface';
-import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
+import {
+  ApiOperation,
+  ApiResponse,
+  ApiTags,
+  ApiQuery,
+} from '@midwayjs/swagger';
 import { Validate } from '@midwayjs/validate';
+import { JwtService } from '@midwayjs/jwt';
+import get = require('lodash/get');
 @ApiTags(['培训问诊-展会用户'])
 @Controller('/trainUser')
 export class TrainUserController extends BaseController {
   @Inject()
   service: TrainUserService;
 
+  @Inject()
+  jwtService: JwtService;
+
+  @Config('jwt.secret')
+  jwtSecret;
+
+  @Config('jwt.expiresIn')
+  jwtExpiresIn;
+
+  @Post('/login')
+  @Validate()
+  async login(@Body() body: LoginDTO) {
+    const data = await this.service.findUserToLogin(body);
+    let vo = new LoginVO(data);
+    vo = JSON.parse(JSON.stringify(vo));
+    const token = await this.jwtService.sign(vo, this.jwtSecret, {
+      expiresIn: this.jwtExpiresIn,
+    });
+    return token;
+  }
+
+  @Post('/rp')
+  @ApiOperation({ description: '修改密码' })
+  async resetPassword(@Body() body: ResetPasswordDTO) {
+    // 获取用户token中的登录信息
+    const user_id = get(this.ctx, 'user._id');
+    if (!user_id)
+      throw new ServiceError('未找到用户信息', FrameworkErrorEnum.NOT_LOGIN);
+    // 查询用户
+    const user = await this.service.fetch(user_id);
+    if (!user)
+      throw new ServiceError('未找到用户', FrameworkErrorEnum.NOT_FOUND_DATA);
+    // 修改密码
+    await this.service.updateOne(user_id, body);
+    // 返回结果
+    return 'ok';
+  }
+
   @Post('/')
   @Validate()
   @ApiResponse({ type: CVO_trainUser })

+ 7 - 3
src/controller/user/personal.controller.ts

@@ -102,14 +102,18 @@ export class PersonalController extends BaseController {
     @Query('skip') skip: number,
     @Query('limit') limit: number
   ) {
-    // const query: any = await this.service.dealQueryCondition(filter);
-    const list = await this.service.query(filter, { skip, limit });
+    const query = await this.service.dealQueryCondition(filter);
+    const list = await this.service.query(query, {
+      skip,
+      limit,
+      sort: { 'meta.createdAt': -1 },
+    });
     const data = [];
     for (const i of list) {
       const newData = new QVO_personal(i);
       data.push(newData);
     }
-    const total = await this.service.count(filter);
+    const total = await this.service.count(query);
     return { data, total };
   }
 

+ 17 - 3
src/entity/channel/channel.entity.ts

@@ -1,15 +1,29 @@
 import { modelOptions, prop } from '@typegoose/typegoose';
 import { BaseModel } from 'free-midway-component';
+import isString = require('lodash/isString');
 @modelOptions({
   schemaOptions: { collection: 'channel' },
 })
 export class Channel extends BaseModel {
   @prop({ required: false, index: true, zh: '房间号', remark: '2001开始' })
   room_id: string;
-  @prop({ required: false, index: true, zh: '用户类型', default: '7' })
+  @prop({ required: false, index: true, zh: '用户类型', default: '8' })
   type: string;
-  @prop({ required: false, index: false, zh: '密码' })
-  password: string;
+  @prop({
+    required: false,
+    index: false,
+    zh: '密码',
+    select: false,
+    set: (val: string | object) => {
+      if (isString(val)) {
+        return { secret: val };
+      }
+      return val;
+    },
+  })
+  password: {
+    secret: string;
+  };
   @prop({ required: false, index: true, zh: '标题' })
   title: string;
   @prop({ required: false, index: true, zh: '来源' })

+ 17 - 3
src/entity/technology/dock.entity.ts

@@ -1,17 +1,31 @@
 import { modelOptions, prop } from '@typegoose/typegoose';
 import { BaseModel } from 'free-midway-component';
+import isString = require('lodash/isString');
 @modelOptions({
   schemaOptions: { collection: 'dock' },
 })
 export class Dock extends BaseModel {
   @prop({ required: false, index: false, zh: '所属用户', remark: '1001开始' })
   user_id: string;
-  @prop({ required: false, index: false, zh: '用户类型', default: '6' })
+  @prop({ required: false, index: false, zh: '用户类型', default: '7' })
   type: string;
   @prop({ required: false, index: true, zh: '房间号' })
   room_id: string;
-  @prop({ required: false, index: false, zh: '密码' })
-  password: string;
+  @prop({
+    required: false,
+    index: false,
+    zh: '密码',
+    select: false,
+    set: (val: string | object) => {
+      if (isString(val)) {
+        return { secret: val };
+      }
+      return val;
+    },
+  })
+  password: {
+    secret: string;
+  };
   @prop({ required: false, index: true, zh: '标题' })
   title: string;
   @prop({ required: false, index: true, zh: '开始时间' })

+ 17 - 3
src/entity/train/train.entity.ts

@@ -1,15 +1,29 @@
 import { modelOptions, prop } from '@typegoose/typegoose';
 import { BaseModel } from 'free-midway-component';
+import isString = require('lodash/isString');
 @modelOptions({
   schemaOptions: { collection: 'train' },
 })
 export class Train extends BaseModel {
   @prop({ required: false, index: true, zh: '房间号', remark: '3001开始' })
   room_id: string;
-  @prop({ required: false, index: true, zh: '用户类型', default: '8' })
+  @prop({ required: false, index: true, zh: '用户类型', default: '9' })
   type: string;
-  @prop({ required: false, index: true, zh: '密码' })
-  password: string;
+  @prop({
+    required: false,
+    index: false,
+    zh: '密码',
+    select: false,
+    set: (val: string | object) => {
+      if (isString(val)) {
+        return { secret: val };
+      }
+      return val;
+    },
+  })
+  password: {
+    secret: string;
+  };
   @prop({ required: false, index: true, zh: '标题' })
   title: string;
   @prop({ required: false, index: true, zh: '开始时间' })

+ 17 - 3
src/entity/train/trainUser.entity.ts

@@ -1,17 +1,31 @@
 import { modelOptions, prop } from '@typegoose/typegoose';
 import { BaseModel } from 'free-midway-component';
+import isString = require('lodash/isString');
 @modelOptions({
   schemaOptions: { collection: 'trainUser' },
 })
 export class TrainUser extends BaseModel {
   @prop({ required: false, index: true, zh: '展会id' })
   train_id: string;
-  @prop({ required: false, index: true, zh: '用户类型', default: '9' })
+  @prop({ required: false, index: true, zh: '用户类型', default: '10' })
   type: string;
   @prop({ required: false, index: true, zh: '账号' })
   account: string;
-  @prop({ required: false, index: false, zh: '密码' })
-  password: string;
+  @prop({
+    required: false,
+    index: false,
+    zh: '密码',
+    select: false,
+    set: (val: string | object) => {
+      if (isString(val)) {
+        return { secret: val };
+      }
+      return val;
+    },
+  })
+  password: {
+    secret: string;
+  };
   @prop({ required: false, index: true, zh: '姓名' })
   name: string;
   @prop({ required: false, index: true, zh: '手机号' })

+ 2 - 0
src/entity/user/expert.entity.ts

@@ -83,4 +83,6 @@ export class Expert extends BaseModel {
     default: '0',
   })
   status: string;
+  @prop({ required: false, index: true, zh: '个人用户id' })
+  personal_id: string;
 }

+ 41 - 0
src/interface/channel/channel.interface.ts

@@ -113,3 +113,44 @@ export class UVAO_channel extends FVO_channel {
     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: '房间号' })
+  'room_id': string = undefined;
+  @ApiProperty({ description: '用户类型' })
+  'type': string = undefined;
+  @ApiProperty({ description: '密码' })
+  'password': string = undefined;
+  @ApiProperty({ description: '标题' })
+  'title': string = undefined;
+  @ApiProperty({ description: '来源' })
+  'origin': string = undefined;
+  @ApiProperty({ description: '类别' })
+  'channel_type': string = undefined;
+  @ApiProperty({ description: '简介' })
+  'brief': string = undefined;
+  @ApiProperty({ description: '状态' })
+  'status': string = undefined;
+}
+
+export class LoginDTO {
+  @ApiProperty({ description: '房间号', example: '2001' })
+  @Rule(RuleType['string']().empty(''))
+  'room_id': string = undefined;
+  @ApiProperty({ description: '密码', example: '111111' })
+  @Rule(RuleType['string']().empty(''))
+  'password': string = undefined;
+}
+
+export class ResetPasswordDTO {
+  @ApiProperty({ description: '密码', example: '123456' })
+  @Rule(RuleType['string']().required())
+  'password': string = undefined;
+}

+ 53 - 0
src/interface/technology/dock.interface.ts

@@ -152,3 +152,56 @@ export class UVAO_dock extends FVO_dock {
     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: '所属用户' })
+  'user_id': string = undefined;
+  @ApiProperty({ description: '用户类型' })
+  'type': string = undefined;
+  @ApiProperty({ description: '房间号' })
+  'room_id': string = undefined;
+  @ApiProperty({ description: '密码' })
+  'password': string = undefined;
+  @ApiProperty({ description: '标题' })
+  'title': string = undefined;
+  @ApiProperty({ description: '开始时间' })
+  'start_time': string = undefined;
+  @ApiProperty({ description: '结束时间' })
+  'end_time': string = undefined;
+  @ApiProperty({ description: '省份' })
+  'province': string = undefined;
+  @ApiProperty({ description: '市区' })
+  'city': string = undefined;
+  @ApiProperty({ description: '负责人' })
+  'contact': string = undefined;
+  @ApiProperty({ description: '手机号' })
+  'phone': string = undefined;
+  @ApiProperty({ description: '主办方' })
+  'sponsor': string = undefined;
+  @ApiProperty({ description: '承办方' })
+  'organizer': string = undefined;
+  @ApiProperty({ description: '状态' })
+  'status': string = undefined;
+}
+
+export class LoginDTO {
+  @ApiProperty({ description: '房间号', example: '1001' })
+  @Rule(RuleType['string']().empty(''))
+  'room_id': string = undefined;
+  @ApiProperty({ description: '密码', example: '111111' })
+  @Rule(RuleType['string']().empty(''))
+  'password': string = undefined;
+}
+
+export class ResetPasswordDTO {
+  @ApiProperty({ description: '密码', example: '123456' })
+  @Rule(RuleType['string']().required())
+  'password': string = undefined;
+}

+ 53 - 0
src/interface/train/train.interface.ts

@@ -158,3 +158,56 @@ export class UVAO_train extends FVO_train {
     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: '房间号' })
+  'room_id': string = undefined;
+  @ApiProperty({ description: '用户类型' })
+  'type': string = undefined;
+  @ApiProperty({ description: '密码' })
+  'password': string = undefined;
+  @ApiProperty({ description: '标题' })
+  'title': string = undefined;
+  @ApiProperty({ description: '开始时间' })
+  'start_time': string = undefined;
+  @ApiProperty({ description: '结束时间' })
+  'end_time': string = undefined;
+  @ApiProperty({ description: '省份' })
+  'province': string = undefined;
+  @ApiProperty({ description: '市区' })
+  'city': string = undefined;
+  @ApiProperty({ description: '负责人' })
+  'contact': string = undefined;
+  @ApiProperty({ description: '手机号' })
+  'phone': string = undefined;
+  @ApiProperty({ description: '主办方' })
+  'sponsor': string = undefined;
+  @ApiProperty({ description: '承办方' })
+  'organizer': string = undefined;
+  @ApiProperty({ description: '信息简介' })
+  'brief': string = undefined;
+  @ApiProperty({ description: '状态' })
+  'status': string = undefined;
+}
+
+export class LoginDTO {
+  @ApiProperty({ description: '房间号', example: '3001' })
+  @Rule(RuleType['string']().empty(''))
+  'room_id': string = undefined;
+  @ApiProperty({ description: '密码', example: '111111' })
+  @Rule(RuleType['string']().empty(''))
+  'password': string = undefined;
+}
+
+export class ResetPasswordDTO {
+  @ApiProperty({ description: '密码', example: '123456' })
+  @Rule(RuleType['string']().required())
+  'password': string = undefined;
+}

+ 39 - 0
src/interface/train/trainUser.interface.ts

@@ -101,3 +101,42 @@ export class UVAO_trainUser extends FVO_trainUser {
     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: '展会id' })
+  'train_id': string = undefined;
+  @ApiProperty({ description: '用户类型' })
+  'type': string = undefined;
+  @ApiProperty({ description: '账号' })
+  'account': string = undefined;
+  @ApiProperty({ description: '密码' })
+  'password': string = undefined;
+  @ApiProperty({ description: '姓名' })
+  'name': string = undefined;
+  @ApiProperty({ description: '手机号' })
+  'phone': string = undefined;
+  @ApiProperty({ description: '状态' })
+  'status': string = undefined;
+}
+
+export class LoginDTO {
+  @ApiProperty({ description: '账号', example: 'test' })
+  @Rule(RuleType['string']().empty(''))
+  'account': string = undefined;
+  @ApiProperty({ description: '密码', example: '111111' })
+  @Rule(RuleType['string']().empty(''))
+  'password': string = undefined;
+}
+
+export class ResetPasswordDTO {
+  @ApiProperty({ description: '密码', example: '123456' })
+  @Rule(RuleType['string']().required())
+  'password': string = undefined;
+}

+ 10 - 3
src/interface/user/expert.interface.ts

@@ -68,6 +68,8 @@ export class FVO_expert {
   'social': string = undefined;
   @ApiProperty({ description: '状态' })
   'status': string = undefined;
+  @ApiProperty({ description: '个人用户id' })
+  'personal_id': string = undefined;
 }
 
 export class QDTO_expert extends SearchBase {
@@ -82,7 +84,7 @@ export class QDTO_expert extends SearchBase {
       'email',
       'card',
       'status',
-      'company',
+      'personal_id',
     ];
     const mapping = [];
     super({ like_prop, props, mapping });
@@ -103,8 +105,8 @@ export class QDTO_expert extends SearchBase {
   'card': string = undefined;
   @ApiProperty({ description: '状态' })
   'status': string = undefined;
-  @ApiProperty({ description: '单位名称' })
-  'company': string = undefined;
+  @ApiProperty({ description: '个人用户id' })
+  'personal_id': string = undefined;
 }
 
 export class QVO_expert extends FVO_expert {
@@ -196,6 +198,9 @@ export class CDTO_expert {
   @ApiProperty({ description: '状态' })
   @Rule(RuleType['string']().empty(''))
   'status': string = undefined;
+  @ApiProperty({ description: '个人用户id' })
+  @Rule(RuleType['string']().empty(''))
+  'personal_id': string = undefined;
 }
 
 export class CVO_expert extends FVO_expert {
@@ -280,6 +285,8 @@ export class LoginVO {
   'social': string = undefined;
   @ApiProperty({ description: '状态' })
   'status': string = undefined;
+  @ApiProperty({ description: '个人用户id' })
+  'personal_id': string = undefined;
 }
 
 export class LoginDTO {

+ 20 - 1
src/service/channel/channel.service.ts

@@ -1,11 +1,30 @@
 import { Provide } from '@midwayjs/decorator';
 import { InjectEntityModel } from '@midwayjs/typegoose';
 import { ReturnModelType } from '@typegoose/typegoose';
-import { BaseService } from 'free-midway-component';
+import {
+  BaseService,
+  FrameworkErrorEnum,
+  ServiceError,
+} from 'free-midway-component';
 import { Channel } from '../../entity/channel/channel.entity';
+import { LoginDTO } from '../../interface/channel/channel.interface';
+import isEqual = require('lodash/isEqual');
 type modelType = ReturnModelType<typeof Channel>;
 @Provide()
 export class ChannelService extends BaseService<modelType> {
   @InjectEntityModel(Channel)
   model: modelType;
+
+  async findUserToLogin(data: LoginDTO): Promise<object> {
+    const { room_id, password } = data;
+    const user = await this.model.findOne({ room_id }, '+password').lean();
+    if (!user)
+      throw new ServiceError(
+        '未找到科技频道信息',
+        FrameworkErrorEnum.NOT_FOUND_DATA
+      );
+    if (!isEqual(user.password.secret, password))
+      throw new ServiceError('密码错误', FrameworkErrorEnum.SERVICE_FAULT);
+    return user;
+  }
 }

+ 20 - 1
src/service/technology/dock.service.ts

@@ -1,11 +1,30 @@
 import { Provide } from '@midwayjs/decorator';
 import { InjectEntityModel } from '@midwayjs/typegoose';
 import { ReturnModelType } from '@typegoose/typegoose';
-import { BaseService } from 'free-midway-component';
+import {
+  BaseService,
+  FrameworkErrorEnum,
+  ServiceError,
+} from 'free-midway-component';
 import { Dock } from '../../entity/technology/dock.entity';
+import { LoginDTO } from '../../interface/technology/dock.interface';
+import isEqual = require('lodash/isEqual');
 type modelType = ReturnModelType<typeof Dock>;
 @Provide()
 export class DockService extends BaseService<modelType> {
   @InjectEntityModel(Dock)
   model: modelType;
+
+  async findUserToLogin(data: LoginDTO): Promise<object> {
+    const { room_id, password } = data;
+    const user = await this.model.findOne({ room_id }, '+password').lean();
+    if (!user)
+      throw new ServiceError(
+        '未找到科技成果信息',
+        FrameworkErrorEnum.NOT_FOUND_DATA
+      );
+    if (!isEqual(user.password.secret, password))
+      throw new ServiceError('密码错误', FrameworkErrorEnum.SERVICE_FAULT);
+    return user;
+  }
 }

+ 20 - 1
src/service/train/train.service.ts

@@ -1,11 +1,30 @@
 import { Provide } from '@midwayjs/decorator';
 import { InjectEntityModel } from '@midwayjs/typegoose';
 import { ReturnModelType } from '@typegoose/typegoose';
-import { BaseService } from 'free-midway-component';
+import {
+  BaseService,
+  FrameworkErrorEnum,
+  ServiceError,
+} from 'free-midway-component';
 import { Train } from '../../entity/train/train.entity';
+import { LoginDTO } from '../../interface/train/train.interface';
+import isEqual = require('lodash/isEqual');
 type modelType = ReturnModelType<typeof Train>;
 @Provide()
 export class TrainService extends BaseService<modelType> {
   @InjectEntityModel(Train)
   model: modelType;
+
+  async findUserToLogin(data: LoginDTO): Promise<object> {
+    const { room_id, password } = data;
+    const user = await this.model.findOne({ room_id }, '+password').lean();
+    if (!user)
+      throw new ServiceError(
+        '未找到培训问诊信息',
+        FrameworkErrorEnum.NOT_FOUND_DATA
+      );
+    if (!isEqual(user.password.secret, password))
+      throw new ServiceError('密码错误', FrameworkErrorEnum.SERVICE_FAULT);
+    return user;
+  }
 }

+ 20 - 1
src/service/train/trainUser.service.ts

@@ -1,11 +1,30 @@
 import { Provide } from '@midwayjs/decorator';
 import { InjectEntityModel } from '@midwayjs/typegoose';
 import { ReturnModelType } from '@typegoose/typegoose';
-import { BaseService } from 'free-midway-component';
+import {
+  BaseService,
+  FrameworkErrorEnum,
+  ServiceError,
+} from 'free-midway-component';
 import { TrainUser } from '../../entity/train/trainUser.entity';
+import { LoginDTO } from '../../interface/train/trainUser.interface';
+import isEqual = require('lodash/isEqual');
 type modelType = ReturnModelType<typeof TrainUser>;
 @Provide()
 export class TrainUserService extends BaseService<modelType> {
   @InjectEntityModel(TrainUser)
   model: modelType;
+
+  async findUserToLogin(data: LoginDTO): Promise<object> {
+    const { account, password } = data;
+    const user = await this.model.findOne({ account }, '+password').lean();
+    if (!user)
+      throw new ServiceError(
+        '未找到培训问诊展会用户信息',
+        FrameworkErrorEnum.NOT_FOUND_DATA
+      );
+    if (!isEqual(user.password.secret, password))
+      throw new ServiceError('密码错误', FrameworkErrorEnum.SERVICE_FAULT);
+    return user;
+  }
 }

+ 9 - 4
src/service/user/personal.service.ts

@@ -8,10 +8,14 @@ import {
 } from 'free-midway-component';
 import { Personal } from '../../entity/user/personal.entity';
 import { Admin } from '../../entity/user/admin.entity';
-import { LoginDTO } from '../../interface/user/personal.interface';
+import {
+  LoginDTO,
+  QDTO_personal,
+} from '../../interface/user/personal.interface';
 import isEqual = require('lodash/isEqual');
 import get = require('lodash/get');
 import head = require('lodash/head');
+// import _ = require('lodash');
 import { UtilService } from '../../service/util/util';
 type modelType = ReturnModelType<typeof Personal>;
 @Provide()
@@ -42,8 +46,9 @@ export class PersonalService extends BaseService<modelType> {
       throw new ServiceError('密码错误', FrameworkErrorEnum.SERVICE_FAULT);
     return user;
   }
-  async dealQueryCondition({ code, ...condition }) {
+  async dealQueryCondition(condition: QDTO_personal): Promise<QDTO_personal> {
     const role = this.ctx.user.type;
+    const code = condition.code;
     condition = this.util.dealQuery(condition);
     // 查询业务管理
     const busFind = async query =>
@@ -66,7 +71,7 @@ export class PersonalService extends BaseService<modelType> {
       const aid = get(head(a), '_id');
       const orgList = await orgFind({ pid: aid });
       const busList = await busFind({ pid: orgList.map(i => i._id) });
-      const codes = [
+      const codes: any = [
         ...orgList.map(i => i.code),
         ...busList.map(i => i.code),
         code,
@@ -83,7 +88,7 @@ export class PersonalService extends BaseService<modelType> {
         );
       const oid = get(head(o), '_id');
       const busList = await busFind({ pid: oid });
-      const codes = [...busList.map(i => i.code), code];
+      const codes: any = [...busList.map(i => i.code), code];
       condition.code = codes;
     } else if (code) {
       // 业务查询