lrf 3 年之前
父节点
当前提交
07ae7fddc1
共有 3 个文件被更改,包括 71 次插入2 次删除
  1. 59 0
      app/controller/patent/.patentinfo.js
  2. 1 0
      app/router/patent/patentinfo.js
  3. 11 2
      app/service/patent/patentinfo.js

+ 59 - 0
app/controller/patent/.patentinfo.js

@@ -192,4 +192,63 @@ module.exports = {
   updateUser: {
     requestBody: ['patentData', 'user_id'],
   },
+  deleteMany: {
+    parameters: {
+      query: {
+        create_number: 'create_number',
+        create_date: 'create_date',
+        success_number: 'success_number',
+        success_date: 'success_date',
+        inventor: '%inventor%',
+        agent: '%agent%',
+        agent_personal: '%agent_personal%',
+        abstract: '%abstract%',
+        address: '%address%',
+        name: '%name%',
+        apply_personal: '%apply_personal%',
+        term: 'term',
+        type: 'type',
+        nationality: '%nationality%',
+        ipc_type: '%ipc_type%',
+        onlegal_status: '%onlegal_status%',
+        legal_status: '%legal_status%',
+        law_date: 'law_date',
+        on_obligee: '%on_obligee%',
+        apply_address: '%apply_address%',
+        apply_other: '%apply_other%',
+        law_num: '%law_num%',
+        first_opendate: 'first_opendate',
+        empower_date: 'empower_date',
+        lose_date: 'lose_date',
+        examine_date: 'examine_date',
+        invention_design: '%invention_design%',
+        incopat_link: '%incopat_link%',
+        first_ask: '%first_ask%',
+        first_apply: '%first_apply%',
+        apply_city: '%apply_city%',
+        business_code: '%business_code%',
+        business_address: '%business_address%',
+        first_inventor: '%first_inventor%',
+        shared_value: '%shared_value%',
+        techol_stable: '%techol_stable%',
+        techol_advanced: '%techol_advanced%',
+        pct_apply: '%pct_apply%',
+        pct_publish: '%pct_publish%',
+        status: 'status',
+        trans_status: 'trans_status',
+        'create_date@start': 'create_date@start',
+        'create_date@end': 'create_date@end',
+        'success_date@start': 'success_date@start',
+        'success_date@end': 'success_date@end',
+        'empower_date@start': 'empower_date@start',
+        'empower_date@end': 'empower_date@end',
+        key_word: 'key_word',
+        single_inventor: 'single_inventor',
+        code: 'code',
+        user_id: 'user_id',
+        pid: 'pid',
+      },
+    },
+    service: 'deleteMany',
+  },
 };

+ 1 - 0
app/router/patent/patentinfo.js

@@ -8,6 +8,7 @@ module.exports = app => {
   const index = 'patent';
   const target = 'patentinfo';
   const metaTime = app.middleware.createTime();
+  router.delete(target, `${profix}${vision}/${index}/${target}/deleteMany`, metaTime, controller[index][target].deleteMany);
   router.get(target, `${profix}${vision}/${index}/${target}/queryByOrg`, metaTime, controller[index][target].queryByOrg);
   router.get(target, `${profix}${vision}/${index}/${target}/mechQuery`, metaTime, controller[index][target].mechQuery);
   router.resources(target, `${profix}${vision}/${index}/${target}`, metaTime, controller[index][target]); // index、create、show、destroy

+ 11 - 2
app/service/patent/patentinfo.js

@@ -110,11 +110,10 @@ class PatentinfoService extends CrudService {
       'techol_advanced',
       'pct_apply',
       'pct_publish',
-
     ];
     const keys = Object.keys(query);
     for (const key of keys) {
-      if(vagueList.includes(key)) {
+      if (vagueList.includes(key)) {
         query[`%${key}%`] = query[key];
         delete query[key];
       }
@@ -584,6 +583,16 @@ class PatentinfoService extends CrudService {
       await i.save();
     }
   }
+
+  /**
+   * 批量删除
+   * @param {Object} query 参数,查询范围
+   */
+  async deleteMany(query) {
+    const newquery = await this.resetCode(query);
+    const res = await this.model.deleteMany(newquery);
+    return res;
+  }
 }
 
 module.exports = PatentinfoService;