From 9a2324a847539406b00a44d3aedddc7ade4a7dca Mon Sep 17 00:00:00 2001 From: shuzheng <469741414@qq.com> Date: Sat, 18 Mar 2017 23:37:17 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8F=9C=E5=8D=95=E7=AE=A1=E7=90=86=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E4=B8=8A=E7=A7=BB=E4=B8=8B=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/manage/CmsMenuController.java | 60 +++++++ .../webapp/WEB-INF/jsp/manage/menu/index.jsp | 154 ++++++++++++++++++ 2 files changed, 214 insertions(+) diff --git a/zheng-cms/zheng-cms-admin/src/main/java/com/zheng/cms/admin/controller/manage/CmsMenuController.java b/zheng-cms/zheng-cms-admin/src/main/java/com/zheng/cms/admin/controller/manage/CmsMenuController.java index c9c3dccf..aa9ad91e 100644 --- a/zheng-cms/zheng-cms-admin/src/main/java/com/zheng/cms/admin/controller/manage/CmsMenuController.java +++ b/zheng-cms/zheng-cms-admin/src/main/java/com/zheng/cms/admin/controller/manage/CmsMenuController.java @@ -129,4 +129,64 @@ public class CmsMenuController extends BaseController { return new CmsResult(CmsResultConstant.SUCCESS, count); } + @ApiOperation(value = "上移菜单") + @RequiresPermissions("cms:menu:up") + @RequestMapping(value = "/up/{id}", method = RequestMethod.GET) + @ResponseBody + public Object up(@PathVariable("id") int id) { + CmsMenu cmsMenu = cmsMenuService.selectByPrimaryKey(id); + if (null == cmsMenu) { + return new CmsResult(CmsResultConstant.INVALID_PARAMETER, "无效参数!"); + } + CmsMenuExample cmsMenuExample = new CmsMenuExample(); + CmsMenuExample.Criteria criteria = cmsMenuExample.createCriteria(); + if (null == cmsMenu.getPid()) { + criteria.andPidIsNull(); + } else { + criteria.andPidEqualTo(cmsMenu.getPid()); + } + criteria.andOrdersLessThan(cmsMenu.getOrders()); + cmsMenuExample.setOrderByClause("orders desc"); + CmsMenu upCmsMenu = cmsMenuService.selectFirstByExample(cmsMenuExample); + if (null == upCmsMenu) { + return new CmsResult(CmsResultConstant.FAILED, "不能上移了!"); + } + long tempOrders = upCmsMenu.getOrders(); + upCmsMenu.setOrders(cmsMenu.getOrders()); + cmsMenu.setOrders(tempOrders); + cmsMenuService.updateByPrimaryKeySelective(cmsMenu); + cmsMenuService.updateByPrimaryKeySelective(upCmsMenu); + return new CmsResult(CmsResultConstant.SUCCESS, 1); + } + + @ApiOperation(value = "下移菜单") + @RequiresPermissions("cms:menu:down") + @RequestMapping(value = "/down/{id}", method = RequestMethod.GET) + @ResponseBody + public Object down(@PathVariable("id") int id) { + CmsMenu cmsMenu = cmsMenuService.selectByPrimaryKey(id); + if (null == cmsMenu) { + return new CmsResult(CmsResultConstant.INVALID_PARAMETER, "无效参数!"); + } + CmsMenuExample cmsMenuExample = new CmsMenuExample(); + CmsMenuExample.Criteria criteria = cmsMenuExample.createCriteria(); + if (null == cmsMenu.getPid()) { + criteria.andPidIsNull(); + } else { + criteria.andPidEqualTo(cmsMenu.getPid()); + } + criteria.andOrdersGreaterThan(cmsMenu.getOrders()); + cmsMenuExample.setOrderByClause("orders asc"); + CmsMenu upCmsMenu = cmsMenuService.selectFirstByExample(cmsMenuExample); + if (null == upCmsMenu) { + return new CmsResult(CmsResultConstant.FAILED, "不能下移了!"); + } + long tempOrders = upCmsMenu.getOrders(); + upCmsMenu.setOrders(cmsMenu.getOrders()); + cmsMenu.setOrders(tempOrders); + cmsMenuService.updateByPrimaryKeySelective(cmsMenu); + cmsMenuService.updateByPrimaryKeySelective(upCmsMenu); + return new CmsResult(CmsResultConstant.SUCCESS, 1); + } + } \ No newline at end of file diff --git a/zheng-cms/zheng-cms-admin/src/main/webapp/WEB-INF/jsp/manage/menu/index.jsp b/zheng-cms/zheng-cms-admin/src/main/webapp/WEB-INF/jsp/manage/menu/index.jsp index 793bb76f..9a75f2cd 100644 --- a/zheng-cms/zheng-cms-admin/src/main/webapp/WEB-INF/jsp/manage/menu/index.jsp +++ b/zheng-cms/zheng-cms-admin/src/main/webapp/WEB-INF/jsp/manage/menu/index.jsp @@ -50,6 +50,8 @@ $(function() { escape: true, searchOnEnterKey: true, idField: 'menuId', + sortName: 'orders', + sortOrder: 'asc', maintainSelected: true, toolbar: '#toolbar', columns: [ @@ -212,6 +214,158 @@ function deleteAction() { }); } } +// 上移 +function upAction() { + var rows = $table.bootstrapTable('getSelections'); + if (rows.length != 1) { + $.confirm({ + title: false, + content: '请选择一条记录!', + autoClose: 'cancel|3000', + backgroundDismiss: true, + buttons: { + cancel: { + text: '取消', + btnClass: 'waves-effect waves-button' + } + } + }); + } else { + $.ajax({ + type: 'get', + url: '${basePath}/manage/menu/up/' + rows[0].menuId, + beforeSend: function() {}, + success: function(result) { + if (result.code != 1) { + if (result.data instanceof Array) { + $.each(result.data, function(index, value) { + $.confirm({ + theme: 'dark', + animation: 'rotateX', + closeAnimation: 'rotateX', + title: false, + content: value.errorMsg, + buttons: { + confirm: { + text: '确认', + btnClass: 'waves-effect waves-button waves-light' + } + } + }); + }); + } else { + $.confirm({ + theme: 'dark', + animation: 'rotateX', + closeAnimation: 'rotateX', + title: false, + content: result.data, + buttons: { + confirm: { + text: '确认', + btnClass: 'waves-effect waves-button waves-light' + } + } + }); + } + } else { + $table.bootstrapTable('refresh'); + } + }, + error: function(XMLHttpRequest, textStatus, errorThrown) { + $.confirm({ + theme: 'dark', + animation: 'rotateX', + closeAnimation: 'rotateX', + title: false, + content: textStatus, + buttons: { + confirm: { + text: '确认', + btnClass: 'waves-effect waves-button waves-light' + } + } + }); + } + }); + } +} +// 下移 +function downAction() { + var rows = $table.bootstrapTable('getSelections'); + if (rows.length != 1) { + $.confirm({ + title: false, + content: '请选择一条记录!', + autoClose: 'cancel|3000', + backgroundDismiss: true, + buttons: { + cancel: { + text: '取消', + btnClass: 'waves-effect waves-button' + } + } + }); + } else { + $.ajax({ + type: 'get', + url: '${basePath}/manage/menu/down/' + rows[0].menuId, + beforeSend: function() {}, + success: function(result) { + if (result.code != 1) { + if (result.data instanceof Array) { + $.each(result.data, function(index, value) { + $.confirm({ + theme: 'dark', + animation: 'rotateX', + closeAnimation: 'rotateX', + title: false, + content: value.errorMsg, + buttons: { + confirm: { + text: '确认', + btnClass: 'waves-effect waves-button waves-light' + } + } + }); + }); + } else { + $.confirm({ + theme: 'dark', + animation: 'rotateX', + closeAnimation: 'rotateX', + title: false, + content: result.data, + buttons: { + confirm: { + text: '确认', + btnClass: 'waves-effect waves-button waves-light' + } + } + }); + } + } else { + $table.bootstrapTable('refresh'); + } + }, + error: function(XMLHttpRequest, textStatus, errorThrown) { + $.confirm({ + theme: 'dark', + animation: 'rotateX', + closeAnimation: 'rotateX', + title: false, + content: textStatus, + buttons: { + confirm: { + text: '确认', + btnClass: 'waves-effect waves-button waves-light' + } + } + }); + } + }); + } +} \ No newline at end of file