【8.0】【sys】获取当前用户的数据范围

pull/57/head
fengshuonan 2023-07-18 23:27:31 +08:00
parent 62deae273c
commit 0696e47724
2 changed files with 30 additions and 1 deletions

View File

@ -1,5 +1,6 @@
package cn.stylefeng.roses.kernel.sys.modular.role.service;
import cn.stylefeng.roses.kernel.sys.api.UserDataScopeApi;
import cn.stylefeng.roses.kernel.sys.modular.role.pojo.request.RoleBindPermissionRequest;
import cn.stylefeng.roses.kernel.sys.modular.role.pojo.response.RoleBindPermissionResponse;
@ -11,7 +12,7 @@ import java.util.Set;
* @author fengshuonan
* @since 2023/6/13 16:13
*/
public interface PermissionAssignService {
public interface PermissionAssignService extends UserDataScopeApi {
/**
*

View File

@ -1,7 +1,10 @@
package cn.stylefeng.roses.kernel.sys.modular.role.service.impl;
import cn.hutool.extra.spring.SpringUtil;
import cn.stylefeng.roses.kernel.auth.api.context.LoginContext;
import cn.stylefeng.roses.kernel.event.sdk.publish.BusinessEventPublisher;
import cn.stylefeng.roses.kernel.sys.api.SysUserRoleServiceApi;
import cn.stylefeng.roses.kernel.sys.api.enums.permission.DataScopeTypeEnum;
import cn.stylefeng.roses.kernel.sys.modular.app.entity.SysApp;
import cn.stylefeng.roses.kernel.sys.modular.app.service.SysAppService;
import cn.stylefeng.roses.kernel.sys.modular.menu.entity.SysMenu;
@ -19,6 +22,7 @@ import cn.stylefeng.roses.kernel.sys.modular.role.pojo.response.RoleBindPermissi
import cn.stylefeng.roses.kernel.sys.modular.role.service.PermissionAssignService;
import cn.stylefeng.roses.kernel.sys.modular.role.service.SysRoleMenuOptionsService;
import cn.stylefeng.roses.kernel.sys.modular.role.service.SysRoleMenuService;
import cn.stylefeng.roses.kernel.sys.modular.role.service.SysRoleService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Service;
@ -53,6 +57,12 @@ public class PermissionAssignServiceImpl implements PermissionAssignService {
@Resource
private SysRoleMenuService sysRoleMenuService;
@Resource
private SysUserRoleServiceApi sysUserRoleServiceApi;
@Resource
private SysRoleService sysRoleService;
@Override
public RoleBindPermissionResponse getRoleBindPermission(RoleBindPermissionRequest roleBindPermissionRequest) {
@ -140,4 +150,22 @@ public class PermissionAssignServiceImpl implements PermissionAssignService {
return resultPermissions;
}
@Override
public DataScopeTypeEnum currentUserDataScopeType() {
// 获取当前用户id
Long userId = LoginContext.me().getLoginUser().getUserId();
// 获取用户的角色列表
List<Long> userHaveRoleIds = sysUserRoleServiceApi.getUserRoleIdList(userId);
// 获取这些角色对应的数据范围
return sysRoleService.getRoleDataScope(userHaveRoleIds);
}
@Override
public Set<Long> currentUserOrgScopeList() {
return null;
}
}