新增了客户端统一界面

This commit is contained in:
wanggeng 2021-11-15 23:34:23 +08:00
parent 1e927a707b
commit 540b235d3b
22 changed files with 422 additions and 21 deletions

View File

@ -0,0 +1,131 @@
package cn.com.tenlion.usercenter.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.apache.commons.lang3.StringUtils;
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 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");
mv.addObject("listOAuth2Client", listOAuth2ClientOfMine());
mv.addObject("systemTitle", ConfigManager.getInstance().getConfig().get("systemTitle"));
return mv;
}
/**
* 我的客户端列表
*
* @return
*/
private List<OAuth2ClientSimpleDTO> listOAuth2ClientOfMine() {
List<String> roleIds = securityComponent.listRoleIds();
if (securityComponent.isAdmin(roleIds)) {
List<OAuth2ClientSimpleDTO> oAuth2ClientSimpleDTOs = oauth2ClientService.listSimple();
oAuth2ClientSimpleDTOs.add(0, getUserCenter());
return oAuth2ClientSimpleDTOs;
}
// 自己角色的菜单
List<String> menuIds = roleMenuBaseService.listMenuId(roleIds);
if (menuIds.isEmpty()) {
return new ArrayList<>();
}
// 根节点菜单
List<MenuDTO> rootMenuDTOs = menuBaseService.listByParentId("0");
if (rootMenuDTOs.isEmpty()) {
return new ArrayList<>();
}
List<String> rootMenuIds = listRootMenuIdOfMine(rootMenuDTOs, menuIds);
if (rootMenuIds.isEmpty()) {
return new ArrayList<>();
}
List<OAuth2ClientSimpleDTO> oAuth2ClientSimpleDTOs = oauth2ClientService.listSimpleByMenuIdsAndEnvironment(rootMenuIds, IOAuth2ClientService.OAUTH_CLIENT_ENVIRONMENT_FORMAL);
if (hasUserCenter(rootMenuIds)) {
oAuth2ClientSimpleDTOs.add(0, getUserCenter());
}
return oAuth2ClientSimpleDTOs;
}
/**
* 是否有用户中心
*
* @return
*/
private boolean hasUserCenter(List<String> menuIds) {
for (String menuId : menuIds) {
if (StringUtils.equals("unified-user", menuId)) {
return true;
}
}
return false;
}
/**
* 我的根节点菜单
*
* @param rootMenuDTOs
* @param mineMenuIds
* @return
*/
private List<String> listRootMenuIdOfMine(List<MenuDTO> rootMenuDTOs, List<String> mineMenuIds) {
List<String> 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.setWebServerRedirectUri("default-main");
return oAuth2ClientSimpleDTO;
}
}

View File

