|
|
@@ -504,173 +504,180 @@ public class JySceneUserAuthServiceImpl extends ServiceImpl<IJySceneUserAuthMapp
|
|
|
|
|
|
@Override
|
|
|
public Object checkNumAuth(String num,Integer caseId,String token,String clientIP,String userName,String password) {
|
|
|
- if(StringUtils.isBlank(num) && caseId == null){
|
|
|
- throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
- }
|
|
|
- log.info("checkNumAuth-----------num:{},caseId:{},token:{},userName:{},password:{}",num,caseId,token,userName,password);
|
|
|
- Long sceneUserId = getUserId(num,caseId);
|
|
|
- JySceneAuth jySceneAuth = getBySceneAuth(num,caseId);
|
|
|
SceneAuthVo sceneAuthVo = new SceneAuthVo();
|
|
|
+ try {
|
|
|
+ if(StringUtils.isBlank(num) && caseId == null){
|
|
|
+ throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
+ }
|
|
|
+ log.info("checkNumAuth-----------num:{},caseId:{},token:{},userName:{},password:{}",num,caseId,token,userName,password);
|
|
|
+ Long sceneUserId = getUserId(num,caseId);
|
|
|
+ JySceneAuth jySceneAuth = getBySceneAuth(num,caseId);
|
|
|
|
|
|
- //公开场景案件,指针对同平台
|
|
|
- if(jySceneAuth!=null && jySceneAuth.getAuthType() == 1){
|
|
|
- sceneAuthVo.setViewAuth(true);
|
|
|
- }
|
|
|
|
|
|
+ //公开场景案件,指针对同平台
|
|
|
+ if(jySceneAuth!=null && jySceneAuth.getAuthType() == 1){
|
|
|
+ sceneAuthVo.setViewAuth(true);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- List<Case> caseList = null;
|
|
|
- HashMap<Integer,JySceneAuth> caseSceneAuthMap = new HashMap<>();
|
|
|
- if(StringUtils.isNotBlank(num)){
|
|
|
- caseList = caseService.getCaseByNum(num);
|
|
|
- for (Case aCase : caseList) {
|
|
|
- JySceneAuth jySceneAuth1 = jySceneAuthService.getByCaseId(aCase.getCaseId());
|
|
|
- caseSceneAuthMap.put(aCase.getCaseId(),jySceneAuth1);
|
|
|
- if(jySceneAuth1!=null && jySceneAuth1.getAuthType() == 1){
|
|
|
- sceneAuthVo.setViewAuth(true);
|
|
|
- break;
|
|
|
+
|
|
|
+ List<Case> caseList = null;
|
|
|
+ HashMap<Integer,JySceneAuth> caseSceneAuthMap = new HashMap<>();
|
|
|
+ if(StringUtils.isNotBlank(num)){
|
|
|
+ caseList = caseService.getCaseByNum(num);
|
|
|
+ for (Case aCase : caseList) {
|
|
|
+ JySceneAuth jySceneAuth1 = jySceneAuthService.getByCaseId(aCase.getCaseId());
|
|
|
+ caseSceneAuthMap.put(aCase.getCaseId(),jySceneAuth1);
|
|
|
+ if(jySceneAuth1!=null && jySceneAuth1.getAuthType() == 1){
|
|
|
+ sceneAuthVo.setViewAuth(true);
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- if(StringUtils.isBlank(token) && (StringUtils.isBlank(userName) || StringUtils.isBlank(password))){
|
|
|
- return sceneAuthVo;
|
|
|
- }
|
|
|
- Long sysUserId = null;
|
|
|
- if(StringUtils.isNotBlank(token)){
|
|
|
- String redisKey = String.format(RedisKeyUtil.loginToken,token);
|
|
|
- if( !redisUtil.hasKey(redisKey) ){
|
|
|
+ if(StringUtils.isBlank(token) && (StringUtils.isBlank(userName) || StringUtils.isBlank(password))){
|
|
|
return sceneAuthVo;
|
|
|
}
|
|
|
- String userStr = redisUtil.get(redisKey);
|
|
|
- ManageLoginResponse result = JSONObject.parseObject(userStr,ManageLoginResponse.class);
|
|
|
- Long userId = result.getUserId();
|
|
|
- if(userId == null){
|
|
|
- redisUtil.del(redisKey);
|
|
|
- throw new BusinessException(ResultCode.USER_NOT_LOGIN);
|
|
|
- }else {
|
|
|
- String redisKeyTime = String.format(RedisKeyUtil.loginTokenTime,StpUtil.getTokenValue());
|
|
|
- if(redisUtil.hasKey(redisKeyTime)){
|
|
|
- redisUtil.expire(redisKey,Integer.valueOf(redisUtil.get(redisKeyTime)));
|
|
|
- redisUtil.expire(redisKeyTime,Integer.valueOf(redisUtil.get(redisKeyTime)));
|
|
|
+ Long sysUserId = null;
|
|
|
+ if(StringUtils.isNotBlank(token)){
|
|
|
+ String redisKey = String.format(RedisKeyUtil.loginToken,token);
|
|
|
+ if( !redisUtil.hasKey(redisKey) ){
|
|
|
+ return sceneAuthVo;
|
|
|
+ }
|
|
|
+ String userStr = redisUtil.get(redisKey);
|
|
|
+ ManageLoginResponse result = JSONObject.parseObject(userStr,ManageLoginResponse.class);
|
|
|
+ Long userId = result.getUserId();
|
|
|
+ if(userId == null){
|
|
|
+ redisUtil.del(redisKey);
|
|
|
+ throw new BusinessException(ResultCode.USER_NOT_LOGIN);
|
|
|
}else {
|
|
|
- redisUtil.expire(redisKey,2 * 60 * 60);
|
|
|
+ String redisKeyTime = String.format(RedisKeyUtil.loginTokenTime,StpUtil.getTokenValue());
|
|
|
+ if(redisUtil.hasKey(redisKeyTime)){
|
|
|
+ redisUtil.expire(redisKey,Integer.valueOf(redisUtil.get(redisKeyTime)));
|
|
|
+ redisUtil.expire(redisKeyTime,Integer.valueOf(redisUtil.get(redisKeyTime)));
|
|
|
+ }else {
|
|
|
+ redisUtil.expire(redisKey,2 * 60 * 60);
|
|
|
+ }
|
|
|
}
|
|
|
+ sysUserId = result.getId();
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(userName) && StringUtils.isNotBlank(password)){
|
|
|
+ ManageLoginRequest param = new ManageLoginRequest();
|
|
|
+ param.setClientIp(clientIP);
|
|
|
+ param.setUserName(userName);
|
|
|
+ param.setPassword(password);
|
|
|
+ param.setMingwen(true);
|
|
|
+ ManageLoginResponse login = manageService.login(param);
|
|
|
+ sysUserId = login.getId();
|
|
|
}
|
|
|
- sysUserId = result.getId();
|
|
|
- }
|
|
|
- if(StringUtils.isNotBlank(userName) && StringUtils.isNotBlank(password)){
|
|
|
- ManageLoginRequest param = new ManageLoginRequest();
|
|
|
- param.setClientIp(clientIP);
|
|
|
- param.setUserName(userName);
|
|
|
- param.setPassword(password);
|
|
|
- param.setMingwen(true);
|
|
|
- ManageLoginResponse login = manageService.login(param);
|
|
|
- sysUserId = login.getId();
|
|
|
- }
|
|
|
|
|
|
- if(sysUserId == null){
|
|
|
- return sceneAuthVo;
|
|
|
- }
|
|
|
- if(StringUtils.isNotBlank(num)){
|
|
|
- List<String> numList = manageConfig.getNumList();
|
|
|
- if(numList.contains(num)){
|
|
|
- sceneAuthVo.setViewAuth(true);
|
|
|
- sceneAuthVo.setEditAuth(true);
|
|
|
+ if(sysUserId == null){
|
|
|
return sceneAuthVo;
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- SysUser byId = sysUserService.getById(sysUserId);
|
|
|
- if(byId.getRoleId() == 1L ){
|
|
|
- sceneAuthVo.setViewAuth(true);
|
|
|
- sceneAuthVo.setEditAuth(true);
|
|
|
- return sceneAuthVo;
|
|
|
- }
|
|
|
- if(byId.getRoleId() == 45L || byId.getRoleId() == 48L){
|
|
|
- Integer loginPlatformId = jyUserPlatformService.getLoginPlatformId();
|
|
|
- if(loginPlatformId != null){
|
|
|
- List<JyUser> userIds = jyUserService.getByUserPlatform(loginPlatformId);
|
|
|
- List<Long> sysUserIds = userIds.stream().map(JyUser::getSysUserId).collect(Collectors.toList());
|
|
|
-
|
|
|
- List<Long> byUserIdPlatform = userIds.stream().map(JyUser::getUserId).collect(Collectors.toList());
|
|
|
- if(byUserIdPlatform.contains(sceneUserId)){
|
|
|
+ if(StringUtils.isNotBlank(num)){
|
|
|
+ List<String> numList = manageConfig.getNumList();
|
|
|
+ if(numList.contains(num)){
|
|
|
sceneAuthVo.setViewAuth(true);
|
|
|
sceneAuthVo.setEditAuth(true);
|
|
|
return sceneAuthVo;
|
|
|
}
|
|
|
- if(caseList != null && !caseList.isEmpty()){
|
|
|
- for (Case aCase : caseList) {
|
|
|
- if(sysUserIds.contains(aCase.getSysUserId())){
|
|
|
- sceneAuthVo.setViewAuth(true);
|
|
|
- break;
|
|
|
+ }
|
|
|
+
|
|
|
+ SysUser byId = sysUserService.getById(sysUserId);
|
|
|
+ if(byId.getRoleId() == 1L ){
|
|
|
+ sceneAuthVo.setViewAuth(true);
|
|
|
+ sceneAuthVo.setEditAuth(true);
|
|
|
+ return sceneAuthVo;
|
|
|
+ }
|
|
|
+ if(byId.getRoleId() == 45L || byId.getRoleId() == 48L){
|
|
|
+ Integer loginPlatformId = jyUserPlatformService.getLoginPlatformId();
|
|
|
+ if(loginPlatformId != null){
|
|
|
+ List<JyUser> userIds = jyUserService.getByUserPlatform(loginPlatformId);
|
|
|
+ List<Long> sysUserIds = userIds.stream().map(JyUser::getSysUserId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<Long> byUserIdPlatform = userIds.stream().map(JyUser::getUserId).collect(Collectors.toList());
|
|
|
+ if(byUserIdPlatform.contains(sceneUserId)){
|
|
|
+ sceneAuthVo.setViewAuth(true);
|
|
|
+ sceneAuthVo.setEditAuth(true);
|
|
|
+ return sceneAuthVo;
|
|
|
+ }
|
|
|
+ if(caseList != null && !caseList.isEmpty()){
|
|
|
+ for (Case aCase : caseList) {
|
|
|
+ if(sysUserIds.contains(aCase.getSysUserId())){
|
|
|
+ sceneAuthVo.setViewAuth(true);
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- if(caseList != null && !caseList.isEmpty()){
|
|
|
- for (Case aCase : caseList) {
|
|
|
- if(aCase.getSysUserId().equals(sysUserId)){
|
|
|
- sceneAuthVo.setViewAuth(true);
|
|
|
- break;
|
|
|
+ if(caseList != null && !caseList.isEmpty()){
|
|
|
+ for (Case aCase : caseList) {
|
|
|
+ if(aCase.getSysUserId().equals(sysUserId)){
|
|
|
+ sceneAuthVo.setViewAuth(true);
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- JyUser jyUser = jyUserService.getBySysId(byId.getId());
|
|
|
- //if(jySceneAuth != null && jySceneAuth.getAuthType() == 0){
|
|
|
- if(jySceneAuth != null ){
|
|
|
- JySceneUserAuth jySceneUserAuth = null;
|
|
|
- if(StringUtils.isNotBlank(num)){
|
|
|
- jySceneUserAuth = jySceneUserAuthService.getByNumAndJyUserId(jyUser.getId(), num,jySceneAuth.getAuthType());
|
|
|
- }
|
|
|
- if(caseId != null){
|
|
|
- jySceneUserAuth = jySceneUserAuthService.getByCaseIdAndJyUserId(jyUser.getId(), caseId,jySceneAuth.getAuthType());
|
|
|
- }
|
|
|
- setFlag(jySceneUserAuth,sceneAuthVo);
|
|
|
+ JyUser jyUser = jyUserService.getBySysId(byId.getId());
|
|
|
+ //if(jySceneAuth != null && jySceneAuth.getAuthType() == 0){
|
|
|
+ if(jySceneAuth != null ){
|
|
|
+ JySceneUserAuth jySceneUserAuth = null;
|
|
|
+ if(StringUtils.isNotBlank(num)){
|
|
|
+ jySceneUserAuth = jySceneUserAuthService.getByNumAndJyUserId(jyUser.getId(), num,jySceneAuth.getAuthType());
|
|
|
+ }
|
|
|
+ if(caseId != null){
|
|
|
+ jySceneUserAuth = jySceneUserAuthService.getByCaseIdAndJyUserId(jyUser.getId(), caseId,jySceneAuth.getAuthType());
|
|
|
+ }
|
|
|
+ setFlag(jySceneUserAuth,sceneAuthVo);
|
|
|
|
|
|
- }
|
|
|
- if(caseList != null && !caseList.isEmpty()){
|
|
|
- JySceneUserAuth jySceneUserAuth = null;
|
|
|
- for (Case aCase : caseList) {
|
|
|
- JySceneAuth jySceneAuth1 = caseSceneAuthMap.get(aCase.getCaseId());
|
|
|
- if(jySceneAuth1 != null){
|
|
|
- jySceneUserAuth = jySceneUserAuthService.getByCaseIdAndJyUserId(jyUser.getId(), aCase.getCaseId(),jySceneAuth1.getAuthType());
|
|
|
- setFlag(jySceneUserAuth,sceneAuthVo);
|
|
|
+ }
|
|
|
+ if(caseList != null && !caseList.isEmpty()){
|
|
|
+ JySceneUserAuth jySceneUserAuth = null;
|
|
|
+ for (Case aCase : caseList) {
|
|
|
+ JySceneAuth jySceneAuth1 = caseSceneAuthMap.get(aCase.getCaseId());
|
|
|
+ if(jySceneAuth1 != null){
|
|
|
+ jySceneUserAuth = jySceneUserAuthService.getByCaseIdAndJyUserId(jyUser.getId(), aCase.getCaseId(),jySceneAuth1.getAuthType());
|
|
|
+ setFlag(jySceneUserAuth,sceneAuthVo);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- if(jyUser.getUserId().equals(sceneUserId)){
|
|
|
- sceneAuthVo.setViewAuth(true);
|
|
|
- sceneAuthVo.setEditAuth(true);
|
|
|
- sceneAuthVo.setIsAuthor(true);
|
|
|
- }
|
|
|
- if(!sceneAuthVo.getViewAuth() && StringUtils.isNotBlank(num)){
|
|
|
- List<JyUserShare> jyUserShares = jyUserShareService.getByJyUserId(jyUser.getId());
|
|
|
- List<Integer> mainUserIds = jyUserShares.stream().map(JyUserShare::getMainJyUserId).collect(Collectors.toList());
|
|
|
- HashMap<Integer,Long> roleMap = new HashMap<>();
|
|
|
- if(!mainUserIds.isEmpty()){
|
|
|
- List<JyUser> jyUsers = jyUserService.listByIds(mainUserIds);
|
|
|
- Set<Long> sysIds = jyUsers.stream().map(JyUser::getSysUserId).collect(Collectors.toSet());
|
|
|
- HashMap<Long, SysUser> byIds = sysUserService.getByIds(sysIds);
|
|
|
- jyUsers.forEach( e-> roleMap.put(e.getId(),byIds.get(e.getSysUserId()).getRoleId()));
|
|
|
|
|
|
- for (JyUser user : jyUsers) {
|
|
|
- Long roleId = roleMap.get(user.getId());
|
|
|
- if(user.getPlatformId() != null && (roleId == 1L || roleId == 45L || roleId == 48L)){
|
|
|
- sceneAuthVo.setViewAuth(true);
|
|
|
- }else if(user.getUserId().equals(sceneUserId)){
|
|
|
- sceneAuthVo.setViewAuth(true);
|
|
|
+ if(jyUser.getUserId().equals(sceneUserId)){
|
|
|
+ sceneAuthVo.setViewAuth(true);
|
|
|
+ sceneAuthVo.setEditAuth(true);
|
|
|
+ sceneAuthVo.setIsAuthor(true);
|
|
|
+ }
|
|
|
+ if(!sceneAuthVo.getViewAuth() && StringUtils.isNotBlank(num)){
|
|
|
+ List<JyUserShare> jyUserShares = jyUserShareService.getByJyUserId(jyUser.getId());
|
|
|
+ List<Integer> mainUserIds = jyUserShares.stream().map(JyUserShare::getMainJyUserId).collect(Collectors.toList());
|
|
|
+ HashMap<Integer,Long> roleMap = new HashMap<>();
|
|
|
+ if(!mainUserIds.isEmpty()){
|
|
|
+ List<JyUser> jyUsers = jyUserService.listByIds(mainUserIds);
|
|
|
+ Set<Long> sysIds = jyUsers.stream().map(JyUser::getSysUserId).collect(Collectors.toSet());
|
|
|
+ HashMap<Long, SysUser> byIds = sysUserService.getByIds(sysIds);
|
|
|
+ jyUsers.forEach( e-> roleMap.put(e.getId(),byIds.get(e.getSysUserId()).getRoleId()));
|
|
|
+
|
|
|
+ for (JyUser user : jyUsers) {
|
|
|
+ Long roleId = roleMap.get(user.getId());
|
|
|
+ if(user.getPlatformId() != null && (roleId == 1L || roleId == 45L || roleId == 48L)){
|
|
|
+ sceneAuthVo.setViewAuth(true);
|
|
|
+ }else if(user.getUserId().equals(sceneUserId)){
|
|
|
+ sceneAuthVo.setViewAuth(true);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
|
|
+ }
|
|
|
+ return sceneAuthVo;
|
|
|
+ }catch (Exception e){
|
|
|
+ log.info("checkNumAuth-error:{}",e);
|
|
|
+ return sceneAuthVo;
|
|
|
}
|
|
|
- return sceneAuthVo;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private void setFlag(JySceneUserAuth jySceneUserAuth,SceneAuthVo sceneAuthVo){
|