diff --git a/pom.xml b/pom.xml index 7ec1c86..963e26d 100644 --- a/pom.xml +++ b/pom.xml @@ -101,7 +101,6 @@ 1.0-SNAPSHOT - ink.wgink service-core @@ -133,15 +132,12 @@ 0.1.1 - org.quartz-scheduler quartz RELEASE - - ink.wgink module-article diff --git a/src/main/java/cn/com/tenlion/xzszwhy/base/controller/route/index/CustomIndexPageRouteController.java b/src/main/java/cn/com/tenlion/xzszwhy/base/controller/route/index/CustomIndexPageRouteController.java new file mode 100644 index 0000000..57f16a2 --- /dev/null +++ b/src/main/java/cn/com/tenlion/xzszwhy/base/controller/route/index/CustomIndexPageRouteController.java @@ -0,0 +1,134 @@ +package cn.com.tenlion.xzszwhy.base.controller.route.index; + +import ink.wgink.common.component.SecurityComponent; +import ink.wgink.interfaces.consts.ISystemConstant; +import ink.wgink.interfaces.menu.IMenuBaseService; +import ink.wgink.interfaces.role.IRoleMenuBaseService; +import ink.wgink.login.base.manager.ConfigManager; +import ink.wgink.login.oauth2.server.pojo.dtos.OAuth2ClientSimpleDTO; +import ink.wgink.login.oauth2.server.service.IOAuth2ClientService; +import ink.wgink.pojo.dtos.menu.MenuDTO; +import io.swagger.annotations.Api; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.ModelAndView; +import org.thymeleaf.util.StringUtils; + +import java.util.ArrayList; +import java.util.List; + +/** + * @ClassName: CustomIndexPageRouteController + * @Description: 自定义index页面 + * @Author: wanggeng + * @Date: 2021/11/15 2:37 下午 + * @Version: 1.0 + */ +@Api(tags = ISystemConstant.ROUTE_TAGS_PREFIX + "自定义index页面路由") +@RestController +@RequestMapping(ISystemConstant.ROUTE_PREFIX + "/custom") +public class CustomIndexPageRouteController { + + @Autowired + private SecurityComponent securityComponent; + @Autowired + private IMenuBaseService menuBaseService; + @Autowired + private IRoleMenuBaseService roleMenuBaseService; + @Autowired + private IOAuth2ClientService oauth2ClientService; + + @GetMapping("index") + public ModelAndView index() { + ModelAndView mv = new ModelAndView("index/index"); + List oAuth2ClientSimpleDTOs = listOAuth2ClientOfMine(); + mv.addObject("listOAuth2Client", oAuth2ClientSimpleDTOs); + mv.addObject("listOAuth2ClientSize", oAuth2ClientSimpleDTOs.size()); + mv.addObject("systemTitle", ConfigManager.getInstance().getConfig().get("systemTitle")); + return mv; + } + + /** + * 我的客户端列表 + * + * @return + */ + private List listOAuth2ClientOfMine() { + List roleIds = securityComponent.listRoleIds(); + if (securityComponent.isAdmin(roleIds)) { + List oAuth2ClientSimpleDTOs = oauth2ClientService.listSimpleByEnvironment(IOAuth2ClientService.OAUTH_CLIENT_ENVIRONMENT_FORMAL); + oAuth2ClientSimpleDTOs.add(0, getUserCenter()); + return oAuth2ClientSimpleDTOs; + } + // 自己角色的菜单 + List menuIds = roleMenuBaseService.listMenuId(roleIds); + if (menuIds.isEmpty()) { + return new ArrayList<>(); + } + // 根节点菜单 + List rootMenuDTOs = menuBaseService.listByParentId("0"); + if (rootMenuDTOs.isEmpty()) { + return new ArrayList<>(); + } + List rootMenuIds = listRootMenuIdOfMine(rootMenuDTOs, menuIds); + if (rootMenuIds.isEmpty()) { + return new ArrayList<>(); + } + List oAuth2ClientSimpleDTOs = oauth2ClientService.listSimpleByMenuIdsAndEnvironment(rootMenuIds, IOAuth2ClientService.OAUTH_CLIENT_ENVIRONMENT_FORMAL); + if (hasUserCenter(rootMenuIds)) { + oAuth2ClientSimpleDTOs.add(0, getUserCenter()); + } + return oAuth2ClientSimpleDTOs; + } + + /** + * 是否有用户中心 + * + * @return + */ + private boolean hasUserCenter(List menuIds) { + for (String menuId : menuIds) { + if (StringUtils.equals("unified-user", menuId)) { + return true; + } + } + return false; + } + + /** + * 我的根节点菜单 + * + * @param rootMenuDTOs + * @param mineMenuIds + * @return + */ + private List listRootMenuIdOfMine(List rootMenuDTOs, List mineMenuIds) { + List rootMenuIds = new ArrayList<>(); + for (MenuDTO menuDTO : rootMenuDTOs) { + for (String mineMenuId : mineMenuIds) { + if (StringUtils.equals(menuDTO.getMenuId(), mineMenuId)) { + rootMenuIds.add(menuDTO.getMenuId()); + break; + } + } + } + return rootMenuIds; + } + + /** + * 统一用户 + * + * @return + */ + private OAuth2ClientSimpleDTO getUserCenter() { + OAuth2ClientSimpleDTO oAuth2ClientSimpleDTO = new OAuth2ClientSimpleDTO(); + oAuth2ClientSimpleDTO.setSystemIcon(""); + oAuth2ClientSimpleDTO.setClientName("统一用户管理系统"); + oAuth2ClientSimpleDTO.setEnvironment("oauth2 server"); + oAuth2ClientSimpleDTO.setWebServerRedirectUri("default-main"); + return oAuth2ClientSimpleDTO; + } + +} diff --git a/src/main/resources/templates/index/index.html b/src/main/resources/templates/index/index.html new file mode 100644 index 0000000..24bd9e0 --- /dev/null +++ b/src/main/resources/templates/index/index.html @@ -0,0 +1,95 @@ + + + + + + + + + + + +
+
+ {{date}} + + + 退出系统 + +
+
+
+ +
+
+
+
+ + + + + \ No newline at end of file