lrf402788946 4 år sedan
förälder
incheckning
2974d80e64
4 ändrade filer med 9 tillägg och 17 borttagningar
  1. 0 3
      app/controller/.user.js
  2. 0 1
      app/model/user.js
  3. 1 5
      app/service/login.js
  4. 8 8
      app/service/user.js

+ 0 - 3
app/controller/.user.js

@@ -13,7 +13,6 @@ module.exports = {
       "pid",
       "code",
       "remark",
-      "institution_code",
     ],
   },
   destroy: {
@@ -35,7 +34,6 @@ module.exports = {
       "pid",
       "code",
       "remark",
-      "institution_code",
     ],
   },
   show: {
@@ -55,7 +53,6 @@ module.exports = {
         pid: "pid",
         code: "code",
         role: "role",
-        institution_code: "institution_code",
       },
     },
     service: "query",

+ 0 - 1
app/model/user.js

@@ -16,7 +16,6 @@ const UserSchema = {
   deptname: { type: String, required: false }, // 机构名称
   remark: { type: String, required: false }, // 备注
   code: { type: String, required: false }, // 邀请码
-  institution_code: { type: String, required: false, maxLength: 500 }, // 机构代码
 };
 
 

+ 1 - 5
app/service/login.js

@@ -25,11 +25,7 @@ class LoginService extends CrudService {
     // 如果用户不存在抛出异常
     if (!user) {
       // 添加code作为登录的方式
-      console.error(role);
-      if (role === '5') {
-        console.error('function in');
-        user = await this.model.findOne({ institution_code: phone, role });
-      } else { user = await this.model.findOne({ code: phone, role }); }
+      user = await this.model.findOne({ code: phone, role });
       if (!user) { throw new BusinessError(ErrorCode.USER_NOT_EXIST); } else is_code = true;
     }
     const pdata = {};

+ 8 - 8
app/service/user.js

@@ -9,7 +9,7 @@ const jwt = require('jsonwebtoken');
 
 class UserService extends CrudService {
   constructor(ctx) {
-    super(ctx, "user");
+    super(ctx, 'user');
     this.model = this.ctx.model.User;
     this.rmodel = this.ctx.model.Role;
   }
@@ -18,8 +18,8 @@ class UserService extends CrudService {
   async create(data) {
     const { name, phone, passwd } = data;
     console.log(data);
-    assert(name && phone && passwd, "缺少部分信息项");
-    assert(/^\d{11}$/i.test(phone), "phone无效");
+    assert(name && phone && passwd, '缺少部分信息项');
+    assert(/^\d{11}$/i.test(phone), 'phone无效');
     // const user = await this.model.findOne({ phone });
     // if (user) {
     //   throw new BusinessError(ErrorCode.DATA_EXISTED);
@@ -53,7 +53,7 @@ class UserService extends CrudService {
       deptname,
       pid,
     } = data;
-    const user = await this.model.findById(id, "+passwd");
+    const user = await this.model.findById(id, '+passwd');
     if (name) {
       user.name = name;
     }
@@ -94,9 +94,9 @@ class UserService extends CrudService {
   // 用户修改密码
   async uppasswd(data) {
     const { id, oldpasswd, newpasswd } = data;
-    assert(id && oldpasswd && newpasswd, "缺少部分信息项");
+    assert(id && oldpasswd && newpasswd, '缺少部分信息项');
     // 根据用户id查询其他用户表中是否存在相应数据
-    const user = await this.model.findById(id, "+passwd");
+    const user = await this.model.findById(id, '+passwd');
     // 如果用户不存在抛出异常
     if (!user) {
       throw new BusinessError(ErrorCode.USER_NOT_EXIST);
@@ -155,7 +155,7 @@ class UserService extends CrudService {
   async finduserlist({ skip, limit, ...info }) {
     const query = {
       ...info,
-      $or: [{ role: "4" }, { role: "5" }, { role: "6" }],
+      $or: [{ role: '4' }, { role: '5' }, { role: '6' }],
     };
     const total = await this.model.count(query);
     const data = await this.model
@@ -166,7 +166,7 @@ class UserService extends CrudService {
   }
   async businessuser({ pid, skip, limit }) {
     const query = { code: { $regex: /^.{9}$/ } };
-    pid ? (query.pid = pid) : "";
+    pid ? (query.pid = pid) : '';
     const total = await this.model.count(query);
     const data = await this.model
       .find(query)