|
|
@@ -4,6 +4,7 @@ import cn.hutool.log.Log;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.fdkankan.common.util.JwtUtil;
|
|
|
+import com.fdkankan.manage_jp.common.RedisKeyUtil;
|
|
|
import com.fdkankan.manage_jp.common.Result;
|
|
|
import com.fdkankan.manage_jp.common.ResultCode;
|
|
|
import com.fdkankan.manage_jp.entity.*;
|
|
|
@@ -13,6 +14,7 @@ import com.fdkankan.manage_jp.mapper.ISceneProMapper;
|
|
|
import com.fdkankan.manage_jp.service.*;
|
|
|
import com.fdkankan.manage_jp.vo.request.SceneParam;
|
|
|
import com.fdkankan.manage_jp.vo.response.SceneVo;
|
|
|
+import com.fdkankan.redis.util.RedisUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -44,14 +46,26 @@ public class LaserController extends BaseController{
|
|
|
ITmContractorNumService tmContractorNumService;
|
|
|
@Autowired
|
|
|
ITmColdStorageService tmColdStorageService;
|
|
|
+ @Autowired
|
|
|
+ RedisUtil redisUtil;
|
|
|
|
|
|
@GetMapping("/checkEditPermission")
|
|
|
public Result checkEditPermission(@RequestParam(required = false)String sceneNum){
|
|
|
+ String redisKey = String.format(RedisKeyUtil.checkEditPermissionCacheKey,sceneNum,getToken());
|
|
|
+ if(redisUtil.hasKey(redisKey)){
|
|
|
+ return Result.success(redisUtil.get(redisKey).equals("1"));
|
|
|
+ }
|
|
|
+ Boolean flag = this.checkEditPer(sceneNum, getToken());
|
|
|
+ redisUtil.set(redisKey,flag?"1":"0",30);
|
|
|
+ return Result.success(flag);
|
|
|
+ }
|
|
|
+
|
|
|
+ private Boolean checkEditPer(String sceneNum, String token) {
|
|
|
//log.info("checkEditPermission--:{},{}",sceneNum,getToken());
|
|
|
String username = JwtUtil.getUsername(getToken());
|
|
|
User user = userService.getByUserName(username);
|
|
|
if(user == null){
|
|
|
- return Result.success(false);
|
|
|
+ return false;
|
|
|
}
|
|
|
// List<String> coldLogNumList = tmColdStorageService.getNumListColdLog(sceneNum);
|
|
|
// if(coldLogNumList.contains(sceneNum)){
|
|
|
@@ -59,7 +73,7 @@ public class LaserController extends BaseController{
|
|
|
// }
|
|
|
Set<Long> roleIds = userRoleService.getByUser(user);
|
|
|
if(roleIds.contains(5L)){
|
|
|
- return Result.success(true);
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
Long cameraId = null;
|
|
|
@@ -77,14 +91,14 @@ public class LaserController extends BaseController{
|
|
|
}
|
|
|
User sceneUser = userService.getById(userId);
|
|
|
if(sceneUser == null || sceneUser.getCompanyId() == null){
|
|
|
- return Result.success(false);
|
|
|
+ return false;
|
|
|
}
|
|
|
if( sceneUser.getId().equals(user.getId())){
|
|
|
- return Result.success(true);
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
if(sceneUser.getCompanyId().equals(user.getCompanyId())){
|
|
|
- return Result.success(true);
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
List<TmContractorNum> numList = tmContractorNumService.getByNum(sceneNum);
|
|
|
@@ -93,12 +107,12 @@ public class LaserController extends BaseController{
|
|
|
List<TmContractor> tmContractors = tmContractorService.listByIds(ids);
|
|
|
for (TmContractor tmContractor : tmContractors) {
|
|
|
if(tmContractor.getContractorCompanyId().equals(user.getCompanyId())){
|
|
|
- return Result.success(true);
|
|
|
+ return true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return Result.success(false);
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
@Autowired
|
|
|
@@ -147,8 +161,5 @@ public class LaserController extends BaseController{
|
|
|
return Result.success(jsonObject);
|
|
|
}
|
|
|
|
|
|
- public static void main(String[] args) {
|
|
|
- String username = JwtUtil.getUsername("eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMzU5MjQxODE4QHFxLmNvbSIsImxvZ2luVHlwZSI6InVzZXIiLCJ1c2VyTmFtZSI6IjEzNTkyNDE4MThAcXEuY29tIiwiaWF0IjoxNzExNDQ3OTI2LCJqdGkiOiJjYTcyNTlkMC00ZDExLTRlYTQtYWU4Yi04YmQwZTZhNjRlOGEifQ.kLUx9XZdyBXCVENuMZWOU-Ge4-gg1mED7bZ8DnH8g1E");
|
|
|
- System.out.println(username);
|
|
|
- }
|
|
|
+
|
|
|
}
|