Browse Source

添加注释与开发模式登录区别

lrf 10 months ago
parent
commit
0b819dbf1b
2 changed files with 30 additions and 15 deletions
  1. 19 4
      app/service/yunjiuye.js
  2. 11 11
      config/config.local.js

+ 19 - 4
app/service/yunjiuye.js

@@ -53,7 +53,14 @@ class YunjiuyeService extends Service {
     return result.suid;
   }
 
-  // 用户与云就业关联
+  /**
+   * 用户与云就业关联
+   * @param {string} type 用户角色
+   * @param {string} mobile 电话
+   * @param {string} code 身份编码
+   * @param {string} org 云就业的组织机构编码
+   * @param {string} ytype 云就业角色类型
+   */
   async userBind({ type, mobile, code, org, ytype }) {
     assert(mobile, '登录账户不能为空');
     assert(type, '用户角色不能为空');
@@ -89,9 +96,17 @@ class YunjiuyeService extends Service {
     const yjycModel = this.ctx.model.Yjyconnect;
     const obj = { ycode: code, yorg: org, suid: ObjectId(res._id).toString(), ytype };
     const isHas = await yjycModel.count({ suid: obj.suid });
-    if (isHas > 0) throw new BusinessError(ErrorCode.DATA_EXISTED, '账户已绑定,无需再次绑定');
-    await yjycModel.create(obj);
-    return obj.suid;
+    if (process.env.NODE_ENV === 'development') {
+      if (isHas > 0) return obj.suid;
+      else {
+        await yjycModel.create(obj);
+        return obj.suid;
+      }
+    } else {
+      if (isHas > 0) throw new BusinessError(ErrorCode.DATA_EXISTED, '账户已绑定,无需再次绑定');
+      await yjycModel.create(obj);
+      return obj.suid;
+    }
   }
 
   // 用户id获取用户信息,登录获取token返回

+ 11 - 11
config/config.local.js

@@ -48,17 +48,17 @@ module.exports = () => {
     },
   };
 
-  // config.mongoose = {
-  //   url: 'mongodb://localhost:27017/train',
-  //   options: {
-  // user: 'demo',
-  // pass: 'demo',
-  // authSource: 'admin',
-  // useNewUrlParser: true,
-  // useCreateIndex: true,
-  // useUnifiedTopology: true,
-  //   },
-  // };
+  config.mongoose = {
+    url: 'mongodb://localhost:27017/train',
+    options: {
+      user: 'admin',
+      pass: 'admin',
+      authSource: 'admin',
+      useNewUrlParser: true,
+      useCreateIndex: true,
+      useUnifiedTopology: true,
+    },
+  };
 
   config.yunjiuye = {
     toBindPage: 'http://127.0.0.1:8008/y/', // 云就业绑定页面