lrf 2 年之前
父節點
當前提交
8bfdd9a925

+ 40 - 0
app/controller/patent/.cpcimporterror.js

@@ -0,0 +1,40 @@
+module.exports = {
+  create: {
+    requestBody: ['key', 'word', 'filepath', 'time'],
+  },
+  destroy: {
+    params: ['!id'],
+    service: 'delete',
+  },
+  update: {
+    params: ['!id'],
+    requestBody: ['key', 'word', 'filepath', 'time'],
+  },
+  show: {
+    parameters: {
+      params: ['!id'],
+    },
+    service: 'fetch',
+  },
+  index: {
+    parameters: {
+      query: {
+        key: 'key',
+        'time@start': 'time@start',
+        'time@end': 'time@end',
+        'meta.createdAt@start': 'meta.createdAt@start',
+        'meta.createdAt@end': 'meta.createdAt@end',
+      },
+      // options: {
+      //   "meta.state": 0 // 默认条件
+      // },
+    },
+    service: 'query',
+    options: {
+      query: ['skip', 'limit'],
+      sort: ['meta.createdAt'],
+      desc: true,
+      count: true,
+    },
+  },
+};

+ 13 - 0
app/controller/patent/cpcimporterror.js

@@ -0,0 +1,13 @@
+'use strict';
+const meta = require('./.cpcimporterror.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
+
+// 
+class CpcimporterrorController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.patent.cpcimporterror;
+  }
+}
+module.exports = CrudController(CpcimporterrorController, meta);

+ 20 - 0
app/model/patent/cpcimporterror.js

@@ -0,0 +1,20 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
+// 交底书表
+const cpcimporterror = {
+  key: { type: String }, // 专利信息
+  word: { type: String }, // 错误信息
+  filepath: { type: String }, // 导入的zip包路径(绝对)
+  time: { type: String }, // 时间
+};
+const schema = new Schema(cpcimporterror, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ key: 1 });
+schema.index({ time: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.plugin(metaPlugin);
+module.exports = (app) => {
+  const { mongoose } = app;
+  return mongoose.model('Cpcimporterror', schema, 'cpcimporterror');
+};

+ 2 - 1
app/router.js

@@ -98,4 +98,5 @@ module.exports = (app) => {
   require('./router/patent/agent_mech')(app); // 代理机构表
   require('./router/patent/answer_tea')(app); // 咨询师表
   require('./router/patent/problem_service')(app); // 问题咨询表
-};;;
+  require('./router/patent/cpcimporterror')(app); // cpc导入信息表
+};

+ 11 - 0
app/router/patent/cpcimporterror.js

@@ -0,0 +1,11 @@
+'use strict';
+
+module.exports = (app) => {
+  const { router, controller } = app;
+  const profix = '/api/live/';
+  const vision = 'v0';
+  const index = 'patent';
+  const target = 'cpcimporterror';
+  router.resources(target, `${profix}${vision}/${index}/${target}`,  controller[index][target]); // index、create、show、destroy
+  router.post(target, `${profix}${vision}/${index}/${target}/update/:id`,  controller[index][target].update);
+};

+ 15 - 0
app/service/patent/cpcimporterror.js

@@ -0,0 +1,15 @@
+'use strict';
+const { CrudService } = require('naf-framework-mongoose/lib/service');
+const { BusinessError, ErrorCode } = require('naf-core').Error;
+const _ = require('lodash');
+const assert = require('assert');
+
+// 
+class CpcimporterrorService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'cpcimporterror');
+    this.model = this.ctx.model.Patent.Cpcimporterror;
+  }
+}
+
+module.exports = CpcimporterrorService;

+ 4 - 1
app/service/patent/patentwarning.js

@@ -18,6 +18,7 @@ class PatentwarningService extends CrudService {
     this.patentInfo = this.ctx.model.Patent.Patentinfo;
     this.patentApply = this.ctx.model.Patent.Patentapply;
     this.personalModel = this.ctx.model.Personal;
+    this.cpcErrorMsg = this.ctx.model.Patent.Cpcimporterror;
   }
   async import({ uri }) {
     uri = uri.replace('/files', this.import_root_path);
@@ -132,7 +133,6 @@ class PatentwarningService extends CrudService {
               continue;
             }
           }
-
         }
       } finally {
         try {
@@ -142,6 +142,9 @@ class PatentwarningService extends CrudService {
         }
       }
     }
+    // 2022-09-05 将错误信息添加到表中
+    errorList = errorList.map((i) => ({ ...i, filepath: uri, time: moment().format('YYYY-MM-DD HH:mm:ss') }));
+    await this.cpcErrorMsg.insertMany(errorList);
     if (errorList.length > 0) return errorList;
     return 'ok';
   }