|
@@ -4,6 +4,8 @@ package com.gis.web.controller;
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
import com.gis.common.constant.ConfigConstant;
|
|
|
import com.gis.common.constant.MsgCode;
|
|
|
+import com.gis.common.constant.RedisConstant;
|
|
|
+import com.gis.common.util.RedisUtil;
|
|
|
import com.gis.common.util.Result;
|
|
|
import com.gis.domain.entity.SceneEntity;
|
|
|
import com.gis.domain.entity.WorkEntity;
|
|
@@ -14,12 +16,14 @@ import com.gis.service.WorkService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.log4j.Log4j2;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -49,7 +53,8 @@ public class WebController extends BaseController {
|
|
|
@Autowired
|
|
|
ConfigConstant configConstant;
|
|
|
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ RedisUtil redisUtil;
|
|
|
|
|
|
|
|
|
|
|
@@ -57,14 +62,29 @@ public class WebController extends BaseController {
|
|
|
@ApiOperation(value = "检查作品是否可用", notes = "true:可用, false:不可用, visit有值表示要添加浏览量")
|
|
|
@GetMapping("checkWork/{workId}")
|
|
|
public Result checkWork(@PathVariable Long workId, String visit) {
|
|
|
+ log.info("作品id: {}", workId);
|
|
|
+ boolean flag = false;
|
|
|
+
|
|
|
+ if (redisUtil.hasKey(RedisConstant.WORK_ID+workId)){
|
|
|
+ if (visit != null) {
|
|
|
+ workService.addVisit(workId);
|
|
|
+ }
|
|
|
+ flag = true;
|
|
|
+ log.info("检查走缓存: {}", workId);
|
|
|
+ return Result.success(flag);
|
|
|
+ }
|
|
|
+
|
|
|
WorkEntity entity = workService.findById(workId);
|
|
|
- Boolean flag = false;
|
|
|
+
|
|
|
if (entity != null) {
|
|
|
- log.info("作品不存在");
|
|
|
flag = true;
|
|
|
if (visit != null) {
|
|
|
workService.addVisit(workId);
|
|
|
}
|
|
|
+ redisUtil.set(RedisConstant.WORK_ID+workId, entity, 30, TimeUnit.SECONDS);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ log.warn("作品不存在");
|
|
|
}
|
|
|
return Result.success(flag);
|
|
|
}
|
|
@@ -88,16 +108,6 @@ public class WebController extends BaseController {
|
|
|
}
|
|
|
|
|
|
|
|
|
-// @ApiOperation(value = "初始场景-获取", position = 3)
|
|
|
-// @GetMapping("getIndex/{workId}")
|
|
|
-// public Result getIndex(@PathVariable Long workId) {
|
|
|
-// return sceneService.getVoIndex(workId);
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
|
|
|
@ApiOperation(value = "检查token是否有效" , position = 3)
|
|
|
@GetMapping("checkToken")
|