lrf 2 yıl önce
ebeveyn
işleme
29ceb3a5e5

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

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

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

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

+ 25 - 0
app/model/system/goodsTags.js

@@ -0,0 +1,25 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
+
+// 商品标签
+const goodsTags = {
+  label: { type: String, required: false, zh: '显示名称' }, //
+  code: { type: String, required: false, zh: '标签编码' }, //
+  pid: { type: String, required: false, zh: '上级标签' }, //
+  status: { type: String, required: false, default: '0', zh: '状态' }, // 字典:use
+};
+const schema = new Schema(goodsTags, { toJSON: { getters: true, virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.index({ label: 1 });
+schema.index({ code: 1 });
+schema.index({ pid: 1 });
+schema.index({ status: 1 });
+
+schema.plugin(metaPlugin);
+
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('GoodsTags', schema, 'goodsTags');
+};

+ 1 - 1
app/model/user/user.js

@@ -13,7 +13,7 @@ const user = {
   birth: { type: String, required: false, zh: '生日' }, //
   gender: { type: String, required: false, zh: '性别' }, // 字典:gender
   openid: { type: String, required: false, zh: '微信小程序' }, //
-  status: { type: String, required: false, default: '0', zh: '状态' }, // 字典:user_type
+  status: { type: String, required: false, default: '0', zh: '状态' }, // 字典:user_status
 };
 const schema = new Schema(user, { toJSON: { getters: true, virtuals: true } });
 schema.index({ id: 1 });

+ 63 - 0
app/public/defaultData/dict.js

@@ -210,4 +210,67 @@ module.exports = [
       },
     ],
   },
+  {
+    name: '商品状态',
+    code: 'goods_status',
+    status: '0',
+    children: [
+      {
+        label: '未上架',
+        value: '0',
+        sort: 1,
+        status: '0',
+      },
+      {
+        label: '已上架',
+        value: '1',
+        sort: 2,
+        status: '0',
+      },
+    ],
+  },
+  {
+    name: '性别',
+    code: 'gender',
+    status: '0',
+    children: [
+      {
+        label: '女',
+        value: '0',
+        sort: 1,
+        status: '0',
+      },
+      {
+        label: '男',
+        value: '1',
+        sort: 2,
+        status: '0',
+      },
+      {
+        label: '未知',
+        value: '2',
+        sort: 3,
+        status: '0',
+      },
+    ],
+  },
+  {
+    name: '用户状态',
+    code: 'user_status',
+    status: '0',
+    children: [
+      {
+        label: '正常',
+        value: '0',
+        sort: 1,
+        status: '0',
+      },
+      {
+        label: '冻结',
+        value: '1',
+        sort: 2,
+        status: '0',
+      },
+    ],
+  },
 ];

+ 18 - 0
app/public/defaultData/goodsTags.js

@@ -0,0 +1,18 @@
+module.exports = [
+  {
+    label: '休闲食品',
+    code: 'xxsp',
+    children: [
+      {
+        label: '坚果炒货',
+        code: 'jgch',
+        children: [
+          {
+            label: '核桃',
+            code: 'ht',
+          },
+        ],
+      },
+    ],
+  },
+];

+ 20 - 0
app/service/system/goodsTags.js

@@ -0,0 +1,20 @@
+'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 GoodsTagsService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'goodstags');
+    this.model = this.ctx.model.System.GoodsTags;
+  }
+  async beforeQuery(filter) {
+    const pid = _.get(filter, 'pid');
+    if (!pid) filter.pid = { $exists: false };
+    return filter;
+  }
+}
+
+module.exports = GoodsTagsService;

+ 2 - 2
app/z_router/dev/dictData.js

@@ -9,8 +9,8 @@ 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`, middleware: [ 'password' ], name: `${ckey}Create`, zh: `创建${keyZh}` },
-  { method: 'post', path: `${rkey}/:id`, controller: `${ckey}.update`, middleware: [ 'password' ], name: `${ckey}Update`, 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}` },
 ];
 

+ 2 - 2
app/z_router/dev/dictIndex.js

@@ -9,8 +9,8 @@ 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`, middleware: [ 'password' ], name: `${ckey}Create`, zh: `创建${keyZh}` },
-  { method: 'post', path: `${rkey}/:id`, controller: `${ckey}.update`, middleware: [ 'password' ], name: `${ckey}Update`, 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}` },
 ];
 

+ 2 - 2
app/z_router/shop/goods.js

@@ -9,8 +9,8 @@ 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`, middleware: [ 'password' ], name: `${ckey}Create`, zh: `创建${keyZh}` },
-  { method: 'post', path: `${rkey}/:id`, controller: `${ckey}.update`, middleware: [ 'password' ], name: `${ckey}Update`, 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}` },
 ];
 

+ 1 - 1
app/z_router/shop/selfShop.js

@@ -9,7 +9,7 @@ const keyZh = '自营店铺';
 const routes = [
   { method: 'get', path: `${rkey}/goods`, controller: `${ckey}.goods`, middleware: [ 'dealQuery' ], name: `${ckey}Goods`, zh: `${keyZh}商品查询` },
   { method: 'get', path: `${rkey}`, controller: `${ckey}.index`, name: `${ckey}Query`, zh: `${keyZh}查询` },
-  { method: 'post', path: `${rkey}/:id`, controller: `${ckey}.update`, middleware: [ 'password' ], name: `${ckey}Update`, zh: `修改${keyZh}` },
+  { method: 'post', path: `${rkey}/:id`, controller: `${ckey}.update`, name: `${ckey}Update`, zh: `修改${keyZh}` },
 ];
 
 module.exports = app => {

+ 2 - 2
app/z_router/shop/shop.js

@@ -9,8 +9,8 @@ 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`, middleware: [ 'password' ], name: `${ckey}Create`, zh: `创建${keyZh}` },
-  { method: 'post', path: `${rkey}/:id`, controller: `${ckey}.update`, middleware: [ 'password' ], name: `${ckey}Update`, 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}` },
 ];
 

+ 2 - 2
app/z_router/system/banner.js

@@ -9,8 +9,8 @@ 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`, middleware: [ 'password' ], name: `${ckey}Create`, zh: `创建${keyZh}` },
-  { method: 'post', path: `${rkey}/:id`, controller: `${ckey}.update`, middleware: [ 'password' ], name: `${ckey}Update`, 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}` },
 ];
 

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

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

@@ -5,4 +5,5 @@ module.exports = app => {
   require('./banner')(app); // 广告图
   require('./indexModule')(app); // 图标菜单
   require('./serviceContace')(app); // 客服信息
+  require('./goodsTags')(app); // 商品标签
 };

+ 2 - 2
app/z_router/system/indexModule.js

@@ -9,8 +9,8 @@ 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`, middleware: [ 'password' ], name: `${ckey}Create`, zh: `创建${keyZh}` },
-  { method: 'post', path: `${rkey}/:id`, controller: `${ckey}.update`, middleware: [ 'password' ], name: `${ckey}Update`, 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}` },
 ];
 

+ 2 - 2
app/z_router/system/serviceContace.js

@@ -9,8 +9,8 @@ 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`, middleware: [ 'password' ], name: `${ckey}Create`, zh: `创建${keyZh}` },
-  { method: 'post', path: `${rkey}/:id`, controller: `${ckey}.update`, middleware: [ 'password' ], name: `${ckey}Update`, 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}` },
 ];
 

+ 2 - 2
app/z_router/trade/afterSale.js

@@ -9,8 +9,8 @@ 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`, middleware: [ 'password' ], name: `${ckey}Create`, zh: `创建${keyZh}` },
-  { method: 'post', path: `${rkey}/:id`, controller: `${ckey}.update`, middleware: [ 'password' ], name: `${ckey}Update`, 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}` },
 ];
 

+ 2 - 2
app/z_router/trade/order.js

@@ -9,8 +9,8 @@ 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`, middleware: [ 'password' ], name: `${ckey}Create`, zh: `创建${keyZh}` },
-  { method: 'post', path: `${rkey}/:id`, controller: `${ckey}.update`, middleware: [ 'password' ], name: `${ckey}Update`, 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}` },
 ];
 

+ 2 - 2
app/z_router/trade/orderDetail.js

@@ -9,8 +9,8 @@ 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`, middleware: [ 'password' ], name: `${ckey}Create`, zh: `创建${keyZh}` },
-  { method: 'post', path: `${rkey}/:id`, controller: `${ckey}.update`, middleware: [ 'password' ], name: `${ckey}Update`, 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}` },
 ];