Commit 938b6ed6 authored by fangxinjiang's avatar fangxinjiang

B端服务-登录改造

parent a465f883
......@@ -41,7 +41,7 @@
</select>
<select id="getCustomerUser" resultType="com.yifu.cloud.plus.v1.yifu.archives.vo.MSetttleCustomerUserVo">
select a.user_id,GROUP_CONCAT(DISTINCT b.CUSTOMER_NAME) as CUSTOMER_NAME from m_setttle_customer_user a
left join t_customer_info b on a.customer_id = b.id
left join t_settle_domain b on a.customer_id = b.CUSTOMER_ID
where a.user_id in
<foreach item="item" index="index" collection="userIdList" open="(" separator="," close=")">
'${item}'
......
......@@ -80,12 +80,12 @@ public class YifuClientLoginSuccessHandler implements AuthenticationSuccessHandl
}*/
/*if (null != user.getClientRoleMap()){//验证角色
List<Integer> thisClientRoleList = user.getClientRoleMap().get(clientId);
List<Long> thisClientRoleList = user.getClientRoleMap().get(clientId);
if(null == thisClientRoleList){
if(null != ServiceNameConstants.CLIENT_NAME_MAP.get(clientId)){
clientId = ServiceNameConstants.CLIENT_NAME_MAP.get(clientId);
}
throw new InvalidException(user.getNickName()+"没有\""+ clientId +"\"的角色!请联系管理员分配角色!");
throw new InvalidException(user.getNickname()+"没有\""+ clientId +"\"的角色!请联系管理员分配角色!");
}else{
if (null != user.getAuthorities()){//剔除非登录终端的权限(权限只能重建,不能修改)
final String finalClientId = clientId;
......
package com.yifu.cloud.plus.v1.yifu.common.core.constant;
/**
* @Author fxj
* @Date 2022/12/28
* @Description
* @Version 1.0
*/
public interface ClientNameConstants {
/**
* MVP
*/
String CLIENT_MVP = "yifu-mvp";
/**
* MVP
*/
String CLIENT_B = "hrCustomer";
}
......@@ -88,7 +88,8 @@ public class YifuUser extends User {
public YifuUser(String id, Long deptId,String deptName, String username, String nickname,String systemFlag,
String password, String phone, boolean enabled, boolean accountNonExpired,
boolean credentialsNonExpired, boolean accountNonLocked,
String userGroup, Collection<? extends GrantedAuthority> authorities, String ldapDn) {
String userGroup, Collection<? extends GrantedAuthority> authorities, String ldapDn,
Map<String, List<Long>> clientRoleMap) {
super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);
this.id = id;
this.deptId = deptId;
......@@ -98,6 +99,7 @@ public class YifuUser extends User {
this.systemFlag = systemFlag;
this.userGroup = userGroup;
this.ldapDn = ldapDn;
this.clientRoleMap=clientRoleMap;
}
}
......@@ -73,7 +73,7 @@ public interface YifuUserDetailsService extends UserDetailsService, Ordered {
user.getNickname(),user.getSystemFlag(), SecurityConstants.BCRYPT + user.getPassword(),
user.getPhone(), true, true, true,
StrUtil.equals(user.getLockFlag(), CommonConstants.STATUS_NORMAL),
user.getUserGroup(),authorities, user.getLdapDn());
user.getUserGroup(),authorities, user.getLdapDn(),info.getClientRoleMap());
}
/**
......
......@@ -23,12 +23,12 @@ public class TreeUtil {
for (T treeNode : treeNodes) {
if (root.equals(treeNode.getParentId())) {
if (root.equals(treeNode.getParentId()) || "-1".equals(treeNode.getParentId())) {
trees.add(treeNode);
}
for (T it : treeNodes) {
if (it.getParentId() == treeNode.getId()) {
if (it.getParentId() .equals(treeNode.getId()) ) {
if (treeNode.getChildren() == null) {
treeNode.setChildren(new ArrayList<>());
}
......
......@@ -12,6 +12,7 @@ import com.yifu.cloud.plus.v1.yifu.admin.api.vo.MenuTreeForVue;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.RoleMenuR;
import com.yifu.cloud.plus.v1.yifu.admin.service.*;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ClientNameConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ServiceNameConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
......@@ -219,10 +220,9 @@ public class BusinessUserController {
@Operation(description = "返回当前用户的树形菜单集合")
@GetMapping("/menu")
public R<List<MenuTreeForVue>> getUserMenuForVue(@RequestHeader(value = HttpHeaders.AUTHORIZATION, required = false) String authHeader, String type) {
OAuth2Authentication oAuth2Auth = remoteTokenServices.loadAuthentication(authHeader.replace("bearer ", "").trim());
// 获取符合条件的菜单
Set<SysMenu> all = new HashSet<>();
SecurityUtils.getRolesByClient(oAuth2Auth.getOAuth2Request().getClientId())
SecurityUtils.getRolesByClient(ClientNameConstants.CLIENT_B)
.forEach(roleId -> all.addAll(sysMenuService.findMenuByRoleId(roleId)));
List<MenuTreeForVue> menuTreeList;
if (Common.isNotNull(type)) {
......
......@@ -22,7 +22,9 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysMenu;
import com.yifu.cloud.plus.v1.yifu.admin.service.SysMenuService;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ClientNameConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ServiceNameConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.exception.ErrorCodes;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.MsgUtils;
......@@ -81,9 +83,12 @@ public class MenuController {
* @return 当前用户的树形菜单
*/
@GetMapping
public R<List<Tree<Long>>> getUserMenu(Long parentId) {
public R<List<Tree<Long>>> getUserMenu(Long parentId,String clientId) {
// 获取符合条件的菜单
Set<SysMenu> menuSet = SecurityUtils.getRoles().stream().map(sysMenuService::findMenuByRoleId)
if (Common.isEmpty(clientId)){
clientId = ClientNameConstants.CLIENT_MVP;
}
Set<SysMenu> menuSet = SecurityUtils.getRolesByClient(clientId).stream().map(sysMenuService::findMenuByRoleId)
.flatMap(Collection::stream).collect(Collectors.toSet());
return R.ok(sysMenuService.filterMenu(menuSet, parentId));
}
......@@ -138,6 +143,7 @@ public class MenuController {
return R.failed(MsgUtils.getMessage(ErrorCodes.SYS_MENU_ADD_NAME_EXIST));
}
}
sysMenu.setClientId(ClientNameConstants.CLIENT_MVP);
SysMenu menu = sysMenuService.saveAsso(sysMenu);
return R.ok(menu);
}
......
......@@ -26,11 +26,13 @@ import com.yifu.cloud.plus.v1.yifu.admin.api.vo.RoleExcelVO;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.RoleVo;
import com.yifu.cloud.plus.v1.yifu.admin.service.SysRoleMenuService;
import com.yifu.cloud.plus.v1.yifu.admin.service.SysRoleService;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ClientNameConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.autoconfigure.integration.IntegrationProperties;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
......@@ -75,6 +77,7 @@ public class RoleController {
if ( Common.isNotNull(check)) {
return check;
}
sysRole.setClientId(ClientNameConstants.CLIENT_MVP);
return R.ok(sysRoleService.save(sysRole));
}
......
......@@ -57,7 +57,7 @@
a.role_name,
c.menu_id,
c.name,
c.sort
c.sort_order
FROM
sys_role a,
sys_role_menu b
......
......@@ -300,8 +300,8 @@
select *
from sys_user AS `user`
<where> `user`.del_flag = '0'
<if test="query.organId != null and query.organId != ''">
and `user`.organ_id = #{query.organId}
<if test="query.deptId != null and query.deptId != ''">
and `user`.dept_id = #{query.deptId}
</if>
<if test="query.nickname != null and query.nickname != ''">
and `user`.nickname LIKE CONCAT('%',#{query.nickname},'%')
......@@ -309,9 +309,6 @@
<if test="query.username != null and query.username != ''">
and `user`.username LIKE CONCAT('%',#{query.username},'%')
</if>
<if test="query.organCode != null and query.organCode != ''">
and `user`.organ_code LIKE CONCAT(#{query.organCode},'%')
</if>
<if test="null != query.userIdsB and query.userIdsB.size > 0">
where b.user_id in
<foreach collection="query.userIdsB" item="item" index="index" open="(" close=")" separator=",">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment