lrf 3 年之前
父节点
当前提交
b05e6648fa
共有 3 个文件被更改,包括 12 次插入7 次删除
  1. 1 1
      app/controller/users/.personal.js
  2. 6 1
      app/service/patent/patentinfo.js
  3. 5 5
      app/service/users/personal.js

+ 1 - 1
app/controller/users/.personal.js

@@ -85,7 +85,7 @@ module.exports = {
   },
   // 登陆
   login: {
-    requestBody: ['phone', 'password'],
+    requestBody: ['phone', 'password', '!code'],
     service: 'login',
   },
   upgrade: {

+ 6 - 1
app/service/patent/patentinfo.js

@@ -164,7 +164,12 @@ class PatentinfoService extends CrudService {
               status: '1',
               code,
             };
-            person = await this.ctx.service.users.personal.create(personObject);
+            try {
+              person = await this.ctx.service.users.personal.create(personObject);
+            } catch (error) {
+              allNotice.push(`${create_number} 的 第一发明人用户,已有机构所属的个人用户使用该手机号!`);
+              continue;
+            }
             if (person) {
               user_id.user_id = person._id || person.id;
               user_id.name = person.name;

+ 5 - 5
app/service/users/personal.js

@@ -23,10 +23,10 @@ class PersonalService extends CrudService {
   async create({ password, ...data }) {
     if (!password) password = '123456';
     data.password = { secret: password };
-    const { name, phone } = data;
+    const { name, phone, code } = data;
     // 检查手机号
-    const num = await this.model.count({ phone, isdel: '0' });
-    if (num > 0) throw new BusinessError(ErrorCode.DATA_EXISTED, `姓名:${name} ; 手机号: ${phone} ;已有个人用户使用该手机号`);
+    const num = await this.model.count({ phone, code, isdel: '0' });
+    if (num > 0) throw new BusinessError(ErrorCode.DATA_EXISTED, `姓名:${name} ; 手机号: ${phone} ;已有机构所属的个人用户使用该手机号`);
     return await this.model.create(data);
   }
   /**
@@ -45,8 +45,8 @@ class PersonalService extends CrudService {
    * @property phone 手机号
    * @property password 密码
    */
-  async login({ phone, password }) {
-    const object = await this.model.findOne({ phone, isdel: '0' }, '+password');
+  async login({ phone, password, code }) {
+    const object = await this.model.findOne({ phone, code, isdel: '0' }, '+password');
     if (!object) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到用户的信息');
     const { password: op, status } = object;
     const { secret } = op;