| | |
| | | package com.zy.acs.manager.system.controller; |
| | | |
| | | import com.zy.acs.common.utils.Utils; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.framework.common.R; |
| | | import com.zy.acs.manager.common.annotation.OperationLog; |
| | | import com.zy.acs.manager.common.config.ConfigProperties; |
| | | import com.zy.acs.manager.common.security.JwtSubject; |
| | |
| | | import com.zy.acs.manager.system.controller.param.LoginParam; |
| | | import com.zy.acs.manager.system.controller.param.UpdatePasswordParam; |
| | | import com.zy.acs.manager.system.controller.result.LoginResult; |
| | | import com.zy.acs.manager.system.controller.result.MenuVo; |
| | | import com.zy.acs.manager.system.entity.Menu; |
| | | import com.zy.acs.manager.system.entity.User; |
| | | import com.zy.acs.manager.system.entity.UserLogin; |
| | |
| | | import com.zy.acs.manager.system.service.TenantService; |
| | | import com.zy.acs.manager.system.service.UserLoginService; |
| | | import com.zy.acs.manager.system.service.UserService; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.framework.common.R; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 认证控制器 |
| | |
| | | @GetMapping("/auth/menu") |
| | | public R userMenu() { |
| | | List<Menu> menus = roleMenuService.listMenuByUserId(getLoginUserId(), Menu.TYPE_MENU); |
| | | return R.ok().add(Utils.toTreeData(menus, 0L, Menu::getParentId, Menu::getId, Menu::setChildren)); |
| | | // return R.ok().add(Utils.toTreeData(menus, 0L, Menu::getParentId, Menu::getId, Menu::setChildren)); |
| | | List<MenuVo> voList = menus.stream().map(this::convertToVo).collect(Collectors.toList()); |
| | | return R.ok().add(Utils.toTreeData(voList, 0L, MenuVo::getParentId, MenuVo::getId, MenuVo::setChildren)); |
| | | } |
| | | |
| | | |
| | | |
| | | @GetMapping("/auth/tenant") |
| | | public R authHost() { |
| | |
| | | return R.error("Update Fail"); |
| | | } |
| | | |
| | | |
| | | // ---------------------------------------------------- |
| | | |
| | | private MenuVo convertToVo(Menu menu) { |
| | | if (menu == null) { |
| | | return null; |
| | | } |
| | | MenuVo vo = new MenuVo(); |
| | | vo.setId(menu.getId()); |
| | | vo.setName(menu.getName()); |
| | | vo.setParentId(menu.getParentId()); |
| | | // vo.setParentName(menu.getParentName()); |
| | | vo.setPath(menu.getPath()); |
| | | // vo.setPathName(menu.getPathName()); |
| | | vo.setRoute(menu.getRoute()); |
| | | vo.setComponent(menu.getComponent()); |
| | | vo.setType(menu.getType()); |
| | | vo.setIcon(menu.getIcon()); |
| | | vo.setSort(menu.getSort()); |
| | | if (menu.getChildren() != null && !menu.getChildren().isEmpty()) { |
| | | List<MenuVo> childDTOs = menu.getChildren().stream() |
| | | .map(this::convertToVo) |
| | | .collect(Collectors.toList()); |
| | | vo.setChildren(childDTOs); |
| | | } |
| | | return vo; |
| | | } |
| | | |
| | | } |