Ver Fonte

Merge branch 'master' of http://git.cc-lotus.info/service-platform/service-auth

lrf402788946 há 4 anos atrás
pai
commit
8964391156
4 ficheiros alterados com 20 adições e 6 exclusões
  1. 3 0
      app/controller/.user.js
  2. 1 0
      app/model/user.js
  3. 3 6
      app/service/login.js
  4. 13 0
      app/service/user.js

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

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

+ 1 - 0
app/model/user.js

@@ -16,6 +16,7 @@ const UserSchema = {
   deptname: { type: String, required: false }, // 机构名称
   remark: { type: String, required: false }, // 备注
   code: { type: String, required: false }, // 邀请码
+  isdel: { type: String, required: false, default: '0' }, // 0=>未删除;1=>已删除
 };
 
 

+ 3 - 6
app/service/login.js

@@ -97,12 +97,7 @@ class LoginService extends CrudService {
     let logFlag = false;
     let dockList = [];
     // "4568"如果是456的需要去dock里面查有没有这个人(是否在apply),2,8必存
-    if (
-      _user.role === '4' ||
-      _user.role === '5' ||
-      _user.role === '6' ||
-      _user.role === '8'
-    ) {
+    if (_user.role === '4' || _user.role === '5' || _user.role === '6' || _user.role === '8') {
       const applydata = { user_id: user.id };
       const url = 'http://127.0.0.1:9008/api/live/getapply';
       const applyflag = await this.ctx.curl(url, {
@@ -117,6 +112,8 @@ class LoginService extends CrudService {
       if (applyflag.data.res.length > 0) {
         logFlag = true;
         dockList = applyflag.data.res;
+      } else {
+        logFlag = true;
       }
     } else if (_user.role === '2') {
       logFlag = true;

+ 13 - 0
app/service/user.js

@@ -174,6 +174,19 @@ class UserService extends CrudService {
       .limit(Number(limit));
     return { data, total };
   }
+  // 重写删除方法
+  /**
+   * 根据id删除=>修改isdel为1
+   * @param {Object} {id} 只接收id,不过需要解构,因为是object形式过来的
+   */
+  async delete({ id }) {
+    const data = await this.model.findById(id);
+    if (!data) {
+      throw new BusinessError(ErrorCode.DATA_NOT_EXIST);
+    }
+    const res = await data.update({ isdel: '1' });
+    return res;
+  }
 }
 
 module.exports = UserService;