lyhzzz před 2 roky
rodič
revize
980b260f75

+ 9 - 0
src/main/java/com/fdkankan/ucenter/controller/app/AppController.java

@@ -14,6 +14,7 @@ import com.fdkankan.ucenter.entity.CameraDetail;
 import com.fdkankan.ucenter.entity.User;
 import com.fdkankan.ucenter.service.ICameraDetailService;
 import com.fdkankan.ucenter.service.ICameraService;
+import com.fdkankan.ucenter.service.IUserRoleService;
 import com.fdkankan.ucenter.service.IUserService;
 import com.fdkankan.ucenter.service.impl.AppService;
 import com.fdkankan.ucenter.service.impl.LoginService;
@@ -27,6 +28,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.util.ObjectUtils;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.Set;
+
 @RestController
 @RequestMapping("/ucenter/sso/app")
 @Slf4j
@@ -43,6 +46,8 @@ public class AppController extends BaseController {
     @Autowired
     private ICameraDetailService cameraDetailService;
     @Autowired
+    private IUserRoleService userRoleService;
+    @Autowired
     RedisUtil redisUtil;
     /**
      * 登录
@@ -159,9 +164,13 @@ public class AppController extends BaseController {
                 return Result.failure(CameraConstant.FAILURE_CODE_6003, CameraConstant.FAILURE_MSG_6003);
             }
             CameraDetail detailEntity = cameraDetailService.getByCameraId(camera.getId());
+            Set<Long> roleIds = userRoleService.getByUser(user);
             if(ObjectUtils.isEmpty(detailEntity) || ObjectUtils.isEmpty( detailEntity.getCompanyId()) || !detailEntity.getCompanyId().equals(user.getCompanyId())){
                 return Result.failure(CameraConstant.FAILURE_CODE_6003, CameraConstant.FAILURE_MSG_6003);
             }
+            if(roleIds.contains(8L) && ( detailEntity.getUserId()== null || !detailEntity.getUserId().equals(user.getId()))){
+                return Result.failure(CameraConstant.FAILURE_CODE_6003, CameraConstant.FAILURE_MSG_6003);
+            }
         }
         if(!redisUtil.hasKey(RedisKeyUtil.PREFIX_CACHE_CAMERA + username)){
             return Result.failure(LoginConstant.FAILURE_CODE_3004,LoginConstant.FAILURE_MSG_3004);