lrf 2 년 전
부모
커밋
72710224b0

+ 22 - 15
app/controller/system/config/.actTags.js

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

+ 7 - 0
app/controller/system/config/.goodsTags.js

@@ -46,4 +46,11 @@ module.exports = {
       },
     },
   },
+  getData: {
+    parameters: {
+      query: {
+        code: 'code',
+      },
+    },
+  },
 };

+ 6 - 1
app/service/system/actTags.js

@@ -4,12 +4,17 @@ const { BusinessError, ErrorCode } = require('naf-core').Error;
 const _ = require('lodash');
 const assert = require('assert');
 
-// 
+//
 class ActTagsService extends CrudService {
   constructor(ctx) {
     super(ctx, 'acttags');
     this.model = this.ctx.model.System.ActTags;
   }
+
+  async getData({ value }) {
+    const data = await this.model.findOne({ value });
+    return data;
+  }
 }
 
 module.exports = ActTagsService;

+ 8 - 3
app/service/system/goodsTags.js

@@ -26,13 +26,13 @@ class GoodsTagsService extends CrudService {
   async tree({ pid }) {
     let list = await this.model.find({ status: '0' });
     list = JSON.parse(JSON.stringify(list));
-    list = list.map(i => _.omit(i, [ 'meta', '__v' ]));
-    const level1 = list.filter(f => (pid ? f.id === pid : !f.pid));
+    list = list.map((i) => _.omit(i, ['meta', '__v']));
+    const level1 = list.filter((f) => (pid ? f.id === pid : !f.pid));
     const loop = (list, parents) => {
       for (const p of parents) {
         const pid = _.get(p, '_id');
         if (!pid) continue;
-        const children = list.filter(f => ObjectId(pid).equals(f.pid));
+        const children = list.filter((f) => ObjectId(pid).equals(f.pid));
         if (children.length <= 0) continue;
         const newChildren = loop(list, children);
         p.children = newChildren;
@@ -42,6 +42,11 @@ class GoodsTagsService extends CrudService {
     const tree = loop(list, level1);
     return tree;
   }
+
+  async getData({ code }) {
+    const data = await this.model.findOne({ code });
+    return data;
+  }
 }
 
 module.exports = GoodsTagsService;

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

@@ -7,6 +7,7 @@ const rkey = 'actTags';
 const ckey = 'system.actTags';
 const keyZh = '活动标签';
 const routes = [
+  { method: 'get', path: `${rkey}/getData`, controller: `${ckey}.getData`, name: `${ckey}getData`, zh: `${keyZh}查询标签` },
   { 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}` },

+ 1 - 0
app/z_router/system/goodsTags.js

@@ -7,6 +7,7 @@ const rkey = 'goodsTags';
 const ckey = 'system.goodsTags';
 const keyZh = '商品标签';
 const routes = [
+  { method: 'get', path: `${rkey}/getData`, controller: `${ckey}.getData`, name: `${ckey}getData`, zh: `${keyZh}获取数据` },
   { method: 'get', path: `${rkey}/tree`, controller: `${ckey}.tree`, name: `${ckey}Tree`, zh: `${keyZh}树结构查询` },
   { 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}查询` },