|
@@ -21,6 +21,7 @@ import java.math.BigInteger;
|
|
|
import java.util.Collections;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Set;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
@@ -38,6 +39,8 @@ public class AppCameraService {
|
|
|
IScenePlusService scenePlusService;
|
|
|
@Autowired
|
|
|
IUserIncrementService userIncrementService;
|
|
|
+ @Autowired
|
|
|
+ IUserRoleService userRoleService;
|
|
|
|
|
|
|
|
|
public List<CameraAppVo> getCameraForUser(String userName, Integer cameraType) {
|
|
@@ -72,8 +75,12 @@ public class AppCameraService {
|
|
|
if(cameraDetail == null){
|
|
|
throw new BusinessException(AppConstant.FAILURE_CODE_4010, AppConstant.FAILURE_MSG_4010);
|
|
|
}
|
|
|
- if (cameraDetail.getUserId() != null){
|
|
|
- throw new BusinessException(CameraConstant.FAILURE_CODE_6006, CameraConstant.FAILURE_MSG_6006);
|
|
|
+ Set<Long> roleIds = userRoleService.getByUser(user);
|
|
|
+ if(!roleIds.contains(5L) || !roleIds.contains(6L) || !roleIds.contains(1L)){
|
|
|
+ throw new BusinessException(CameraConstant.FAILURE_CODE_6005, CameraConstant.FAILURE_MSG_6005);
|
|
|
+ }
|
|
|
+ if(!user.getCompanyId().equals(cameraDetail.getCompanyId())){
|
|
|
+ throw new BusinessException(CameraConstant.FAILURE_CODE_6005, CameraConstant.FAILURE_MSG_6005);
|
|
|
}
|
|
|
List<Long> cameraIds = Collections.singletonList(camera.getId());
|
|
|
|
|
@@ -104,7 +111,12 @@ public class AppCameraService {
|
|
|
if(cameraDetail == null){
|
|
|
throw new BusinessException(AppConstant.FAILURE_CODE_4010, AppConstant.FAILURE_MSG_4010);
|
|
|
}
|
|
|
- if(!user.getId().equals(cameraDetail.getUserId())){
|
|
|
+
|
|
|
+ Set<Long> roleIds = userRoleService.getByUser(user);
|
|
|
+ if(!roleIds.contains(5L) || !roleIds.contains(6L) || !roleIds.contains(1L)){
|
|
|
+ throw new BusinessException(CameraConstant.FAILURE_CODE_6005, CameraConstant.FAILURE_MSG_6005);
|
|
|
+ }
|
|
|
+ if(!user.getCompanyId().equals(cameraDetail.getCompanyId())){
|
|
|
throw new BusinessException(CameraConstant.FAILURE_CODE_6005, CameraConstant.FAILURE_MSG_6005);
|
|
|
}
|
|
|
List<Long> cameraIds = Collections.singletonList(camera.getId());
|