Browse Source

菜单增加字段

nihao 5 years ago
parent
commit
53481a38ef

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

@@ -4,14 +4,14 @@ module.exports = {
     "parameters": {
       "query": ["!site"],
     },
-    "requestBody": ["!moudle", "!name", "picurl", "description", "inMenu", "showModes", "isAudit", "attachment", "issuer"],
+    "requestBody": ["!moudle", "!columnname", "picurl", "description", "inMenu", "showModes", "isAudit", "attachment", "issuer"],
   },
   // 修改栏目
   "update": {
     "parameters": {
       "params": ["!id"],
     },
-    "requestBody": ["moudle", "name", "picurl", "description", "inMenu", "showModes", "isAudit", "attachment", "issuer"],
+    "requestBody": ["moudle", "columnname", "picurl", "description", "inMenu", "showModes", "isAudit", "attachment", "issuer"],
     // "options": {
     //   "projection": "+name",
     // },

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

@@ -4,14 +4,14 @@ module.exports = {
     "parameters": {
       "query": ["!site"],
     },
-    "requestBody": ["parentId", "!name", "picurl", "description", "isShow", "attachment", "issuer"],
+    "requestBody": ["parent_id", "!level", "parent_name", "path", "!name", "picurl", "description", "isShow", "attachment", "issuer"],
   },
   // 修改菜单
   "update": {
     "parameters": {
       "params": ["!id"],
     },
-    "requestBody": ["parentId", "!name", "picurl", "description", "isShow", "attachment", "issuer"],
+    "requestBody": ["parent_id", "!level", "parent_name", "path","!name", "picurl", "description", "isShow", "attachment", "issuer"],
     // "options": {
     //   "projection": "+name",
     // },
@@ -40,7 +40,7 @@ module.exports = {
   // 后台查询菜单列表
   "query": {
     "parameters": {
-      "query": ["!site"],
+      "query": ["!site", "level"],
       "options": {
         "meta.state": 0, // 只显示未删除数据
       },

+ 6 - 3
app/controller/.news.js

@@ -9,7 +9,7 @@ module.exports = {
   // 修改新闻信息
   "update": {
     "parameters": {
-      "query": ["!id"],
+      "params": ["!id"],
     },
     "requestBody": ["title", "content", "picurl", "top", "tags", "attachment", "issuer"],
     "options": {
@@ -19,7 +19,7 @@ module.exports = {
   // 获取新闻详情
   "fetch": {
     "parameters": {
-      "query": ["!id"],
+      "params": ["!id"],
     },
     "options": {
       "projection": "+content",
@@ -28,7 +28,7 @@ module.exports = {
   // 删除新闻
   "delete": {
     "parameters": {
-      "query": ["!id"],
+      "params": ["!id"],
     },
   },
   // 恢复新闻
@@ -41,6 +41,9 @@ module.exports = {
   "query": {
     "parameters": {
       "query": ["!column"],
+      "options": {
+        "meta.state": 0, // 只显示未删除数据
+      },
     },
     "service": "query",
     "options": {

+ 5 - 5
app/controller/.site.js

@@ -2,15 +2,15 @@ module.exports = {
   // 添加分站信息
   "create": {
     "parameters": {
-      "requestBody": ["!name", "!site", "!domain", "banner", "!copyright", "theme", "!content"],
+      "requestBody": ["!name", "!site", "!domain", "banner", "!copyright", "theme", "remark", "!content"],
     },
   },
   // 修改分站信息
   "update": {
     "parameters": {
-      "query": ["!site"],
+      "params": ["!site"],
     },
-    "requestBody": ["name", "domain", "banner", "copyright", "theme", "content"],
+    "requestBody": ["name", "domain", "banner", "copyright", "theme", "remark","content"],
     "options": {
       "projection": "+content",
     },
@@ -18,7 +18,7 @@ module.exports = {
   // 获取分站详情
   "fetch": {
     "parameters": {
-      "query": ["!site"],
+      "params": ["!site"],
     },
     "options": {
       "projection": "+content",
@@ -27,7 +27,7 @@ module.exports = {
   // 删除分站信息
   "delete": {
     "parameters": {
-      "query": ["!site"],
+      "params": ["!site"],
     },
   },
   // 【管理端】查询分站列表

+ 1 - 1
app/model/column.js

@@ -15,7 +15,7 @@ const Attachment = new Schema({
 const SchemaDefine = {
   site: { type: String, required: true, maxLength: 64 }, // 归属站点
   moudle: { type: String, required: true, maxLength: 20 }, // 栏目模块
-  name: { type: String, required: true, maxLength: 100 }, // 栏目名称
+  columnname: { type: String, required: true, maxLength: 100 }, // 栏目名称
   picurl: { type: String, required: false, maxLength: 256 }, // 栏目图片URL
   description: { type: String, required: false, maxLength: 256 }, // 栏目描述
   inMenu: { type: String, required: false, maxLength: 5 }, // 是否在菜单中显示

+ 4 - 1
app/model/menu.js

@@ -14,7 +14,10 @@ const Attachment = new Schema({
 // 栏目信息
 const SchemaDefine = {
   site: { type: String, required: true, maxLength: 64 }, // 归属站点
-  parentId: { type: String, required: false, maxLength: 64 }, // 父级ID
+  parent_id: { type: String, required: false, maxLength: 64 }, // 父级ID
+  parent_name: { type: String, required: false, maxLength: 64 }, // 父级名称
+  level: { type: String, required: false, maxLength: 5 }, // 层级
+  path: { type: String, required: false, maxLength: 500 }, // 路径
   name: { type: String, required: true, maxLength: 100 }, // 菜单名称
   picurl: { type: String, required: false, maxLength: 256 }, // 栏目图片URL
   description: { type: String, required: false, maxLength: 256 }, // 栏目描述

+ 7 - 7
app/router.js

@@ -21,11 +21,11 @@ module.exports = app => {
   // 管理接口
   // 【分站】新闻接口
   router.get('/adminapi/news/query', controller.news.query);// 查询新闻信息
-  router.get('/adminapi/news/fetch', controller.news.fetch);// 获得新闻详情
+  router.get('/adminapi/news/fetch/:id', controller.news.fetch);// 获得新闻详情
   router.post('/adminapi/news/create', controller.news.create);// 发布新闻信息
-  router.post('/adminapi/news/update', controller.news.update);// 修改新闻信息
-  router.post('/adminapi/news/delete', controller.news.delete);// 删除新闻信息
-  router.post('/adminapi/news/restore', controller.news.restore);// 恢复新闻信息
+  router.post('/adminapi/news/update/:id', controller.news.update);// 修改新闻信息
+  router.post('/adminapi/news/delete/:id', controller.news.delete);// 删除新闻信息
+  router.post('/adminapi/news/restore/:id', controller.news.restore);// 恢复新闻信息
 
   // 栏目接口
   // 【分站】栏目接口
@@ -50,8 +50,8 @@ module.exports = app => {
   router.post('/adminapi/site/config', controller.site.config_set);// 分站配置自身
   // 系统管理员管理接口
   router.get('/adminapi/site/query', controller.site.query);// 查询分站信息
-  router.get('/adminapi/site/fetch', controller.site.fetch);// 获得分站详情
+  router.get('/adminapi/site/fetch/:site', controller.site.fetch);// 获得分站详情
   router.post('/adminapi/site/create', controller.site.create);// 发布分站信息
-  router.post('/adminapi/site/update', controller.site.update);// 修改分站信息
-  router.post('/adminapi/site/delete', controller.site.delete);// 删除分站信息
+  router.post('/adminapi/site/update/:site', controller.site.update);// 修改分站信息
+  router.post('/adminapi/site/delete/:site', controller.site.delete);// 删除分站信息
 };

+ 6 - 6
app/service/column.js

@@ -12,11 +12,11 @@ class ColumnService extends CrudService {
     this.model = this.ctx.model.Column;
   }
 
-  async create({ site }, { moudle, name, picurl, description, inMenu, showModes, isAudit, issuer }) {
+  async create({ site }, { moudle, columnname, picurl, description, inMenu, showModes, isAudit, issuer }) {
     // 检查数据
     assert(_.isString(site), 'site不能为空');
     assert(_.isString(moudle), 'moudle不能为空');
-    assert(_.isString(name), 'name不能为空');
+    assert(_.isString(columnname), 'columnname不能为空');
     assert(!picurl || _.isString(picurl), 'picurl必须为字符串');
     assert(!description || _.isString(description), 'description必须为字符串');
     assert(!inMenu || _.isString(inMenu), 'inMenu必须为字符串');
@@ -30,7 +30,7 @@ class ColumnService extends CrudService {
 
     // TODO:保存数据
     const data = {
-      site , moudle, name, picurl, description, inMenu, showModes, isAudit, issuer,
+      site, moudle, columnname, picurl, description, inMenu, showModes, isAudit, issuer,
       meta: { createdBy: userid },
     };
     
@@ -40,11 +40,11 @@ class ColumnService extends CrudService {
 
   async update({ id }, payload) {
     // 检查数据
-    const { moudle, name, picurl, description, inMenu, showModes, isAudit, issuer } = payload;
+    const { moudle, columnname, picurl, description, inMenu, showModes, isAudit, issuer } = payload;
     assert(id, 'id不能为空');
     // assert(_.isString(site), 'site不能为空');
     assert(_.isString(moudle), 'moudle不能为空');
-    assert(_.isString(name), 'name不能为空');
+    assert(_.isString(columnname), 'columnname不能为空');
     assert(!picurl || _.isString(picurl), 'picurl必须为字符串');
     assert(!description || _.isString(description), 'description必须为字符串');
     assert(!inMenu || _.isString(inMenu), 'inMenu必须为字符串');
@@ -65,7 +65,7 @@ class ColumnService extends CrudService {
     // TODO:保存数据
     const data = trimData(payload);
     await this.model.findByIdAndUpdate(doc.id, { ...data, 'meta.updatedBy': userid }, { new: true }).exec();
-    const res = this.model.findById(id, '+name').exec();
+    const res = this.model.findById(id, '+columnname').exec();
     return res;
   }
 

+ 11 - 5
app/service/menu.js

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