mirror of https://gitee.com/xiaonuobase/snowy
【更新】解决普通账号新增机构列表不显示问题及删除错误
parent
e798962030
commit
7ea83d770a
|
@ -132,4 +132,13 @@ public interface AuthService {
|
|||
* @date 2020/9/20 15:21
|
||||
**/
|
||||
SysLoginUser genSysLoginUser(SysUser sysUser);
|
||||
|
||||
/**
|
||||
* 新增用户的数据授权范围
|
||||
*
|
||||
* @author yubaoshan
|
||||
* @date 2021/7/20 14:50
|
||||
*/
|
||||
void refreshUserDataScope(Long orgId);
|
||||
|
||||
}
|
||||
|
|
|
@ -37,6 +37,8 @@ import org.springframework.security.core.userdetails.UserDetailsService;
|
|||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.security.crypto.bcrypt.BCrypt;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
import vip.xiaonuo.core.consts.CommonConstant;
|
||||
import vip.xiaonuo.core.context.constant.ConstantContextHolder;
|
||||
import vip.xiaonuo.core.dbs.CurrentDataSourceContext;
|
||||
|
@ -359,4 +361,14 @@ public class AuthServiceImpl implements AuthService, UserDetailsService {
|
|||
String redisLoginUserKey = jwtPayLoad.getUuid();
|
||||
userCache.put(redisLoginUserKey, sysLoginUser, Convert.toLong(ConstantContextHolder.getSessionTokenExpireSec()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshUserDataScope(Long orgId) {
|
||||
// request获取到token
|
||||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||
String token = this.getTokenFromRequest(request);
|
||||
SysLoginUser sysLoginUser = this.getLoginUserByToken(token);
|
||||
sysLoginUser.getDataScopes().add(orgId);
|
||||
this.cacheLoginUser(JwtTokenUtil.getJwtPayLoad(token), sysLoginUser);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ import vip.xiaonuo.core.pojo.node.AntdBaseTreeNode;
|
|||
import vip.xiaonuo.core.pojo.page.PageResult;
|
||||
import vip.xiaonuo.core.util.PoiUtil;
|
||||
import vip.xiaonuo.sys.core.enums.DataScopeTypeEnum;
|
||||
import vip.xiaonuo.sys.modular.auth.service.AuthService;
|
||||
import vip.xiaonuo.sys.modular.emp.service.SysEmpExtOrgPosService;
|
||||
import vip.xiaonuo.sys.modular.emp.service.SysEmpService;
|
||||
import vip.xiaonuo.sys.modular.org.entity.SysOrg;
|
||||
|
@ -82,6 +83,9 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
|
|||
@Resource
|
||||
private SysUserDataScopeService sysUserDataScopeService;
|
||||
|
||||
@Resource
|
||||
private AuthService authService;
|
||||
|
||||
@Override
|
||||
public PageResult<SysOrg> page(SysOrgParam sysOrgParam) {
|
||||
LambdaQueryWrapper<SysOrg> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
@ -192,6 +196,7 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
|
|||
this.fillPids(sysOrg);
|
||||
sysOrg.setStatus(CommonStatusEnum.ENABLE.getCode());
|
||||
this.save(sysOrg);
|
||||
this.authService.refreshUserDataScope(sysOrg.getId());
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
@ -202,7 +207,7 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
|
|||
Long id = sysOrg.getId();
|
||||
boolean superAdmin = LoginContextHolder.me().isSuperAdmin();
|
||||
if (!superAdmin) {
|
||||
List<Long> dataScope = sysOrgParam.getDataScope();
|
||||
List<Long> dataScope = LoginContextHolder.me().getLoginUserDataScopeIdList();
|
||||
//数据范围为空
|
||||
if (ObjectUtil.isEmpty(dataScope)) {
|
||||
throw new PermissionException(PermissionExceptionEnum.NO_PERMISSION_OPERATE);
|
||||
|
|
Loading…
Reference in New Issue