@ -41,7 +41,7 @@ public class UserExpandDTO extends UserDTO {
}
public Integer getUserLevel() {
return userLevel == null ? 0 : userLevel;
return userLevel == null ? -1 : userLevel;
}
public void setUserLevel(Integer userLevel) {

View File

@ -84,8 +84,7 @@ public class UserExpandServiceImpl extends DefaultBaseService implements IUserEx
Map<String, Object> params = getHashMap(2);
params.put("userIds", userIds);
List<UserExpandDTO> userExpandDTOs = list(params);
setUser(userDTOs, userExpandDTOs);
return userExpandDTOs;
return listUserExpand(userDTOs, userExpandDTOs);
}
@Override
@ -98,8 +97,7 @@ public class UserExpandServiceImpl extends DefaultBaseService implements IUserEx
Map<String, Object> params = getHashMap(2);
params.put("userIds", userIds);
List<UserExpandDTO> userExpandDTOs = list(params);
setUser(userDTOs, userExpandDTOs);
return userExpandDTOs;
return listUserExpand(userDTOs, userExpandDTOs);
}
@Override
@ -210,6 +208,34 @@ public class UserExpandServiceImpl extends DefaultBaseService implements IUserEx
}
}
/**
* 拓展用户列表
*
* @param userDTOs
* @param userExpandDTOs
* @return
*/
private List<UserExpandDTO> listUserExpand(List<UserDTO> userDTOs, List<UserExpandDTO> userExpandDTOs) {
List<UserExpandDTO> resultUserExpandDTOs = new ArrayList<>();
for (UserDTO userDTO : userDTOs) {
boolean isUserExpandExist = false;
for (UserExpandDTO userExpandDTO : userExpandDTOs) {
if (StringUtils.equals(userExpandDTO.getUserId(), userDTO.getUserId())) {
isUserExpandExist = true;
userExpandDTO.setUserDTO(userDTO);
resultUserExpandDTOs.add(userExpandDTO);
break;
}
}
if (!isUserExpandExist) {
UserExpandDTO userExpandDTO = new UserExpandDTO();
userExpandDTO.setUserDTO(userDTO);
resultUserExpandDTOs.add(userExpandDTO);
}
}
return resultUserExpandDTOs;
}
/**
* 设置部门
*

View File

@ -3,6 +3,7 @@ server:
url: http://192.168.0.103:7011/usercenter
system-title: 统一用户管理系统
system-sub-title: 智慧城市
default-index-page: route/custom/index
servlet:
context-path: /usercenter
@ -94,5 +95,6 @@ logging:
level:
root: error
org.springframework.data.mongodb: debug
org.springframework.web.client: debug
org.springframework.boot.autoconfigure.security.servlet: debug
ink.wgink: debug

View File

@ -136,14 +136,18 @@
t1.gmt_modified
FROM
sys_user_expand t1
WHERE
<if test="userIds != null and userIds.size > 0">
AND
t1.user_id IN
<foreach collection="userIds" index="index" open="(" separator="," close=")">
#{userIds[${index}]}
</foreach>
</if>
<where>
<if test="areaCode != null and areaCode != ''">
t1.area_code = #{areaCode}
</if>
<if test="userIds != null and userIds.size > 0">
AND
t1.user_id IN
<foreach collection="userIds" index="index" open="(" separator="," close=")">
#{userIds[${index}]}
</foreach>
</if>
</where>
</select>
<!-- 列表 -->
@ -155,14 +159,18 @@
t1.user_level
FROM
sys_user_expand t1
WHERE
<if test="userIds != null and userIds.size > 0">
AND
t1.user_id IN
<foreach collection="userIds" index="index" open="(" separator="," close=")">
#{userIds[${index}]}
</foreach>
</if>
<where>
<if test="areaCode != null and areaCode != ''">
t1.area_code = #{areaCode}
</if>
<if test="userIds != null and userIds.size > 0">
AND
t1.user_id IN
<foreach collection="userIds" index="index" open="(" separator="," close=")">
#{userIds[${index}]}
</foreach>
</if>
</where>
</select>
</mapper>

View File

@ -0,0 +1,106 @@
@charset "utf-8";
/* CSS Document */
body {
background: url('../../../images/oauth/07.jpeg') no-repeat;
background-size: cover;
}
#certify {
width: 1200px;
margin: 0 auto;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%)
}
#certify .swiper-container {
padding-bottom: 60px;
}
#certify .swiper-slide {
width: 520px;
height: 350px;
background: #fff;
/*box-shadow: 0 8px 30px #ddd;*/
position: relative;
cursor: pointer;
}
#certify .swiper-slide img {
display: block;
width: 100%;
height: 100%
}
#certify .swiper-slide p {
line-height: 98px;
padding-top: 0;
text-align: center;
margin: 0;
position: absolute;
bottom: 0;
width: 100%;
color: #fff;
font-size: 1.5em;
font-weight: bold;
}
#certify .swiper-pagination {
width: 100%;
bottom: 20px;
}
#certify .swiper-pagination-bullets .swiper-pagination-bullet {
margin: 0 5px;
border: 3px solid #fff;
background-color: #d5d5d5;
width: 10px;
height: 10px;
opacity: 1;
}
#certify .swiper-pagination-bullets .swiper-pagination-bullet-active {
border: 3px solid #00aadc;
background-color: #fff;
}
#certify .swiper-button-prev {
left: -30px;
width: 45px;
height: 45px;
background: url(../images/wm_button_icon.png) no-repeat;
background-position: 0 0;
background-size: 100%;
}
#certify .swiper-button-prev:hover {
background-position: 0 -46px;
background-size: 100%
}
#certify .swiper-button-next {
right: -30px;
width: 45px;
height: 45px;
background: url(../images/wm_button_icon.png) no-repeat;
background-position: 0 -93px;
background-size: 100%;
}
#certify .swiper-button-next:hover {
background-position: 0 -139px;
background-size: 100%
}
#logoutBtn {
position: fixed;
top: 15px;
right: 15px;
width: 32px;
height: 32px;
display: block;
background: url('../../../images/oauth/btn-logout.png') no-repeat;
background-size: 100% 100%;
}

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 548 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 298 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 KiB

