|
@@ -27,10 +27,12 @@ import com.qunzhixinxi.hnqz.admin.service.SysFileService;
|
|
|
import com.qunzhixinxi.hnqz.common.core.util.R;
|
|
|
import com.qunzhixinxi.hnqz.common.log.annotation.SysLog;
|
|
|
import com.qunzhixinxi.hnqz.common.security.annotation.Inner;
|
|
|
+import com.qunzhixinxi.hnqz.common.security.service.HnqzUser;
|
|
|
import com.qunzhixinxi.hnqz.common.security.util.SecurityUtils;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -49,13 +51,13 @@ import java.util.concurrent.TimeUnit;
|
|
|
*/
|
|
|
@RestController
|
|
|
@AllArgsConstructor
|
|
|
+@Slf4j
|
|
|
@RequestMapping("/sys-file")
|
|
|
@Api(value = "sys-file", tags = "文件管理")
|
|
|
public class SysFileController {
|
|
|
|
|
|
private final SysFileService sysFileService;
|
|
|
private final RedisTemplate<String,String> redisTemplate;
|
|
|
- private final List<String> IMG_EXT_NAME= Arrays.asList("png", "jpg", "gif","jpeg","tif","bmp");
|
|
|
|
|
|
/**
|
|
|
* 分页查询
|
|
@@ -109,8 +111,17 @@ public class SysFileController {
|
|
|
|
|
|
String extName = FileUtil.extName(originalFilename);
|
|
|
|
|
|
+ List<String> IMG_EXT_NAME= Arrays.asList("png", "jpg", "gif","jpeg","tif","bmp");
|
|
|
+
|
|
|
+ log.info("源文件名称:{}", originalFilename);
|
|
|
+ log.info("源文件后缀:{}", extName);
|
|
|
if (IMG_EXT_NAME.contains(extName)){
|
|
|
- Integer id = SecurityUtils.getUser().getId();
|
|
|
+ HnqzUser user = SecurityUtils.getUser();
|
|
|
+ log.info("用户:{}",user);
|
|
|
+ if (user == null){
|
|
|
+ return R.failed("无法获取用户id");
|
|
|
+ }
|
|
|
+ Integer id = user.getId();
|
|
|
Boolean aBoolean = redisTemplate.opsForValue().setIfAbsent(String.format("%s:%s", id, originalFilename), IdUtil.fastSimpleUUID(), 7, TimeUnit.DAYS);
|
|
|
|
|
|
if (aBoolean != null && !aBoolean){
|