|
|
@ -6,10 +6,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
import com.cloud.kicc.common.core.api.R; |
|
|
|
|
|
|
|
import com.cloud.kicc.common.core.constant.SecurityConstants; |
|
|
|
import com.cloud.kicc.common.core.constant.SecurityConstants; |
|
|
|
import com.cloud.kicc.common.core.exception.CheckedException; |
|
|
|
import com.cloud.kicc.common.core.exception.CheckedException; |
|
|
|
import com.cloud.kicc.common.core.exception.CommonException; |
|
|
|
|
|
|
|
import com.cloud.kicc.common.data.entity.KiccUser; |
|
|
|
import com.cloud.kicc.common.data.entity.KiccUser; |
|
|
|
import com.cloud.kicc.common.security.util.SecurityUtils; |
|
|
|
import com.cloud.kicc.common.security.util.SecurityUtils; |
|
|
|
import com.cloud.kicc.system.api.entity.Dept; |
|
|
|
import com.cloud.kicc.system.api.entity.Dept; |
|
|
@ -106,7 +104,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us |
|
|
|
}); |
|
|
|
}); |
|
|
|
// 检测多租户信息是否存在,不存在抛出异常
|
|
|
|
// 检测多租户信息是否存在,不存在抛出异常
|
|
|
|
if (tenantCode.size() == 0) { |
|
|
|
if (tenantCode.size() == 0) { |
|
|
|
throw new CommonException("当前用户多租户不存在,请联系统管理员检查多租户是否过期或者冻结!"); |
|
|
|
throw new CheckedException("当前用户多租户不存在,请联系统管理员检查多租户是否过期或者冻结!"); |
|
|
|
} |
|
|
|
} |
|
|
|
user.setTenantId(String.join(",", tenantCode)); |
|
|
|
user.setTenantId(String.join(",", tenantCode)); |
|
|
|
user.setPermissions(ArrayUtil.toArray(permissions, String.class)); |
|
|
|
user.setPermissions(ArrayUtil.toArray(permissions, String.class)); |
|
|
@ -118,7 +116,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us |
|
|
|
User user = super.getOne(Wrappers.<User>query().lambda().eq(User::getId, SecurityUtils.getUser().getId())); |
|
|
|
User user = super.getOne(Wrappers.<User>query().lambda().eq(User::getId, SecurityUtils.getUser().getId())); |
|
|
|
this.getUserAuthority(user); |
|
|
|
this.getUserAuthority(user); |
|
|
|
if (user == null) { |
|
|
|
if (user == null) { |
|
|
|
throw new CommonException("用户信息为空,请检查当前多租户下是否有当前用户信息!"); |
|
|
|
throw new CheckedException("用户信息为空,请检查当前多租户下是否有当前用户信息!"); |
|
|
|
} |
|
|
|
} |
|
|
|
return user; |
|
|
|
return user; |
|
|
|
} |
|
|
|
} |
|
|
@ -127,7 +125,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us |
|
|
|
public void setCurrentUserTenant(String... tenantIds) { |
|
|
|
public void setCurrentUserTenant(String... tenantIds) { |
|
|
|
Authentication currentAuthentication = SecurityContextHolder.getContext().getAuthentication(); |
|
|
|
Authentication currentAuthentication = SecurityContextHolder.getContext().getAuthentication(); |
|
|
|
if (currentAuthentication == null) { |
|
|
|
if (currentAuthentication == null) { |
|
|
|
new CommonException("当前用户未登录,请登录后重试!"); |
|
|
|
new CheckedException("当前用户未登录,请登录后重试!"); |
|
|
|
} |
|
|
|
} |
|
|
|
OAuth2Authentication oAuth2Authentication = (OAuth2Authentication) currentAuthentication; |
|
|
|
OAuth2Authentication oAuth2Authentication = (OAuth2Authentication) currentAuthentication; |
|
|
|
OAuth2AccessToken accessToken = tokenStore.getAccessToken(oAuth2Authentication); |
|
|
|
OAuth2AccessToken accessToken = tokenStore.getAccessToken(oAuth2Authentication); |
|
|
|