guhongwei 3 years ago
parent
commit
fd965dcf2f

+ 56 - 0
app/controller/patent/.patentwarning.js

@@ -0,0 +1,56 @@
+module.exports = {
+  create: {
+    requestBody: [
+      "to_id",
+      "to_name",
+      "patent_id",
+      "patent_name",
+      "content",
+      "file_url",
+      "is_read",
+    ],
+  },
+  destroy: {
+    params: ["!id"],
+    service: "delete",
+  },
+  update: {
+    params: ["!id"],
+    requestBody: [
+      "to_id",
+      "to_name",
+      "patent_id",
+      "patent_name",
+      "content",
+      "file_url",
+      "is_read",
+    ],
+  },
+  show: {
+    parameters: {
+      params: ["!id"],
+    },
+    service: "fetch",
+  },
+  index: {
+    parameters: {
+      query: {
+        to_id: "to_id",
+        to_name: "to_name",
+        patent_id: "patent_id",
+        patent_name: "patent_name",
+        is_read: "is_read",
+      },
+      // options: {
+      //   "meta.state": 0 // 默认条件
+      // },
+    },
+    service: "query",
+    options: {
+      query: ["skip", "limit"],
+      sort: ["meta.createdAt"],
+      desc: true,
+      count: true,
+    },
+  },
+};

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

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

+ 29 - 0
app/model/patent/patentwarning.js

@@ -0,0 +1,29 @@
+'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 patentwarning = {
+  to_id: { type: ObjectId }, // 接收人id
+  to_name: { type: ObjectId }, // 接收人姓名
+  patent_id: { type: ObjectId }, // 预警专利id
+  patent_name: { type: ObjectId }, // 预警专利姓名
+  content: { type: String }, // 预警信息
+  file_url: { type: Array }, // 预警文件
+  is_read: { type: Boolean, default: false }, // 是否已读
+  remark: { type: String },
+};
+const schema = new Schema(patentwarning, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ to_id: 1 });
+schema.index({ to_name: 1 });
+schema.index({ patent_id: 1 });
+schema.index({ patent_name: 1 });
+schema.index({ is_read: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.plugin(metaPlugin);
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Patentwarning', schema, 'patent_warning');
+};

+ 1 - 0
app/router.js

@@ -82,6 +82,7 @@ module.exports = app => {
   require('./router/patent/patentexamine')(app); // 审核通知表
   require('./router/patent/patentnotice')(app); // 通知表
   require('./router/patent/patentapply')(app); // 专利申请表-审批单
+  require('./router/patent/patentwarning')(app); // 专利申请预警表
   require('./router/patent/patentanalysis')(app); // 专利分析表-交底单
   require('./router/patent/patentassess')(app); // 专利评估表
   require('./router/patent/patentinfo')(app); // 专利信息表

+ 12 - 0
app/router/patent/patentwarning.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 = 'patentwarning';
+  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/patentwarning.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 PatentwarningService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'patentwarning');
+    this.model = this.ctx.model.Patent.Patentwarning;
+  }
+}
+
+module.exports = PatentwarningService;
+