|
@@ -0,0 +1,70 @@
|
|
|
+package com.fdkankan.manage_jp.controller;
|
|
|
+
|
|
|
+import com.fdkankan.common.util.JwtUtil;
|
|
|
+import com.fdkankan.manage_jp.common.Result;
|
|
|
+import com.fdkankan.manage_jp.entity.*;
|
|
|
+import com.fdkankan.manage_jp.service.*;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.Set;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping("/laser-use")
|
|
|
+public class LaserController extends BaseController{
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ IUserService userService;
|
|
|
+ @Autowired
|
|
|
+ IUserRoleService userRoleService;
|
|
|
+ @Autowired
|
|
|
+ ISceneProService sceneProService;
|
|
|
+ @Autowired
|
|
|
+ IScenePlusService scenePlusService;
|
|
|
+ @Autowired
|
|
|
+ ICompanyService companyService;
|
|
|
+
|
|
|
+ @GetMapping("/checkEditPermission")
|
|
|
+ public Result checkEditPermission(@RequestParam(required = false)String sceneNum){
|
|
|
+ String username = JwtUtil.getUsername(getToken());
|
|
|
+ User user = userService.getByUserName(username);
|
|
|
+ if(user == null){
|
|
|
+ return Result.success(false);
|
|
|
+ }
|
|
|
+ Set<Long> roleIds = userRoleService.getByUser(user);
|
|
|
+ if(roleIds.contains(5L)){
|
|
|
+ return Result.success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ Long cameraId = null;
|
|
|
+ Long userId = null;
|
|
|
+ ScenePro scenePro = sceneProService.getByNum(sceneNum);
|
|
|
+ if(scenePro == null){
|
|
|
+ ScenePlus scenePlus = scenePlusService.getByNum(sceneNum);
|
|
|
+ if(scenePlus !=null){
|
|
|
+ cameraId = scenePlus.getCameraId();
|
|
|
+ userId = scenePlus.getUserId();
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ cameraId = scenePro.getCameraId();
|
|
|
+ userId = scenePro.getUserId();
|
|
|
+ }
|
|
|
+
|
|
|
+ if(userId != null && userId.equals(user.getId())){
|
|
|
+ return Result.success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(roleIds.contains(6L)){
|
|
|
+ Company company = companyService.getByCameraId(cameraId);
|
|
|
+ if(company != null && company.getId().equals(user.getCompanyId())){
|
|
|
+ return Result.success(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return Result.success(false);
|
|
|
+ }
|
|
|
+}
|