修复角色菜单临时接口
This commit is contained in:
@@ -36,4 +36,15 @@ public interface MenuService {
|
||||
* @return
|
||||
*/
|
||||
Long addMenu(AddMenuDTO param, MenuTypeEnum menuType);
|
||||
|
||||
|
||||
Long deleteMenuAuth(Long id);
|
||||
|
||||
/**
|
||||
* 菜单排序
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
Integer sortMenu(List<Long> ids);
|
||||
|
||||
}
|
||||
|
||||
@@ -9,9 +9,11 @@ import com.cool.store.entity.SysRoleMenuDO;
|
||||
import com.cool.store.enums.MenuTypeEnum;
|
||||
import com.cool.store.enums.PlatFormTypeEnum;
|
||||
import com.cool.store.service.MenuService;
|
||||
import com.cool.store.utils.CommonNodeUtils;
|
||||
import com.cool.store.vo.menu.MenuAuthTreeVO;
|
||||
import com.cool.store.vo.menu.MenuTreeVO;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -64,6 +66,33 @@ public class MenuServiceImpl implements MenuService {
|
||||
return sysMenuDAO.addMenu(AddMenuDTO.convertDO(param, menuType));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long deleteMenuAuth(Long id) {
|
||||
List<SysMenuDO> sysMenuDOList = sysMenuDAO.selectMenuAll(null, PlatFormTypeEnum.PC.getCode());
|
||||
List<Long> idList = ListUtils.emptyIfNull(sysMenuDOList)
|
||||
.stream()
|
||||
.map(SysMenuDO::getId)
|
||||
.collect(Collectors.toList());
|
||||
Map<Long, List<Long>> parentGroupMap = ListUtils.emptyIfNull(sysMenuDOList)
|
||||
.stream()
|
||||
.collect(Collectors.groupingBy(SysMenuDO::getParentId, Collectors.mapping(SysMenuDO::getId, Collectors.toList())));
|
||||
List<Long> allChildList = CommonNodeUtils.getAllChildListContainSelf(0L,id, idList, parentGroupMap);
|
||||
sysMenuDAO.batchDeleteMenu(allChildList);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer sortMenu(List<Long> ids) {
|
||||
List<SysMenuDO> list = new LinkedList<>();
|
||||
for (int i = 1; i <= ids.size(); i++) {
|
||||
SysMenuDO sysMenuDO = new SysMenuDO();
|
||||
sysMenuDO.setSort(i);
|
||||
sysMenuDO.setId(ids.get(i - 1));
|
||||
list.add(sysMenuDO);
|
||||
}
|
||||
return sysMenuDAO.batchUpdateMenu(list);
|
||||
}
|
||||
|
||||
private void getParentNode(Long menuId, Map<Long, Long> idMap, Set<Long> authMenuList) {
|
||||
Long parentId = idMap.get(menuId);
|
||||
authMenuList.add(parentId);
|
||||
|
||||
Reference in New Issue
Block a user