| | |
| | | @GetMapping("/auth/menu") |
| | | public R userMenu() { |
| | | List<Menu> menus = roleMenuService.listMenuByUserId(getLoginUserId(), Menu.TYPE_MENU); |
| | | return R.ok().add(Utils.toTreeData(menus, 0, Menu::getParentId, Menu::getId, Menu::setChildren)); |
| | | return R.ok().add(Utils.toTreeData(menus, 0L, Menu::getParentId, Menu::getId, Menu::setChildren)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('sys:auth:user')") |
| | |
| | | public interface RoleMenuMapper extends BaseMapper<RoleMenu> { |
| | | |
| | | @InterceptorIgnore(tenantLine = "true") |
| | | List<Menu> listMenuByUserId(@Param("userId") Long userId, @Param("menuType") Integer menuType); |
| | | List<Menu> listMenuByUserId(@Param("userId") Long userId, @Param("type") Integer menuType); |
| | | |
| | | } |
| | |
| | | * @param <R> parentId的类型 |
| | | * @return List<T> |
| | | */ |
| | | public static <T, R> List<T> toTreeData(List<T> data, R parentId, |
| | | public static <T, R> List<T> toTreeData(List<T> data, |
| | | R parentId, |
| | | Function<? super T, ? extends R> parentIdMapper, |
| | | Function<? super T, ? extends R> idMapper, |
| | | BiConsumer<T, List<T>> consumer) { |
| | |
| | | <select id="listMenuByUserId" resultType="com.zy.asrs.wcs.sys.entity.Menu"> |
| | | select * from sys_menu |
| | | where 1=1 |
| | | <if test="type != null"> |
| | | AND type = #{type} |
| | | </if> |
| | | and id in ( |
| | | select menu_id from sys_role_menu |
| | | where role_id in ( |