ruifeng_liu 3 年之前
父節點
當前提交
226b445d30
共有 2 個文件被更改,包括 8 次插入10 次删除
  1. 3 2
      app/router/patent/patentanalysis.js
  2. 5 8
      app/service/patent/patentanalysis.js

+ 3 - 2
app/router/patent/patentanalysis.js

@@ -8,7 +8,8 @@ module.exports = app => {
   const index = 'patent';
   const target = 'patentanalysis';
   const metaTime = app.middleware.createTime();
-  router.resources(target, `${profix}${vision}/${index}/${target}`, metaTime, controller[index][target]); // index、create、show、destroy
+  const record = app.middleware.patentapplyRecord(`${index}.${target}`);
+  router.resources(target, `${profix}${vision}/${index}/${target}`, metaTime, record, controller[index][target]); // index、create、show、destroy
   router.post(target, `${profix}${vision}/${index}/${target}/check`, controller[index][target].check);
-  router.post(target, `${profix}${vision}/${index}/${target}/update/:id`, controller[index][target].update);
+  router.post(target, `${profix}${vision}/${index}/${target}/update/:id`, record, controller[index][target].update);
 };

+ 5 - 8
app/service/patent/patentanalysis.js

@@ -26,7 +26,6 @@ class PatentanalysisService extends CrudService {
    */
   async check({ id, status, remark }) {
     const data = { status };
-    if (status === '4') data['meta.state'] = 1;
     await this.model.updateOne({ _id: ObjectId(id) }, data);
     // 换成对应的状态码,record在下面
     return await this.record({ id, method: status, remark });
@@ -91,19 +90,17 @@ class PatentanalysisService extends CrudService {
         to = user_id;
         break;
       case '1':
-        arr.push({
-          content: `您的专利申请书【${name}】已通过管理员的审核,请您耐心等待管理员审核`,
-          to: user_id,
-        });
+        content = `您的专利申请书【${name}】已通过管理员的审核,请您耐心等待管理员审核`;
+        to = user_id;
         break;
       default:
         break;
     }
-    if (code !== '2') {
+    if (arr.length > 0) {
+      await this.notice.insertMany(arr);
+    } else {
       const obj = { to, content };
       await this.notice.create(obj);
-    } else {
-      await this.notice.insertMany(arr);
     }
   }
 }