Browse Source

e57调用重复锁

lyhzzz 5 months ago
parent
commit
b856891cff

+ 2 - 0
src/main/java/com/fdkankan/manage_jp/common/ResultCode.java

@@ -56,6 +56,8 @@ public enum ResultCode  {
     UPLOAD_ERROR2(5034, "上传失败。文件格式不对"),
 
     UPLOAD_ERROR3(5035, "文件不存在!"),
+
+    REPEAT_ERROR(5036, "重复提交!"),
     ;
 
     private Integer code;

+ 9 - 0
src/main/java/com/fdkankan/manage_jp/controller/UploadController.java

@@ -10,6 +10,7 @@ import com.fdkankan.manage_jp.config.FyunConfig;
 import com.fdkankan.manage_jp.exception.BusinessException;
 import com.fdkankan.manage_jp.httpClient.client.FdKKClient;
 import com.fdkankan.manage_jp.httpClient.param.UploadEditSceneParam;
+import com.fdkankan.redis.util.RedisUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -105,11 +106,19 @@ public class UploadController extends BaseController{
         return Result.success(map);
     }
 
+    @Autowired
+    RedisUtil redisUtil;
     @PostMapping("/relevanceE57")
     public Result relevanceE57( @RequestParam(value = "isObj",required = false)Integer isObj,
                                 @RequestParam(value = "title",required = false)String title,
                                 @RequestParam(value = "newFileName",required = false)String newFileName ){
 
+        String redisKey = "manage:e57:create:lock:"+ newFileName;
+        if(redisUtil.hasKey(redisKey)){
+            throw new BusinessException(ResultCode.REPEAT_ERROR);
+        }
+        redisUtil.set(redisKey,newFileName,48 * 60 * 60);
+
         if(StringUtils.isBlank(newFileName)){
             throw new BusinessException(ResultCode.PARAM_ERROR);
         }