guhongwei 3 年之前
父节点
当前提交
3f388607a2

+ 58 - 0
app/controller/patent/.patenttechol.js

@@ -0,0 +1,58 @@
+module.exports = {
+  create: {
+    requestBody: [
+      "describe",
+      "urgent",
+      "contact",
+      "phone",
+      "email",
+      "requirement",
+      "status",
+    ],
+  },
+  destroy: {
+    params: ["!id"],
+    service: "delete",
+  },
+  update: {
+    params: ["!id"],
+    requestBody: [
+      "describe",
+      "urgent",
+      "contact",
+      "phone",
+      "email",
+      "requirement",
+      "status",
+    ],
+  },
+  show: {
+    parameters: {
+      params: ["!id"],
+    },
+    service: "fetch",
+  },
+  index: {
+    parameters: {
+      query: {
+        urgent: "%urgent%",
+        contact: "%contact%",
+        phone: "%phone%",
+        email: "%email%",
+        status: "%status%",
+        "sell_money@start": "sell_money@start",
+        "sell_money@end": "sell_money@end",
+      },
+      // options: {
+      //   "meta.state": 0 // 默认条件
+      // },
+    },
+    service: "query",
+    options: {
+      query: ["skip", "limit"],
+      sort: ["meta.createdAt"],
+      desc: true,
+      count: true,
+    },
+  },
+};

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

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

+ 29 - 0
app/model/patent/patenttechol.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 patenttechol = {
+  describe: { type: String }, // 需求描述(用途)
+  urgent: { type: String }, // 紧急程度
+  contact: { type: String }, // 联系人
+  phone: { type: String }, // 联系电话
+  email: { type: String }, // 电子邮箱
+  requirement: { type: String }, // 合作条件及要求
+  status: { type: String }, // 状态
+  remark: { type: String },
+};
+const schema = new Schema(patenttechol, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ urgent: 1 });
+schema.index({ contact: 1 });
+schema.index({ phone: 1 });
+schema.index({ email: 1 });
+schema.index({ status: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.plugin(metaPlugin);
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Patenttechol', schema, 'patent_techol');
+};

+ 1 - 0
app/router.js

@@ -90,4 +90,5 @@ module.exports = app => {
   require('./router/patent/patentinfo')(app); // 专利信息表
   require('./router/patent/patentearly')(app); // 专利信息已授权专利预警表
   require('./router/patent/patenttrans')(app); // 专利交易表
+  require('./router/patent/patenttechol')(app); // 专利需求表
 };

+ 13 - 0
app/router/patent/patenttechol.js

@@ -0,0 +1,13 @@
+'use strict';
+
+
+module.exports = app => {
+  const { router, controller } = app;
+  const profix = '/api/live/';
+  const vision = 'v0';
+  const index = 'patent';
+  const target = 'patenttechol';
+  const metaTime = app.middleware.createTime();
+  router.resources(target, `${profix}${vision}/${index}/${target}`, metaTime, 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/patenttechol.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 PatenttecholService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'patenttechol');
+    this.model = this.ctx.model.Patent.Patenttechol;
+  }
+}
+
+module.exports = PatenttecholService;