|
|
@ -16,44 +16,42 @@
|
|
|
|
package me.zhengjie.modules.uploadnew.rest;
|
|
|
|
package me.zhengjie.modules.uploadnew.rest;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
import io.swagger.models.auth.In;
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import me.zhengjie.annotation.AnonymousAccess;
|
|
|
|
import me.zhengjie.annotation.AnonymousAccess;
|
|
|
|
import me.zhengjie.annotation.Log;
|
|
|
|
import me.zhengjie.annotation.Log;
|
|
|
|
import me.zhengjie.common.http.CommonResponse;
|
|
|
|
import me.zhengjie.common.http.CommonResponse;
|
|
|
|
import me.zhengjie.common.http.ResponseCode;
|
|
|
|
import me.zhengjie.common.http.ResponseCode;
|
|
|
|
import me.zhengjie.modules.security.security.TokenFilter;
|
|
|
|
|
|
|
|
import me.zhengjie.modules.upload.service.dto.UploadFileDto;
|
|
|
|
|
|
|
|
import me.zhengjie.modules.upload.service.dto.UploadFileQueryCriteria;
|
|
|
|
|
|
|
|
import me.zhengjie.modules.uploadnew.domain.TbUploadFileNew;
|
|
|
|
import me.zhengjie.modules.uploadnew.domain.TbUploadFileNew;
|
|
|
|
import me.zhengjie.modules.uploadnew.service.TbUploadFileNewService;
|
|
|
|
import me.zhengjie.modules.uploadnew.service.TbUploadFileNewService;
|
|
|
|
import me.zhengjie.modules.uploadnew.service.dto.TbUploadFileNewDto;
|
|
|
|
import me.zhengjie.modules.uploadnew.service.dto.TbUploadFileNewDto;
|
|
|
|
import me.zhengjie.modules.uploadnew.service.dto.TbUploadFileNewQueryCriteria;
|
|
|
|
import me.zhengjie.modules.uploadnew.service.dto.TbUploadFileNewQueryCriteria;
|
|
|
|
import me.zhengjie.modules.uploadnew.task.SaveToFileNewTask;
|
|
|
|
import me.zhengjie.modules.uploadnew.task.SaveToFileNewTask;
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
//import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import io.swagger.annotations.*;
|
|
|
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
|
|
|
import javax.servlet.ServletRequest;
|
|
|
|
import javax.servlet.ServletRequest;
|
|
|
|
import javax.servlet.http.Cookie;
|
|
|
|
import javax.servlet.http.Cookie;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
|
|
|
|
|
|
|
import static me.zhengjie.modules.upload.consts.UploadFileConst.FILE_PATH_SPLIT;
|
|
|
|
import static me.zhengjie.modules.upload.consts.UploadFileConst.FILE_PATH_SPLIT;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @website https://el-admin.vip
|
|
|
|
* @website https://el-admin.vip
|
|
|
|
* @author weizhongxi
|
|
|
|
* @author weizhongxi
|
|
|
@ -126,10 +124,15 @@ public class TbUploadFileNewController {
|
|
|
|
@AnonymousAccess
|
|
|
|
@AnonymousAccess
|
|
|
|
@PostMapping("/fileUpload")
|
|
|
|
@PostMapping("/fileUpload")
|
|
|
|
// @ResponseBody
|
|
|
|
// @ResponseBody
|
|
|
|
public ResponseEntity<Object> fileUpload(@RequestParam("file") MultipartFile file, @RequestParam(value = "taskName") String taskName, @RequestParam(value = "isEcryptionNew") String isEcryptionNew, ServletRequest servletRequest) {
|
|
|
|
public ResponseEntity<Object> fileUpload(@RequestParam("file") MultipartFile file,
|
|
|
|
|
|
|
|
@RequestParam(value = "taskName") String taskName,
|
|
|
|
|
|
|
|
@RequestParam(value = "isEcryptionNew") String isEcryptionNew,
|
|
|
|
|
|
|
|
ServletRequest servletRequest) {
|
|
|
|
// 记录日志
|
|
|
|
// 记录日志
|
|
|
|
log.info("TbUploadFileNewController:fileUpload | taskName="+taskName+"===== isEcryptionNew="+isEcryptionNew);
|
|
|
|
log.info("TbUploadFileNewController:fileUpload | taskName="+taskName+"===== isEcryptionNew="+isEcryptionNew);
|
|
|
|
|
|
|
|
// FIXME: 2021/4/23 0023
|
|
|
|
Integer isEcryption = Integer.parseInt(isEcryptionNew);
|
|
|
|
Integer isEcryption = Integer.parseInt(isEcryptionNew);
|
|
|
|
|
|
|
|
// FIXME: 2021/4/23 0023
|
|
|
|
String name=file.getOriginalFilename();
|
|
|
|
String name=file.getOriginalFilename();
|
|
|
|
|
|
|
|
|
|
|
|
String keyName = "";
|
|
|
|
String keyName = "";
|
|
|
@ -140,22 +143,24 @@ public class TbUploadFileNewController {
|
|
|
|
//获取cookie的名字
|
|
|
|
//获取cookie的名字
|
|
|
|
String cookieName = cookie.getName();
|
|
|
|
String cookieName = cookie.getName();
|
|
|
|
token=cookie.getValue();
|
|
|
|
token=cookie.getValue();
|
|
|
|
System.out.println(cookieName);
|
|
|
|
// FIXME: 2021/4/23 0023
|
|
|
|
System.out.println(cookieName+" : "+ cookie.getValue() );
|
|
|
|
// System.out.println(cookieName);
|
|
|
|
|
|
|
|
// System.out.println(cookieName+" : "+ cookie.getValue() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// FIXME: 2021/4/23 0023 ===
|
|
|
|
keyName = token+"==="+name;
|
|
|
|
keyName = token+"==="+name;
|
|
|
|
Object keyValue = redisTemplate.opsForValue().get(keyName);
|
|
|
|
Object keyValue = redisTemplate.opsForValue().get(keyName);
|
|
|
|
//防止用户多次提交
|
|
|
|
//防止用户多次提交
|
|
|
|
if (keyValue != null){
|
|
|
|
if (keyValue != null){
|
|
|
|
return new ResponseEntity<>(CommonResponse.createByError(ResponseCode.TASK_STAETING), HttpStatus.OK);
|
|
|
|
return new ResponseEntity<>(CommonResponse.createByError(ResponseCode.TASK_STAETING), HttpStatus.OK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
redisTemplate.opsForValue().set(keyName, "value11");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
redisTemplate.opsForValue().set(keyName, "value11");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int lastIndexOf = name.lastIndexOf(".");
|
|
|
|
int lastIndexOf = name.lastIndexOf(".");
|
|
|
|
String nameStr = name.substring(lastIndexOf);
|
|
|
|
|
|
|
|
// 校验文件格式
|
|
|
|
// 校验文件格式
|
|
|
|
|
|
|
|
String nameStr = name.substring(lastIndexOf);
|
|
|
|
if (!((nameStr.equals(".xlsx")||nameStr.equals(".xls")) || nameStr.equals(".txt") ||nameStr.equals(".csv"))){
|
|
|
|
if (!((nameStr.equals(".xlsx")||nameStr.equals(".xls")) || nameStr.equals(".txt") ||nameStr.equals(".csv"))){
|
|
|
|
return new ResponseEntity<>(CommonResponse.createByError(ResponseCode.NO_FILE_FORMAT), HttpStatus.OK);
|
|
|
|
return new ResponseEntity<>(CommonResponse.createByError(ResponseCode.NO_FILE_FORMAT), HttpStatus.OK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|