lrf 3 years ago
parent
commit
314ebe6075

+ 45 - 0
app/controller/config/.problem.js

@@ -0,0 +1,45 @@
+module.exports = {
+  create: {
+    requestBody: ['name', 'ask_id', 'ask_name', 'ask_date', 'ask_explain', 'ask_file', 'answer_id', 'answer_name', 'answer_date', 'answer_explain', 'answer_file', 'status'],
+  },
+  destroy: {
+    params: ['!id'],
+    service: 'delete',
+  },
+  update: {
+    params: ['!id'],
+    requestBody: ['name', 'ask_id', 'ask_name', 'ask_date', 'ask_explain', 'ask_file', 'answer_id', 'answer_name', 'answer_date', 'answer_explain', 'answer_file', 'status'],
+  },
+  show: {
+    parameters: {
+      params: ['!id'],
+    },
+    service: 'fetch',
+  },
+  index: {
+    parameters: {
+      query: {
+        'meta.createdAt@start': 'meta.createdAt@start',
+        'meta.createdAt@end': 'meta.createdAt@end',
+        name: 'name',
+        ask_id: 'ask_id',
+        ask_name: 'ask_name',
+        ask_date: 'ask_date',
+        answer_id: 'answer_id',
+        answer_name: 'answer_name',
+        answer_date: 'answer_date',
+        status: 'status',
+      },
+      // options: {
+      //   "meta.state": 0 // 默认条件
+      // },
+    },
+    service: 'query',
+    options: {
+      query: ['skip', 'limit'],
+      sort: ['meta.createdAt'],
+      desc: true,
+      count: true,
+    },
+  },
+};

+ 43 - 0
app/controller/config/.techol.js

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

+ 13 - 0
app/controller/problem.js

@@ -0,0 +1,13 @@
+'use strict';
+const meta = require('./config/.problem.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose-free/lib/controller');
+
+// 问题咨询
+class ProblemController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.problem;
+  }
+}
+module.exports = CrudController(ProblemController, meta);

+ 13 - 0
app/controller/techol.js

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

+ 36 - 0
app/model/problem.js

@@ -0,0 +1,36 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
+
+// 问题咨询
+const problem = {
+  name: { type: String, required: false }, // 问题名称
+  ask_id: { type: String, required: false }, // 发问人id
+  ask_name: { type: String, required: false }, // 发问人姓名
+  ask_date: { type: String, required: false }, // 发问时间
+  ask_explain: { type: String, required: false }, // 问题说明
+  ask_file: { type: Array, required: false }, // 问题文件
+  answer_id: { type: String, required: false }, // 答题人id
+  answer_name: { type: String, required: false }, // 答题人姓名
+  answer_date: { type: String, required: false }, // 答题时间
+  answer_explain: { type: String, required: false }, // 答题说明
+  answer_file: { type: Array, required: false }, // 答题文件
+  status: { type: String, required: false, default: '0' }, // 状态:0:待审,1:已分配,2:已回答,3:已发送答案,4:已阅读
+};
+const schema = new Schema(problem, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.index({ name: 1 });
+schema.index({ ask_id: 1 });
+schema.index({ ask_name: 1 });
+schema.index({ ask_date: 1 });
+schema.index({ answer_id: 1 });
+schema.index({ answer_name: 1 });
+schema.index({ answer_date: 1 });
+schema.index({ status: 1 });
+
+schema.plugin(metaPlugin);
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Problem', schema, 'problem');
+};

+ 30 - 0
app/model/techol.js

@@ -0,0 +1,30 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
+
+// 专利需求
+const techol = {
+  order_num: { type: String, required: false }, // 需求订单号
+  describe: { type: String, required: false }, // 需求描述(用途)
+  urgent: { type: String, required: false }, // 紧急程度
+  contact: { type: String, required: false }, // 联系人
+  phone: { type: String, required: false }, // 联系电话
+  email: { type: String, required: false }, // 电子邮箱
+  requirement: { type: String, required: false }, // 合作条件及要求
+  status: { type: String, required: false, default: '0' }, // 状态
+};
+const schema = new Schema(techol, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.index({ order_num: 1 });
+schema.index({ urgent: 1 });
+schema.index({ contact: 1 });
+schema.index({ phone: 1 });
+schema.index({ email: 1 });
+schema.index({ status: 1 });
+
+schema.plugin(metaPlugin);
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Techol', schema, 'techol');
+};

+ 3 - 0
app/router.js

