删除无用字段

This commit is contained in:
zhangchenbiao
2023-08-01 15:08:54 +08:00
parent 4d23b83490
commit ab3ccf47bf
9 changed files with 18 additions and 35 deletions

View File

@@ -21,8 +21,8 @@ public class SysMenuDAO {
@Resource
private SysMenuMapper sysMenuMapper;
public List<SysMenuDO> selectMenuAll(List<Long> parentIds, String platformType){
return sysMenuMapper.selectMenuAll(parentIds, platformType);
public List<SysMenuDO> selectMenuAll(List<Long> parentIds){
return sysMenuMapper.selectMenuAll(parentIds);
}
public Long addMenu(SysMenuDO param){

View File

@@ -1,8 +1,6 @@
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.enums.PlatFormTypeEnum;
import com.cool.store.mapper.SysRoleMenuMapper;
import com.google.common.collect.Lists;
import org.springframework.stereotype.Repository;
@@ -28,22 +26,21 @@ public class SysRoleMenuDAO {
* @param platform
* @return
*/
public List<SysRoleMenuDO> getRoleMenuByRoleId(String roleId, String platform){
if(Objects.isNull(roleId) || StringUtils.isBlank(platform)){
public List<SysRoleMenuDO> getRoleMenuByRoleId(String roleId){
if(Objects.isNull(roleId)){
return Lists.newArrayList();
}
return sysRoleMenuMapper.getRoleMenuByRoleId(roleId, platform);
return sysRoleMenuMapper.getRoleMenuByRoleId(roleId);
}
public Integer updateRoleAuth(String roleId, List<Long> menuIds){
//先删后增
sysRoleMenuMapper.deleteRoleAuth(roleId, PlatFormTypeEnum.PC.getCode());
sysRoleMenuMapper.deleteRoleAuth(roleId);
List<SysRoleMenuDO> insertList = new ArrayList<>();
for (Long menuId : menuIds) {
SysRoleMenuDO insert = new SysRoleMenuDO();
insert.setMenuId(menuId);
insert.setRoleId(roleId);
insert.setPlatform(PlatFormTypeEnum.PC.getCode());
insertList.add(insert);
}
return sysRoleMenuMapper.batchInsert(insertList);

View File

@@ -25,7 +25,7 @@ public interface SysMenuMapper {
*/
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();

View File

@@ -28,15 +28,14 @@ public interface SysRoleMenuMapper {
/**
* 根据角色获取菜单
* @param roleId
* @param platform
* @return
*/
List<SysRoleMenuDO> getRoleMenuByRoleId(@Param("roleId")String roleId, @Param("platform")String platform);
List<SysRoleMenuDO> getRoleMenuByRoleId(@Param("roleId")String roleId);
/**
* 删除角色权限
* @param roleId
* @return
*/
Integer deleteRoleAuth(@Param("roleId")String roleId, @Param("platform")String platform);
Integer deleteRoleAuth(@Param("roleId")String roleId);
}

View File

@@ -139,7 +139,7 @@
from
sys_menu
where
platform=#{platformType} and is_deleted = '0'
is_deleted = '0'
<if test="list!=null and list.size>0">
and parent_id in
<foreach collection="list" item="parentId" open="(" close=")" separator=",">

View File

@@ -5,10 +5,9 @@
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="menu_id" jdbcType="BIGINT" property="menuId"/>
<result column="role_id" jdbcType="VARCHAR" property="roleId"/>
<result column="platform" jdbcType="VARCHAR" property="platform"/>
</resultMap>
<sql id="Base_Column_List">
id, menu_id, role_id, platform
id, menu_id, role_id
</sql>
<insert id="batchInsert">
<foreach collection="recordList" item="record" separator=";">
@@ -20,9 +19,6 @@
<if test="record.roleId != null">
role_id,
</if>
<if test="record.platform != null">
platform,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="record.menuId != null">
@@ -31,9 +27,6 @@
<if test="record.roleId != null">
#{record.roleId},
</if>
<if test="record.platform != null">
#{record.platform},
</if>
</trim>
</foreach>
</insert>
@@ -46,9 +39,6 @@
<if test="record.roleId != null">
role_id = #{record.roleId},
</if>
<if test="record.platform != null">
platform = #{record.platform},
</if>
</set>
where id = #{record.id}
</update>
@@ -59,10 +49,10 @@
from
sys_role_menu
where
role_id=#{roleId} and platform=#{platform}
role_id=#{roleId}
</select>
<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>
</mapper>

View File

@@ -26,7 +26,4 @@ public class SysRoleMenuDO implements Serializable {
@ApiModelProperty("角色id")
private String roleId;
@ApiModelProperty("菜单类型")
private String platform;
}

View File

@@ -35,8 +35,8 @@ public class MenuServiceImpl implements MenuService {
@Override
public List<MenuTreeVO> getUserMenus(String userId, String roleId) {
List<SysMenuDO> menuList= sysMenuDAO.selectMenuAll(null, PlatFormTypeEnum.PC.getCode());
List<SysRoleMenuDO> roleMenuList = sysRoleMenuDAO.getRoleMenuByRoleId(roleId, PlatFormTypeEnum.PC.getCode());
List<SysMenuDO> menuList= sysMenuDAO.selectMenuAll(null);
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> roleMenuIdList = roleMenuList.stream().map(SysRoleMenuDO::getMenuId).filter(anthMenuIdList::contains).collect(Collectors.toList());
Set<Long> authMenuSet = new HashSet<>();
@@ -56,7 +56,7 @@ public class MenuServiceImpl implements MenuService {
@Override
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);
}
@@ -67,7 +67,7 @@ public class MenuServiceImpl implements MenuService {
@Override
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());
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);

View File

@@ -49,7 +49,7 @@ public class RoleServiceImpl implements RoleService {
if(Objects.isNull(roleDetail)){
return null;
}
List<SysRoleMenuDO> roleMenuAuths = sysRoleMenuDAO.getRoleMenuByRoleId(roleId, PlatFormTypeEnum.PC.getCode());
List<SysRoleMenuDO> roleMenuAuths = sysRoleMenuDAO.getRoleMenuByRoleId(roleId);
return RoleAuthInfoVO.convertVO(roleDetail, roleMenuAuths);
}