guhongwei 3 rokov pred
rodič
commit
a7d4fea55f

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

@@ -0,0 +1,40 @@
+module.exports = {
+  create: {
+    requestBody: ["parent_id", "name", "inventor", "lose_date", "content"],
+  },
+  destroy: {
+    params: ["!id"],
+    service: "delete",
+  },
+  update: {
+    params: ["!id"],
+    requestBody: ["parent_id", "name", "inventor", "lose_date", "content"],
+  },
+  show: {
+    parameters: {
+      params: ["!id"],
+    },
+    service: "fetch",
+  },
+  index: {
+    parameters: {
+      query: {
+        parent_id: "parent_id",
+        name: "%name%",
+        inventor: "%inventor%",
+        lose_date:'lose_date',
+        user_id: "user_id",
+      },
+      // options: {
+      //   "meta.state": 0 // 默认条件
+      // },
+    },
+    service: "query",
+    options: {
+      query: ["skip", "limit"],
+      sort: ["meta.createdAt"],
+      desc: true,
+      count: true,
+    },
+  },
+};

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

@@ -0,0 +1,13 @@
+'use strict';
+const meta = require('./.patentearly.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
+
+// 专利运营已授权专利预警表
+class PatentearlyController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.patent.patentearly;
+  }
+}
+module.exports = CrudController(PatentearlyController, meta);

+ 27 - 0
app/model/patent/patentearly.js

@@ -0,0 +1,27 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const moment = require('moment');
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
+const { ObjectId } = require('mongoose').Types;
+// 专利运营已授权专利预警表
+const patentearly = {
+  parent_id: { type: ObjectId }, // 专利id
+  name: { type: String }, // 专利名称
+  inventor: { type: String }, // 发明人
+  lose_date: { type: String }, // 失效日
+  content: { type: String }, // 预警消息
+  user_id: { type: [ ObjectId ] }, // 接收人id
+  remark: { type: String },
+};
+const schema = new Schema(patentearly, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ parent_id: 1 });
+schema.index({ name: 1 });
+schema.index({ inventor: 1 });
+schema.index({ to_id: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.plugin(metaPlugin);
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Patentearly', schema, 'patent_early');
+};

+ 1 - 0
app/router.js

@@ -86,5 +86,6 @@ module.exports = app => {
   require('./router/patent/patentanalysis')(app); // 专利分析表-交底单
   require('./router/patent/patentassess')(app); // 专利评估表
   require('./router/patent/patentinfo')(app); // 专利信息表
+  require('./router/patent/patentearly')(app); // 专利信息已授权专利预警表
   require('./router/patent/patenttrans')(app); // 专利交易表
 };

+ 12 - 0
app/router/patent/patentearly.js

@@ -0,0 +1,12 @@
+'use strict';
+
+
+module.exports = app => {
+  const { router, controller } = app;
+  const profix = '/api/live/';
+  const vision = 'v0';
+  const index = 'patent';
+  const target = 'patentearly';
+  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);
+};

+ 18 - 0
app/service/patent/patentearly.js

@@ -0,0 +1,18 @@
+'use strict';
+const { CrudService } = require('naf-framework-mongoose/lib/service');
+const { BusinessError, ErrorCode } = require('naf-core').Error;
+const { ObjectId } = require('mongoose').Types;
+const _ = require('lodash');
+const assert = require('assert');
+
+
+// 专利运营已授权专利预警表
+class PatentearlyService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'patentearly');
+    this.model = this.ctx.model.Patent.Patentearly;
+  }
+}
+
+module.exports = PatentearlyService;
+