mirror of https://gitee.com/stylefeng/roses
【auth】【system】重新整理登录逻辑
parent
effff8c6e0
commit
26f692459b
|
@ -54,33 +54,4 @@ public interface LoginUserApi {
|
|||
*/
|
||||
boolean getSuperAdminFlag();
|
||||
|
||||
/**
|
||||
* 判断当前用户是否登录
|
||||
*
|
||||
* @return 是否登录,true是,false否
|
||||
* @author fengshuonan
|
||||
* @date 2020/10/17 11:02
|
||||
*/
|
||||
boolean hasLogin();
|
||||
|
||||
/**
|
||||
* 判断当前登录用户是否有某资源的访问权限
|
||||
*
|
||||
* @param requestUri 请求的url,例如: /userInfo/list
|
||||
* @return 是否有访问权限,true是,false否
|
||||
* @author fengshuonan
|
||||
* @date 2020/10/17 11:03
|
||||
*/
|
||||
boolean hasPermission(String requestUri);
|
||||
|
||||
/**
|
||||
* 判断当前登录用户是否包含某个角色
|
||||
*
|
||||
* @param roleCode 角色编码
|
||||
* @return 是否包含该角色,true是,false否
|
||||
* @author fengshuonan
|
||||
* @date 2020/10/17 11:04
|
||||
*/
|
||||
boolean hasRole(String roleCode);
|
||||
|
||||
}
|
||||
|
|
|
@ -2,11 +2,12 @@ package cn.stylefeng.roses.kernel.auth.api.pojo.login;
|
|||
|
||||
import cn.hutool.core.lang.Dict;
|
||||
import cn.stylefeng.roses.kernel.auth.api.enums.DataScopeTypeEnum;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.dict.SimpleDict;
|
||||
import cn.stylefeng.roses.kernel.auth.api.pojo.login.basic.SimpleRoleInfo;
|
||||
import cn.stylefeng.roses.kernel.auth.api.pojo.login.basic.SimpleUserInfo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
|
@ -25,84 +26,42 @@ public class LoginUser implements Serializable {
|
|||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
private String realName;
|
||||
|
||||
/**
|
||||
* 账号
|
||||
*/
|
||||
private String account;
|
||||
|
||||
/**
|
||||
* 公司/组织id
|
||||
*/
|
||||
private Long organizationId;
|
||||
|
||||
/**
|
||||
* 头像(图片最终访问的url)
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 生日
|
||||
*/
|
||||
private Date birthday;
|
||||
|
||||
/**
|
||||
* 性别(具体SexEnum枚举类)(M-男,F-女)
|
||||
*/
|
||||
private String sex;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 手机
|
||||
*/
|
||||
private String mobilePhone;
|
||||
|
||||
/**
|
||||
* 固定电话
|
||||
*/
|
||||
private String tel;
|
||||
|
||||
/**
|
||||
* 超级管理员标识,true-是超级管理员
|
||||
*/
|
||||
private Boolean superAdmin;
|
||||
|
||||
/**
|
||||
* 用户数据范围类型的集合
|
||||
* 用户基本信息
|
||||
*/
|
||||
private Set<DataScopeTypeEnum> dataScopeTypes;
|
||||
private SimpleUserInfo simpleUserInfo;
|
||||
|
||||
/**
|
||||
* 用户数据范围(userId的集合)
|
||||
* <p>
|
||||
* 用户能看哪些用户数据的权限
|
||||
* 用户角色信息
|
||||
*/
|
||||
private Set<Long> userIdDataScope;
|
||||
private List<SimpleRoleInfo> simpleRoleInfoList;
|
||||
|
||||
/**
|
||||
* 组织机构数据范围(组织架构id的集合)
|
||||
* <p>
|
||||
* 用户能看哪些组织机构数据的信息
|
||||
* 公司/组织id
|
||||
*/
|
||||
private Set<Long> organizationIdDataScope;
|
||||
private Long organizationId;
|
||||
|
||||
/**
|
||||
* 具备应用信息
|
||||
* 职务信息
|
||||
*/
|
||||
private Set<SimpleDict> apps;
|
||||
private Long positionId;
|
||||
|
||||
/**
|
||||
* 角色信息
|
||||
* 用户数据范围信息
|
||||
*/
|
||||
private Set<SimpleDict> roles;
|
||||
private Set<DataScopeTypeEnum> dataScopeTypeEnums;
|
||||
private Set<Long> dataScopeUserIds;
|
||||
private Set<Long> dataScopeOrganizationIds;
|
||||
|
||||
/**
|
||||
* 可用资源集合
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package cn.stylefeng.roses.kernel.auth.api.pojo.login.basic;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 用户基本信息
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/12/26 18:14
|
||||
*/
|
||||
@Data
|
||||
public class SimpleRoleInfo {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String roleName;
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
private String roleCode;
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package cn.stylefeng.roses.kernel.auth.api.pojo.login.basic;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 用户基本信息
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/12/26 18:14
|
||||
*/
|
||||
@Data
|
||||
public class SimpleUserInfo {
|
||||
|
||||
/**
|
||||
* 昵称
|
||||
*/
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
private String realName;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private Long avatar;
|
||||
|
||||
/**
|
||||
* 生日
|
||||
*/
|
||||
private Date birthday;
|
||||
|
||||
/**
|
||||
* 性别(M-男,F-女)
|
||||
*/
|
||||
private String sex;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 手机
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 电话
|
||||
*/
|
||||
private String tel;
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package cn.stylefeng.roses.kernel.auth.api.prop;
|
||||
|
||||
import cn.stylefeng.roses.kernel.auth.api.pojo.login.LoginUser;
|
||||
|
||||
/**
|
||||
* 当前登录用户属性的组装和填充
|
||||
* <p>
|
||||
* LoginUser对象的属性比较多,为了方便后期拓展,统一用此接口为新字段set值
|
||||
* <p>
|
||||
* 使用方法:
|
||||
* <p>
|
||||
* 第一步,为LoginUser加新的字段
|
||||
* <p>
|
||||
* 第二步,新写一个类实现本接口,在expandAction方法为新属性赋值即可
|
||||
* <p>
|
||||
* 注意,这个方法里边的实现在编写时,不能使用 LoginContext 获取当前用户
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/12/22 14:18
|
||||
*/
|
||||
public interface LoginUserPropExpander {
|
||||
|
||||
/**
|
||||
* 为loginUser赋值
|
||||
*
|
||||
* @param loginUser 当前登录用户
|
||||
* @author fengshuonan
|
||||
* @date 2020/12/22 14:26
|
||||
*/
|
||||
void expandAction(LoginUser loginUser);
|
||||
|
||||
}
|
|
@ -6,13 +6,11 @@ import cn.stylefeng.roses.kernel.auth.api.SessionManagerApi;
|
|||
import cn.stylefeng.roses.kernel.auth.api.exception.AuthException;
|
||||
import cn.stylefeng.roses.kernel.auth.api.expander.AuthConfigExpander;
|
||||
import cn.stylefeng.roses.kernel.auth.api.pojo.login.LoginUser;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.dict.SimpleDict;
|
||||
import cn.stylefeng.roses.kernel.rule.util.HttpServletUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Set;
|
||||
|
||||
import static cn.stylefeng.roses.kernel.auth.api.exception.enums.AuthExceptionEnum.TOKEN_GET_ERROR;
|
||||
|
||||
|
@ -91,52 +89,4 @@ public class LoginUserImpl implements LoginUserApi {
|
|||
return loginUser.getSuperAdmin();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasLogin() {
|
||||
|
||||
// 获取用户的token
|
||||
String token = null;
|
||||
try {
|
||||
token = getToken();
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 获取是否在会话中有
|
||||
return sessionManagerApi.haveSession(token);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String requestUri) {
|
||||
|
||||
LoginUser loginUser = getLoginUser();
|
||||
|
||||
Set<String> resourceUrls = loginUser.getResourceUrls();
|
||||
|
||||
if (resourceUrls != null && resourceUrls.size() > 0) {
|
||||
return resourceUrls.contains(requestUri);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasRole(String roleCode) {
|
||||
|
||||
LoginUser loginUser = getLoginUser();
|
||||
|
||||
Set<SimpleDict> roles = loginUser.getRoles();
|
||||
|
||||
if (roles != null && roles.size() > 0) {
|
||||
for (SimpleDict role : roles) {
|
||||
if (role.getCode().equals(roleCode)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package cn.stylefeng.roses.kernel.system;
|
||||
|
||||
import cn.stylefeng.roses.kernel.system.pojo.organization.DataScopeResponse;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.role.response.SysRoleResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据范围的获取接口
|
||||
|
@ -17,11 +20,12 @@ public interface DataScopeApi {
|
|||
* <p>
|
||||
* 此方法用在非超级管理员用户的获取数据范围
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @param userId 用户id
|
||||
* @param sysRoles 角色信息
|
||||
* @return 数据范围内容
|
||||
* @author majianguo
|
||||
* @date 2020/11/5 上午11:44
|
||||
*/
|
||||
DataScopeResponse getDataScope(Long userId);
|
||||
DataScopeResponse getDataScope(Long userId, List<SysRoleResponse> sysRoles);
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import cn.stylefeng.roses.kernel.resource.api.pojo.resource.ResourceDefinition;
|
|||
import cn.stylefeng.roses.kernel.resource.api.pojo.resource.ResourceUrlParam;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 资源服务相关接口
|
||||
|
@ -24,23 +25,13 @@ public interface ResourceServiceApi {
|
|||
ResourceDefinition getResourceByUrl(ResourceUrlParam resourceUrlReq);
|
||||
|
||||
/**
|
||||
* 获取资源详情,根据资源id集合
|
||||
* 获取资源的url列表,根据资源code集合查询
|
||||
*
|
||||
* @param resourceCodes 资源code集合
|
||||
* @return 资源详情列表
|
||||
* @author fengshuonan
|
||||
* @date 2020/11/29 19:49
|
||||
*/
|
||||
List<ResourceDefinition> getResourceListByIds(List<String> resourceCodes);
|
||||
|
||||
/**
|
||||
* 获取资源的url列表,根据资源ids查询
|
||||
*
|
||||
* @param resourceIds 资源id集合
|
||||
* @param resourceCodes 资源编码集合
|
||||
* @return 资源url列表
|
||||
* @author fengshuonan
|
||||
* @date 2020/11/29 19:49
|
||||
*/
|
||||
List<String> getResourceUrlsListByIds(List<String> resourceIds);
|
||||
Set<String> getResourceUrlsListByCodes(List<String> resourceCodes);
|
||||
|
||||
}
|
||||
|
|
|
@ -53,13 +53,13 @@ public interface RoleServiceApi {
|
|||
List<Long> getMenuIdsByRoleIds(List<Long> roleIds);
|
||||
|
||||
/**
|
||||
* 获取角色的资源id集合
|
||||
* 获取角色的资源code集合
|
||||
*
|
||||
* @param roleIdList 角色id集合
|
||||
* @return 资源id集合
|
||||
* @return 资源code集合
|
||||
* @author majianguo
|
||||
* @date 2020/11/5 上午11:17
|
||||
*/
|
||||
List<String> getRoleResourceList(List<Long> roleIdList);
|
||||
List<String> getRoleResourceCodeList(List<Long> roleIdList);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package cn.stylefeng.roses.kernel.system.exception;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.stylefeng.roses.kernel.rule.abstracts.AbstractExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||
import cn.stylefeng.roses.kernel.system.constants.SystemConstants;
|
||||
|
@ -12,6 +13,10 @@ import cn.stylefeng.roses.kernel.system.constants.SystemConstants;
|
|||
*/
|
||||
public class SystemModularException extends ServiceException {
|
||||
|
||||
public SystemModularException(AbstractExceptionEnum exception, Object... params) {
|
||||
super(SystemConstants.SYSTEM_MODULE_NAME, exception.getErrorCode(), StrUtil.format(exception.getUserTip(), params));
|
||||
}
|
||||
|
||||
public SystemModularException(AbstractExceptionEnum exception, String userTip) {
|
||||
super(SystemConstants.SYSTEM_MODULE_NAME, exception.getErrorCode(), userTip);
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ public enum SysUserExceptionEnum implements AbstractExceptionEnum {
|
|||
/**
|
||||
* 用户不存在
|
||||
*/
|
||||
USER_NOT_EXIST(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + SystemConstants.SYSTEM_EXCEPTION_STEP_CODE + "51", "用户不存在"),
|
||||
USER_NOT_EXIST(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + SystemConstants.SYSTEM_EXCEPTION_STEP_CODE + "51", "用户不存在,用户id或账号为:{}"),
|
||||
|
||||
/**
|
||||
* 账号已存在
|
||||
|
@ -86,7 +86,17 @@ public enum SysUserExceptionEnum implements AbstractExceptionEnum {
|
|||
/**
|
||||
* 当前用户未分配菜单
|
||||
*/
|
||||
USER_NOT_HAVE_MENUS(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + SystemConstants.SYSTEM_EXCEPTION_STEP_CODE + "60", "当前用户未分配菜单");
|
||||
USER_NOT_HAVE_MENUS(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + SystemConstants.SYSTEM_EXCEPTION_STEP_CODE + "60", "当前用户未分配菜单"),
|
||||
|
||||
/**
|
||||
* 用户未绑定角色
|
||||
*/
|
||||
USER_NOT_BIND_ROLE(RuleConstants.BUSINESS_ERROR_TYPE_CODE + SystemConstants.SYSTEM_EXCEPTION_STEP_CODE + "61", "用户未绑定角色"),
|
||||
|
||||
/**
|
||||
* 系统错误,账号存在多个
|
||||
*/
|
||||
ACCOUNT_HAVE_MANY(RuleConstants.BUSINESS_ERROR_TYPE_CODE + SystemConstants.SYSTEM_EXCEPTION_STEP_CODE + "62", "系统错误,账号存在多个,账号为:{}");
|
||||
|
||||
/**
|
||||
* 错误编码
|
||||
|
|
|
@ -62,7 +62,7 @@ public class SysMenuRequest extends BaseRequest {
|
|||
/**
|
||||
* 应用分类(应用编码)
|
||||
*/
|
||||
@NotBlank(message = "应用分类不能为空", groups = {add.class, edit.class, getAppMenus.class})
|
||||
@NotBlank(message = "appCode不能为空", groups = {add.class, edit.class, getAppMenus.class})
|
||||
private String appCode;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
package cn.stylefeng.roses.kernel.system.pojo.organization;
|
||||
|
||||
import cn.stylefeng.roses.kernel.auth.api.enums.DataScopeTypeEnum;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.role.response.SysRoleResponse;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
|
@ -31,9 +29,4 @@ public class DataScopeResponse {
|
|||
*/
|
||||
private Set<Long> organizationIds;
|
||||
|
||||
/**
|
||||
* 角色信息
|
||||
*/
|
||||
private List<SysRoleResponse> sysRoleResponses;
|
||||
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ public class DataScopeUtil {
|
|||
return tips.append("空:获取不到当前用户").toString();
|
||||
}
|
||||
|
||||
Set<DataScopeTypeEnum> dataScopeTypes = loginUser.getDataScopeTypes();
|
||||
Set<DataScopeTypeEnum> dataScopeTypes = loginUser.getDataScopeTypeEnums();
|
||||
if (dataScopeTypes == null) {
|
||||
return tips.append("空:数据范围为空").toString();
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class DataScopeUtil {
|
|||
}
|
||||
}
|
||||
|
||||
Set<Long> userDataScope = loginUser.getUserIdDataScope();
|
||||
Set<Long> userDataScope = loginUser.getDataScopeUserIds();
|
||||
tips.append("用户userId数据范围:");
|
||||
if (userDataScope != null && !userDataScope.isEmpty()) {
|
||||
for (Long id : userDataScope) {
|
||||
|
@ -57,7 +57,7 @@ public class DataScopeUtil {
|
|||
}
|
||||
}
|
||||
|
||||
Set<Long> organizationDataScope = loginUser.getOrganizationIdDataScope();
|
||||
Set<Long> organizationDataScope = loginUser.getDataScopeOrganizationIds();
|
||||
tips.append("用户organizationId数据范围:");
|
||||
if (organizationDataScope != null && !organizationDataScope.isEmpty()) {
|
||||
for (Long id : organizationDataScope) {
|
||||
|
@ -91,8 +91,8 @@ public class DataScopeUtil {
|
|||
}
|
||||
|
||||
// 获取用户的数据范围类型,user数据范围,组织机构数据范围
|
||||
Set<DataScopeTypeEnum> dataScopeTypes = loginUser.getDataScopeTypes();
|
||||
Set<Long> organizationDataScope = loginUser.getOrganizationIdDataScope();
|
||||
Set<DataScopeTypeEnum> dataScopeTypes = loginUser.getDataScopeTypeEnums();
|
||||
Set<Long> organizationDataScope = loginUser.getDataScopeOrganizationIds();
|
||||
|
||||
// 如果数据范围类型为空,则返回没权限
|
||||
if (dataScopeTypes == null || dataScopeTypes.isEmpty()) {
|
||||
|
|
|
@ -29,6 +29,7 @@ import cn.hutool.core.collection.CollectionUtil;
|
|||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.stylefeng.roses.kernel.auth.api.context.LoginContext;
|
||||
import cn.stylefeng.roses.kernel.auth.api.pojo.login.LoginUser;
|
||||
import cn.stylefeng.roses.kernel.auth.api.pojo.login.basic.SimpleRoleInfo;
|
||||
import cn.stylefeng.roses.kernel.db.api.DbOperatorApi;
|
||||
import cn.stylefeng.roses.kernel.menu.modular.entity.SysMenu;
|
||||
import cn.stylefeng.roses.kernel.menu.modular.factory.MenuFactory;
|
||||
|
@ -38,7 +39,6 @@ import cn.stylefeng.roses.kernel.rule.enums.StatusEnum;
|
|||
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||
import cn.stylefeng.roses.kernel.rule.factory.DefaultTreeBuildFactory;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.dict.SimpleDict;
|
||||
import cn.stylefeng.roses.kernel.system.MenuServiceApi;
|
||||
import cn.stylefeng.roses.kernel.system.RoleServiceApi;
|
||||
import cn.stylefeng.roses.kernel.system.constants.SymbolConstant;
|
||||
|
@ -293,7 +293,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
|
||||
// 获取当前用户的角色id集合
|
||||
LoginUser loginUser = LoginContext.me().getLoginUser();
|
||||
List<Long> roleIdList = loginUser.getRoles().stream().map(SimpleDict::getId).collect(Collectors.toList());
|
||||
List<Long> roleIdList = loginUser.getSimpleRoleInfoList().stream().map(SimpleRoleInfo::getRoleId).collect(Collectors.toList());
|
||||
|
||||
// 当前用户角色为空,则没菜单
|
||||
if (ObjectUtil.isEmpty(roleIdList)) {
|
||||
|
|
|
@ -42,7 +42,7 @@ public class DataScopeService implements DataScopeApi {
|
|||
private DbOperatorApi dbOperatorApi;
|
||||
|
||||
@Override
|
||||
public DataScopeResponse getDataScope(Long userId) {
|
||||
public DataScopeResponse getDataScope(Long userId, List<SysRoleResponse> sysRoles) {
|
||||
|
||||
// 初始化返回结果
|
||||
DataScopeResponse dataScopeResponse = new DataScopeResponse();
|
||||
|
@ -54,27 +54,20 @@ public class DataScopeService implements DataScopeApi {
|
|||
throw new DataScopeException(DataScopeExceptionEnum.USER_ID_EMPTY_ERROR, userTip);
|
||||
}
|
||||
|
||||
// 获取用户的所有角色
|
||||
List<Long> userRoleIdList = userServiceApi.getUserRoleIdList(userId);
|
||||
if (userRoleIdList.isEmpty()) {
|
||||
String userTip = StrUtil.format(DataScopeExceptionEnum.ROLE_EMPTY_ERROR.getUserTip(), userId);
|
||||
throw new DataScopeException(DataScopeExceptionEnum.ROLE_EMPTY_ERROR, userTip);
|
||||
}
|
||||
|
||||
// 获取角色信息详情
|
||||
List<SysRoleResponse> sysRoles = roleServiceApi.getRolesByIds(userRoleIdList);
|
||||
dataScopeResponse.setSysRoleResponses(sysRoles);
|
||||
// 获取用户的主要部门信息
|
||||
SysUserOrgResponse sysUserOrgResponse = userOrgServiceApi.getUserOrgInfo(userId);
|
||||
|
||||
// 获取角色中的数据范围类型
|
||||
Set<DataScopeTypeEnum> dataScopeTypeEnums = sysRoles.stream().map(SysRoleResponse::getDataScopeTypeEnum).collect(Collectors.toSet());
|
||||
dataScopeResponse.setDataScopeTypeEnums(dataScopeTypeEnums);
|
||||
|
||||
// 包含全部数据类型的,直接不用设置组织机构,直接放开
|
||||
// 1.根据数据范围类型的不同,填充角色拥有的 organizationIds 和 userIds 范围
|
||||
// 1.1 包含全部数据类型的,直接不用设置组织机构,直接放开
|
||||
if (dataScopeTypeEnums.contains(DataScopeTypeEnum.ALL)) {
|
||||
return dataScopeResponse;
|
||||
}
|
||||
|
||||
// 包含指定部门数据,将指定数据范围增加到Set中
|
||||
// 1.2 包含指定部门数据,将指定数据范围增加到Set中
|
||||
if (dataScopeTypeEnums.contains(DataScopeTypeEnum.DEFINE)) {
|
||||
|
||||
// 获取角色对应的组织机构范围
|
||||
|
@ -83,10 +76,7 @@ public class DataScopeService implements DataScopeApi {
|
|||
organizationIds.addAll(orgIds);
|
||||
}
|
||||
|
||||
// 获取用户的主要部门信息
|
||||
SysUserOrgResponse sysUserOrgResponse = userOrgServiceApi.getUserOrgInfo(userId);
|
||||
|
||||
// 本部门和本部门以下,查出用户的主要部门,并且查询该部门本部门及以下的组织机构id列表
|
||||
// 1.3 本部门和本部门以下,查出用户的主要部门,并且查询该部门本部门及以下的组织机构id列表
|
||||
if (dataScopeTypeEnums.contains(DataScopeTypeEnum.DEPT_WITH_CHILD)) {
|
||||
|
||||
// 获取部门及以下部门的id列表
|
||||
|
@ -96,7 +86,7 @@ public class DataScopeService implements DataScopeApi {
|
|||
organizationIds.addAll(subOrgIds);
|
||||
}
|
||||
|
||||
// 如果是本部门,则查出本部门并添加到组织机构列表
|
||||
// 1.4 如果是本部门,则查出本部门并添加到组织机构列表
|
||||
if (dataScopeTypeEnums.contains(DataScopeTypeEnum.DEPT)) {
|
||||
|
||||
// 获取本部门的id
|
||||
|
@ -104,15 +94,16 @@ public class DataScopeService implements DataScopeApi {
|
|||
organizationIds.add(organizationId);
|
||||
}
|
||||
|
||||
// 如果只是本用户数据,将用户本身装进userId数据范围
|
||||
// 1.5 如果只是本用户数据,将用户本身装进userId数据范围
|
||||
if (dataScopeTypeEnums.contains(DataScopeTypeEnum.SELF)) {
|
||||
userIds.add(userId);
|
||||
}
|
||||
|
||||
// 获取用户单独绑定的组织机构id
|
||||
// 2. 获取用户单独绑定的组织机构id
|
||||
List<Long> userBindDataScope = userServiceApi.getUserBindDataScope(userId);
|
||||
organizationIds.addAll(userBindDataScope);
|
||||
|
||||
// 3. 组装返回结果
|
||||
dataScopeResponse.setUserIds(userIds);
|
||||
dataScopeResponse.setOrganizationIds(organizationIds);
|
||||
|
||||
|
|
|
@ -179,7 +179,7 @@ public class HrOrganizationServiceImpl extends ServiceImpl<HrOrganizationMapper,
|
|||
// 如果是超级管理员 或 数据范围是所有,则不过滤数据范围
|
||||
boolean needToDataScope = true;
|
||||
if (LoginContext.me().getSuperAdminFlag()) {
|
||||
Set<DataScopeTypeEnum> dataScopeTypes = LoginContext.me().getLoginUser().getDataScopeTypes();
|
||||
Set<DataScopeTypeEnum> dataScopeTypes = LoginContext.me().getLoginUser().getDataScopeTypeEnums();
|
||||
if (dataScopeTypes != null && dataScopeTypes.contains(DataScopeTypeEnum.ALL)) {
|
||||
needToDataScope = false;
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ public class HrOrganizationServiceImpl extends ServiceImpl<HrOrganizationMapper,
|
|||
|
||||
// 如果需要数据范围过滤,则获取用户的数据范围,拼接查询条件
|
||||
if (needToDataScope) {
|
||||
Set<Long> dataScope = LoginContext.me().getLoginUser().getOrganizationIdDataScope();
|
||||
Set<Long> dataScope = LoginContext.me().getLoginUser().getDataScopeOrganizationIds();
|
||||
|
||||
// 数据范围没有,直接返回空
|
||||
if (ObjectUtil.isEmpty(dataScope)) {
|
||||
|
|
|
@ -25,10 +25,7 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.stylefeng.roses.kernel.system.constants.SystemConstants.DEFAULT_PARENT_ID;
|
||||
|
@ -173,45 +170,20 @@ public class SysResourceServiceImpl extends ServiceImpl<SysResourceMapper, SysRe
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<ResourceDefinition> getResourceListByIds(List<String> resourceCodes) {
|
||||
|
||||
ArrayList<ResourceDefinition> resourceDefinitions = new ArrayList<>();
|
||||
public Set<String> getResourceUrlsListByCodes(List<String> resourceCodes) {
|
||||
|
||||
if (resourceCodes == null || resourceCodes.isEmpty()) {
|
||||
return resourceDefinitions;
|
||||
return new HashSet<>();
|
||||
}
|
||||
|
||||
// 拼接in条件
|
||||
LambdaQueryWrapper<SysResource> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(SysResource::getResourceCode, resourceCodes);
|
||||
|
||||
// 获取资源详情
|
||||
List<SysResource> list = this.list(queryWrapper);
|
||||
for (SysResource sysResource : list) {
|
||||
ResourceDefinition resourceDefinition = ResourceFactory.createResourceDefinition(sysResource);
|
||||
resourceDefinitions.add(resourceDefinition);
|
||||
}
|
||||
|
||||
return resourceDefinitions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getResourceUrlsListByIds(List<String> resourceIds) {
|
||||
|
||||
ArrayList<String> resourceUrls = new ArrayList<>();
|
||||
|
||||
if (resourceIds == null || resourceIds.isEmpty()) {
|
||||
return resourceUrls;
|
||||
}
|
||||
|
||||
// 拼接in条件
|
||||
LambdaQueryWrapper<SysResource> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(SysResource::getResourceId, resourceIds);
|
||||
queryWrapper.select(SysResource::getUrl);
|
||||
|
||||
// 获取资源详情
|
||||
List<SysResource> list = this.list(queryWrapper);
|
||||
return list.stream().map(SysResource::getUrl).collect(Collectors.toList());
|
||||
return list.stream().map(SysResource::getUrl).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,12 +24,12 @@ Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意
|
|||
*/
|
||||
package cn.stylefeng.roses.kernel.role.modular.service;
|
||||
|
||||
import cn.stylefeng.roses.kernel.role.modular.entity.SysRole;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.role.modular.entity.SysRole;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.dict.SimpleDict;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.role.request.SysRoleRequest;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.role.response.SysRoleResponse;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -116,16 +116,6 @@ public interface SysRoleService extends IService<SysRole> {
|
|||
*/
|
||||
List<Long> getRoleDataScope(SysRoleRequest sysRoleRequest);
|
||||
|
||||
/**
|
||||
* 获取用户角色相关信息
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return 增强版hashMap,格式:[{"id":456, "code":"zjl", "name":"总经理"}]
|
||||
* @author majianguo
|
||||
* @date 2020/11/5 上午11:12
|
||||
*/
|
||||
List<SimpleDict> getLoginRoles(Long userId);
|
||||
|
||||
/**
|
||||
* 根据角色名模糊搜索系统角色列表
|
||||
*
|
||||
|
|
|
@ -31,6 +31,7 @@ import cn.stylefeng.roses.kernel.auth.api.context.LoginContext;
|
|||
import cn.stylefeng.roses.kernel.auth.api.enums.DataScopeTypeEnum;
|
||||
import cn.stylefeng.roses.kernel.auth.api.exception.AuthException;
|
||||
import cn.stylefeng.roses.kernel.auth.api.exception.enums.AuthExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.auth.api.pojo.login.basic.SimpleRoleInfo;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
|
@ -194,10 +195,10 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|||
if (!LoginContext.me().getSuperAdminFlag()) {
|
||||
|
||||
// 查询自己拥有的
|
||||
Set<SimpleDict> roles = LoginContext.me().getLoginUser().getRoles();
|
||||
List<SimpleRoleInfo> roles = LoginContext.me().getLoginUser().getSimpleRoleInfoList();
|
||||
|
||||
// 取出所有角色id
|
||||
Set<Long> loginUserRoleIds = roles.stream().map(SimpleDict::getId).collect(Collectors.toSet());
|
||||
Set<Long> loginUserRoleIds = roles.stream().map(SimpleRoleInfo::getRoleId).collect(Collectors.toSet());
|
||||
if (ObjectUtil.isEmpty(loginUserRoleIds)) {
|
||||
return dictList;
|
||||
}
|
||||
|
@ -223,30 +224,6 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|||
return sysRoleDataScopeService.getRoleDataScopeIdList(CollectionUtil.newArrayList(sysRole.getRoleId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SimpleDict> getLoginRoles(Long userId) {
|
||||
List<SimpleDict> dictList = CollectionUtil.newArrayList();
|
||||
|
||||
// 获取用户角色id集合
|
||||
List<Long> roleIdList = userServiceApi.getUserRoleIdList(userId);
|
||||
if (ObjectUtil.isNotEmpty(roleIdList)) {
|
||||
LambdaQueryWrapper<SysRole> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(SysRole::getRoleId, roleIdList)
|
||||
.eq(SysRole::getStatusFlag, StatusEnum.ENABLE.getCode())
|
||||
.ne(SysRole::getDelFlag, YesOrNotEnum.N.getCode());
|
||||
|
||||
// 根据角色id集合查询并返回结果
|
||||
this.list(queryWrapper).forEach(sysRole -> {
|
||||
SimpleDict simpleDict = new SimpleDict();
|
||||
simpleDict.setId(sysRole.getRoleId());
|
||||
simpleDict.setCode(sysRole.getRoleCode());
|
||||
simpleDict.setName(sysRole.getRoleName());
|
||||
dictList.add(simpleDict);
|
||||
});
|
||||
}
|
||||
return dictList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SimpleDict> list(SysRoleRequest sysRoleParam) {
|
||||
List<SimpleDict> dictList = CollectionUtil.newArrayList();
|
||||
|
@ -344,12 +321,11 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<String> getRoleResourceList(List<Long> roleIdList) {
|
||||
List<String> resourceList = CollectionUtil.newArrayList();
|
||||
public List<String> getRoleResourceCodeList(List<Long> roleIdList) {
|
||||
LambdaQueryWrapper<SysRoleResource> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(SysRoleResource::getRoleId, roleIdList);
|
||||
sysRoleResourceService.list(queryWrapper).forEach(sysRoleResource -> resourceList.add(sysRoleResource.getResourceCode()));
|
||||
return resourceList;
|
||||
List<SysRoleResource> sysRoleResources = sysRoleResourceService.list(queryWrapper);
|
||||
return sysRoleResources.stream().map(SysRoleResource::getResourceCode).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,8 +6,8 @@ import cn.stylefeng.roses.kernel.resource.api.annotation.PostResource;
|
|||
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
|
||||
import cn.stylefeng.roses.kernel.system.UserServiceApi;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.pojo.request.SysUserRequest;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.service.SysUserRoleService;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.service.SysUserService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
@ -31,7 +31,7 @@ public class SysUserController {
|
|||
private SysUserService sysUserService;
|
||||
|
||||
@Resource
|
||||
private UserServiceApi userServiceApi;
|
||||
private SysUserRoleService sysUserRoleService;
|
||||
|
||||
/**
|
||||
* 增加用户
|
||||
|
@ -183,7 +183,8 @@ public class SysUserController {
|
|||
*/
|
||||
@GetResource(name = "系统用户_获取用户的角色列表", path = "/sysUser/getUserRoles")
|
||||
public ResponseData ownRole(@Validated(SysUserRequest.detail.class) SysUserRequest sysUserRequest) {
|
||||
return new SuccessResponseData(sysUserService.getUserRoles(sysUserRequest));
|
||||
Long userId = sysUserRequest.getUserId();
|
||||
return new SuccessResponseData(sysUserRoleService.getUserRoles(userId));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -194,7 +195,7 @@ public class SysUserController {
|
|||
*/
|
||||
@GetResource(name = "系统用户_获取用户数据范围列表", path = "/sysUser/getUserDataScope")
|
||||
public ResponseData ownData(@Validated(SysUserRequest.detail.class) SysUserRequest sysUserRequest) {
|
||||
List<Long> userBindDataScope = userServiceApi.getUserBindDataScope(sysUserRequest.getUserId());
|
||||
List<Long> userBindDataScope = sysUserService.getUserBindDataScope(sysUserRequest.getUserId());
|
||||
return new SuccessResponseData(userBindDataScope);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,154 +0,0 @@
|
|||
package cn.stylefeng.roses.kernel.system.modular.user.factory;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.lang.Dict;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.stylefeng.roses.kernel.auth.api.enums.DataScopeTypeEnum;
|
||||
import cn.stylefeng.roses.kernel.auth.api.pojo.login.LoginUser;
|
||||
import cn.stylefeng.roses.kernel.file.FileInfoApi;
|
||||
import cn.stylefeng.roses.kernel.file.FileOperatorApi;
|
||||
import cn.stylefeng.roses.kernel.file.expander.FileConfigExpander;
|
||||
import cn.stylefeng.roses.kernel.file.pojo.response.SysFileInfoResponse;
|
||||
import cn.stylefeng.roses.kernel.resource.api.pojo.resource.ResourceDefinition;
|
||||
import cn.stylefeng.roses.kernel.rule.enums.SexEnum;
|
||||
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.dict.SimpleDict;
|
||||
import cn.stylefeng.roses.kernel.system.AppServiceApi;
|
||||
import cn.stylefeng.roses.kernel.system.DataScopeApi;
|
||||
import cn.stylefeng.roses.kernel.system.ResourceServiceApi;
|
||||
import cn.stylefeng.roses.kernel.system.RoleServiceApi;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.entity.SysUser;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.service.SysUserOrgService;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.organization.DataScopeResponse;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.role.response.SysRoleResponse;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.user.SysUserOrgResponse;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 组装当前登录用户的信息
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/11/26 22:25
|
||||
*/
|
||||
public class LoginUserFactory {
|
||||
|
||||
/**
|
||||
* 创建登录用户
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/11/26 22:32
|
||||
*/
|
||||
public static LoginUser createLoginUser(SysUser sysUser) {
|
||||
|
||||
// 一些需要调用的别的模块的接口
|
||||
FileOperatorApi fileOperatorApi = SpringUtil.getBean(FileOperatorApi.class);
|
||||
FileInfoApi fileInfoApi = SpringUtil.getBean(FileInfoApi.class);
|
||||
RoleServiceApi roleServiceApi = SpringUtil.getBean(RoleServiceApi.class);
|
||||
ResourceServiceApi resourceServiceApi = SpringUtil.getBean(ResourceServiceApi.class);
|
||||
SysUserOrgService sysUserOrgService = SpringUtil.getBean(SysUserOrgService.class);
|
||||
DataScopeApi dataScopeApi = SpringUtil.getBean(DataScopeApi.class);
|
||||
AppServiceApi appServiceApi = SpringUtil.getBean(AppServiceApi.class);
|
||||
|
||||
// 填充基本信息
|
||||
LoginUser loginUser = new LoginUser();
|
||||
BeanUtil.copyProperties(sysUser, loginUser);
|
||||
Long userId = sysUser.getUserId();
|
||||
|
||||
// 填充用户主组织机构id
|
||||
SysUserOrgResponse userOrgInfo = sysUserOrgService.getUserOrgInfo(userId);
|
||||
loginUser.setOrganizationId(userOrgInfo.getOrgId());
|
||||
|
||||
// 获取头像文件详细信息
|
||||
SysFileInfoResponse fileInfoWithoutContent = fileInfoApi.getFileInfoWithoutContent(sysUser.getAvatar());
|
||||
// 填充用户头像url
|
||||
String fileAuthUrl = fileOperatorApi.getFileAuthUrl(
|
||||
fileInfoWithoutContent.getFileBucket(),
|
||||
fileInfoWithoutContent.getFileObjectName(),
|
||||
FileConfigExpander.getDefaultFileTimeoutSeconds() * 1000);
|
||||
loginUser.setAvatar(fileAuthUrl);
|
||||
|
||||
// 填充管理员转化
|
||||
loginUser.setSuperAdmin(YesOrNotEnum.Y.getCode().equals(sysUser.getSuperAdminFlag()));
|
||||
|
||||
// 填充性别枚举转换
|
||||
loginUser.setSex(SexEnum.codeToEnum(sysUser.getSex()).getMessage());
|
||||
|
||||
// 填充手机号
|
||||
loginUser.setMobilePhone(sysUser.getPhone());
|
||||
|
||||
// 填充用户的数据范围
|
||||
DataScopeResponse dataScopeResponse = dataScopeApi.getDataScope(userId);
|
||||
if (loginUser.getSuperAdmin()) {
|
||||
loginUser.setDataScopeTypes(getSuperAdminDataScopeTypeEnum());
|
||||
} else {
|
||||
loginUser.setDataScopeTypes(dataScopeResponse.getDataScopeTypeEnums());
|
||||
}
|
||||
loginUser.setOrganizationIdDataScope(dataScopeResponse.getOrganizationIds());
|
||||
loginUser.setUserIdDataScope(dataScopeResponse.getUserIds());
|
||||
|
||||
// 填充用户角色信息
|
||||
Set<SimpleDict> roleList = getRoleList(dataScopeResponse.getSysRoleResponses());
|
||||
loginUser.setRoles(roleList);
|
||||
|
||||
// 通过用户角色,获取角色所有的资源id
|
||||
List<Long> roleIds = roleList.stream().map(SimpleDict::getId).collect(Collectors.toList());
|
||||
List<String> resourceIdsList = roleServiceApi.getRoleResourceList(roleIds);
|
||||
// 根据资源id获取资源的所有详情信息
|
||||
List<ResourceDefinition> resourceDefinitions = resourceServiceApi.getResourceListByIds(resourceIdsList);
|
||||
Set<String> resourceUrls = resourceDefinitions.stream().map(ResourceDefinition::getUrl).collect(Collectors.toSet());
|
||||
// 填充用户的urls
|
||||
loginUser.setResourceUrls(resourceUrls);
|
||||
|
||||
// 用户包含的app信息
|
||||
Set<String> appCodes = resourceDefinitions.stream().map(ResourceDefinition::getAppCode).collect(Collectors.toSet());
|
||||
Set<SimpleDict> appsByAppCodes = appServiceApi.getAppsByAppCodes(appCodes);
|
||||
// 填充应用信息
|
||||
loginUser.setApps(appsByAppCodes);
|
||||
|
||||
// 日志系统问题 默认初始化其他信息 dict
|
||||
loginUser.setOtherInfos(new Dict());
|
||||
|
||||
return loginUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* 组装角色信息
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/11/29 19:12
|
||||
*/
|
||||
private static Set<SimpleDict> getRoleList(List<SysRoleResponse> sysRoleResponses) {
|
||||
|
||||
if (sysRoleResponses == null || sysRoleResponses.isEmpty()) {
|
||||
return new HashSet<>();
|
||||
}
|
||||
|
||||
Set<SimpleDict> simpleRoles = new HashSet<>();
|
||||
for (SysRoleResponse sysRoleResponse : sysRoleResponses) {
|
||||
SimpleDict simpleRole = new SimpleDict();
|
||||
simpleRole.setId(sysRoleResponse.getRoleId());
|
||||
simpleRole.setName(sysRoleResponse.getRoleName());
|
||||
simpleRole.setCode(sysRoleResponse.getRoleCode());
|
||||
simpleRoles.add(simpleRole);
|
||||
}
|
||||
|
||||
return simpleRoles;
|
||||
}
|
||||
|
||||
/**
|
||||
* 超级管理员的数据范围是所有数据范围
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/12/14 23:12
|
||||
*/
|
||||
private static Set<DataScopeTypeEnum> getSuperAdminDataScopeTypeEnum() {
|
||||
HashSet<DataScopeTypeEnum> dataScopeTypeEnums = new HashSet<>();
|
||||
dataScopeTypeEnums.add(DataScopeTypeEnum.ALL);
|
||||
return dataScopeTypeEnums;
|
||||
}
|
||||
|
||||
}
|
|
@ -16,7 +16,7 @@ import cn.stylefeng.roses.kernel.system.modular.user.pojo.request.SysUserRequest
|
|||
* @author fengshuonan
|
||||
* @date 2020/11/21 12:55
|
||||
*/
|
||||
public class SysUserFactory {
|
||||
public class SysUserCreateFactory {
|
||||
|
||||
/**
|
||||
* 新增用户时候的用户信息填充
|
|
@ -0,0 +1,105 @@
|
|||
package cn.stylefeng.roses.kernel.system.modular.user.factory;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.stylefeng.roses.kernel.auth.api.pojo.login.LoginUser;
|
||||
import cn.stylefeng.roses.kernel.auth.api.pojo.login.basic.SimpleRoleInfo;
|
||||
import cn.stylefeng.roses.kernel.auth.api.pojo.login.basic.SimpleUserInfo;
|
||||
import cn.stylefeng.roses.kernel.auth.api.prop.LoginUserPropExpander;
|
||||
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.entity.SysUser;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.organization.DataScopeResponse;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.role.response.SysRoleResponse;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.user.SysUserOrgResponse;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.user.UserLoginInfoDTO;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 组装当前登录用户的信息
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/11/26 22:25
|
||||
*/
|
||||
public class UserLoginInfoFactory {
|
||||
|
||||
/**
|
||||
* 组装登录用户信息对象
|
||||
*
|
||||
* @param sysUser 用户信息
|
||||
* @param roleResponseList 角色信息
|
||||
* @param dataScopeResponse 数据范围信息
|
||||
* @param userOrgInfo 组织机构信息
|
||||
* @param resourceUrlsListByCodes 用户的所有资源url
|
||||
* @author fengshuonan
|
||||
* @date 2020/12/26 17:53
|
||||
*/
|
||||
public static UserLoginInfoDTO userLoginInfoDTO(SysUser sysUser,
|
||||
List<SysRoleResponse> roleResponseList,
|
||||
DataScopeResponse dataScopeResponse,
|
||||
SysUserOrgResponse userOrgInfo,
|
||||
Set<String> resourceUrlsListByCodes) {
|
||||
|
||||
UserLoginInfoDTO userLoginInfoDTO = new UserLoginInfoDTO();
|
||||
|
||||
// 设置用户加密的密码和状态
|
||||
userLoginInfoDTO.setUserPasswordHexed(sysUser.getPassword());
|
||||
userLoginInfoDTO.setUserStatus(sysUser.getStatusFlag());
|
||||
|
||||
// 创建登录用户对象
|
||||
LoginUser loginUser = new LoginUser();
|
||||
|
||||
// 填充用户账号,账号id,管理员类型
|
||||
loginUser.setAccount(sysUser.getAccount());
|
||||
loginUser.setUserId(sysUser.getUserId());
|
||||
loginUser.setSuperAdmin(YesOrNotEnum.Y.getCode().equals(sysUser.getSuperAdminFlag()));
|
||||
|
||||
// 填充用户基本信息
|
||||
SimpleUserInfo simpleUserInfo = new SimpleUserInfo();
|
||||
BeanUtil.copyProperties(sysUser, simpleUserInfo);
|
||||
loginUser.setSimpleUserInfo(simpleUserInfo);
|
||||
|
||||
// 填充用户角色信息
|
||||
if (!roleResponseList.isEmpty()) {
|
||||
ArrayList<SimpleRoleInfo> simpleRoleInfos = new ArrayList<>();
|
||||
for (SysRoleResponse sysRoleResponse : roleResponseList) {
|
||||
SimpleRoleInfo simpleRoleInfo = new SimpleRoleInfo();
|
||||
BeanUtil.copyProperties(sysRoleResponse, simpleRoleInfo);
|
||||
simpleRoleInfos.add(simpleRoleInfo);
|
||||
}
|
||||
loginUser.setSimpleRoleInfoList(simpleRoleInfos);
|
||||
}
|
||||
|
||||
// 填充用户公司和职务
|
||||
if (userOrgInfo != null) {
|
||||
loginUser.setOrganizationId(userOrgInfo.getOrgId());
|
||||
loginUser.setPositionId(userOrgInfo.getPositionId());
|
||||
}
|
||||
|
||||
// 设置用户数据范围
|
||||
if (dataScopeResponse != null) {
|
||||
loginUser.setDataScopeTypeEnums(dataScopeResponse.getDataScopeTypeEnums());
|
||||
loginUser.setDataScopeOrganizationIds(dataScopeResponse.getOrganizationIds());
|
||||
loginUser.setDataScopeUserIds(dataScopeResponse.getUserIds());
|
||||
}
|
||||
|
||||
// 设置用户拥有的资源
|
||||
loginUser.setResourceUrls(resourceUrlsListByCodes);
|
||||
|
||||
// 基于接口拓展用户登录信息
|
||||
Map<String, LoginUserPropExpander> beansOfLoginUserExpander = SpringUtil.getBeansOfType(LoginUserPropExpander.class);
|
||||
if (beansOfLoginUserExpander != null && beansOfLoginUserExpander.size() > 0) {
|
||||
for (Map.Entry<String, LoginUserPropExpander> stringLoginUserPropExpanderEntry : beansOfLoginUserExpander.entrySet()) {
|
||||
stringLoginUserPropExpanderEntry.getValue().expandAction(loginUser);
|
||||
}
|
||||
}
|
||||
|
||||
// 响应dto
|
||||
userLoginInfoDTO.setLoginUser(loginUser);
|
||||
return userLoginInfoDTO;
|
||||
}
|
||||
|
||||
}
|
|
@ -4,6 +4,8 @@ import cn.stylefeng.roses.kernel.system.modular.user.entity.SysUserRole;
|
|||
import cn.stylefeng.roses.kernel.system.modular.user.pojo.request.SysUserRequest;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统用户角色service接口
|
||||
*
|
||||
|
@ -12,6 +14,15 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
*/
|
||||
public interface SysUserRoleService extends IService<SysUserRole> {
|
||||
|
||||
/**
|
||||
* 获取账号绑定的角色
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @author fengshuonan
|
||||
* @date 2020/12/22 16:52
|
||||
*/
|
||||
List<SysUserRole> getUserRoles(Long userId);
|
||||
|
||||
/**
|
||||
* 给某个用户授权角色
|
||||
*
|
||||
|
@ -29,4 +40,5 @@ public interface SysUserRoleService extends IService<SysUserRole> {
|
|||
* @date 2020/11/6 15:03
|
||||
*/
|
||||
void deleteUserRoleListByUserId(Long userId);
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package cn.stylefeng.roses.kernel.system.modular.user.service;
|
|||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.dict.SimpleDict;
|
||||
import cn.stylefeng.roses.kernel.system.UserServiceApi;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.entity.SysUser;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.pojo.request.SysUserRequest;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.pojo.response.SysUserResponse;
|
||||
|
@ -16,7 +17,7 @@ import java.util.List;
|
|||
* @author luojie
|
||||
* @date 2020/11/6 10:28
|
||||
*/
|
||||
public interface SysUserService extends IService<SysUser> {
|
||||
public interface SysUserService extends IService<SysUser>, UserServiceApi {
|
||||
|
||||
/**
|
||||
* 增加用户
|
||||
|
@ -122,25 +123,12 @@ public interface SysUserService extends IService<SysUser> {
|
|||
* 查询系统用户
|
||||
*
|
||||
* @param sysUserRequest 查询参数
|
||||
* searchValue 关键字
|
||||
* organizationId 机构id
|
||||
* statusFlag 用户状态
|
||||
* @return 查询分页结果
|
||||
* @author fengshuonan
|
||||
* @date 2020/11/21 15:24
|
||||
*/
|
||||
PageResult<SysUserResponse> page(SysUserRequest sysUserRequest);
|
||||
|
||||
/**
|
||||
* 获取用户所有角色
|
||||
*
|
||||
* @param sysUserRequest 查询参数
|
||||
* @return 角色id集合
|
||||
* @author luojie
|
||||
* @date 2020/11/6 13:47
|
||||
*/
|
||||
List<Long> getUserRoles(SysUserRequest sysUserRequest);
|
||||
|
||||
/**
|
||||
* 用户下拉列表选择
|
||||
*
|
||||
|
@ -168,6 +156,6 @@ public interface SysUserService extends IService<SysUser> {
|
|||
* @author luojie
|
||||
* @date 2020/11/6 15:09
|
||||
*/
|
||||
SysUser getUserByCount(String account);
|
||||
SysUser getUserByAccount(String account);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package cn.stylefeng.roses.kernel.system.modular.user.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.stylefeng.roses.kernel.system.UserOrgServiceApi;
|
||||
import cn.stylefeng.roses.kernel.system.exception.SystemModularException;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.entity.SysUserOrg;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.mapper.SysUserOrgMapper;
|
||||
|
@ -24,7 +23,7 @@ import static cn.stylefeng.roses.kernel.system.exception.enums.SysUserOrgExcepti
|
|||
* @date 2020/12/19 22:17
|
||||
*/
|
||||
@Service
|
||||
public class SysUserOrgServiceServiceImpl extends ServiceImpl<SysUserOrgMapper, SysUserOrg> implements SysUserOrgService, UserOrgServiceApi {
|
||||
public class SysUserOrgServiceServiceImpl extends ServiceImpl<SysUserOrgMapper, SysUserOrg> implements SysUserOrgService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package cn.stylefeng.roses.kernel.system.modular.user.service.impl;
|
||||
|
||||
import cn.stylefeng.roses.kernel.system.DataScopeApi;
|
||||
import cn.stylefeng.roses.kernel.system.RoleServiceApi;
|
||||
import cn.stylefeng.roses.kernel.system.exception.SystemModularException;
|
||||
import cn.stylefeng.roses.kernel.system.exception.enums.SysUserExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.entity.SysUserRole;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.mapper.SysUserRoleMapper;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.pojo.request.SysUserRequest;
|
||||
|
@ -11,7 +11,6 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -24,11 +23,19 @@ import java.util.List;
|
|||
@Service
|
||||
public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUserRole> implements SysUserRoleService {
|
||||
|
||||
@Resource
|
||||
private RoleServiceApi roleServiceApi;
|
||||
@Override
|
||||
public List<SysUserRole> getUserRoles(Long userId) {
|
||||
LambdaQueryWrapper<SysUserRole> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(SysUserRole::getUserId, userId);
|
||||
List<SysUserRole> list = this.list(wrapper);
|
||||
|
||||
@Resource
|
||||
private DataScopeApi dataScopeApi;
|
||||
// 账号下没有绑定角色
|
||||
if (list.isEmpty()) {
|
||||
throw new SystemModularException(SysUserExceptionEnum.USER_NOT_BIND_ROLE);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
|
|
@ -4,7 +4,6 @@ import cn.hutool.core.bean.BeanUtil;
|
|||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.crypto.digest.BCrypt;
|
||||
import cn.stylefeng.roses.kernel.auth.api.expander.AuthConfigExpander;
|
||||
import cn.stylefeng.roses.kernel.auth.api.pojo.login.LoginUser;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
|
@ -12,15 +11,17 @@ import cn.stylefeng.roses.kernel.office.api.OfficeExcelApi;
|
|||
import cn.stylefeng.roses.kernel.office.api.pojo.report.ExcelExportParam;
|
||||
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.dict.SimpleDict;
|
||||
import cn.stylefeng.roses.kernel.system.UserServiceApi;
|
||||
import cn.stylefeng.roses.kernel.system.DataScopeApi;
|
||||
import cn.stylefeng.roses.kernel.system.ResourceServiceApi;
|
||||
import cn.stylefeng.roses.kernel.system.RoleServiceApi;
|
||||
import cn.stylefeng.roses.kernel.system.enums.UserStatusEnum;
|
||||
import cn.stylefeng.roses.kernel.system.exception.SystemModularException;
|
||||
import cn.stylefeng.roses.kernel.system.exception.enums.SysUserExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.entity.SysUser;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.entity.SysUserDataScope;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.entity.SysUserRole;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.factory.LoginUserFactory;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.factory.SysUserFactory;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.factory.SysUserCreateFactory;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.factory.UserLoginInfoFactory;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.mapper.SysUserMapper;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.pojo.request.SysUserRequest;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.pojo.response.SysUserResponse;
|
||||
|
@ -28,6 +29,8 @@ import cn.stylefeng.roses.kernel.system.modular.user.service.SysUserDataScopeSer
|
|||
import cn.stylefeng.roses.kernel.system.modular.user.service.SysUserOrgService;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.service.SysUserRoleService;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.service.SysUserService;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.organization.DataScopeResponse;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.role.response.SysRoleResponse;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.user.SysUserOrgResponse;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.user.UserLoginInfoDTO;
|
||||
import cn.stylefeng.roses.kernel.system.util.DataScopeUtil;
|
||||
|
@ -56,7 +59,7 @@ import java.util.stream.Collectors;
|
|||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements SysUserService, UserServiceApi {
|
||||
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements SysUserService {
|
||||
|
||||
@Resource
|
||||
private SysUserOrgService sysUserOrgService;
|
||||
|
@ -70,6 +73,15 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
@Resource
|
||||
private OfficeExcelApi officeExcelApi;
|
||||
|
||||
@Resource
|
||||
private DataScopeApi dataScopeApi;
|
||||
|
||||
@Resource
|
||||
private RoleServiceApi roleServiceApi;
|
||||
|
||||
@Resource
|
||||
private ResourceServiceApi resourceServiceApi;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void add(SysUserRequest sysUserRequest) {
|
||||
|
@ -83,7 +95,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
// 请求bean转为实体,填充一些基本属性
|
||||
SysUser sysUser = new SysUser();
|
||||
BeanUtil.copyProperties(sysUserRequest, sysUser);
|
||||
SysUserFactory.fillAddSysUser(sysUser);
|
||||
SysUserCreateFactory.fillAddSysUser(sysUser);
|
||||
|
||||
// 保存用户
|
||||
this.save(sysUser);
|
||||
|
@ -107,7 +119,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
BeanUtil.copyProperties(sysUserRequest, sysUser);
|
||||
|
||||
// 填充基础参数
|
||||
SysUserFactory.fillEditSysUser(sysUser);
|
||||
SysUserCreateFactory.fillEditSysUser(sysUser);
|
||||
this.updateById(sysUser);
|
||||
|
||||
Long sysUserId = sysUser.getUserId();
|
||||
|
@ -121,7 +133,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
SysUser sysUser = this.querySysUser(sysUserRequest);
|
||||
|
||||
// 填充更新用户的信息
|
||||
SysUserFactory.fillUpdateInfo(sysUserRequest, sysUser);
|
||||
SysUserCreateFactory.fillUpdateInfo(sysUserRequest, sysUser);
|
||||
|
||||
this.updateById(sysUser);
|
||||
}
|
||||
|
@ -280,11 +292,6 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
return PageResultFactory.createPageResult(userPage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> getUserRoles(SysUserRequest sysUserRequest) {
|
||||
return this.getUserRoleIdList(sysUserRequest.getUserId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SimpleDict> selector(SysUserRequest sysUserRequest) {
|
||||
|
||||
|
@ -323,31 +330,50 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
}
|
||||
|
||||
@Override
|
||||
public SysUser getUserByCount(String account) {
|
||||
public SysUser getUserByAccount(String account) {
|
||||
LambdaQueryWrapper<SysUser> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysUser::getAccount, account);
|
||||
queryWrapper.ne(SysUser::getDelFlag, YesOrNotEnum.Y.getCode());
|
||||
return this.getOne(queryWrapper);
|
||||
|
||||
List<SysUser> list = this.list(queryWrapper);
|
||||
|
||||
// 用户不存在
|
||||
if (list.isEmpty()) {
|
||||
throw new SystemModularException(SysUserExceptionEnum.USER_NOT_EXIST, account);
|
||||
}
|
||||
|
||||
// 账号存在多个
|
||||
if (list.size() > 1) {
|
||||
throw new SystemModularException(SysUserExceptionEnum.ACCOUNT_HAVE_MANY, account);
|
||||
}
|
||||
|
||||
return list.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserLoginInfoDTO getUserLoginInfo(String account) {
|
||||
UserLoginInfoDTO userLoginInfoDTO = new UserLoginInfoDTO();
|
||||
|
||||
// 根据账号获取系统用户表中的信息
|
||||
SysUser sysUser = getUserByCount(account);
|
||||
LoginUser loginUser = LoginUserFactory.createLoginUser(sysUser);
|
||||
// 1. 获取用户和账号信息
|
||||
SysUser sysUser = this.getUserByAccount(account);
|
||||
Long userId = sysUser.getUserId();
|
||||
|
||||
// 获取用户加密的密码,用于登录校验
|
||||
userLoginInfoDTO.setUserPasswordHexed(sysUser.getPassword());
|
||||
// 2. 获取用户角色信息
|
||||
List<SysUserRole> userRoles = sysUserRoleService.getUserRoles(userId);
|
||||
List<Long> roleIds = userRoles.stream().map(SysUserRole::getRoleId).collect(Collectors.toList());
|
||||
List<SysRoleResponse> roleResponseList = roleServiceApi.getRolesByIds(roleIds);
|
||||
|
||||
// 填充用户状态
|
||||
userLoginInfoDTO.setUserStatus(sysUser.getStatusFlag());
|
||||
// 3. 获取用户的数据范围
|
||||
DataScopeResponse dataScopeResponse = dataScopeApi.getDataScope(userId, roleResponseList);
|
||||
|
||||
// 设置用户登录详情信息
|
||||
userLoginInfoDTO.setLoginUser(loginUser);
|
||||
// 4. 获取用户的组织机构和职位信息
|
||||
SysUserOrgResponse userOrgInfo = sysUserOrgService.getUserOrgInfo(userId);
|
||||
|
||||
return userLoginInfoDTO;
|
||||
// 5. 获取用户的所有资源url
|
||||
List<String> resourceCodeList = roleServiceApi.getRoleResourceCodeList(roleIds);
|
||||
Set<String> resourceUrlsListByCodes = resourceServiceApi.getResourceUrlsListByCodes(resourceCodeList);
|
||||
|
||||
// 5. 组装响应结果
|
||||
return UserLoginInfoFactory.userLoginInfoDTO(sysUser, roleResponseList, dataScopeResponse, userOrgInfo, resourceUrlsListByCodes);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
@ -413,7 +439,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
private SysUser querySysUser(SysUserRequest sysUserRequest) {
|
||||
SysUser sysUser = this.getById(sysUserRequest.getUserId());
|
||||
if (ObjectUtil.isNull(sysUser)) {
|
||||
throw new SystemModularException(SysUserExceptionEnum.USER_NOT_EXIST);
|
||||
throw new SystemModularException(SysUserExceptionEnum.USER_NOT_EXIST, sysUserRequest.getUserId());
|
||||
}
|
||||
return sysUser;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue