提交代码

master
胡锐 7 months ago committed by yuanye
parent 0ad4d69b8f
commit 24244a0572
  1. 50
      bweb/src/main/java/com/bweb/controller/SecMenuController.java
  2. 19
      service/src/main/java/com/hfkj/dao/SecMenuMapper.java
  3. 14
      service/src/main/java/com/hfkj/dao/SecMenuSqlProvider.java
  4. 16
      service/src/main/java/com/hfkj/entity/SecMenu.java
  5. 70
      service/src/main/java/com/hfkj/entity/SecMenuExample.java
  6. 2
      service/src/main/java/com/hfkj/service/impl/SecMenuServiceImpl.java

@ -19,8 +19,6 @@ import com.hfkj.sysenum.SecMenuTypeEnum;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
@ -77,7 +75,6 @@ public class SecMenuController {
if (parentMenu == null) { if (parentMenu == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
} }
secMenu.setMenuFullUrl(secMenu.getMenuFullUrl()+"/"+secMenu.getMenuUrl());
} }
secMenu.setMenuType(body.getMenuType()); secMenu.setMenuType(body.getMenuType());
@ -177,10 +174,39 @@ public class SecMenuController {
try { try {
// 查询角色菜单权限 // 查询角色菜单权限
List<SecRoleMenuRel> roleMenuList = secRoleMenuRelService.getRelListByRole(roleId); Map<Long, SecMenu> roleMenu = secMenuService.queryRoleMenu(roleId, SecMenuTypeEnum.type1).stream()
.collect(Collectors.toMap(SecMenu::getId, Function.identity()));
return ResponseMsgUtil.success(roleMenuList.stream().map(SecRoleMenuRel::getMenuId).collect(Collectors.toList()) // 系统菜单叶节点
.stream().map(Object::toString).collect(Collectors.toList())); List<String> menuLeafList = new ArrayList<>();
// 角色菜单叶节点
List<String> roleLeafList = new ArrayList<>();
// 获取全部菜单
List<SecMenu> menuList = secMenuService.getAllList();
// 获取最顶层菜单
List<SecMenu> topLevelMenuList = menuList.stream()
.filter(o -> o.getMenuPSid() == null)
.sorted(Comparator.comparing(SecMenu::getMenuSort))
.collect(Collectors.toList());
// 递归获取系统菜单叶子节点
for (SecMenu topLevelMenu : topLevelMenuList) {
if (topLevelMenu.getMenuType().equals(SecMenuTypeEnum.type1.getCode())) {
recursionMenu(menuList, topLevelMenu.getId(), menuLeafList);
}
}
// 筛选角色菜单叶节点
for (String leaf : menuLeafList) {
SecMenu menu = roleMenu.get(Long.parseLong(leaf));
if (menu != null) {
roleLeafList.add(""+menu.getId());
}
}
return ResponseMsgUtil.success(roleLeafList);
} catch (Exception e) { } catch (Exception e) {
log.error("error!",e); log.error("error!",e);
@ -221,11 +247,11 @@ public class SecMenuController {
for (SecMenu topLevelMenu : topLevelMenuList) { for (SecMenu topLevelMenu : topLevelMenuList) {
if (topLevelMenu.getMenuType().equals(SecMenuTypeEnum.type1.getCode())) { if (topLevelMenu.getMenuType().equals(SecMenuTypeEnum.type1.getCode())) {
map = new HashMap<>(); map = new LinkedHashMap<>();
map.put("key", ""+topLevelMenu.getId()); map.put("key", ""+topLevelMenu.getId());
map.put("title", topLevelMenu.getMenuName()); map.put("title", topLevelMenu.getMenuName());
// 获取下级菜单 // 获取下级菜单
map.put("children", recursionMenu(menuList, topLevelMenu.getId())); map.put("children", recursionMenu(menuList, topLevelMenu.getId(), new ArrayList<>()));
mapList.add(map); mapList.add(map);
} }
} }
@ -244,7 +270,7 @@ public class SecMenuController {
* @param parentMenuId 父级菜单id * @param parentMenuId 父级菜单id
* @return * @return
*/ */
public List<Map<String,Object>> recursionMenu(List<SecMenu> dataSource, Long parentMenuId) { public List<Map<String,Object>> recursionMenu(List<SecMenu> dataSource, Long parentMenuId, List<String> leaf) {
List<Map<String,Object>> mapList = new ArrayList<>(); List<Map<String,Object>> mapList = new ArrayList<>();
Map<String,Object> map; Map<String,Object> map;
@ -254,12 +280,13 @@ public class SecMenuController {
.collect(Collectors.toList()); .collect(Collectors.toList());
for (SecMenu menu : collect) { for (SecMenu menu : collect) {
if (menu.getMenuType().equals(SecMenuTypeEnum.type1.getCode())) { if (menu.getMenuType().equals(SecMenuTypeEnum.type1.getCode())) {
map = new HashMap<>(); map = new LinkedHashMap<>();
map.put("key", ""+menu.getId()); map.put("key", ""+menu.getId());
map.put("title", menu.getMenuName()); map.put("title", menu.getMenuName());
// 获取下级菜单 // 获取下级菜单
List<Map<String, Object>> recursioned = recursionMenu(dataSource, menu.getId()); List<Map<String, Object>> recursioned = recursionMenu(dataSource, menu.getId(), leaf);
if (recursioned.isEmpty()) { if (recursioned.isEmpty()) {
leaf.add(""+menu.getId());
map.put("isLeaf", true); map.put("isLeaf", true);
} else { } else {
map.put("children", recursioned); map.put("children", recursioned);
@ -270,4 +297,5 @@ public class SecMenuController {
return mapList; return mapList;
} }
} }

@ -41,14 +41,14 @@ public interface SecMenuMapper extends SecMenuMapperExt {
@Insert({ @Insert({
"insert into sec_menu (menu_name, menu_type, ", "insert into sec_menu (menu_name, menu_type, ",
"menu_url, menu_url_img, ", "menu_url, menu_url_img, ",
"menu_full_url, menu_p_sid, ", "menu_p_sid, menu_sort, ",
"menu_sort, menu_desc, ", "menu_desc, create_time, ",
"create_time, update_time)", "update_time)",
"values (#{menuName,jdbcType=VARCHAR}, #{menuType,jdbcType=INTEGER}, ", "values (#{menuName,jdbcType=VARCHAR}, #{menuType,jdbcType=INTEGER}, ",
"#{menuUrl,jdbcType=VARCHAR}, #{menuUrlImg,jdbcType=VARCHAR}, ", "#{menuUrl,jdbcType=VARCHAR}, #{menuUrlImg,jdbcType=VARCHAR}, ",
"#{menuFullUrl,jdbcType=VARCHAR}, #{menuPSid,jdbcType=BIGINT}, ", "#{menuPSid,jdbcType=BIGINT}, #{menuSort,jdbcType=INTEGER}, ",
"#{menuSort,jdbcType=INTEGER}, #{menuDesc,jdbcType=VARCHAR}, ", "#{menuDesc,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, ",
"#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})" "#{updateTime,jdbcType=TIMESTAMP})"
}) })
@Options(useGeneratedKeys=true,keyProperty="id") @Options(useGeneratedKeys=true,keyProperty="id")
int insert(SecMenu record); int insert(SecMenu record);
@ -64,7 +64,6 @@ public interface SecMenuMapper extends SecMenuMapperExt {
@Result(column="menu_type", property="menuType", jdbcType=JdbcType.INTEGER), @Result(column="menu_type", property="menuType", jdbcType=JdbcType.INTEGER),
@Result(column="menu_url", property="menuUrl", jdbcType=JdbcType.VARCHAR), @Result(column="menu_url", property="menuUrl", jdbcType=JdbcType.VARCHAR),
@Result(column="menu_url_img", property="menuUrlImg", jdbcType=JdbcType.VARCHAR), @Result(column="menu_url_img", property="menuUrlImg", jdbcType=JdbcType.VARCHAR),
@Result(column="menu_full_url", property="menuFullUrl", jdbcType=JdbcType.VARCHAR),
@Result(column="menu_p_sid", property="menuPSid", jdbcType=JdbcType.BIGINT), @Result(column="menu_p_sid", property="menuPSid", jdbcType=JdbcType.BIGINT),
@Result(column="menu_sort", property="menuSort", jdbcType=JdbcType.INTEGER), @Result(column="menu_sort", property="menuSort", jdbcType=JdbcType.INTEGER),
@Result(column="menu_desc", property="menuDesc", jdbcType=JdbcType.VARCHAR), @Result(column="menu_desc", property="menuDesc", jdbcType=JdbcType.VARCHAR),
@ -75,8 +74,8 @@ public interface SecMenuMapper extends SecMenuMapperExt {
@Select({ @Select({
"select", "select",
"id, menu_name, menu_type, menu_url, menu_url_img, menu_full_url, menu_p_sid, ", "id, menu_name, menu_type, menu_url, menu_url_img, menu_p_sid, menu_sort, menu_desc, ",
"menu_sort, menu_desc, create_time, update_time", "create_time, update_time",
"from sec_menu", "from sec_menu",
"where id = #{id,jdbcType=BIGINT}" "where id = #{id,jdbcType=BIGINT}"
}) })
@ -86,7 +85,6 @@ public interface SecMenuMapper extends SecMenuMapperExt {
@Result(column="menu_type", property="menuType", jdbcType=JdbcType.INTEGER), @Result(column="menu_type", property="menuType", jdbcType=JdbcType.INTEGER),
@Result(column="menu_url", property="menuUrl", jdbcType=JdbcType.VARCHAR), @Result(column="menu_url", property="menuUrl", jdbcType=JdbcType.VARCHAR),
@Result(column="menu_url_img", property="menuUrlImg", jdbcType=JdbcType.VARCHAR), @Result(column="menu_url_img", property="menuUrlImg", jdbcType=JdbcType.VARCHAR),
@Result(column="menu_full_url", property="menuFullUrl", jdbcType=JdbcType.VARCHAR),
@Result(column="menu_p_sid", property="menuPSid", jdbcType=JdbcType.BIGINT), @Result(column="menu_p_sid", property="menuPSid", jdbcType=JdbcType.BIGINT),
@Result(column="menu_sort", property="menuSort", jdbcType=JdbcType.INTEGER), @Result(column="menu_sort", property="menuSort", jdbcType=JdbcType.INTEGER),
@Result(column="menu_desc", property="menuDesc", jdbcType=JdbcType.VARCHAR), @Result(column="menu_desc", property="menuDesc", jdbcType=JdbcType.VARCHAR),
@ -110,7 +108,6 @@ public interface SecMenuMapper extends SecMenuMapperExt {
"menu_type = #{menuType,jdbcType=INTEGER},", "menu_type = #{menuType,jdbcType=INTEGER},",
"menu_url = #{menuUrl,jdbcType=VARCHAR},", "menu_url = #{menuUrl,jdbcType=VARCHAR},",
"menu_url_img = #{menuUrlImg,jdbcType=VARCHAR},", "menu_url_img = #{menuUrlImg,jdbcType=VARCHAR},",
"menu_full_url = #{menuFullUrl,jdbcType=VARCHAR},",
"menu_p_sid = #{menuPSid,jdbcType=BIGINT},", "menu_p_sid = #{menuPSid,jdbcType=BIGINT},",
"menu_sort = #{menuSort,jdbcType=INTEGER},", "menu_sort = #{menuSort,jdbcType=INTEGER},",
"menu_desc = #{menuDesc,jdbcType=VARCHAR},", "menu_desc = #{menuDesc,jdbcType=VARCHAR},",

@ -44,10 +44,6 @@ public class SecMenuSqlProvider {
sql.VALUES("menu_url_img", "#{menuUrlImg,jdbcType=VARCHAR}"); sql.VALUES("menu_url_img", "#{menuUrlImg,jdbcType=VARCHAR}");
} }
if (record.getMenuFullUrl() != null) {
sql.VALUES("menu_full_url", "#{menuFullUrl,jdbcType=VARCHAR}");
}
if (record.getMenuPSid() != null) { if (record.getMenuPSid() != null) {
sql.VALUES("menu_p_sid", "#{menuPSid,jdbcType=BIGINT}"); sql.VALUES("menu_p_sid", "#{menuPSid,jdbcType=BIGINT}");
} }
@ -82,7 +78,6 @@ public class SecMenuSqlProvider {
sql.SELECT("menu_type"); sql.SELECT("menu_type");
sql.SELECT("menu_url"); sql.SELECT("menu_url");
sql.SELECT("menu_url_img"); sql.SELECT("menu_url_img");
sql.SELECT("menu_full_url");
sql.SELECT("menu_p_sid"); sql.SELECT("menu_p_sid");
sql.SELECT("menu_sort"); sql.SELECT("menu_sort");
sql.SELECT("menu_desc"); sql.SELECT("menu_desc");
@ -125,10 +120,6 @@ public class SecMenuSqlProvider {
sql.SET("menu_url_img = #{record.menuUrlImg,jdbcType=VARCHAR}"); sql.SET("menu_url_img = #{record.menuUrlImg,jdbcType=VARCHAR}");
} }
if (record.getMenuFullUrl() != null) {
sql.SET("menu_full_url = #{record.menuFullUrl,jdbcType=VARCHAR}");
}
if (record.getMenuPSid() != null) { if (record.getMenuPSid() != null) {
sql.SET("menu_p_sid = #{record.menuPSid,jdbcType=BIGINT}"); sql.SET("menu_p_sid = #{record.menuPSid,jdbcType=BIGINT}");
} }
@ -162,7 +153,6 @@ public class SecMenuSqlProvider {
sql.SET("menu_type = #{record.menuType,jdbcType=INTEGER}"); sql.SET("menu_type = #{record.menuType,jdbcType=INTEGER}");
sql.SET("menu_url = #{record.menuUrl,jdbcType=VARCHAR}"); sql.SET("menu_url = #{record.menuUrl,jdbcType=VARCHAR}");
sql.SET("menu_url_img = #{record.menuUrlImg,jdbcType=VARCHAR}"); sql.SET("menu_url_img = #{record.menuUrlImg,jdbcType=VARCHAR}");
sql.SET("menu_full_url = #{record.menuFullUrl,jdbcType=VARCHAR}");
sql.SET("menu_p_sid = #{record.menuPSid,jdbcType=BIGINT}"); sql.SET("menu_p_sid = #{record.menuPSid,jdbcType=BIGINT}");
sql.SET("menu_sort = #{record.menuSort,jdbcType=INTEGER}"); sql.SET("menu_sort = #{record.menuSort,jdbcType=INTEGER}");
sql.SET("menu_desc = #{record.menuDesc,jdbcType=VARCHAR}"); sql.SET("menu_desc = #{record.menuDesc,jdbcType=VARCHAR}");
@ -194,10 +184,6 @@ public class SecMenuSqlProvider {
sql.SET("menu_url_img = #{menuUrlImg,jdbcType=VARCHAR}"); sql.SET("menu_url_img = #{menuUrlImg,jdbcType=VARCHAR}");
} }
if (record.getMenuFullUrl() != null) {
sql.SET("menu_full_url = #{menuFullUrl,jdbcType=VARCHAR}");
}
if (record.getMenuPSid() != null) { if (record.getMenuPSid() != null) {
sql.SET("menu_p_sid = #{menuPSid,jdbcType=BIGINT}"); sql.SET("menu_p_sid = #{menuPSid,jdbcType=BIGINT}");
} }

@ -38,11 +38,6 @@ public class SecMenu implements Serializable {
*/ */
private String menuUrlImg; private String menuUrlImg;
/**
* 菜单完整URL
*/
private String menuFullUrl;
/** /**
* 父级菜单主键 * 父级菜单主键
*/ */
@ -110,14 +105,6 @@ public class SecMenu implements Serializable {
this.menuUrlImg = menuUrlImg; this.menuUrlImg = menuUrlImg;
} }
public String getMenuFullUrl() {
return menuFullUrl;
}
public void setMenuFullUrl(String menuFullUrl) {
this.menuFullUrl = menuFullUrl;
}
public Long getMenuPSid() { public Long getMenuPSid() {
return menuPSid; return menuPSid;
} }
@ -175,7 +162,6 @@ public class SecMenu implements Serializable {
&& (this.getMenuType() == null ? other.getMenuType() == null : this.getMenuType().equals(other.getMenuType())) && (this.getMenuType() == null ? other.getMenuType() == null : this.getMenuType().equals(other.getMenuType()))
&& (this.getMenuUrl() == null ? other.getMenuUrl() == null : this.getMenuUrl().equals(other.getMenuUrl())) && (this.getMenuUrl() == null ? other.getMenuUrl() == null : this.getMenuUrl().equals(other.getMenuUrl()))
&& (this.getMenuUrlImg() == null ? other.getMenuUrlImg() == null : this.getMenuUrlImg().equals(other.getMenuUrlImg())) && (this.getMenuUrlImg() == null ? other.getMenuUrlImg() == null : this.getMenuUrlImg().equals(other.getMenuUrlImg()))
&& (this.getMenuFullUrl() == null ? other.getMenuFullUrl() == null : this.getMenuFullUrl().equals(other.getMenuFullUrl()))
&& (this.getMenuPSid() == null ? other.getMenuPSid() == null : this.getMenuPSid().equals(other.getMenuPSid())) && (this.getMenuPSid() == null ? other.getMenuPSid() == null : this.getMenuPSid().equals(other.getMenuPSid()))
&& (this.getMenuSort() == null ? other.getMenuSort() == null : this.getMenuSort().equals(other.getMenuSort())) && (this.getMenuSort() == null ? other.getMenuSort() == null : this.getMenuSort().equals(other.getMenuSort()))
&& (this.getMenuDesc() == null ? other.getMenuDesc() == null : this.getMenuDesc().equals(other.getMenuDesc())) && (this.getMenuDesc() == null ? other.getMenuDesc() == null : this.getMenuDesc().equals(other.getMenuDesc()))
@ -192,7 +178,6 @@ public class SecMenu implements Serializable {
result = prime * result + ((getMenuType() == null) ? 0 : getMenuType().hashCode()); result = prime * result + ((getMenuType() == null) ? 0 : getMenuType().hashCode());
result = prime * result + ((getMenuUrl() == null) ? 0 : getMenuUrl().hashCode()); result = prime * result + ((getMenuUrl() == null) ? 0 : getMenuUrl().hashCode());
result = prime * result + ((getMenuUrlImg() == null) ? 0 : getMenuUrlImg().hashCode()); result = prime * result + ((getMenuUrlImg() == null) ? 0 : getMenuUrlImg().hashCode());
result = prime * result + ((getMenuFullUrl() == null) ? 0 : getMenuFullUrl().hashCode());
result = prime * result + ((getMenuPSid() == null) ? 0 : getMenuPSid().hashCode()); result = prime * result + ((getMenuPSid() == null) ? 0 : getMenuPSid().hashCode());
result = prime * result + ((getMenuSort() == null) ? 0 : getMenuSort().hashCode()); result = prime * result + ((getMenuSort() == null) ? 0 : getMenuSort().hashCode());
result = prime * result + ((getMenuDesc() == null) ? 0 : getMenuDesc().hashCode()); result = prime * result + ((getMenuDesc() == null) ? 0 : getMenuDesc().hashCode());
@ -212,7 +197,6 @@ public class SecMenu implements Serializable {
sb.append(", menuType=").append(menuType); sb.append(", menuType=").append(menuType);
sb.append(", menuUrl=").append(menuUrl); sb.append(", menuUrl=").append(menuUrl);
sb.append(", menuUrlImg=").append(menuUrlImg); sb.append(", menuUrlImg=").append(menuUrlImg);
sb.append(", menuFullUrl=").append(menuFullUrl);
sb.append(", menuPSid=").append(menuPSid); sb.append(", menuPSid=").append(menuPSid);
sb.append(", menuSort=").append(menuSort); sb.append(", menuSort=").append(menuSort);
sb.append(", menuDesc=").append(menuDesc); sb.append(", menuDesc=").append(menuDesc);

@ -455,76 +455,6 @@ public class SecMenuExample {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andMenuFullUrlIsNull() {
addCriterion("menu_full_url is null");
return (Criteria) this;
}
public Criteria andMenuFullUrlIsNotNull() {
addCriterion("menu_full_url is not null");
return (Criteria) this;
}
public Criteria andMenuFullUrlEqualTo(String value) {
addCriterion("menu_full_url =", value, "menuFullUrl");
return (Criteria) this;
}
public Criteria andMenuFullUrlNotEqualTo(String value) {
addCriterion("menu_full_url <>", value, "menuFullUrl");
return (Criteria) this;
}
public Criteria andMenuFullUrlGreaterThan(String value) {
addCriterion("menu_full_url >", value, "menuFullUrl");
return (Criteria) this;
}
public Criteria andMenuFullUrlGreaterThanOrEqualTo(String value) {
addCriterion("menu_full_url >=", value, "menuFullUrl");
return (Criteria) this;
}
public Criteria andMenuFullUrlLessThan(String value) {
addCriterion("menu_full_url <", value, "menuFullUrl");
return (Criteria) this;
}
public Criteria andMenuFullUrlLessThanOrEqualTo(String value) {
addCriterion("menu_full_url <=", value, "menuFullUrl");
return (Criteria) this;
}
public Criteria andMenuFullUrlLike(String value) {
addCriterion("menu_full_url like", value, "menuFullUrl");
return (Criteria) this;
}
public Criteria andMenuFullUrlNotLike(String value) {
addCriterion("menu_full_url not like", value, "menuFullUrl");
return (Criteria) this;
}
public Criteria andMenuFullUrlIn(List<String> values) {
addCriterion("menu_full_url in", values, "menuFullUrl");
return (Criteria) this;
}
public Criteria andMenuFullUrlNotIn(List<String> values) {
addCriterion("menu_full_url not in", values, "menuFullUrl");
return (Criteria) this;
}
public Criteria andMenuFullUrlBetween(String value1, String value2) {
addCriterion("menu_full_url between", value1, value2, "menuFullUrl");
return (Criteria) this;
}
public Criteria andMenuFullUrlNotBetween(String value1, String value2) {
addCriterion("menu_full_url not between", value1, value2, "menuFullUrl");
return (Criteria) this;
}
public Criteria andMenuPSidIsNull() { public Criteria andMenuPSidIsNull() {
addCriterion("menu_p_sid is null"); addCriterion("menu_p_sid is null");
return (Criteria) this; return (Criteria) this;

@ -131,7 +131,7 @@ public class SecMenuServiceImpl implements SecMenuService {
// 获取系统菜单 // 获取系统菜单
List<SecMenu> menuList = getAllList().stream() List<SecMenu> menuList = getAllList().stream()
.filter(o->o.getMenuType().equals(SecMenuTypeEnum.type2.getCode())) .filter(o->o.getMenuType().equals(menuType.getCode()))
.collect(Collectors.toList()); .collect(Collectors.toList());
Iterator<SecMenu> iterator = menuList.iterator(); Iterator<SecMenu> iterator = menuList.iterator();

Loading…
Cancel
Save