删除无用字段
This commit is contained in:
@@ -21,8 +21,8 @@ public class SysMenuDAO {
|
|||||||
@Resource
|
@Resource
|
||||||
private SysMenuMapper sysMenuMapper;
|
private SysMenuMapper sysMenuMapper;
|
||||||
|
|
||||||
public List<SysMenuDO> selectMenuAll(List<Long> parentIds, String platformType){
|
public List<SysMenuDO> selectMenuAll(List<Long> parentIds){
|
||||||
return sysMenuMapper.selectMenuAll(parentIds, platformType);
|
return sysMenuMapper.selectMenuAll(parentIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long addMenu(SysMenuDO param){
|
public Long addMenu(SysMenuDO param){
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
package com.cool.store.dao;
|
package com.cool.store.dao;
|
||||||
|
|
||||||
import com.aliyun.openservices.shade.org.apache.commons.lang3.StringUtils;
|
|
||||||
import com.cool.store.entity.SysRoleMenuDO;
|
import com.cool.store.entity.SysRoleMenuDO;
|
||||||
import com.cool.store.enums.PlatFormTypeEnum;
|
|
||||||
import com.cool.store.mapper.SysRoleMenuMapper;
|
import com.cool.store.mapper.SysRoleMenuMapper;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
@@ -28,22 +26,21 @@ public class SysRoleMenuDAO {
|
|||||||
* @param platform
|
* @param platform
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<SysRoleMenuDO> getRoleMenuByRoleId(String roleId, String platform){
|
public List<SysRoleMenuDO> getRoleMenuByRoleId(String roleId){
|
||||||
if(Objects.isNull(roleId) || StringUtils.isBlank(platform)){
|
if(Objects.isNull(roleId)){
|
||||||
return Lists.newArrayList();
|
return Lists.newArrayList();
|
||||||
}
|
}
|
||||||
return sysRoleMenuMapper.getRoleMenuByRoleId(roleId, platform);
|
return sysRoleMenuMapper.getRoleMenuByRoleId(roleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer updateRoleAuth(String roleId, List<Long> menuIds){
|
public Integer updateRoleAuth(String roleId, List<Long> menuIds){
|
||||||
//先删后增
|
//先删后增
|
||||||
sysRoleMenuMapper.deleteRoleAuth(roleId, PlatFormTypeEnum.PC.getCode());
|
sysRoleMenuMapper.deleteRoleAuth(roleId);
|
||||||
List<SysRoleMenuDO> insertList = new ArrayList<>();
|
List<SysRoleMenuDO> insertList = new ArrayList<>();
|
||||||
for (Long menuId : menuIds) {
|
for (Long menuId : menuIds) {
|
||||||
SysRoleMenuDO insert = new SysRoleMenuDO();
|
SysRoleMenuDO insert = new SysRoleMenuDO();
|
||||||
insert.setMenuId(menuId);
|
insert.setMenuId(menuId);
|
||||||
insert.setRoleId(roleId);
|
insert.setRoleId(roleId);
|
||||||
insert.setPlatform(PlatFormTypeEnum.PC.getCode());
|
|
||||||
insertList.add(insert);
|
insertList.add(insert);
|
||||||
}
|
}
|
||||||
return sysRoleMenuMapper.batchInsert(insertList);
|
return sysRoleMenuMapper.batchInsert(insertList);
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public interface SysMenuMapper {
|
|||||||
*/
|
*/
|
||||||
int batchUpdateMenu(@Param("recordList") List<SysMenuDO> recordList);
|
int batchUpdateMenu(@Param("recordList") List<SysMenuDO> recordList);
|
||||||
|
|
||||||
List<SysMenuDO> selectMenuAll(@Param("list") List<Long> parentIds, @Param("platformType") String platformType);
|
List<SysMenuDO> selectMenuAll(@Param("list") List<Long> parentIds);
|
||||||
|
|
||||||
Integer selectMaxSort();
|
Integer selectMaxSort();
|
||||||
|
|
||||||
|
|||||||
@@ -28,15 +28,14 @@ public interface SysRoleMenuMapper {
|
|||||||
/**
|
/**
|
||||||
* 根据角色获取菜单
|
* 根据角色获取菜单
|
||||||
* @param roleId
|
* @param roleId
|
||||||
* @param platform
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<SysRoleMenuDO> getRoleMenuByRoleId(@Param("roleId")String roleId, @Param("platform")String platform);
|
List<SysRoleMenuDO> getRoleMenuByRoleId(@Param("roleId")String roleId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除角色权限
|
* 删除角色权限
|
||||||
* @param roleId
|
* @param roleId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Integer deleteRoleAuth(@Param("roleId")String roleId, @Param("platform")String platform);
|
Integer deleteRoleAuth(@Param("roleId")String roleId);
|
||||||
}
|
}
|
||||||
@@ -139,7 +139,7 @@
|
|||||||
from
|
from
|
||||||
sys_menu
|
sys_menu
|
||||||
where
|
where
|
||||||
platform=#{platformType} and is_deleted = '0'
|
is_deleted = '0'
|
||||||
<if test="list!=null and list.size>0">
|
<if test="list!=null and list.size>0">
|
||||||
and parent_id in
|
and parent_id in
|
||||||
<foreach collection="list" item="parentId" open="(" close=")" separator=",">
|
<foreach collection="list" item="parentId" open="(" close=")" separator=",">
|
||||||
|
|||||||
@@ -5,10 +5,9 @@
|
|||||||
<id column="id" jdbcType="BIGINT" property="id"/>
|
<id column="id" jdbcType="BIGINT" property="id"/>
|
||||||
<result column="menu_id" jdbcType="BIGINT" property="menuId"/>
|
<result column="menu_id" jdbcType="BIGINT" property="menuId"/>
|
||||||
<result column="role_id" jdbcType="VARCHAR" property="roleId"/>
|
<result column="role_id" jdbcType="VARCHAR" property="roleId"/>
|
||||||
<result column="platform" jdbcType="VARCHAR" property="platform"/>
|
|
||||||
</resultMap>
|
</resultMap>
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
id, menu_id, role_id, platform
|
id, menu_id, role_id
|
||||||
</sql>
|
</sql>
|
||||||
<insert id="batchInsert">
|
<insert id="batchInsert">
|
||||||
<foreach collection="recordList" item="record" separator=";">
|
<foreach collection="recordList" item="record" separator=";">
|
||||||
@@ -20,9 +19,6 @@
|
|||||||
<if test="record.roleId != null">
|
<if test="record.roleId != null">
|
||||||
role_id,
|
role_id,
|
||||||
</if>
|
</if>
|
||||||
<if test="record.platform != null">
|
|
||||||
platform,
|
|
||||||
</if>
|
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="record.menuId != null">
|
<if test="record.menuId != null">
|
||||||
@@ -31,9 +27,6 @@
|
|||||||
<if test="record.roleId != null">
|
<if test="record.roleId != null">
|
||||||
#{record.roleId},
|
#{record.roleId},
|
||||||
</if>
|
</if>
|
||||||
<if test="record.platform != null">
|
|
||||||
#{record.platform},
|
|
||||||
</if>
|
|
||||||
</trim>
|
</trim>
|
||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
@@ -46,9 +39,6 @@
|
|||||||
<if test="record.roleId != null">
|
<if test="record.roleId != null">
|
||||||
role_id = #{record.roleId},
|
role_id = #{record.roleId},
|
||||||
</if>
|
</if>
|
||||||
<if test="record.platform != null">
|
|
||||||
platform = #{record.platform},
|
|
||||||
</if>
|
|
||||||
</set>
|
</set>
|
||||||
where id = #{record.id}
|
where id = #{record.id}
|
||||||
</update>
|
</update>
|
||||||
@@ -59,10 +49,10 @@
|
|||||||
from
|
from
|
||||||
sys_role_menu
|
sys_role_menu
|
||||||
where
|
where
|
||||||
role_id=#{roleId} and platform=#{platform}
|
role_id=#{roleId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<delete id="deleteRoleAuth">
|
<delete id="deleteRoleAuth">
|
||||||
delete from sys_role_menu where role_id=#{roleId} and platform=#{platform}
|
delete from sys_role_menu where role_id=#{roleId}
|
||||||
</delete>
|
</delete>
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -26,7 +26,4 @@ public class SysRoleMenuDO implements Serializable {
|
|||||||
|
|
||||||
@ApiModelProperty("角色id")
|
@ApiModelProperty("角色id")
|
||||||
private String roleId;
|
private String roleId;
|
||||||
|
|
||||||
@ApiModelProperty("菜单类型")
|
|
||||||
private String platform;
|
|
||||||
}
|
}
|
||||||
@@ -35,8 +35,8 @@ public class MenuServiceImpl implements MenuService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<MenuTreeVO> getUserMenus(String userId, String roleId) {
|
public List<MenuTreeVO> getUserMenus(String userId, String roleId) {
|
||||||
List<SysMenuDO> menuList= sysMenuDAO.selectMenuAll(null, PlatFormTypeEnum.PC.getCode());
|
List<SysMenuDO> menuList= sysMenuDAO.selectMenuAll(null);
|
||||||
List<SysRoleMenuDO> roleMenuList = sysRoleMenuDAO.getRoleMenuByRoleId(roleId, PlatFormTypeEnum.PC.getCode());
|
List<SysRoleMenuDO> roleMenuList = sysRoleMenuDAO.getRoleMenuByRoleId(roleId);
|
||||||
List<Long> anthMenuIdList = menuList.stream().filter(o -> MenuTypeEnum.AUTH.getCode().equals(o.getMenuType())).map(SysMenuDO::getId).collect(Collectors.toList());
|
List<Long> anthMenuIdList = menuList.stream().filter(o -> MenuTypeEnum.AUTH.getCode().equals(o.getMenuType())).map(SysMenuDO::getId).collect(Collectors.toList());
|
||||||
List<Long> roleMenuIdList = roleMenuList.stream().map(SysRoleMenuDO::getMenuId).filter(anthMenuIdList::contains).collect(Collectors.toList());
|
List<Long> roleMenuIdList = roleMenuList.stream().map(SysRoleMenuDO::getMenuId).filter(anthMenuIdList::contains).collect(Collectors.toList());
|
||||||
Set<Long> authMenuSet = new HashSet<>();
|
Set<Long> authMenuSet = new HashSet<>();
|
||||||
@@ -56,7 +56,7 @@ public class MenuServiceImpl implements MenuService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<MenuAuthTreeVO> getAllMenus() {
|
public List<MenuAuthTreeVO> getAllMenus() {
|
||||||
List<SysMenuDO> menuList= sysMenuDAO.selectMenuAll(null, PlatFormTypeEnum.PC.getCode());
|
List<SysMenuDO> menuList= sysMenuDAO.selectMenuAll(null);
|
||||||
return MenuAuthTreeVO.dealMenuTree(CommonConstants.ZERO_LONG, menuList);
|
return MenuAuthTreeVO.dealMenuTree(CommonConstants.ZERO_LONG, menuList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ public class MenuServiceImpl implements MenuService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long deleteMenuAuth(Long id) {
|
public Long deleteMenuAuth(Long id) {
|
||||||
List<SysMenuDO> menuList = sysMenuDAO.selectMenuAll(null, PlatFormTypeEnum.PC.getCode());
|
List<SysMenuDO> menuList = sysMenuDAO.selectMenuAll(null);
|
||||||
List<Long> idList = menuList.stream().map(SysMenuDO::getId).collect(Collectors.toList());
|
List<Long> idList = menuList.stream().map(SysMenuDO::getId).collect(Collectors.toList());
|
||||||
Map<Long, List<Long>> parentGroupMap = menuList.stream().collect(Collectors.groupingBy(SysMenuDO::getParentId, Collectors.mapping(SysMenuDO::getId, Collectors.toList())));
|
Map<Long, List<Long>> parentGroupMap = menuList.stream().collect(Collectors.groupingBy(SysMenuDO::getParentId, Collectors.mapping(SysMenuDO::getId, Collectors.toList())));
|
||||||
List<Long> allChildList = CommonNodeUtils.getAllChildListContainSelf(0L,id, idList, parentGroupMap);
|
List<Long> allChildList = CommonNodeUtils.getAllChildListContainSelf(0L,id, idList, parentGroupMap);
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public class RoleServiceImpl implements RoleService {
|
|||||||
if(Objects.isNull(roleDetail)){
|
if(Objects.isNull(roleDetail)){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
List<SysRoleMenuDO> roleMenuAuths = sysRoleMenuDAO.getRoleMenuByRoleId(roleId, PlatFormTypeEnum.PC.getCode());
|
List<SysRoleMenuDO> roleMenuAuths = sysRoleMenuDAO.getRoleMenuByRoleId(roleId);
|
||||||
return RoleAuthInfoVO.convertVO(roleDetail, roleMenuAuths);
|
return RoleAuthInfoVO.convertVO(roleDetail, roleMenuAuths);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user