Browse Source

🎉 2.0.0.RC2

test
smallchill 6 years ago
parent
commit
d8255914db
  1. 10
      blade-service/blade-system/src/main/java/org/springblade/system/controller/MenuController.java
  2. 7
      blade-service/blade-system/src/main/java/org/springblade/system/service/IMenuService.java
  3. 17
      blade-service/blade-system/src/main/java/org/springblade/system/service/impl/MenuServiceImpl.java

10
blade-service/blade-system/src/main/java/org/springblade/system/controller/MenuController.java

@ -24,7 +24,6 @@ import org.springblade.core.secure.BladeUser;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.support.Kv;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.dto.MenuDTO;
import org.springblade.system.entity.Menu;
import org.springblade.system.feign.IDictClient;
import org.springblade.system.service.IMenuService;
@ -34,7 +33,6 @@ import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -155,13 +153,7 @@ public class MenuController extends BladeController {
@GetMapping("auth-routes")
@ApiOperation(value = "菜单的角色权限", position = 8)
public R<List<Kv>> authRoutes(BladeUser user) {
if (Func.isEmpty(user)) {
return null;
}
List<Kv> list = new ArrayList<>();
List<MenuDTO> routes = menuService.authRoutes(Func.toIntList(user.getRoleId()));
routes.forEach(route -> list.add(Kv.create().set(route.getPath(), Kv.create().set("authority", Func.toStrArray(route.getAlias())))));
return R.data(list);
return R.data(menuService.authRoutes(user));
}
}

7
blade-service/blade-system/src/main/java/org/springblade/system/service/IMenuService.java

@ -18,7 +18,8 @@ package org.springblade.system.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.system.dto.MenuDTO;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.tool.support.Kv;
import org.springblade.system.entity.Menu;
import org.springblade.system.vo.MenuVO;
@ -81,9 +82,9 @@ public interface IMenuService extends IService<Menu> {
/**
* 获取配置的角色权限
* @param roleIds
* @param user
* @return
*/
List<MenuDTO> authRoutes(List<Integer> roleIds);
List<Kv> authRoutes(BladeUser user);
}

17
blade-service/blade-system/src/main/java/org/springblade/system/service/impl/MenuServiceImpl.java

@ -20,7 +20,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.tool.node.ForestNodeMerger;
import org.springblade.core.tool.support.Kv;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.dto.MenuDTO;
import org.springblade.system.entity.Menu;
@ -32,10 +34,7 @@ import org.springblade.system.vo.MenuVO;
import org.springblade.system.wrapper.MenuWrapper;
import org.springframework.stereotype.Service;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -99,8 +98,14 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements IM
}
@Override
public List<MenuDTO> authRoutes(List<Integer> roleIds) {
return baseMapper.authRoutes(roleIds);
public List<Kv> authRoutes(BladeUser user) {
if (Func.isEmpty(user)) {
return null;
}
List<MenuDTO> routes = baseMapper.authRoutes(Func.toIntList(user.getRoleId()));
List<Kv> list = new ArrayList<>();
routes.forEach(route -> list.add(Kv.create().set(route.getPath(), Kv.create().set("authority", Func.toStrArray(route.getAlias())))));
return list;
}
}

Loading…
Cancel
Save