@@ -34,4 +34,7 @@ module.exports = app => {
   require('./z_router/early')(app); // 专利预警
   require('./z_router/early')(app); // 专利预警
   require('./z_router/safe')(app); // 专利维权
   require('./z_router/safe')(app); // 专利维权
   require('./z_router/assessment')(app); // 价值评估
   require('./z_router/assessment')(app); // 价值评估
+  require('./z_router/techol')(app); // 专利需求
+  require('./z_router/problem')(app); // 问题咨询
 };
 };
+

+ 15 - 0
app/service/problem.js

@@ -0,0 +1,15 @@
+'use strict';
+const { CrudService } = require('naf-framework-mongoose-free/lib/service');
+const { BusinessError, ErrorCode } = require('naf-core').Error;
+const _ = require('lodash');
+const assert = require('assert');
+
+// 问题咨询
+class ProblemService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'problem');
+    this.model = this.ctx.model.Problem;
+  }
+}
+
+module.exports = ProblemService;

+ 15 - 0
app/service/techol.js

@@ -0,0 +1,15 @@
+'use strict';
+const { CrudService } = require('naf-framework-mongoose-free/lib/service');
+const { BusinessError, ErrorCode } = require('naf-core').Error;
+const _ = require('lodash');
+const assert = require('assert');
+
+// 专利需求
+class TecholService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'techol');
+    this.model = this.ctx.model.Techol;
+  }
+}
+
+module.exports = TecholService;

+ 29 - 0
app/z_router/problem.js

@@ -0,0 +1,29 @@
+'use strict';
+// 路由配置
+const rkey = 'problem';
+const ckey = 'problem';
+const keyZh = '问题咨询';
+const routes = [
+  { method: 'get', path: `${rkey}`, controller: `${ckey}.index`, name: `${ckey}Query`, zh: `${keyZh}列表查询` },
+  { method: 'get', path: `${rkey}/:id`, controller: `${ckey}.show`, name: `${ckey}Show`, zh: `${keyZh}查询` },
+  { method: 'post', path: `${rkey}`, controller: `${ckey}.create`, middleware: [ 'password' ], name: `${ckey}Create`, zh: `创建${keyZh}` },
+  { method: 'post', path: `${rkey}/:id`, controller: `${ckey}.update`, name: `${ckey}Update`, zh: `修改${keyZh}` },
+  { method: 'delete', path: `${rkey}/:id`, controller: `${ckey}.destroy`, name: `${ckey}Delete`, zh: `删除${keyZh}` },
+];
+
+module.exports = app => {
+  const { router, config } = app;
+  const mwares = app.middleware;
+  console.log(`${keyZh}:  ${rkey}`);
+  for (const route of routes) {
+    const { method, path, controller: ctl, zh } = route;
+    let { middleware = [] } = route;
+    if (!method || !path || !ctl) continue;
+    // 拼全路径
+    const allPath = `${config.routePrefix}/${path}`;
+    // 处理中间件
+    if (middleware.length > 0) middleware = middleware.map(i => mwares[i]({ enable: true }));
+    // 注册路由
+    router[method](zh, allPath, ...middleware, ctl);
+  }
+};

+ 29 - 0
app/z_router/techol.js

@@ -0,0 +1,29 @@
+'use strict';
+// 路由配置
+const rkey = 'techol';
+const ckey = 'techol';
+const keyZh = '专利需求';
+const routes = [
+  { method: 'get', path: `${rkey}`, controller: `${ckey}.index`, name: `${ckey}Query`, zh: `${keyZh}列表查询` },
+  { method: 'get', path: `${rkey}/:id`, controller: `${ckey}.show`, name: `${ckey}Show`, zh: `${keyZh}查询` },
+  { method: 'post', path: `${rkey}`, controller: `${ckey}.create`, middleware: [ 'password' ], name: `${ckey}Create`, zh: `创建${keyZh}` },
+  { method: 'post', path: `${rkey}/:id`, controller: `${ckey}.update`, name: `${ckey}Update`, zh: `修改${keyZh}` },
+  { method: 'delete', path: `${rkey}/:id`, controller: `${ckey}.destroy`, name: `${ckey}Delete`, zh: `删除${keyZh}` },
+];
+
+module.exports = app => {
+  const { router, config } = app;
+  const mwares = app.middleware;
+  console.log(`${keyZh}:  ${rkey}`);
+  for (const route of routes) {
+    const { method, path, controller: ctl, zh } = route;
+    let { middleware = [] } = route;
+    if (!method || !path || !ctl) continue;
+    // 拼全路径
+    const allPath = `${config.routePrefix}/${path}`;
+    // 处理中间件
+    if (middleware.length > 0) middleware = middleware.map(i => mwares[i]({ enable: true }));
+    // 注册路由
+    router[method](zh, allPath, ...middleware, ctl);
+  }
+};