[Bug修复](master): 提交Bug修复意见

请按fixme修复
master
土豆兄弟 3 years ago
parent 8e5d21bf9c
commit f5ef1f0ada

@ -16,44 +16,42 @@
package me.zhengjie.modules.uploadnew.rest;
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 me.zhengjie.annotation.AnonymousAccess;
import me.zhengjie.annotation.Log;
import me.zhengjie.common.http.CommonResponse;
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.service.TbUploadFileNewService;
import me.zhengjie.modules.uploadnew.service.dto.TbUploadFileNewDto;
import me.zhengjie.modules.uploadnew.service.dto.TbUploadFileNewQueryCriteria;
import me.zhengjie.modules.uploadnew.task.SaveToFileNewTask;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import lombok.RequiredArgsConstructor;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
//import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
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.http.Cookie;
import javax.servlet.http.HttpServletRequest;
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 org.springframework.util.StringUtils;
/**
* @website https://el-admin.vip
* @author weizhongxi
@ -126,10 +124,15 @@ public class TbUploadFileNewController {
@AnonymousAccess
@PostMapping("/fileUpload")
// @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);
// FIXME: 2021/4/23 0023
Integer isEcryption = Integer.parseInt(isEcryptionNew);
// FIXME: 2021/4/23 0023
String name=file.getOriginalFilename();
String keyName = "";
@ -140,22 +143,24 @@ public class TbUploadFileNewController {
//获取cookie的名字
String cookieName = cookie.getName();
token=cookie.getValue();
System.out.println(cookieName);
System.out.println(cookieName+" : "+ cookie.getValue() );
// FIXME: 2021/4/23 0023
// System.out.println(cookieName);
// System.out.println(cookieName+" : "+ cookie.getValue() );
}
// FIXME: 2021/4/23 0023 ===
keyName = token+"==="+name;
Object keyValue = redisTemplate.opsForValue().get(keyName);
//防止用户多次提交
if (keyValue != null){
return new ResponseEntity<>(CommonResponse.createByError(ResponseCode.TASK_STAETING), HttpStatus.OK);
}
redisTemplate.opsForValue().set(keyName, "value11");
redisTemplate.opsForValue().set(keyName, "value11");
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"))){
return new ResponseEntity<>(CommonResponse.createByError(ResponseCode.NO_FILE_FORMAT), HttpStatus.OK);
}

@ -19,35 +19,34 @@ import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.system.OsInfo;
import cn.hutool.system.SystemUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.zhengjie.modules.upload.consts.SysConst;
import me.zhengjie.modules.uploadnew.domain.TbUploadFileNew;
import me.zhengjie.modules.uploadnew.util.ExcelUtils;
import me.zhengjie.modules.uploadnew.util.TxtUtils;
import me.zhengjie.utils.*;
import lombok.RequiredArgsConstructor;
import me.zhengjie.modules.uploadnew.repository.TbUploadFileNewRepository;
import me.zhengjie.modules.uploadnew.service.TbUploadFileNewService;
import me.zhengjie.modules.uploadnew.service.dto.TbUploadFileNewDto;
import me.zhengjie.modules.uploadnew.service.dto.TbUploadFileNewQueryCriteria;
import me.zhengjie.modules.uploadnew.service.mapstruct.TbUploadFileNewMapper;
import me.zhengjie.modules.uploadnew.util.TxtUtils;
import me.zhengjie.utils.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.nio.file.Paths;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import static me.zhengjie.modules.uploadnew.consts.SysConstNew.TEST_USER_NAME;
import static me.zhengjie.modules.uploadnew .consts.UploadFileNewConst.*;
import static me.zhengjie.modules.uploadnew.consts.UploadFileNewConst.*;
/**
* @website https://el-admin.vip
@ -174,6 +173,7 @@ public class TbUploadFileNewServiceImpl implements TbUploadFileNewService {
List<String> list = null;
//根据文件类型进行解析
try {
// FIXME: 2021/4/23 0023
if(nameStr.equals(".xlsx")||nameStr.equals(".xls")){
fileFormat = "excel文件";
list = FileUtil.readLines(eachFilePath, "UTF-8");

Loading…
Cancel
Save