菜单管理增加上移下移
This commit is contained in:
parent
cbbe048cfa
commit
9a2324a847
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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'
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue