liuyu 5 éve
szülő
commit
98d7589f08

+ 61 - 0
app/controller/.productpact.js

@@ -0,0 +1,61 @@
+module.exports = {
+  create: {
+    requestBody: [
+      '!product_id',
+      '!userid',
+      '!market_userid',
+      'description',
+      'username',
+      'product_name',
+      'market_username',
+      'dockid',
+      '!status'
+    ]
+  },
+  destroy: {
+    params: ['!id'],
+    service: 'delete'
+  },
+  update: {
+    params: ['!id'],
+    requestBody: [
+      'product_id',
+      'userid',
+      'market_userid',
+      'description',
+      'username',
+      'product_name',
+      'market_username',
+      'dockid',
+      'status'
+    ]
+  },
+  show: {
+    parameters: {
+      params: ['!id']
+    },
+    service: 'fetch'
+  },
+  index: {
+    parameters: {
+      query: {
+        product_id :'product_id',
+        userid :'userid',
+        market_userid :'market_userid',
+        status :'status',
+        username: 'username',
+        product_name: 'product_name',
+        dockid: 'dockid',
+        market_username : 'market_username',
+        description :'description'
+      }
+    },
+    service: 'query',
+    options: {
+      query: ['skip', 'limit'],
+      sort: ['meta.createdAt'],
+      desc: true,
+      count: true
+    }
+  },
+};

+ 20 - 0
app/controller/productpact.js

@@ -0,0 +1,20 @@
+'use strict';
+
+const _ = require('lodash');
+const meta = require('./.productpact.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
+
+// 产品合同表管理
+class ProductpactController extends Controller {
+
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.productpact;
+  }
+
+
+}
+
+module.exports = CrudController(class ProductpactController extends Controller {
+  , meta);

+ 27 - 0
app/model/productpact.js

@@ -0,0 +1,27 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
+
+// 科技超市产品合同表
+const ProductpactSchema = {
+  dockid: { type: String, required: false, maxLength: 500 }, // 对接id
+  product_id: { type: String, required: true, maxLength: 500 }, // 产品ID
+  product_name: { type: String, required: false, maxLength: 500 }, // 产品名称
+  description: { type: String, required: false }, // 描述
+  userid: { type: String, required: true, maxLength: 500 }, // 购买人ID
+  username: { type: String, required: false, maxLength: 500 }, // 购买人名称
+  market_userid: { type: String, required: true, maxLength: 500 }, // 营销人ID
+  market_username: { type: String, required: false, maxLength: 500 }, // 营销人名称
+  status: { type: String, required: false, maxLength: 200, default: '0' }, // 状态(0:待审核 1:通过审核)
+};
+
+
+const schema = new Schema(ProductpactSchema, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ product_id: 1 });
+schema.plugin(metaPlugin);
+
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Productpact', schema, 'market_product_pact');
+};

+ 4 - 0
app/router.js

@@ -42,6 +42,10 @@ module.exports = app => {
   router.resources('tranaudit', '/api/market/tranaudit', controller.tranaudit); // index、create、show、destroy
   router.post('tranaudit', '/api/market/tranaudit/update/:id', controller.tranaudit.update);
 
+  // 合同记录表设置路由
+  router.resources('productpact', '/api/market/productpact', controller.productpact); // index、create、show、destroy
+  router.post('productpact', '/api/market/productpact/update/:id', controller.productpact.update);
+
   // 科技企业表设置路由
   router.resources('enterprise', '/api/market/enterprise', controller.enterprise); // index、create、show、destroy
   router.post('enterprise', '/api/market/enterprise/update/:id', controller.enterprise.update);

+ 18 - 0
app/service/productpact.js

@@ -0,0 +1,18 @@
+'use strict';
+
+
+const assert = require('assert');
+const _ = require('lodash');
+const { ObjectId } = require('mongoose').Types;
+const { CrudService } = require('naf-framework-mongoose/lib/service');
+const { BusinessError, ErrorCode } = require('naf-core').Error;
+
+class ProductpactService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'market_product_pact');
+    this.model = this.ctx.model.Productpact;
+  }
+
+}
+
+module.exports = ProductpactService;