Sfoglia il codice sorgente

编辑权限校验改为调用管理后台的接口

dsx 1 anno fa
parent
commit
acaf55991d

+ 89 - 89
src/main/java/com/fdkankan/scene/service/impl/SceneEditServiceImpl.java

@@ -141,102 +141,102 @@ public class SceneEditServiceImpl implements ISceneEditService {
         boolean isVip = false;
         //获取该相机是否有权益
         boolean isExpired  = false;
-        Camera sceneCamera = cameraService.getById(scenePlus.getCameraId());
-        if(sceneCamera != null){
-            UserIncrement userIncrementEntity = userIncrementService.findByCameraId(sceneCamera.getId());
-
-            if(userIncrementEntity != null){
-                if( userIncrementEntity.getIsExpired().intValue() == 0){
-                    isVip = true;
-                }
-                if(userIncrementEntity.getIsExpired().intValue() == 1){
-                    isExpired  = true;
-                }
-            }else{
-                try {
-                    Date date = DateUtil.parse("2021-09-09 00:00:00", DateExtUtil.dateStyle);
-
-                    //非07批次的放开
-                    String pc = sceneCamera.getSnCode().substring(0,2);
-                    if(!pc.equals("07") ){
-                        if(sceneCamera.getCreateTime()!=null && date.after(sceneCamera.getCreateTime())){
-                            isVip = true;
-                            isExpired  = false;
-                        }
-                    }
-                }catch (Exception e){
-                    e.printStackTrace();
-                }
-            }
-        }
+//        Camera sceneCamera = cameraService.getById(scenePlus.getCameraId());
+//        if(sceneCamera != null){
+//            UserIncrement userIncrementEntity = userIncrementService.findByCameraId(sceneCamera.getId());
+//
+//            if(userIncrementEntity != null){
+//                if( userIncrementEntity.getIsExpired().intValue() == 0){
+//                    isVip = true;
+//                }
+//                if(userIncrementEntity.getIsExpired().intValue() == 1){
+//                    isExpired  = true;
+//                }
+//            }else{
+//                try {
+//                    Date date = DateUtil.parse("2021-09-09 00:00:00", DateExtUtil.dateStyle);
+//
+//                    //非07批次的放开
+//                    String pc = sceneCamera.getSnCode().substring(0,2);
+//                    if(!pc.equals("07") ){
+//                        if(sceneCamera.getCreateTime()!=null && date.after(sceneCamera.getCreateTime())){
+//                            isVip = true;
+//                            isExpired  = false;
+//                        }
+//                    }
+//                }catch (Exception e){
+//                    e.printStackTrace();
+//                }
+//            }
+//        }
 
         sceneAuthVO.setIsExpired(isExpired);
         sceneAuthVO.setIsVip(isVip);
 
         //判断过期时间
-        Date date = DateUtil.parse(expectedTime, DateExtUtil.dateStyle);
-
-        if(camera != null){
-            if(!scenePlus.getCameraId().equals(camera.getId())){
-                throw new BusinessException(ErrorCode.FAILURE_CODE_5014);
-            }
-
-            CameraDetail cameraDetailEntity = cameraDetailService.findByCameraId(camera.getId());
-            if(cameraDetailEntity.getCompanyId() != null){
-                if(cameraDetailEntity.getCompanyId().longValue() == 1 || cameraDetailEntity.getCompanyId().longValue() == 14){
-                    sceneAuthVO.setExclude(new ArrayList<>());
-                    sceneAuthVO.setCompany(cameraDetailEntity.getCompanyId());
-                }
-            }
-            return sceneAuthVO;
-        }
-
-        User user = userService.findByUserName(username);
-        if("18750226207".equals(username)){
-            log.info("18750226207该账号默认超级管理员,可以操作所有场景");
-        }
-        else if(user == null || scenePlus.getUserId() == null || user.getId().longValue() != scenePlus.getUserId().longValue()){
-            log.info("user:" + user.getId() + ",scene:" + scenePlus.getUserId());
-
-            List<SceneCooperation> list =
-                sceneCooperationService.list(
-                    new LambdaQueryWrapper<SceneCooperation>()
-                        .eq(SceneCooperation::getSceneNum, num));
-            if(list != null && list.size() > 0){
-                if(list.get(0).getUserId().longValue() != user.getId().longValue()){
-                    throw new BusinessException(ErrorCode.FAILURE_CODE_5014);
-                }
-            }else {
-                throw new BusinessException(ErrorCode.FAILURE_CODE_5014);
-            }
-        }
-
-        if(scenePlus.getCameraId() != null){
-            camera = cameraService.getById(scenePlus.getCameraId());
-            if(camera != null){
-                CameraDetail cameraDetail = cameraDetailService.findByCameraId(camera.getId());
-                if(cameraDetail.getCompanyId() != null){
-                    if(cameraDetail.getCompanyId().longValue() == 1 || cameraDetail.getCompanyId().longValue() == 14){
-                        sceneAuthVO.setExclude(new ArrayList<>());
-                        sceneAuthVO.setCompany(cameraDetail.getCompanyId());
-                    }
-                }
-            }
-        }
+//        Date date = DateUtil.parse(expectedTime, DateExtUtil.dateStyle);
+
+//        if(camera != null){
+//            if(!scenePlus.getCameraId().equals(camera.getId())){
+//                throw new BusinessException(ErrorCode.FAILURE_CODE_5014);
+//            }
+//
+//            CameraDetail cameraDetailEntity = cameraDetailService.findByCameraId(camera.getId());
+//            if(cameraDetailEntity.getCompanyId() != null){
+//                if(cameraDetailEntity.getCompanyId().longValue() == 1 || cameraDetailEntity.getCompanyId().longValue() == 14){
+//                    sceneAuthVO.setExclude(new ArrayList<>());
+//                    sceneAuthVO.setCompany(cameraDetailEntity.getCompanyId());
+//                }
+//            }
+//            return sceneAuthVO;
+//        }
+
+//        User user = userService.findByUserName(username);
+//        if("18750226207".equals(username)){
+//            log.info("18750226207该账号默认超级管理员,可以操作所有场景");
+//        }
+//        else if(user == null || scenePlus.getUserId() == null || user.getId().longValue() != scenePlus.getUserId().longValue()){
+//            log.info("user:" + user.getId() + ",scene:" + scenePlus.getUserId());
+//
+//            List<SceneCooperation> list =
+//                sceneCooperationService.list(
+//                    new LambdaQueryWrapper<SceneCooperation>()
+//                        .eq(SceneCooperation::getSceneNum, num));
+//            if(list != null && list.size() > 0){
+//                if(list.get(0).getUserId().longValue() != user.getId().longValue()){
+//                    throw new BusinessException(ErrorCode.FAILURE_CODE_5014);
+//                }
+//            }else {
+//                throw new BusinessException(ErrorCode.FAILURE_CODE_5014);
+//            }
+//        }
+
+//        if(scenePlus.getCameraId() != null){
+//            camera = cameraService.getById(scenePlus.getCameraId());
+//            if(camera != null){
+//                CameraDetail cameraDetail = cameraDetailService.findByCameraId(camera.getId());
+//                if(cameraDetail.getCompanyId() != null){
+//                    if(cameraDetail.getCompanyId().longValue() == 1 || cameraDetail.getCompanyId().longValue() == 14){
+//                        sceneAuthVO.setExclude(new ArrayList<>());
+//                        sceneAuthVO.setCompany(cameraDetail.getCompanyId());
+//                    }
+//                }
+//            }
+//        }
 
         //权限控制完后判断若是协作账号,获取协作权限
-        SceneCooperation sceneCooperation = sceneCooperationService.getByNum(num);
-        //若数据为空表示可操作全部资源
-        if(sceneCooperation == null || sceneCooperation.getUserId().longValue() != ssoUser.getId().longValue()){
-            return sceneAuthVO;
-        }
-
-        if(scenePlus.getUserId()!= null && sceneCooperation.getUserId()!= null &&
-            scenePlus.getUserId().equals(sceneCooperation.getUserId())){
-            return sceneAuthVO;
-        }
-
-        sceneAuthVO.setInclude(sceneResourceService.findByCooperationId(sceneCooperation.getId()));
+//        SceneCooperation sceneCooperation = sceneCooperationService.getByNum(num);
+//        //若数据为空表示可操作全部资源
+//        if(sceneCooperation == null || sceneCooperation.getUserId().longValue() != ssoUser.getId().longValue()){
+//            return sceneAuthVO;
+//        }
+//
+//        if(scenePlus.getUserId()!= null && sceneCooperation.getUserId()!= null &&
+//            scenePlus.getUserId().equals(sceneCooperation.getUserId())){
+//            return sceneAuthVO;
+//        }
+//
+//        sceneAuthVO.setInclude(sceneResourceService.findByCooperationId(sceneCooperation.getId()));
 
         return sceneAuthVO;
     }