upd: 编码规范
This commit is contained in:
+5
-5
@@ -12,13 +12,13 @@ import java.util.Set;
|
|||||||
@Mapper
|
@Mapper
|
||||||
public interface MenuMapper extends BaseMapper<Menu> {
|
public interface MenuMapper extends BaseMapper<Menu> {
|
||||||
|
|
||||||
List<Menu> selectMenuByCriteria(@Param("criteria") QueryMenuRequest criteria);
|
List<Menu> queryMenuListByArgs(@Param("criteria") QueryMenuRequest criteria);
|
||||||
|
|
||||||
LinkedHashSet<Menu> selectMenuByRoleIdsAndType(@Param("roleIds") Set<Long> roleIds, @Param("type") Integer type);
|
LinkedHashSet<Menu> queryMenuSetByRoleIdsAndType(@Param("roleIds") Set<Long> roleIds, @Param("type") Integer type);
|
||||||
|
|
||||||
List<Menu> selectMenuByPidIsNullOrderByMenuSort();
|
List<Menu> queryMenuListByPidIsNullOrderByMenuSort();
|
||||||
|
|
||||||
List<Menu> selectMenuByPidOrderByMenuSort(@Param("pid") Long pid);
|
List<Menu> queryMenuListByPidOrderByMenuSort(@Param("pid") Long pid);
|
||||||
|
|
||||||
Menu getMenuByTitle(@Param("title") String title);
|
Menu getMenuByTitle(@Param("title") String title);
|
||||||
|
|
||||||
@@ -26,5 +26,5 @@ public interface MenuMapper extends BaseMapper<Menu> {
|
|||||||
|
|
||||||
Integer getMenuCountByPid(@Param("pid") Long pid);
|
Integer getMenuCountByPid(@Param("pid") Long pid);
|
||||||
|
|
||||||
void updateSubCntById(@Param("count") int count, @Param("menuId") Long menuId);
|
void updateSubCntByMenuId(@Param("count") int count, @Param("menuId") Long menuId);
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-8
@@ -71,7 +71,7 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return menuMapper.selectMenuByCriteria(criteria);
|
return menuMapper.queryMenuListByArgs(criteria);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -98,7 +98,7 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
|
|||||||
if (CollUtil.isEmpty(menus)) {
|
if (CollUtil.isEmpty(menus)) {
|
||||||
List<Role> roles = roleService.selectRoleByUsersId(currentUserId);
|
List<Role> roles = roleService.selectRoleByUsersId(currentUserId);
|
||||||
Set<Long> roleIds = roles.stream().map(Role::getId).collect(Collectors.toSet());
|
Set<Long> roleIds = roles.stream().map(Role::getId).collect(Collectors.toSet());
|
||||||
menus = new ArrayList<>(menuMapper.selectMenuByRoleIdsAndType(roleIds, 2));
|
menus = new ArrayList<>(menuMapper.queryMenuSetByRoleIdsAndType(roleIds, 2));
|
||||||
redisHelper.set(key, menus, 1, TimeUnit.DAYS);
|
redisHelper.set(key, menus, 1, TimeUnit.DAYS);
|
||||||
}
|
}
|
||||||
return menus;
|
return menus;
|
||||||
@@ -186,7 +186,7 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
|
|||||||
public Set<Menu> selectChildMenus(List<Menu> menuList, Set<Menu> menuSet) {
|
public Set<Menu> selectChildMenus(List<Menu> menuList, Set<Menu> menuSet) {
|
||||||
for (Menu menu : menuList) {
|
for (Menu menu : menuList) {
|
||||||
menuSet.add(menu);
|
menuSet.add(menu);
|
||||||
List<Menu> menus = menuMapper.selectMenuByPidOrderByMenuSort(menu.getId());
|
List<Menu> menus = menuMapper.queryMenuListByPidOrderByMenuSort(menu.getId());
|
||||||
if (CollUtil.isNotEmpty(menus)) {
|
if (CollUtil.isNotEmpty(menus)) {
|
||||||
selectChildMenus(menus, menuSet);
|
selectChildMenus(menus, menuSet);
|
||||||
}
|
}
|
||||||
@@ -210,9 +210,9 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
|
|||||||
public List<Menu> selectMenuByPid(Long pid) {
|
public List<Menu> selectMenuByPid(Long pid) {
|
||||||
List<Menu> menus;
|
List<Menu> menus;
|
||||||
if (pid != null && !pid.equals(0L)) {
|
if (pid != null && !pid.equals(0L)) {
|
||||||
menus = menuMapper.selectMenuByPidOrderByMenuSort(pid);
|
menus = menuMapper.queryMenuListByPidOrderByMenuSort(pid);
|
||||||
} else {
|
} else {
|
||||||
menus = menuMapper.selectMenuByPidIsNullOrderByMenuSort();
|
menus = menuMapper.queryMenuListByPidIsNullOrderByMenuSort();
|
||||||
}
|
}
|
||||||
return menus;
|
return menus;
|
||||||
}
|
}
|
||||||
@@ -220,10 +220,10 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
|
|||||||
@Override
|
@Override
|
||||||
public List<Menu> selectSuperiorMenu(Menu menu, List<Menu> menus) {
|
public List<Menu> selectSuperiorMenu(Menu menu, List<Menu> menus) {
|
||||||
if (menu.getPid() == null) {
|
if (menu.getPid() == null) {
|
||||||
menus.addAll(menuMapper.selectMenuByPidIsNullOrderByMenuSort());
|
menus.addAll(menuMapper.queryMenuListByPidIsNullOrderByMenuSort());
|
||||||
return menus;
|
return menus;
|
||||||
}
|
}
|
||||||
menus.addAll(menuMapper.selectMenuByPidOrderByMenuSort(menu.getPid()));
|
menus.addAll(menuMapper.queryMenuListByPidOrderByMenuSort(menu.getPid()));
|
||||||
return selectSuperiorMenu(getMenuById(menu.getPid()), menus);
|
return selectSuperiorMenu(getMenuById(menu.getPid()), menus);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -315,7 +315,7 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
|
|||||||
private void updateSubCnt(Long menuId) {
|
private void updateSubCnt(Long menuId) {
|
||||||
if (menuId != null) {
|
if (menuId != null) {
|
||||||
int count = menuMapper.getMenuCountByPid(menuId);
|
int count = menuMapper.getMenuCountByPid(menuId);
|
||||||
menuMapper.updateSubCntById(count, menuId);
|
menuMapper.updateSubCntByMenuId(count, menuId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<result column="create_time" property="createTime"/>
|
<result column="create_time" property="createTime"/>
|
||||||
<result column="update_time" property="updateTime"/>
|
<result column="update_time" property="updateTime"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
<select id="selectMenuByCriteria" resultMap="BaseResultMap">
|
<select id="queryMenuListByArgs" resultMap="BaseResultMap">
|
||||||
select
|
select
|
||||||
menu_id, title, name, menu_sort, component, path, type, permission, icon, cache, hidden, pid, sub_count,
|
menu_id, title, name, menu_sort, component, path, type, permission, icon, cache, hidden, pid, sub_count,
|
||||||
i_frame, create_by, update_by, create_time, update_time
|
i_frame, create_by, update_by, create_time, update_time
|
||||||
@@ -46,7 +46,7 @@
|
|||||||
</where>
|
</where>
|
||||||
order by menu_sort
|
order by menu_sort
|
||||||
</select>
|
</select>
|
||||||
<select id="selectMenuByRoleIdsAndType" resultMap="BaseResultMap">
|
<select id="queryMenuSetByRoleIdsAndType" resultMap="BaseResultMap">
|
||||||
SELECT m.* FROM sys_menu m, sys_roles_menus r
|
SELECT m.* FROM sys_menu m, sys_roles_menus r
|
||||||
WHERE m.menu_id = r.menu_id AND r.role_id IN
|
WHERE m.menu_id = r.menu_id AND r.role_id IN
|
||||||
<foreach collection="roleIds" item="roleId" open="(" separator="," close=")">
|
<foreach collection="roleIds" item="roleId" open="(" separator="," close=")">
|
||||||
@@ -55,7 +55,7 @@
|
|||||||
AND type != #{type}
|
AND type != #{type}
|
||||||
order by m.menu_sort
|
order by m.menu_sort
|
||||||
</select>
|
</select>
|
||||||
<select id="selectMenuByPidIsNullOrderByMenuSort" resultMap="BaseResultMap">
|
<select id="queryMenuListByPidIsNullOrderByMenuSort" resultMap="BaseResultMap">
|
||||||
SELECT menu_id,
|
SELECT menu_id,
|
||||||
title,
|
title,
|
||||||
name,
|
name,
|
||||||
@@ -78,7 +78,7 @@
|
|||||||
where pid is null
|
where pid is null
|
||||||
order by menu_sort
|
order by menu_sort
|
||||||
</select>
|
</select>
|
||||||
<select id="selectMenuByPidOrderByMenuSort" resultMap="BaseResultMap">
|
<select id="queryMenuListByPidOrderByMenuSort" resultMap="BaseResultMap">
|
||||||
SELECT menu_id,
|
SELECT menu_id,
|
||||||
title,
|
title,
|
||||||
name,
|
name,
|
||||||
@@ -111,12 +111,12 @@
|
|||||||
FROM sys_menu
|
FROM sys_menu
|
||||||
WHERE name = #{name}
|
WHERE name = #{name}
|
||||||
</select>
|
</select>
|
||||||
<select id="getMenuCountByPid">
|
<select id="getMenuCountByPid" resultType="java.lang.Integer">
|
||||||
SELECT count(*)
|
SELECT count(*)
|
||||||
FROM sys_menu
|
FROM sys_menu
|
||||||
WHERE pid = #{pid}
|
WHERE pid = #{pid}
|
||||||
</select>
|
</select>
|
||||||
<update id="updateSubCntById">
|
<update id="updateSubCntByMenuId">
|
||||||
update sys_menu
|
update sys_menu
|
||||||
set sub_count = #{count}
|
set sub_count = #{count}
|
||||||
where menu_id = #{menuId}
|
where menu_id = #{menuId}
|
||||||
|
|||||||
Reference in New Issue
Block a user