View File

@ -0,0 +1,83 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<base th:href="${#request.getContextPath() + '/'}">
<meta charset="utf-8">
<title th:text="${systemTitle}"></title>
<link rel="stylesheet" href="assets/custom/index/css/swiper.min.css">
<link rel="stylesheet" href="assets/custom/index/css/certify.css">
<style>
</style>
</head>
<body>
<div id="certify">
<div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide" th:each="oAuth2Client: ${listOAuth2Client}" th:attr="data-href=${oAuth2Client.webServerRedirectUri}">
<img th:if="${oAuth2Client.systemIcon ne ''}" th:src="'route/file/download/false/'+ ${oAuth2Client.systemIcon}"/>
<img th:if="${oAuth2Client.systemIcon eq ''}" src="assets/images/oauth/icon-user-center.jpg"/>
<p th:text="${oAuth2Client.clientName}"></p>
</div>
</div>
</div>
<div class="swiper-pagination"></div>
<div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div>
</div>
<a id="logoutBtn" href="oauth/logout" title="退出系统"></a>
<script src="assets/js/jquery-3.5.1.min.js"></script>
<script src="assets/custom/index/js/swiper.min.js"></script>
<script>
(function() {
var certifySwiper = new Swiper('#certify .swiper-container', {
watchSlidesProgress: true,
slidesPerView: 'auto',
centeredSlides: true,
loop: true,
loopedSlides: 5,
// autoplay: true,
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
pagination: {
el: '.swiper-pagination',
clickable :true,
},
on: {
progress: function(progress) {
for (i = 0; i < this.slides.length; i++) {
var slide = this.slides.eq(i);
var slideProgress = this.slides[i].progress;
modify = 1;
if (Math.abs(slideProgress) > 1) {
modify = (Math.abs(slideProgress) - 1) * 0.3 + 1;
}
translate = slideProgress * modify * 260 + 'px';
scale = 1 - Math.abs(slideProgress) / 5;
zIndex = 999 - Math.abs(Math.round(10 * slideProgress));
slide.transform('translateX(' + translate + ') scale(' + scale + ')');
slide.css('zIndex', zIndex);
slide.css('opacity', 1);
if (Math.abs(slideProgress) > 3) {
slide.css('opacity', 0);
}
}
},
setTransition: function(transition) {
for (var i = 0; i < this.slides.length; i++) {
var slide = this.slides.eq(i)
slide.transition(transition);
}
}
}
})
$('.swiper-slide').on('click', function() {
var data = this.dataset;
window.location.href = data.href;
});
})();
</script>
</body>
</html>

View File

@ -1,13 +1,33 @@
package cn.com.tenlion.usercenter;
import cn.com.tenlion.usercenter.pojo.dtos.userexpand.UserExpandDTO;
import cn.com.tenlion.usercenter.service.userexpand.IUserExpandService;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.ArrayList;
import java.util.List;
@RunWith(SpringRunner.class)
@ActiveProfiles("test")
@SpringBootTest
class SmartCityUsercenterApplicationTests {
@Autowired
private IUserExpandService userExpandService;
@Test
void contextLoads() {
List<String> userIds = new ArrayList<>();
userIds.add("9df78aad-28a2-4881-8c43-59ef732c6f1f");
List<UserExpandDTO> userExpandDTOs = userExpandService.listWholeByUserIds(userIds);
for (UserExpandDTO userExpandDTO : userExpandDTOs) {
System.out.println(userExpandDTO);
}
}
}