lrf 3 anni fa
parent
commit
a7f4d519ac

+ 13 - 0
app/controller/analysis.js

@@ -0,0 +1,13 @@
+'use strict';
+const meta = require('./config/.analysis.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose-free/lib/controller');
+
+// 查新检索
+class AnalysisController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.analysis;
+  }
+}
+module.exports = CrudController(AnalysisController, meta);

+ 13 - 0
app/controller/apply.js

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

+ 13 - 0
app/controller/applyRecord.js

@@ -0,0 +1,13 @@
+'use strict';
+const meta = require('./config/.applyRecord.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose-free/lib/controller');
+
+// 审核记录
+class ApplyRecordController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.applyRecord;
+  }
+}
+module.exports = CrudController(ApplyRecordController, meta);

+ 37 - 0
app/controller/config/.analysis.js

@@ -0,0 +1,37 @@
+module.exports = {
+  create: {
+    requestBody: ['name', 'user_id', 'user_name', 'type', 'inventor', 'contact', 'phone', 'email', 'questions', 'file', 'status'],
+  },
+  destroy: {
+    params: ['!id'],
+    service: 'delete',
+  },
+  update: {
+    params: ['!id'],
+    requestBody: ['name', 'user_id', 'user_name', 'type', 'inventor', 'contact', 'phone', 'email', 'questions', 'file', 'status'],
+  },
+  show: {
+    parameters: {
+      params: ['!id'],
+    },
+    service: 'fetch',
+  },
+  index: {
+    parameters: {
+      query: {
+        '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,
+    },
+  },
+};

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

@@ -0,0 +1,45 @@
+module.exports = {
+  create: {
+    requestBody: ['mech_id', 'mech_name', 'name', 'user_id', 'user_name', 'type', 'inventor', 'contact', 'phone', 'email', 'check_url', 'apply_url', 'questions', 'status'],
+  },
+  destroy: {
+    params: ['!id'],
+    service: 'delete',
+  },
+  update: {
+    params: ['!id'],
+    requestBody: ['mech_id', 'mech_name', 'name', 'user_id', 'user_name', 'type', 'inventor', 'contact', 'phone', 'email', 'check_url', 'apply_url', 'questions', 'status'],
+  },
+  show: {
+    parameters: {
+      params: ['!id'],
+    },
+    service: 'fetch',
+  },
+  index: {
+    parameters: {
+      query: {
+        'meta.createdAt@start': 'meta.createdAt@start',
+        'meta.createdAt@end': 'meta.createdAt@end',
+        mech_id: 'mech_id',
+        mech_name: 'mech_name',
+        name: 'name',
+        user_id: 'user_id',
+        user_name: 'user_name',
+        type: 'type',
+        phone: 'phone',
+        status: 'status',
+      },
+      // options: {
+      //   "meta.state": 0 // 默认条件
+      // },
+    },
+    service: 'query',
+    options: {
+      query: ['skip', 'limit'],
+      sort: ['meta.createdAt'],
+      desc: true,
+      count: true,
+    },
+  },
+};

+ 41 - 0
app/controller/config/.applyRecord.js

@@ -0,0 +1,41 @@
+module.exports = {
+  create: {
+    requestBody: ['apply_id', 'name', 'examine_id', 'examine_name', 'examine_phone', 'desc', 'status', 'step', 'type'],
+  },
+  destroy: {
+    params: ['!id'],
+    service: 'delete',
+  },
+  update: {
+    params: ['!id'],
+    requestBody: ['apply_id', 'name', 'examine_id', 'examine_name', 'examine_phone', 'desc', 'status', 'step', 'type'],
+  },
+  show: {
+    parameters: {
+      params: ['!id'],
+    },
+    service: 'fetch',
+  },
+  index: {
+    parameters: {
+      query: {
+        'meta.createdAt@start': 'meta.createdAt@start',
+        'meta.createdAt@end': 'meta.createdAt@end',
+        apply_id: 'apply_id',
+        name: 'name',
+        examine_id: 'examine_id',
+        examine_name: 'examine_name',
+      },
+      // options: {
+      //   "meta.state": 0 // 默认条件
+      // },
+    },
+    service: 'query',
+    options: {
+      query: ['skip', 'limit'],
+      sort: ['meta.createdAt'],
+      desc: true,
+      count: true,
+    },
+  },
+};

+ 40 - 0
app/controller/config/.examine.js

@@ -0,0 +1,40 @@
+module.exports = {
+  create: {
+    requestBody: ['receive_id', 'receive_name', 'content', 'is_read'],
+  },
+  destroy: {
+    params: ['!id'],
+    service: 'delete',
+  },
+  update: {
+    params: ['!id'],
+    requestBody: ['receive_id', 'receive_name', 'content', 'is_read'],
+  },
+  show: {
+    parameters: {
+      params: ['!id'],
+    },
+    service: 'fetch',
+  },
+  index: {
+    parameters: {
+      query: {
+        receive_id: 'receive_id',
+        receive_name: 'receive_name',
+        is_read: 'is_read',
+        '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,
+    },
+  },
+};

+ 41 - 0
app/controller/config/.notice.js

@@ -0,0 +1,41 @@
+module.exports = {
+  create: {
+    requestBody: ['send_id', 'send_name', 'receive_type', 'receive', 'is_read', 'content', 'file'],
+  },
+  destroy: {
+    params: ['!id'],
+    service: 'delete',
+  },
+  update: {
+    params: ['!id'],
+    requestBody: ['send_id', 'send_name', 'receive_type', 'receive', 'is_read', 'content', 'file'],
+  },
+  show: {
+    parameters: {
+      params: ['!id'],
+    },
+    service: 'fetch',
+  },
+  index: {
+    parameters: {
+      query: {
+        'meta.createdAt@start': 'meta.createdAt@start',
+        'meta.createdAt@end': 'meta.createdAt@end',
+        send_id: 'send_id',
+        send_name: 'send_name',
+        receive_type: 'receive_type',
+        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/examine.js

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

+ 13 - 0
app/controller/notice.js

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

+ 27 - 0
app/model/analysis.js

@@ -0,0 +1,27 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
+
+// 查新检索
+const analysis = {
+  name: { type: String, required: false }, // 发明名称
+  user_id: { type: String, required: false }, // 申请人id
+  user_name: { type: String, required: false }, // 申请人姓名
+  type: { type: String, required: false }, // 专利类型
+  inventor: { type: String, required: false }, // 发明人
+  contact: { type: String, required: false }, // 技术联系人
+  phone: { type: String, required: false }, // 联系电话
+  email: { type: String, required: false }, // 电子邮箱
+  questions: { type: String, required: false }, // 其他内容合集
+  file: { type: String, required: false }, // 报告文件
+  status: { type: String, required: false }, // 状态:0:待审中,1:审核通过,待发报告文件,-1:审核未通过,2:文件已发,请及时下载
+};
+const schema = new Schema(analysis, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ 'meta.createdAt': 1 });
+
+schema.plugin(metaPlugin);
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Analysis', schema, 'analysis');
+};

+ 38 - 0
app/model/apply.js

@@ -0,0 +1,38 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
+
+// 专利申请
+const apply = {
+  mech_id: { type: String, required: false }, // 机构id
+  mech_name: { type: String, required: false }, // 机构名称
+  name: { type: String, required: false }, // 专利名称
+  user_id: { type: String, required: false }, // 申请人id
+  user_name: { type: String, required: false }, // 申请人姓名
+  type: { type: String, required: false }, // 专利类型
+  inventor: { type: String, required: false }, // 发明人
+  contact: { type: String, required: false }, // 技术联系人
+  phone: { type: String, required: false }, // 联系电话
+  email: { type: String, required: false }, // 电子邮箱
+  check_url: { type: String, required: false }, // 审查文件
+  apply_url: { type: String, required: false }, // 申请文件
+  questions: { type: String, required: false }, // 其他内容合集
+  status: { type: String, required: false }, // 状态
+};
+const schema = new Schema(apply, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.index({ mech_id: 1 });
+schema.index({ mech_name: 1 });
+schema.index({ name: 1 });
+schema.index({ user_id: 1 });
+schema.index({ user_name: 1 });
+schema.index({ type: 1 });
+schema.index({ phone: 1 });
+schema.index({ status: 1 });
+
+schema.plugin(metaPlugin);
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Apply', schema, 'apply');
+};

+ 29 - 0
app/model/applyRecord.js

@@ -0,0 +1,29 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
+
+// 审核记录表
+const apply_record = {
+  apply_id: { type: String, required: false }, // 专利id
+  name: { type: String, required: false }, // 专利名称
+  examine_id: { type: String, required: false }, // 审核人id
+  examine_name: { type: String, required: false }, // 审核人姓名
+  examine_phone: { type: String, required: false }, // 审核人联系电话
+  desc: { type: String, required: false }, // 审核意见
+  status: { type: String, required: false }, // 审核结果
+  step: { type: String, required: false }, // 审核进度
+  type: { type: String, required: false }, // 记录类型:1:专利申请,2:查新检索,3:价值评估
+};
+const schema = new Schema(apply_record, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.index({ apply_id: 1 });
+schema.index({ name: 1 });
+schema.index({ examine_id: 1 });
+schema.index({ examine_name: 1 });
+
+schema.plugin(metaPlugin);
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Apply_Record', schema, 'apply_record');
+};

+ 20 - 0
app/model/examine.js

@@ -0,0 +1,20 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
+
+// 审核信息
+const examine = {
+  receive_id: { type: String, required: false }, // 接收人
+  receive_name: { type: String, required: false }, // 接收人姓名
+  content: { type: String, required: false }, // 接收内容
+  is_read: { type: Boolean, required: false, default: false }, // 是否已读
+};
+const schema = new Schema(examine, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ 'meta.createdAt': 1 });
+
+schema.plugin(metaPlugin);
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Examine', schema, 'examine');
+};

+ 27 - 0
app/model/notice.js

@@ -0,0 +1,27 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
+
+// 通知信息
+const notice = {
+  send_id: { type: String, required: false }, // 发送人id
+  send_name: { type: String, required: false }, // 发送人姓名
+  receive_type: { type: String, required: false }, // 接收人类型0:管理员发给所有人,1:管理员发给机构用户,2:管理员发给个人用户,3:机构发给个人用户
+  receive: { type: Array, required: false }, // 接收人
+  is_read: { type: Boolean, required: false }, // 是否已读
+  content: { type: String, required: false }, // 内容
+  file: { type: Array, required: false }, // 通知文件
+};
+const schema = new Schema(notice, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.index({ send_id: 1 });
+schema.index({ send_name: 1 });
+schema.index({ receive_type: 1 });
+schema.index({ is_read: 1 });
+
+schema.plugin(metaPlugin);
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Notice', schema, 'notice');
+};

+ 5 - 0
app/router.js

@@ -25,4 +25,9 @@ module.exports = app => {
   require('./z_router/agent')(app); // 代理机构
   require('./z_router/consulting')(app); // 咨询师
   require('./z_router/patent')(app); // 专利信息
+  require('./z_router/examine')(app); // 审核信息
+  require('./z_router/notice')(app); // 通知信息
+  require('./z_router/apply')(app); // 申请信息
+  require('./z_router/applyRecord')(app); // 审核记录
+  require('./z_router/analysis')(app); // 查新检索
 };

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

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

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

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

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

+ 29 - 0
app/z_router/analysis.js

@@ -0,0 +1,29 @@
+'use strict';
+// 路由配置
+const rkey = 'analysis';
+const ckey = 'analysis';
+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/apply.js

@@ -0,0 +1,29 @@
+'use strict';
+// 路由配置
+const rkey = 'apply';
+const ckey = 'apply';
+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/applyRecord.js

@@ -0,0 +1,29 @@
+'use strict';
+// 路由配置
+const rkey = 'applyRecord';
+const ckey = 'applyRecord';
+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/examine.js

@@ -0,0 +1,29 @@
+'use strict';
+// 路由配置
+const rkey = 'examine';
+const ckey = 'examine';
+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/notice.js

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