lrf 2 år sedan
förälder
incheckning
b171530c1b

+ 38 - 0
app/controller/shop/config/.goodsJoinAct.js

@@ -0,0 +1,38 @@
+module.exports = {
+  create: {
+    requestBody: ['platformAct', 'shop', 'goods', 'status'],
+  },
+  destroy: {
+    params: ['!id'],
+    service: 'delete',
+  },
+  update: {
+    params: ['!id'],
+    requestBody: ['platformAct', 'shop', 'goods', 'status'],
+  },
+  show: {
+    parameters: {
+      params: ['!id'],
+    },
+    service: 'fetch',
+  },
+  index: {
+    parameters: {
+      query: {
+        'meta.createdAt@start': 'meta.createdAt@start',
+        'meta.createdAt@end': 'meta.createdAt@end',
+        platformAct: 'platformAct',
+        shop: 'shop',
+        goods: 'goods',
+        status: 'status',
+      },
+    },
+    service: 'query',
+    options: {
+      query: ['skip', 'limit'],
+      sort: ['meta.createdAt'],
+      desc: true,
+      count: true,
+    },
+  },
+};

+ 13 - 0
app/controller/shop/goodsJoinAct.js

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

+ 25 - 0
app/model/shop/goodsJoinAct.js

@@ -0,0 +1,25 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
+
+// 参加平台活动商品
+const goodsJoinAct = {
+  platformAct: { type: String, required: false, zh: '平台活动', ref: 'System.PlatformAct' }, //
+  shop: { type: String, required: false, zh: '店铺', ref: 'Shop.Shop' }, //
+  goods: { type: String, required: false, zh: '商品', ref: 'Shop.Goods' }, //
+  status: { type: String, required: false, default: '0', zh: '状态' }, // 字典:platformAct_goods_status
+};
+const schema = new Schema(goodsJoinAct, { toJSON: { getters: true, virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.index({ platformAct: 1 });
+schema.index({ shop: 1 });
+schema.index({ goods: 1 });
+schema.index({ status: 1 });
+
+schema.plugin(metaPlugin);
+
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('GoodsJoinAct', schema, 'goodsJoinAct');
+};

+ 15 - 0
app/service/shop/goodsJoinAct.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 GoodsJoinActService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'goodsjoinact');
+    this.model = this.ctx.model.Shop.GoodsJoinAct;
+  }
+}
+
+module.exports = GoodsJoinActService;

+ 19 - 0
app/z_router/shop/goodsJoinAct.js

@@ -0,0 +1,19 @@
+'use strict';
+// 路由配置
+const path = require('path');
+const regPath = path.resolve('app', 'public', 'routerRegister');
+const routerRegister = require(regPath);
+const rkey = 'goodsJoinAct';
+const ckey = 'shop.goodsJoinAct';
+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`, 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 => {
+  routerRegister(app, routes, keyZh, rkey, ckey);
+};

+ 1 - 0
app/z_router/shop/index.js

@@ -7,4 +7,5 @@ module.exports = app => {
   require('./selfShop')(app); // 自营店铺相关
   require('./goodsSpec')(app); // 商品规格
   require('./goodsRate')(app); // 商品评价
+  require('./goodsJoinAct')(app); // 平台活动商品关联
 };