Commit 92e9e66e by naan1993

Merge branch 'master' into dev

parents 7cf19620 3d632329
......@@ -46,6 +46,8 @@ public enum BizExceptionEnum {
/**
* 错误的请求
*/
MENU_PCODE_COINCIDENCE(400,"菜单编号和副编号不能一致"),
EXISTED_THE_MENU(400,"菜单编号重复,不能添加"),
DICT_MUST_BE_NUMBER(400,"字典的值必须为数字"),
REQUEST_NULL(400, "请求有错误"),
SESSION_TIMEOUT(400, "会话超时"),
......
......@@ -140,6 +140,13 @@ public class MenuController extends BaseController {
if (result.hasErrors()) {
throw new BussinessException(BizExceptionEnum.REQUEST_NULL);
}
//判断是否存在该编号
String existedMenuName = ConstantFactory.me().getMenuNameByCode(menu.getCode());
if (ToolUtil.isNotEmpty(existedMenuName)) {
throw new BussinessException(BizExceptionEnum.EXISTED_THE_MENU);
}
//设置父级菜单编号
menuSetPcode(menu);
......@@ -223,12 +230,19 @@ public class MenuController extends BaseController {
private void menuSetPcode(@Valid Menu menu) {
if (ToolUtil.isEmpty(menu.getPcode()) || menu.getPcode().equals("0")) {
menu.setPcode("0");
menu.setPcodes("[0],");
menu.setLevels(1);
} else {
int code = Integer.parseInt(menu.getPcode());
Menu pMenu = menuMapper.selectById(code);
Integer pLevels = pMenu.getLevels();
menu.setPcode(pMenu.getCode());
//如果编号和父编号一致会导致无限递归
if (menu.getCode().equals(menu.getPcode())) {
throw new BussinessException(BizExceptionEnum.MENU_PCODE_COINCIDENCE);
}
menu.setLevels(pLevels + 1);
menu.setPcodes(pMenu.getPcodes() + "[" + pMenu.getCode() + "],");
}
......
......@@ -32,6 +32,13 @@ var MenuInfoDlg = {
message: '请求地址不能为空'
}
}
},
num: {
validators: {
notEmpty: {
message: '序号不能为空'
}
}
}
}
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment