lrf 3 år sedan
förälder
incheckning
1ece530a7a
7 ändrade filer med 304 tillägg och 0 borttagningar
  1. 140 0
      app/controller/config/.patent.js
  2. 13 0
      app/controller/patent.js
  3. 58 0
      app/model/patent.js
  4. 1 0
      app/router.js
  5. 15 0
      app/service/patent.js
  6. 29 0
      app/z_router/patent.js
  7. 48 0
      test/test.js

+ 140 - 0
app/controller/config/.patent.js

@@ -0,0 +1,140 @@
+module.exports = {
+  create: {
+    requestBody: [
+      'create_number',
+      'create_date',
+      'success_number',
+      'success_date',
+      'inventor',
+      'agent',
+      'agent_personal',
+      'address',
+      'name',
+      'apply_personal',
+      'term',
+      'type',
+      'nationality',
+      'ipc_type',
+      'onlegal_status',
+      'legal_status',
+      'law_date',
+      'on_obligee',
+      'apply_address',
+      'apply_other',
+      'law_num',
+      'first_opendate',
+      'empower_date',
+      'lose_date',
+      'examine_date',
+      'invention_design',
+      'incopat_link',
+      'first_ask',
+      'first_apply',
+      'apply_city',
+      'business_code',
+      'business_address',
+      'first_inventor',
+      'shared_value',
+      'techol_stable',
+      'techol_advanced',
+      'pct_apply',
+      'pct_publish',
+      'status',
+      'abstract',
+      'img_url',
+      'user_id',
+      'remark',
+    ],
+  },
+  destroy: {
+    params: ['!id'],
+    service: 'delete',
+  },
+  update: {
+    params: ['!id'],
+    requestBody: [
+      'create_number',
+      'create_date',
+      'success_number',
+      'success_date',
+      'inventor',
+      'agent',
+      'agent_personal',
+      'address',
+      'name',
+      'apply_personal',
+      'term',
+      'type',
+      'nationality',
+      'ipc_type',
+      'onlegal_status',
+      'legal_status',
+      'law_date',
+      'on_obligee',
+      'apply_address',
+      'apply_other',
+      'law_num',
+      'first_opendate',
+      'empower_date',
+      'lose_date',
+      'examine_date',
+      'invention_design',
+      'incopat_link',
+      'first_ask',
+      'first_apply',
+      'apply_city',
+      'business_code',
+      'business_address',
+      'first_inventor',
+      'shared_value',
+      'techol_stable',
+      'techol_advanced',
+      'pct_apply',
+      'pct_publish',
+      'status',
+      'abstract',
+      'img_url',
+      'user_id',
+      'remark',
+    ],
+  },
+  show: {
+    parameters: {
+      params: ['!id'],
+    },
+    service: 'fetch',
+  },
+  index: {
+    parameters: {
+      query: {
+        create_number: 'create_number',
+        success_number: 'success_number',
+        inventor: 'inventor',
+        agent: 'agent',
+        agent_personal: 'agent_personal',
+        term: 'term',
+        type: 'type',
+        nationality: 'nationality',
+        ipc_type: 'ipc_type',
+        invention_design: 'invention_design',
+        first_apply: 'first_apply',
+        business_code: 'business_code',
+        law_num: 'law_num',
+        first_inventor: 'first_inventor',
+        status: 'status',
+        '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.js

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

+ 58 - 0
app/model/patent.js

@@ -0,0 +1,58 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
+const { ObjectId } = require('mongoose').Types;
+// 专利信息表
+const patent = {
+  create_number: { type: String, required: false }, // 申请号
+  create_date: { type: String, required: false }, // 申请日
+  success_number: { type: String, required: false }, // 公开(公告)号
+  success_date: { type: String, required: false }, // 公开(公告)日
+  inventor: { type: String, required: false }, // 发明人
+  agent: { type: String, required: false }, // 代理机构
+  agent_personal: { type: String, required: false }, // 代理人
+  address: { type: String, required: false }, // 发明人地址
+  name: { type: String, required: false }, // 标题
+  apply_personal: { type: String, required: false }, // 申请人
+  term: { type: String, required: false }, // 专利有效性
+  type: { type: String, required: false }, // 专利类型
+  nationality: { type: String, required: false }, // 公开国别
+  ipc_type: { type: String, required: false }, // IPC主分类
+  onlegal_status: { type: String, required: false }, // 当前法律状态
+  legal_status: { type: String, required: false }, // 法律状态
+  law_date: { type: String, required: false }, // 法律文书日期
+  on_obligee: { type: String, required: false }, // 当前权利人--变更前权利人
+  apply_address: { type: String, required: false }, // 申请人地址(其他)
+  apply_other: { type: String, required: false }, // 申请人(其他)
+  law_num: { type: String, required: false }, // 法律文书编号
+  first_opendate: { type: String, required: false }, // 首次公开日
+  empower_date: { type: String, required: false }, // 授权公告日
+  lose_date: { type: String, required: false }, // 失效日
+  examine_date: { type: String, required: false }, // 实质审查生效日
+  invention_design: { type: String, required: false }, // 发明(设计)人(其他)
+  incopat_link: { type: String, required: false }, // 链接到incoPat
+  first_ask: { type: String, required: false }, // 首项权利要求
+  first_apply: { type: String, required: false }, // 第一申请人
+  apply_city: { type: String, required: false }, // 中国申请人地市
+  business_code: { type: String, required: false }, // 工商统一社会信用代码
+  business_address: { type: String, required: false }, // 工商注册地址
+  first_inventor: { type: String, required: false }, // 第一发明人
+  shared_value: { type: String, required: false }, // 合享价值度
+  techol_stable: { type: String, required: false }, // 技术稳定性
+  techol_advanced: { type: String, required: false }, // 技术先进性
+  pct_apply: { type: String, required: false }, // PCT国际申请号
+  pct_publish: { type: String, required: false }, // PCT国际公布号
+  status: { type: String, required: false, default: '0' }, // 状态
+  abstract: { type: String, required: false }, // 摘要
+  img_url: { type: Array }, // 首页附图
+  user_id: { type: Array }, // 专利关联人
+  remark: { type: String },
+};
+const schema = new Schema(patent, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.plugin(metaPlugin);
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Patent', schema, 'patent');
+};

+ 1 - 0
app/router.js

@@ -24,4 +24,5 @@ module.exports = app => {
   router.get('/', controller.home.index);
   require('./z_router/agent')(app); // 代理机构
   require('./z_router/consulting')(app); // 咨询师
+  require('./z_router/patent')(app); // 专利信息
 };

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

+ 29 - 0
app/z_router/patent.js

@@ -0,0 +1,29 @@
+'use strict';
+// 路由配置
+const rkey = 'patent';
+const ckey = 'patent';
+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);
+  }
+};

+ 48 - 0
test/test.js

@@ -0,0 +1,48 @@
+'use strict';
+const patent = {
+  create_number: { type: String, required: false }, // 申请号
+  create_date: { type: String, required: false }, // 申请日
+  success_number: { type: String, required: false }, // 公开(公告)号
+  success_date: { type: String, required: false }, // 公开(公告)日
+  inventor: { type: String, required: false }, // 发明人
+  agent: { type: String, required: false }, // 代理机构
+  agent_personal: { type: String, required: false }, // 代理人
+  address: { type: String, required: false }, // 发明人地址
+  name: { type: String, required: false }, // 标题
+  apply_personal: { type: String, required: false }, // 申请人
+  term: { type: String, required: false }, // 专利有效性
+  type: { type: String, required: false }, // 专利类型
+  nationality: { type: String, required: false }, // 公开国别
+  ipc_type: { type: String, required: false }, // IPC主分类
+  onlegal_status: { type: String, required: false }, // 当前法律状态
+  legal_status: { type: String, required: false }, // 法律状态
+  law_date: { type: String, required: false }, // 法律文书日期
+  on_obligee: { type: String, required: false }, // 当前权利人--变更前权利人
+  apply_address: { type: String, required: false }, // 申请人地址(其他)
+  apply_other: { type: String, required: false }, // 申请人(其他)
+  law_num: { type: String, required: false }, // 法律文书编号
+  first_opendate: { type: String, required: false }, // 首次公开日
+  empower_date: { type: String, required: false }, // 授权公告日
+  lose_date: { type: String, required: false }, // 失效日
+  examine_date: { type: String, required: false }, // 实质审查生效日
+  invention_design: { type: String, required: false }, // 发明(设计)人(其他)
+  incopat_link: { type: String, required: false }, // 链接到incoPat
+  first_ask: { type: String, required: false }, // 首项权利要求
+  first_apply: { type: String, required: false }, // 第一申请人
+  apply_city: { type: String, required: false }, // 中国申请人地市
+  business_code: { type: String, required: false }, // 工商统一社会信用代码
+  business_address: { type: String, required: false }, // 工商注册地址
+  first_inventor: { type: String, required: false }, // 第一发明人
+  shared_value: { type: String, required: false }, // 合享价值度
+  techol_stable: { type: String, required: false }, // 技术稳定性
+  techol_advanced: { type: String, required: false }, // 技术先进性
+  pct_apply: { type: String, required: false }, // PCT国际申请号
+  pct_publish: { type: String, required: false }, // PCT国际公布号
+  status: { type: String, required: false, default: '0' }, // 状态
+  abstract: { type: String, required: false }, // 摘要
+  img_url: { type: Array }, // 首页附图
+  user_id: { type: Array }, // 专利关联人
+  remark: { type: String },
+};
+const keys = Object.keys(patent);
+console.log(keys);