lrf402788946 4 年之前
父節點
當前提交
a3522addc5
共有 6 個文件被更改,包括 132 次插入0 次删除
  1. 62 0
      app/controller/.policy.js
  2. 13 0
      app/controller/policy.js
  3. 32 0
      app/model/policy.js
  4. 1 0
      app/router.js
  5. 9 0
      app/router/policy.js
  6. 15 0
      app/service/policy.js

+ 62 - 0
app/controller/.policy.js

@@ -0,0 +1,62 @@
+module.exports = {
+  create: {
+    requestBody: [
+      "user_id",
+      "type",
+      "company",
+      "apply_personal",
+      "phone",
+      "qyfr",
+      "yyzz",
+      "qylr",
+      "desc",
+      "status",
+    ],
+  },
+  destroy: {
+    params: ["!id"],
+    service: "delete",
+  },
+  update: {
+    params: ["!id"],
+    requestBody: [
+      "user_id",
+      "type",
+      "company",
+      "apply_personal",
+      "phone",
+      "qyfr",
+      "yyzz",
+      "qylr",
+      "desc",
+      "status",
+    ],
+  },
+  show: {
+    parameters: {
+      params: ["!id"],
+    },
+    service: "fetch",
+  },
+  index: {
+    parameters: {
+      query: {
+        company: "company",
+        type: "type",
+        phone: "phone",
+        "create_time@start": "create_time@start",
+        "create_time@end": "create_time@end",
+      },
+      // options: {
+      //   "meta.state": 0 // 默认条件
+      // },
+    },
+    service: "query",
+    options: {
+      query: ["skip", "limit"],
+      sort: ["meta.createdAt"],
+      desc: true,
+      count: true,
+    },
+  },
+};

+ 13 - 0
app/controller/policy.js

@@ -0,0 +1,13 @@
+'use strict';
+const meta = require('./.policy.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
+
+// 高企政策服务
+class PolicyController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.policy;
+  }
+}
+module.exports = CrudController(PolicyController, meta);

+ 32 - 0
app/model/policy.js

@@ -0,0 +1,32 @@
+'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 policy = {
+  user_id: { type: ObjectId },
+  type: { type: String }, // 研发补贴,奖励兑现
+  company: { type: String }, // 申请单位
+  apply_personal: { type: String }, // 申请人
+  phone: { type: String }, // 联系电话
+  qyfr: { type: Array }, // 法人复印件
+  yyzz: { type: Array }, // 企业营业执照
+  qylr: { type: Array }, // 企业利润表
+  desc: { type: String }, //  建议
+  status: { type: String, default: '0' }, // 0:申请;1:通过;2拒绝
+
+  remark: { type: String },
+  create_time: { type: String, default: moment(new Date()).format('YYYY-MM-DD HH:mm:ss') },
+};
+const schema = new Schema(policy, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ type: 1 });
+schema.index({ company: 1 });
+schema.index({ phone: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.plugin(metaPlugin);
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Policy', schema, 'policy');
+};

+ 1 - 0
app/router.js

@@ -17,4 +17,5 @@ module.exports = app => {
   require('./router/mechanism')(app); // 机构
   require('./router/online')(app); // 在线
   require('./router/code')(app); // 字典表
+  require('./router/policy')(app); // 高企服务
 };

+ 9 - 0
app/router/policy.js

@@ -0,0 +1,9 @@
+'use strict';
+
+
+module.exports = app => {
+  const { router, controller } = app;
+  const prefix = 'policy';
+  router.resources(prefix, `/${prefix}`, controller[prefix]); // index、create、show、destroy
+  router.post(prefix, `/${prefix}/update/:id`, controller[prefix].update);
+};

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