12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- 'use strict';
- const Controller = require('egg').Controller;
- class WxInfoController extends Controller {
- async isExist() {
- const { ctx, service } = this;
- const query = ctx.query;
- const { openId } = query;
- const result = await service.sysUserService.oneData({ openId });
- if (result) {
- // 添加log
- const addQuery = {};
- addQuery.dept1 = result.dept1;
- addQuery.dept2 = result.dept2;
- addQuery.dept3 = result.dept3;
- addQuery.dept4 = result.dept4;
- addQuery.dept5 = result.dept5;
- addQuery.role = result.role;
- addQuery.loginName = result.loginName;
- // addQuery.tableName = 'user';
- addQuery.type = '登录';
- addQuery.detail = 'openid是否存在';
- addQuery.state = 'WeiXin';
- await this.service.sysLogService.add(addQuery);
- }
- ctx.logic(result, ' ');
- }
- async bing() {
- const { ctx, service } = this;
- const query = ctx.query;
- const result = await service.sysUserService.bing(query);
- if (result) {
- ctx.error(result);
- } else {
- // 添加log
- const addQuery = {};
- const user = await service.sysUserService.oneData({ loginName: query.name, loginPwd: query.pwd });
- ctx.logger.info('user===================>' + user);
- addQuery.dept1 = user.dept1;
- addQuery.dept2 = user.dept2;
- addQuery.dept3 = user.dept3;
- addQuery.dept4 = user.dept4;
- addQuery.dept5 = user.dept5;
- addQuery.role = user.role;
- addQuery.loginName = query.name;
- // addQuery.tableName = 'user';
- addQuery.type = '绑定';
- addQuery.detail = JSON.stringify(query);
- addQuery.state = 'WeiXin';
- await this.service.sysLogService.add(addQuery);
- ctx.success();
- }
- }
- async unbind() {
- const { ctx, service } = this;
- const user = ctx.user;
- const result = await service.sysUserService.update(user._id, { openId: '' });
- ctx.success(result);
- }
- async updatePwd() {
- const { ctx, service } = this;
- const query = ctx.request.body;
- const result = await service.sysUserService.updatePwdWithOpenId(query);
- ctx.logic(result, '修改密码失败,原密码错误');
- }
- }
- module.exports = WxInfoController;
|