瀏覽代碼

新曾字段position

nihao 5 年之前
父節點
當前提交
b7c487fe40
共有 4 個文件被更改,包括 19 次插入17 次删除
  1. 1 1
      app/controller/.column.js
  2. 7 5
      app/controller/.menu.js
  3. 7 7
      app/model/menu.js
  4. 4 4
      app/service/menu.js

+ 1 - 1
app/controller/.column.js

@@ -67,7 +67,7 @@ module.exports = {
     "service": "query",
     "options": {
       "query": ["skip", "limit"],
-      "sort": ["top", "meta.createdAt"],
+      "sort": ["meta.createdAt"],
       "desc": true,
       "count": true,
       "projection": {

+ 7 - 5
app/controller/.menu.js

@@ -4,14 +4,14 @@ module.exports = {
     "parameters": {
       "query": ["!site"],
     },
-    "requestBody": ["parent_id", "!level", "parent_name", "path", "position",  "!name", "picurl", "description", "isShow", "attachment", "issuer"],
+    "requestBody": ["parent_id", "level", "parent_name", "path", "position",  "name", "picurl", "description", "isShow", "issuer"],
   },
   // 修改菜单
   "update": {
     "parameters": {
       "params": ["!id"],
     },
-    "requestBody": ["parent_id", "!level", "parent_name", "path", "position","!name", "picurl", "description", "isShow", "attachment", "issuer"],
+    "requestBody": ["parent_id", "level", "parent_name", "path", "position","name", "picurl", "description", "isShow", "issuer"],
     // "options": {
     //   "projection": "+name",
     // },
@@ -43,13 +43,15 @@ module.exports = {
       "query": ["!site", "level"],
       "options": {
         "meta.state": 0, // 只显示未删除数据
+        // "sort": ["position"],
+        // "desc": true,
       },
     },
     "service": "query",
     "options": {
       "query": ["skip", "limit"],
-      "sort": ["meta.createdAt"],
-      "desc": true,
+      "sort": ["position","meta.createdAt"],
+      "desc": false,
       "count": true,
       "projection": {
         "attachment": 0
@@ -67,7 +69,7 @@ module.exports = {
     "service": "query",
     "options": {
       "query": ["skip", "limit"],
-      "sort": ["top", "meta.createdAt"],
+      "sort": ["meta.createdAt"],
       "desc": true,
       "count": true,
       "projection": {

+ 7 - 7
app/model/menu.js

@@ -6,10 +6,10 @@ const Schema = require('mongoose').Schema;
 const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
 
 // 附件信息
-const Attachment = new Schema({
-  name: { type: String, maxLength: 128 },
-  uri: { type: String, maxLength: 128 },
-}, { _id: false });
+// const Attachment = new Schema({
+//   name: { type: String, maxLength: 128 },
+//   uri: { type: String, maxLength: 128 },
+// }, { _id: false });
 
 // 栏目信息
 const SchemaDefine = {
@@ -18,12 +18,12 @@ 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 }, // 菜单名称
+  position: { type: Number, required: false, maxLength: 5 }, // 位置
+  name: { type: String, required: false, maxLength: 100 }, // 菜单名称
   picurl: { type: String, required: false, maxLength: 256 }, // 栏目图片URL
   description: { type: String, required: false, maxLength: 256 }, // 栏目描述
   isShow: { type: String, required: false, maxLength: 5 }, // 是否需要审核
-  attachment: [ Attachment ], // 附件
+  // attachment: [ Attachment ], // 附件
   issuer: String, // 栏目单位
   meta: {
     createdBy: String, // 创建用户

+ 4 - 4
app/service/menu.js

@@ -17,10 +17,10 @@ class MenuService extends CrudService {
     assert(_.isString(site), 'site不能为空');
     assert(!level || _.isString(level), 'level不能为空');
     assert(!path || _.isString(path), 'path不能为空');
-    assert(!position || _.isString(position), 'position不能为空');
+    assert(!position || _.isNumber(position), 'position不能为空');
     assert(!parent_id || _.isString(parent_id), 'parent_id不能为空');
     assert(!parent_name || _.isString(parent_name), 'parent_name不能为空');
-    assert(_.isString(name), 'name不能为空');
+    assert(!name || _.isString(name), 'name不能为空');
     assert(!picurl || _.isString(picurl), 'picurl必须为字符串');
     assert(!description || _.isString(description), 'description必须为字符串');
     assert(!isShow || _.isString(isShow), 'isShow必须为字符串');
@@ -46,10 +46,10 @@ class MenuService extends CrudService {
     assert(id, 'id不能为空');
     assert(!parent_id || _.isString(parent_id), 'parent_id不能为空');
     assert(!level || _.isString(level), 'level不能为空');
-    assert(!position || _.isString(position), 'position不能为空');
+    assert(!position || _.isNumber(position), 'position不能为空');
     assert(!path || _.isString(path), 'path不能为空');
     assert(!parent_name || _.isString(parent_name), 'parent_name不能为空');
-    assert(_.isString(name), 'name不能为空');
+    assert(!name || _.isString(name), 'name不能为空');
     assert(!picurl || _.isString(picurl), 'picurl必须为字符串');
     assert(!description || _.isString(description), 'description必须为字符串');
     assert(!isShow || _.isString(isShow), 'isShow必须为字符串');