lrf vor 2 Jahren
Ursprung
Commit
57239bf356

+ 13 - 0
app/controller/system/actTags.js

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

+ 38 - 0
app/controller/system/config/.actTags.js

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

+ 23 - 0
app/model/system/actTags.js

@@ -0,0 +1,23 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
+
+// 活动标签
+const actTags = {
+  label: { type: String, required: false, zh: '活动标签' }, //
+  value: { type: String, required: false, zh: '编码' }, //
+  sort: { type: Array, required: false, zh: '排序' }, //
+  status: { type: String, required: false, default: '0', zh: '状态' }, // 字典:use
+};
+const schema = new Schema(actTags, { toJSON: { getters: true, virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.index({ sort: 1 });
+schema.index({ status: 1 });
+
+schema.plugin(metaPlugin);
+
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('ActTags', schema, 'actTags');
+};

+ 19 - 0
app/z_router/system/actTags.js

@@ -0,0 +1,19 @@
+'use strict';
+// 路由配置
+const path = require('path');
+const regPath = path.resolve('app', 'public', 'routerRegister');
+const routerRegister = require(regPath);
+const rkey = 'actTags';
+const ckey = 'system.actTags';
+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/system/index.js

@@ -6,4 +6,5 @@ module.exports = app => {
   require('./indexModule')(app); // 图标菜单
   require('./serviceContact')(app); // 客服信息
   require('./goodsTags')(app); // 商品标签
+  require('./actTags')(app); // 活动标签
 };