Commit 58369355 by guojuxing

编辑子页面接口修改:判断父级层级和当前层级,一验证父级ID参数

parent 2e8ad2d2
......@@ -142,6 +142,7 @@ public class MenuApiServiceImpl implements MenuApiService {
if (record == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "父级页面不存在");
}
menuDTO.setMenuVersion("_" + menuDTO.getMenuVersion().replaceAll(",", "_") + "_");
//sort
int maxSort = menuService.getMaxSortByParentId(menuDTO.getParentId(), menuDTO.getProject());
menuDTO.setSort(maxSort + 1);
......@@ -174,8 +175,20 @@ public class MenuApiServiceImpl implements MenuApiService {
if (parent == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "父级页面不存在");
}
TabSysMenu record = menuService.getMenuById(menuDTO.getMenuId());
if (record == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "主键参数有误,查无数据");
}
if (parent.getLevel().intValue() >= record.getLevel().intValue()) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "父级ID有误,层级在当前页面之下");
}
ServiceResponse paramsValid = ValidParamsUtils.allCheckValidate(menuDTO, clazz);
if (!paramsValid.isSuccess()) {
return paramsValid;
}
menuDTO.setMenuVersion("_" + menuDTO.getMenuVersion().replaceAll(",", "_") + "_");
menuService.updatePage(menuDTO);
return updatePage(menuDTO, clazz);
return ServiceResponse.success();
}
private List<MenuDTO> treeMenu(List<TabSysMenu> menuList, int level, int parentId) {
......
......@@ -5,7 +5,9 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.gic.auth.constant.GicVersionEnum;
import com.gic.auth.constant.MenuLevelConstants;
import org.apache.commons.lang.StringUtils;
import org.apache.dubbo.rpc.RpcContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -132,7 +134,7 @@ public class MenuController {
data.put("sort", menuDTO.getSort());
data.put("menuCode", menuDTO.getMenuCode());
data.put("parentCode", menuDTO.getParentCode());
data.put("menuVersion", menuDTO.getMenuVersion());
data.put("menuVersion", getMenuVersionStr(menuDTO.getMenuVersion()));
List<Map<String, Object>> children = changeListToTree(menuDTO.getMenuId(), list);
if (children == null || children.size() < 1) {
data.put("children", null);
......@@ -145,4 +147,20 @@ public class MenuController {
}
return result;
}
private static String getMenuVersionStr(String menuVersion) {
if (StringUtils.isBlank(menuVersion)) {
return null;
}
String[] menuVersionArr = menuVersion.split("_");
StringBuilder result = new StringBuilder();
for (String str : menuVersionArr) {
if (StringUtils.isBlank(str)) {
continue;
}
result.append(GicVersionEnum.getMessageByCode(Integer.parseInt(str))).append("/");
}
String menuVersionStr = result.toString();
return menuVersionStr.substring(0, menuVersionStr.length() - 1);
}
}
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