Browse Source

menu增加字段

nihao 5 years ago
parent
commit
af7bfcf05e
3 changed files with 8 additions and 5 deletions
  1. 2 2
      app/controller/.menu.js
  2. 1 0
      app/model/menu.js
  3. 5 3
      app/service/menu.js

+ 2 - 2
app/controller/.menu.js

@@ -4,14 +4,14 @@ module.exports = {
     "parameters": {
       "query": ["!site"],
     },
-    "requestBody": ["parent_id", "!level", "parent_name", "path", "!name", "picurl", "description", "isShow", "attachment", "issuer"],
+    "requestBody": ["parent_id", "!level", "parent_name", "path", "position",  "!name", "picurl", "description", "isShow", "attachment", "issuer"],
   },
   // 修改菜单
   "update": {
     "parameters": {
       "params": ["!id"],
     },
-    "requestBody": ["parent_id", "!level", "parent_name", "path","!name", "picurl", "description", "isShow", "attachment", "issuer"],
+    "requestBody": ["parent_id", "!level", "parent_name", "path", "position","!name", "picurl", "description", "isShow", "attachment", "issuer"],
     // "options": {
     //   "projection": "+name",
     // },

+ 1 - 0
app/model/menu.js

@@ -18,6 +18,7 @@ const SchemaDefine = {
   parent_name: { type: String, required: false, maxLength: 64 }, // 父级名称
   level: { type: String, required: false, maxLength: 5 }, // 层级
   path: { type: String, required: false, maxLength: 500 }, // 路径
+  position: { type: String, required: false, maxLength: 5 }, // 位置
   name: { type: String, required: true, maxLength: 100 }, // 菜单名称
   picurl: { type: String, required: false, maxLength: 256 }, // 栏目图片URL
   description: { type: String, required: false, maxLength: 256 }, // 栏目描述

+ 5 - 3
app/service/menu.js

@@ -12,11 +12,12 @@ class MenuService extends CrudService {
     this.model = this.ctx.model.Menu;
   }
 
-  async create({ site }, { parent_id, level, parent_name, path,name, picurl, description, isShow,  issuer }) {
+  async create({ site }, { parent_id, level, parent_name, position,path,name, picurl, description, isShow,  issuer }) {
     // 检查数据
     assert(_.isString(site), 'site不能为空');
     assert(!level || _.isString(level), 'level不能为空');
     assert(!path || _.isString(path), 'path不能为空');
+    assert(!position || _.isString(position), 'position不能为空');
     assert(!parent_id || _.isString(parent_id), 'parent_id不能为空');
     assert(!parent_name || _.isString(parent_name), 'parent_name不能为空');
     assert(_.isString(name), 'name不能为空');
@@ -31,7 +32,7 @@ class MenuService extends CrudService {
 
     // TODO:保存数据
     const data = {
-      site, parent_id, parent_name, level, path,name, picurl, description, isShow, issuer,
+      site, parent_id, parent_name, level, position,path,name, picurl, description, isShow, issuer,
       meta: { createdBy: userid },
     };
 
@@ -41,10 +42,11 @@ class MenuService extends CrudService {
 
   async update({ id }, payload) {
     // 检查数据
-    const { parent_id, level, parent_name, path,name, picurl, description, isShow, issuer } = payload;
+    const { parent_id, level, parent_name, position,path,name, picurl, description, isShow, issuer } = payload;
     assert(id, 'id不能为空');
     assert(!parent_id || _.isString(parent_id), 'parent_id不能为空');
     assert(!level || _.isString(level), 'level不能为空');
+    assert(!position || _.isString(position), 'position不能为空');
     assert(!path || _.isString(path), 'path不能为空');
     assert(!parent_name || _.isString(parent_name), 'parent_name不能为空');
     assert(_.isString(name), 'name不能为空');