|
|
@@ -40,34 +40,6 @@ import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
@Order(101)
|
|
|
public class CheckPermitAspect {
|
|
|
|
|
|
- public static Set<String> demoAllowApis = new HashSet<>();
|
|
|
-
|
|
|
- static {
|
|
|
- demoAllowApis.add("/tag/list");
|
|
|
- demoAllowApis.add("/linkPan/list");
|
|
|
- demoAllowApis.add("/getInfo");
|
|
|
- demoAllowApis.add("/downloadPanorama");
|
|
|
- demoAllowApis.add("/downloadBallScreenVideo");
|
|
|
- demoAllowApis.add("/getAuth");
|
|
|
- demoAllowApis.add("/tour/video/download");
|
|
|
- demoAllowApis.add("/mosaics/list");
|
|
|
- demoAllowApis.add("/filter/list");
|
|
|
- demoAllowApis.add("/surveillance/list");
|
|
|
- demoAllowApis.add("/billboards/list");
|
|
|
- demoAllowApis.add("/cutModel/list");
|
|
|
- demoAllowApis.add("/point/getLatAndLon");
|
|
|
- demoAllowApis.add("/box4/getInfos");
|
|
|
- demoAllowApis.add("/dynamicPanel/list");
|
|
|
- demoAllowApis.add("/sceneDraw/list");
|
|
|
- demoAllowApis.add("/downloadPanorama");
|
|
|
- demoAllowApis.add("/downloadModel");
|
|
|
- demoAllowApis.add("/getAsynOperLog");
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @Value("#{'${demo.scene.num:}'.split(',')}")
|
|
|
- private List<String> demoSceneNums;
|
|
|
-
|
|
|
@Autowired
|
|
|
private SSOLoginHelper ssoLoginHelper;
|
|
|
@Autowired
|
|
|
@@ -92,20 +64,16 @@ public class CheckPermitAspect {
|
|
|
@Before("checkCooperationPermit()")
|
|
|
public void doBefore(JoinPoint joinPoint) throws Exception {
|
|
|
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
|
|
- String requestURI = request.getRequestURI();
|
|
|
+ // 读取session中的用户
|
|
|
+ SSOUser user = ssoLoginHelper.getSsoUser(request.getHeader("token"));
|
|
|
+ if(Objects.isNull(user)){
|
|
|
+ throw new BusinessException(ErrorCode.TOKEN_NOT_FOUND);
|
|
|
+ }
|
|
|
String num = WebUtil.getParameter("num", joinPoint, request);
|
|
|
if(StrUtil.isEmpty(num)){
|
|
|
throw new BusinessException(ErrorCode.PARAM_REQUIRED);
|
|
|
}
|
|
|
|
|
|
- // 读取session中的用户
|
|
|
- SSOUser user = ssoLoginHelper.getSsoUser(request.getHeader("token"));
|
|
|
- boolean pass = this.demoScenePassPai(num, requestURI);
|
|
|
- if(!pass){//非demo场景,需要检验登录用户是否为空
|
|
|
- if(Objects.isNull(user)){
|
|
|
- throw new BusinessException(ErrorCode.TOKEN_NOT_FOUND);
|
|
|
- }
|
|
|
- }
|
|
|
ScenePlus scenePlus= scenePlusService.getScenePlusByNum(num);
|
|
|
if(Objects.isNull(scenePlus)){
|
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
@@ -120,7 +88,7 @@ public class CheckPermitAspect {
|
|
|
}
|
|
|
|
|
|
//判断是否相机登录,是否场景的相机id和相机登录的相机id是否相等,如果都满足,则放行,否则判定为用户登录
|
|
|
- if(Objects.nonNull(user) && Objects.nonNull(user.getCameraLogin())
|
|
|
+ if(Objects.nonNull(user.getCameraLogin())
|
|
|
&& CommonStatus.YES.code().byteValue() == user.getCameraLogin().intValue()){
|
|
|
if(scenePlus.getCameraId().equals(user.getCameraId())){
|
|
|
return;
|
|
|
@@ -129,21 +97,16 @@ public class CheckPermitAspect {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //这是一个demo场景,允许无条件打开编辑页,但是不允许提交数据
|
|
|
- if(pass){
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
//走到这里代表是用户账号密码登录,如果查到的场景的userid是空,证明相机解绑了,需要返回无权操作
|
|
|
if(Objects.isNull(scenePlus.getUserId())){
|
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5014);
|
|
|
}
|
|
|
|
|
|
- if(scenePlus.getUserId().equals(user.getId())){
|
|
|
- return;
|
|
|
- }
|
|
|
+ if(scenePlus.getUserId().equals(user.getId())){
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- //如果不是用户自己的场景,判断是否有协作权限
|
|
|
+ //如果不是用户自己的场景,判断是否有协作权限
|
|
|
SceneCooperation sceneCooperation = sceneCooperationService.getByNumAndUserId(num, user.getId());
|
|
|
if(Objects.isNull(sceneCooperation)){
|
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5014);
|
|
|
@@ -152,17 +115,5 @@ public class CheckPermitAspect {
|
|
|
|
|
|
}
|
|
|
|
|
|
- private boolean demoScenePassPai(String num, String uri){
|
|
|
- //校验场景码是否是demo场景
|
|
|
- if(CollUtil.isEmpty(demoSceneNums) && !demoSceneNums.contains(num)){
|
|
|
- return false;
|
|
|
- }
|
|
|
- for (String demoAllowApi : demoAllowApis) {
|
|
|
- if(uri.contains(demoAllowApi)){
|
|
|
- return true;
|
|
|
- }
|
|
|
- }
|
|
|
- return false;
|
|
|
- }
|
|
|
|
|
|
}
|