|
@@ -56,40 +56,76 @@ public class JySceneUserAuthServiceImpl extends ServiceImpl<IJySceneUserAuthMapp
|
|
|
IScenePlusService scenePlusService;
|
|
|
@Autowired
|
|
|
ISysUserService sysUserService;
|
|
|
+ @Autowired
|
|
|
+ ICaseService caseService;
|
|
|
+
|
|
|
|
|
|
|
|
|
@Override
|
|
|
public Object getAuthType(SceneParam param) {
|
|
|
- if(StringUtils.isBlank(param.getNum())){
|
|
|
+ if(StringUtils.isBlank(param.getNum()) || param.getCaseId() == null){
|
|
|
throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
}
|
|
|
- ScenePro pro = sceneProService.getByNum(param.getNum());
|
|
|
- ScenePlus plus = scenePlusService.getByNum(param.getNum());
|
|
|
- if(pro == null && plus == null){
|
|
|
- throw new BusinessException(ResultCode.SCENE_NOT_EXIST);
|
|
|
+ if(StringUtils.isNotBlank(param.getNum()) && param.getCaseId() !=null){
|
|
|
+ param.setCaseId(null);
|
|
|
}
|
|
|
- JySceneAuth jySceneAuth = jySceneAuthService.getByNum(param.getNum());
|
|
|
- if(jySceneAuth == null ){
|
|
|
- return new JySceneAuth(0);
|
|
|
+ JySceneAuth jySceneAuth = null;
|
|
|
+ if(StringUtils.isNotBlank(param.getNum())){
|
|
|
+ caseService.checkNumInCase(param.getNum());
|
|
|
+ ScenePlus plus = scenePlusService.getByNum(param.getNum());
|
|
|
+ if(plus == null){
|
|
|
+ throw new BusinessException(ResultCode.SCENE_NOT_EXIST);
|
|
|
+ }
|
|
|
+ jySceneAuth = jySceneAuthService.getByNum(param.getNum());
|
|
|
+ if(jySceneAuth == null ){
|
|
|
+ return new JySceneAuth(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(param.getCaseId() != null){
|
|
|
+ Case caseEntity = caseService.getById(param.getCaseId());
|
|
|
+ if(caseEntity == null){
|
|
|
+ throw new BusinessException(ResultCode.CASE_NOT_EXIST);
|
|
|
+ }
|
|
|
+
|
|
|
+ jySceneAuth = jySceneAuthService.getByCaseId(param.getCaseId());
|
|
|
+ if(jySceneAuth == null ){
|
|
|
+ return new JySceneAuth(0);
|
|
|
+ }
|
|
|
}
|
|
|
return jySceneAuth;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Object getAuthList(SceneParam param) {
|
|
|
- if(StringUtils.isBlank(param.getNum())){
|
|
|
+ if(StringUtils.isBlank(param.getNum()) || param.getCaseId() == null){
|
|
|
throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
}
|
|
|
-
|
|
|
- ScenePro pro = sceneProService.getByNum(param.getNum());
|
|
|
- ScenePlus plus = scenePlusService.getByNum(param.getNum());
|
|
|
- if(pro == null && plus == null){
|
|
|
- throw new BusinessException(ResultCode.SCENE_NOT_EXIST);
|
|
|
+ if(StringUtils.isNotBlank(param.getNum()) && param.getCaseId() !=null){
|
|
|
+ param.setCaseId(null);
|
|
|
}
|
|
|
- Long sceneUserId = pro == null ? plus.getUserId(): pro.getUserId();
|
|
|
-
|
|
|
+ Long sceneUserId = null;
|
|
|
JyUser loginUser = null;
|
|
|
Long sysRoleId = null;
|
|
|
+ if(StringUtils.isNotBlank(param.getNum())){
|
|
|
+ ScenePlus plus = scenePlusService.getByNum(param.getNum());
|
|
|
+ if(plus == null){
|
|
|
+ throw new BusinessException(ResultCode.SCENE_NOT_EXIST);
|
|
|
+ }
|
|
|
+ caseService.checkNumInCase(param.getNum());
|
|
|
+ sceneUserId = plus.getUserId();
|
|
|
+ }
|
|
|
+ if(param.getCaseId() != null){
|
|
|
+ Case caseEntity = caseService.getById(param.getCaseId());
|
|
|
+ if(caseEntity == null){
|
|
|
+ throw new BusinessException(ResultCode.CASE_NOT_EXIST);
|
|
|
+ }
|
|
|
+ JyUser jyUser = jyUserService.getBySysId(caseEntity.getSysUserId());
|
|
|
+ if(jyUser == null){
|
|
|
+ throw new BusinessException(ResultCode.USER_NOT_EXIST);
|
|
|
+ }
|
|
|
+ sceneUserId = jyUser.getUserId();
|
|
|
+ }
|
|
|
+
|
|
|
if(StpUtil.isLogin()){
|
|
|
loginUser = jyUserService.getBySysId(StpUtil.getLoginId());
|
|
|
SysUser byId = sysUserService.getById(Long.valueOf(StpUtil.getLoginId().toString()));
|
|
@@ -111,16 +147,23 @@ public class JySceneUserAuthServiceImpl extends ServiceImpl<IJySceneUserAuthMapp
|
|
|
}
|
|
|
|
|
|
LambdaQueryWrapper<JySceneUserAuth> wrapper = new LambdaQueryWrapper<>();
|
|
|
- wrapper.eq(JySceneUserAuth::getNum,param.getNum());
|
|
|
+ if(StringUtils.isNotBlank(param.getNum())){
|
|
|
+ wrapper.eq(JySceneUserAuth::getNum,param.getNum());
|
|
|
+ }
|
|
|
+ if(param.getCaseId() != null){
|
|
|
+ wrapper.eq(JySceneUserAuth::getCaseId,param.getCaseId());
|
|
|
+ }
|
|
|
wrapper.eq(JySceneUserAuth::getAuthType,param.getAuthType());
|
|
|
+
|
|
|
if(!sceneUserId.equals(loginUser.getUserId()) && sysRoleId!=null && sysRoleId == 47L ){
|
|
|
List<Integer> ids = new ArrayList<>();
|
|
|
- getSubAuthorIdsById(loginUser.getId(),param.getNum(),ids);
|
|
|
+ getSubAuthorIdsById(loginUser.getId(),param.getNum(),param.getCaseId(),ids);
|
|
|
if(ids.size()<=0){
|
|
|
return PageInfo.PageInfo(new Page(param.getPageNum(),param.getPageSize()));
|
|
|
}
|
|
|
wrapper.in(JySceneUserAuth::getAuthorId,ids);
|
|
|
}
|
|
|
+
|
|
|
wrapper.orderByDesc(JySceneUserAuth::getCreateTime);
|
|
|
Page<JySceneUserAuth> page = this.page(new Page<>(param.getPageNum(), param.getPageSize()), wrapper);
|
|
|
|
|
@@ -139,16 +182,21 @@ public class JySceneUserAuthServiceImpl extends ServiceImpl<IJySceneUserAuthMapp
|
|
|
return PageInfo.PageInfo(page);
|
|
|
}
|
|
|
|
|
|
- private void getSubAuthorIdsById(Integer id,String num,List<Integer> ids) {
|
|
|
+ private void getSubAuthorIdsById(Integer id,String num,Integer caseId,List<Integer> ids) {
|
|
|
ids.add(id);
|
|
|
LambdaQueryWrapper<JySceneUserAuth> wrapper = new LambdaQueryWrapper<>();
|
|
|
- wrapper.eq(JySceneUserAuth::getNum,num);
|
|
|
+ if(StringUtils.isNotBlank(num)){
|
|
|
+ wrapper.eq(JySceneUserAuth::getNum,num);
|
|
|
+ }
|
|
|
+ if(caseId != null){
|
|
|
+ wrapper.eq(JySceneUserAuth::getCaseId,caseId);
|
|
|
+ }
|
|
|
wrapper.eq(JySceneUserAuth::getAuthorId,id);
|
|
|
List<JySceneUserAuth> list = this.list(wrapper);
|
|
|
if(list.size() >0){
|
|
|
for (JySceneUserAuth auth : list) {
|
|
|
ids.add(auth.getAuthorId());
|
|
|
- getSubAuthorIdsById(auth.getId(),num,ids);
|
|
|
+ getSubAuthorIdsById(auth.getId(),num,caseId,ids);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -156,28 +204,36 @@ public class JySceneUserAuthServiceImpl extends ServiceImpl<IJySceneUserAuthMapp
|
|
|
|
|
|
@Override
|
|
|
public void setAuthType(JySceneUserAuth param) {
|
|
|
- if(StringUtils.isBlank(param.getNum()) || param.getAuthType() == null){
|
|
|
+
|
|
|
+ if(StringUtils.isBlank(param.getNum()) || param.getCaseId() == null || param.getAuthType() == null){
|
|
|
throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
}
|
|
|
- ScenePro pro = sceneProService.getByNum(param.getNum());
|
|
|
- ScenePlus plus = scenePlusService.getByNum(param.getNum());
|
|
|
- if(pro == null && plus == null){
|
|
|
- throw new BusinessException(ResultCode.SCENE_NOT_EXITS);
|
|
|
+ if(StringUtils.isNotBlank(param.getNum()) && param.getCaseId() !=null){
|
|
|
+ param.setCaseId(null);
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(param.getNum())){
|
|
|
+ ScenePlus plus = scenePlusService.getByNum(param.getNum());
|
|
|
+ if( plus == null){
|
|
|
+ throw new BusinessException(ResultCode.SCENE_NOT_EXITS);
|
|
|
+ }
|
|
|
+ jySceneAuthService.updateAuthTypeByNum(param.getNum(),param.getAuthType());
|
|
|
+ }
|
|
|
+ if(param.getCaseId() != null){
|
|
|
+ Case caseEntity = caseService.getById(param.getCaseId());
|
|
|
+ if(caseEntity == null){
|
|
|
+ throw new BusinessException(ResultCode.CASE_NOT_EXIST);
|
|
|
+ }
|
|
|
+ jySceneAuthService.updateAuthTypeByCaseId(param.getCaseId(),param.getAuthType());
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- jySceneAuthService.updateAuthTypeByNum(param.getNum(),param.getAuthType());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public synchronized void addAuth(JySceneUserAuth param) {
|
|
|
- if(StringUtils.isBlank(param.getNum()) ){
|
|
|
+ if(StringUtils.isBlank(param.getNum()) || param.getCaseId() == null ){
|
|
|
throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
}
|
|
|
- ScenePro pro = sceneProService.getByNum(param.getNum());
|
|
|
- ScenePlus plus = scenePlusService.getByNum(param.getNum());
|
|
|
- if(pro == null && plus == null){
|
|
|
- throw new BusinessException(ResultCode.SCENE_NOT_EXITS);
|
|
|
- }
|
|
|
|
|
|
JyUser jyUser = null;
|
|
|
if(StringUtils.isNotBlank(param.getRyId()) ){
|
|
@@ -195,14 +251,38 @@ public class JySceneUserAuthServiceImpl extends ServiceImpl<IJySceneUserAuthMapp
|
|
|
if(jyUser == null){
|
|
|
throw new BusinessException(ResultCode.JY_ID_NO_EXIST);
|
|
|
}
|
|
|
- JySceneUserAuth jySceneUserAuth = jySceneUserAuthService.getByNumAndJyUserId(jyUser.getId(), param.getNum(),param.getAuthType());
|
|
|
+
|
|
|
+ Long sceneUserId = null;
|
|
|
+ JySceneUserAuth jySceneUserAuth = null;
|
|
|
+ if(StringUtils.isNotBlank(param.getNum())){
|
|
|
+ ScenePlus plus = scenePlusService.getByNum(param.getNum());
|
|
|
+ if(plus == null){
|
|
|
+ throw new BusinessException(ResultCode.SCENE_NOT_EXIST);
|
|
|
+ }
|
|
|
+ caseService.checkNumInCase(param.getNum());
|
|
|
+ sceneUserId = plus.getUserId();
|
|
|
+ jySceneUserAuth = jySceneUserAuthService.getByNumAndJyUserId(jyUser.getId(), param.getNum(),param.getAuthType());
|
|
|
+ }
|
|
|
+ if(param.getCaseId() != null){
|
|
|
+ Case caseEntity = caseService.getById(param.getCaseId());
|
|
|
+ if(caseEntity == null){
|
|
|
+ throw new BusinessException(ResultCode.CASE_NOT_EXIST);
|
|
|
+ }
|
|
|
+ JyUser jyUser2 = jyUserService.getBySysId(caseEntity.getSysUserId());
|
|
|
+ if(jyUser2 == null){
|
|
|
+ throw new BusinessException(ResultCode.USER_NOT_EXIST);
|
|
|
+ }
|
|
|
+ sceneUserId = jyUser2.getUserId();
|
|
|
+ jySceneUserAuth = jySceneUserAuthService.getByCaseIdAndJyUserId(jyUser.getId(), param.getCaseId(),param.getAuthType());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
if(jySceneUserAuth != null && param.getCanDel() != 1){
|
|
|
throw new BusinessException(ResultCode.SCENE_AUTH_EXITS);
|
|
|
}
|
|
|
if(jySceneUserAuth != null && param.getCanDel() == 1){
|
|
|
param.setId(jySceneUserAuth.getId());
|
|
|
}
|
|
|
- Long sceneUserId = pro == null ? plus.getUserId():pro.getUserId();
|
|
|
|
|
|
if(sceneUserId.equals(jyUser.getUserId())){
|
|
|
throw new BusinessException(ResultCode.AUTH_ERROR);
|
|
@@ -222,10 +302,21 @@ public class JySceneUserAuthServiceImpl extends ServiceImpl<IJySceneUserAuthMapp
|
|
|
if(param.getCanEditLook() == 0 && param.getCanAuthLook() == 0){
|
|
|
param.setIsAuthor(0);
|
|
|
}
|
|
|
- JySceneAuth jySceneAuth = jySceneAuthService.getByNum(param.getNum());
|
|
|
+ JySceneAuth jySceneAuth = null;
|
|
|
+ if(StringUtils.isNotBlank(param.getNum())){
|
|
|
+ jySceneAuth = jySceneAuthService.getByNum(param.getNum());
|
|
|
+ }
|
|
|
+ if(param.getCaseId() != null){
|
|
|
+ jySceneAuth = jySceneAuthService.getByCaseId(param.getCaseId());
|
|
|
+ }
|
|
|
if(jySceneAuth == null){
|
|
|
jySceneAuth = new JySceneAuth(param.getAuthType());
|
|
|
- jySceneAuth.setNum(param.getNum());
|
|
|
+ if(StringUtils.isNotBlank(param.getNum())){
|
|
|
+ jySceneAuth.setNum(param.getNum());
|
|
|
+ }
|
|
|
+ if(param.getCaseId() != null){
|
|
|
+ jySceneAuth.setCaseId(param.getCaseId());
|
|
|
+ }
|
|
|
jySceneAuthService.save(jySceneAuth);
|
|
|
}
|
|
|
|
|
@@ -255,6 +346,15 @@ public class JySceneUserAuthServiceImpl extends ServiceImpl<IJySceneUserAuthMapp
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public JySceneUserAuth getByCaseIdAndJyUserId(Integer jyUserId, Integer caseId, Integer authType) {
|
|
|
+ LambdaQueryWrapper<JySceneUserAuth> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(JySceneUserAuth::getJyUserId,jyUserId);
|
|
|
+ wrapper.eq(JySceneUserAuth::getCaseId,caseId);
|
|
|
+ wrapper.eq(JySceneUserAuth::getAuthType,authType);
|
|
|
+ return this.getOne(wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public JySceneUserAuth getByNumAndRyId(String num, String ryId) {
|
|
|
JyUser jyUser = jyUserService.getByRyId(ryId);
|
|
|
if(jyUser == null){
|
|
@@ -281,6 +381,32 @@ public class JySceneUserAuthServiceImpl extends ServiceImpl<IJySceneUserAuthMapp
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public JySceneUserAuth getByCaseIdAndRyId(Integer caseId, String ryId) {
|
|
|
+ JyUser jyUser = jyUserService.getByRyId(ryId);
|
|
|
+ if(jyUser == null){
|
|
|
+ throw new BusinessException(ResultCode.JY_ID_NO_EXIST);
|
|
|
+ }
|
|
|
+ JySceneAuth jySceneAuth = jySceneAuthService.getByCaseId(caseId);
|
|
|
+ if(jySceneAuth == null){
|
|
|
+ throw new BusinessException(ResultCode.DEL_AUTH_ERROR);
|
|
|
+ }
|
|
|
+ return this.getByCaseIdAndJyUserId(jyUser.getId(),caseId,jySceneAuth.getAuthType());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public JySceneUserAuth getByCaseIdAndRyNo(Integer caseId, String ryNo) {
|
|
|
+ JyUser jyUser = jyUserService.getByRyNo(ryNo);
|
|
|
+ if(jyUser == null){
|
|
|
+ throw new BusinessException(ResultCode.JY_ID_NO_EXIST);
|
|
|
+ }
|
|
|
+ JySceneAuth jySceneAuth = jySceneAuthService.getByCaseId(caseId);
|
|
|
+ if(jySceneAuth == null){
|
|
|
+ throw new BusinessException(ResultCode.DEL_AUTH_ERROR);
|
|
|
+ }
|
|
|
+ return this.getByCaseIdAndJyUserId(jyUser.getId(),caseId,jySceneAuth.getAuthType());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public Object checkAuthOther(JySceneUserAuth param) {
|
|
|
if(StringUtils.isBlank(param.getNum())){
|
|
|
throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
|
|
@@ -343,6 +469,15 @@ public class JySceneUserAuthServiceImpl extends ServiceImpl<IJySceneUserAuthMapp
|
|
|
if(jySceneAuth!=null && jySceneAuth.getAuthType() == 1){
|
|
|
sceneAuthVo.setViewAuth(true);
|
|
|
}
|
|
|
+ List<Case> caseList = caseService.getCaseByNum(num);
|
|
|
+ for (Case aCase : caseList) {
|
|
|
+ JySceneAuth jySceneAuth1 = jySceneAuthService.getByCaseId(aCase.getCaseId());
|
|
|
+ if(jySceneAuth1!=null && jySceneAuth1.getAuthType() == 1){
|
|
|
+ sceneAuthVo.setViewAuth(true);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if(StringUtils.isBlank(token) && (StringUtils.isBlank(userName) || StringUtils.isBlank(password))){
|
|
|
return sceneAuthVo;
|
|
|
}
|
|
@@ -393,16 +528,12 @@ public class JySceneUserAuthServiceImpl extends ServiceImpl<IJySceneUserAuthMapp
|
|
|
//if(jySceneAuth != null && jySceneAuth.getAuthType() == 0){
|
|
|
if(jySceneAuth != null ){
|
|
|
JySceneUserAuth jySceneUserAuth = jySceneUserAuthService.getByNumAndJyUserId(jyUser.getId(), num,jySceneAuth.getAuthType());
|
|
|
- if(jySceneUserAuth != null){
|
|
|
- Date date = new Date();
|
|
|
- if(jySceneUserAuth.getLookAuth() == 1 ||
|
|
|
- ( jySceneUserAuth.getLookAuth() == 2 && jySceneUserAuth.getLookEndTime().getTime() >date.getTime())){
|
|
|
- sceneAuthVo.setViewAuth(true);
|
|
|
- }
|
|
|
- if(jySceneUserAuth.getEditAuth() == 1 ||
|
|
|
- (jySceneUserAuth.getEditAuth() == 2 && jySceneUserAuth.getEditEndTime().getTime() >date.getTime())){
|
|
|
- sceneAuthVo.setEditAuth(true);
|
|
|
- }
|
|
|
+ setFlag(jySceneUserAuth,sceneAuthVo);
|
|
|
+ }
|
|
|
+ if(!caseList.isEmpty()){
|
|
|
+ for (Case aCase : caseList) {
|
|
|
+ JySceneUserAuth jySceneUserAuth = jySceneUserAuthService.getByCaseIdAndJyUserId(jyUser.getId(), aCase.getCaseId(),jySceneAuth.getAuthType());
|
|
|
+ setFlag(jySceneUserAuth,sceneAuthVo);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -443,6 +574,20 @@ public class JySceneUserAuthServiceImpl extends ServiceImpl<IJySceneUserAuthMapp
|
|
|
return sceneAuthVo;
|
|
|
}
|
|
|
|
|
|
+ private void setFlag(JySceneUserAuth jySceneUserAuth,SceneAuthVo sceneAuthVo){
|
|
|
+ if(jySceneUserAuth != null){
|
|
|
+ Date date = new Date();
|
|
|
+ if(jySceneUserAuth.getLookAuth() == 1 ||
|
|
|
+ ( jySceneUserAuth.getLookAuth() == 2 && jySceneUserAuth.getLookEndTime().getTime() >date.getTime())){
|
|
|
+ sceneAuthVo.setViewAuth(true);
|
|
|
+ }
|
|
|
+ if(jySceneUserAuth.getEditAuth() == 1 ||
|
|
|
+ (jySceneUserAuth.getEditAuth() == 2 && jySceneUserAuth.getEditEndTime().getTime() >date.getTime())){
|
|
|
+ sceneAuthVo.setEditAuth(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<JySceneUserAuth> getByJyUserId(Integer jyUserId) {
|
|
|
LambdaQueryWrapper<JySceneUserAuth> wrapper = new LambdaQueryWrapper<>();
|