123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- 'use strict';
- const Controller = require('egg').Controller;
- class AppletsController extends Controller {
- async isExist() {
- const { ctx, service } = this;
- const query = ctx.query;
- const { appletsId } = query;
- const result = await service.sysUserService.oneData({ appletsId });
- if (result) {
- // ctx.logger.info('isExist--result=============>' + 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 = 'appletsId是否存在';
- addQuery.state = 'Applets';
- await this.service.sysLogService.add(addQuery);
- }
- ctx.logic(result, ' ');
- }
- async bing() {
- const { ctx, service } = this;
- const query = ctx.query;
- const result = await service.appletsService.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 = 'Applets';
- 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, { appletsId: '' });
- ctx.success(result);
- }
- async updatePwd() {
- const { ctx, service } = this;
- const query = ctx.query;
- const result = await service.appletsService.updatePwdWithAppletsId(query);
- ctx.logic(result, '修改密码失败,原密码错误');
- }
- async homeStatistics() {
- const { ctx, service } = this;
- const query = ctx.query;
- const result = await service.appletsService.deptStatistics(query);
- ctx.success(result);
- }
- async suppleUserInfo() {
- const { ctx, service } = this;
- const user = ctx.user;
- const query = ctx.request.body;
- query.time = Date.now();
- const result = await service.sysUserService.update(user._id, query);
- ctx.success(result);
- }
- async findUserInfo() {
- const { ctx } = this;
- const user = ctx.user;
- ctx.success(user);
- }
- // 积分排名
- async userValue() {
- const { ctx, service } = this;
- const result = await service.appletsService.userValue();
- ctx.success(result);
- }
- async getToken() {
- const { ctx } = this;
- const result = await this.ctx.service.appletsService.getToken({ key: 'NgkKVL2KIyGTOqAs4FBKl8tW', secret: 'v4C8G72bREjtdWGScQAWLKlHhpoNb3u6' });
- ctx.success(result);
- }
- }
- module.exports = AppletsController;
|