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