[Bug修复](master): Bug

修复些许Bug
master
土豆兄弟 3 years ago
parent 322f9593a7
commit 1fa2db32fe

@ -9,8 +9,8 @@ import org.springframework.stereotype.Component;
@Generated( @Generated(
value = "org.mapstruct.ap.MappingProcessor", value = "org.mapstruct.ap.MappingProcessor",
date = "2021-04-20T11:01:39+0800", date = "2021-04-24T00:12:04+0800",
comments = "version: 1.3.1.Final, compiler: javac, environment: Java 1.8.0_251 (Oracle Corporation)" comments = "version: 1.3.1.Final, compiler: javac, environment: Java 1.8.0_261 (Oracle Corporation)"
) )
@Component @Component
public class LogErrorMapperImpl implements LogErrorMapper { public class LogErrorMapperImpl implements LogErrorMapper {

@ -9,8 +9,8 @@ import org.springframework.stereotype.Component;
@Generated( @Generated(
value = "org.mapstruct.ap.MappingProcessor", value = "org.mapstruct.ap.MappingProcessor",
date = "2021-04-20T11:01:39+0800", date = "2021-04-24T00:12:04+0800",
comments = "version: 1.3.1.Final, compiler: javac, environment: Java 1.8.0_251 (Oracle Corporation)" comments = "version: 1.3.1.Final, compiler: javac, environment: Java 1.8.0_261 (Oracle Corporation)"
) )
@Component @Component
public class LogSmallMapperImpl implements LogSmallMapper { public class LogSmallMapperImpl implements LogSmallMapper {

@ -16,7 +16,7 @@ public class SysConst {
// Test相关的 - end // Test相关的 - end
public static final String REMOTE_TRANS_HOST = "127.0.0.1"; // 118.178.137.129 116.62.197.152 public static final String REMOTE_TRANS_HOST = "116.62.197.152"; // 118.178.137.129 116.62.197.152
public static final Integer REMOTE_TRANS_PORT = 22; public static final Integer REMOTE_TRANS_PORT = 22;
@ -30,7 +30,7 @@ public class SysConst {
public static final String REMOTE_TRANS_DIR_PATH = "/home/"; public static final String REMOTE_TRANS_DIR_PATH = "/home/";
// fixme 以后改成rpc调用的地址 // fixme 以后改成rpc调用的地址
public static final String REMOTE_UPDATE_ADDR = "http://127.0.0.1:8001/api/remoteRecord/remote/rec"; public static final String REMOTE_UPDATE_ADDR = "http://116.62.197.152:8000/api/remoteRecord/remote/rec";
// 测试内容临时定义 // 测试内容临时定义
public static final String TEST_USER_NAME = "测试用户"; public static final String TEST_USER_NAME = "测试用户";

@ -1,18 +1,18 @@
/* /*
* Copyright 2019-2020 Zheng Jie * Copyright 2019-2020 Zheng Jie
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package me.zhengjie.modules.uploadnew.rest; package me.zhengjie.modules.uploadnew.rest;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
@ -56,10 +56,10 @@ import static me.zhengjie.modules.uploadnew.consts.SysConstNew.*;
//import org.springframework.util.StringUtils; //import org.springframework.util.StringUtils;
/** /**
* @website https://el-admin.vip * @author weizhongxi
* @author weizhongxi * @website https://el-admin.vip
* @date 2021-04-14 * @date 2021-04-14
**/ **/
@RestController @RestController
@RequiredArgsConstructor @RequiredArgsConstructor
@Api(tags = "文件上传接口管理") @Api(tags = "文件上传接口管理")
@ -87,23 +87,23 @@ public class TbUploadFileNewController {
@Log("查询文件上传接口") @Log("查询文件上传接口")
@ApiOperation("查询文件上传接口") @ApiOperation("查询文件上传接口")
@PreAuthorize("@el.check('tbUploadFileNew:list')") @PreAuthorize("@el.check('tbUploadFileNew:list')")
public ResponseEntity<Object> query(TbUploadFileNewQueryCriteria criteria, Pageable pageable){ public ResponseEntity<Object> query(TbUploadFileNewQueryCriteria criteria, Pageable pageable) {
return new ResponseEntity<>(tbUploadFileNewService.queryAll(criteria,pageable),HttpStatus.OK); return new ResponseEntity<>(tbUploadFileNewService.queryAll(criteria, pageable), HttpStatus.OK);
} }
@PostMapping @PostMapping
@Log("新增文件上传接口") @Log("新增文件上传接口")
@ApiOperation("新增文件上传接口") @ApiOperation("新增文件上传接口")
@PreAuthorize("@el.check('tbUploadFileNew:add')") @PreAuthorize("@el.check('tbUploadFileNew:add')")
public ResponseEntity<Object> create(@Validated @RequestBody TbUploadFileNew resources){ public ResponseEntity<Object> create(@Validated @RequestBody TbUploadFileNew resources) {
return new ResponseEntity<>(tbUploadFileNewService.create(resources),HttpStatus.CREATED); return new ResponseEntity<>(tbUploadFileNewService.create(resources), HttpStatus.CREATED);
} }
@PutMapping @PutMapping
@Log("修改文件上传接口") @Log("修改文件上传接口")
@ApiOperation("修改文件上传接口") @ApiOperation("修改文件上传接口")
@PreAuthorize("@el.check('tbUploadFileNew:edit')") @PreAuthorize("@el.check('tbUploadFileNew:edit')")
public ResponseEntity<Object> update(@Validated @RequestBody TbUploadFileNew resources){ public ResponseEntity<Object> update(@Validated @RequestBody TbUploadFileNew resources) {
tbUploadFileNewService.update(resources); tbUploadFileNewService.update(resources);
return new ResponseEntity<>(HttpStatus.NO_CONTENT); return new ResponseEntity<>(HttpStatus.NO_CONTENT);
} }
@ -133,36 +133,37 @@ public class TbUploadFileNewController {
@RequestParam(value = "isEcryptionNew") String isEcryptionNew, @RequestParam(value = "isEcryptionNew") String isEcryptionNew,
ServletRequest servletRequest) { ServletRequest servletRequest) {
// 记录日志 // 记录日志
log.info("TbUploadFileNewController:fileUpload | taskName="+taskName+"===== isEcryptionNew="+isEcryptionNew); log.info("TbUploadFileNewController:fileUpload | taskName=" + taskName + "===== isEcryptionNew=" + isEcryptionNew);
// 校验上传是否有文件 // 校验上传是否有文件
if (file== null ){ if (null == file) {
return new ResponseEntity<>(CommonResponse.createByError(ResponseCode.NO_FILE_INPUT), HttpStatus.OK); return new ResponseEntity<>(CommonResponse.createByError(ResponseCode.NO_FILE_INPUT), HttpStatus.OK);
} }
Integer isEcryption = 0;
int isEcryption = 1;
try { try {
isEcryption = Integer.parseInt(isEcryptionNew); isEcryption = Integer.parseInt(isEcryptionNew);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
log.error("TbUploadFileNewController|fileUpload 转换异常!!!!"); log.error("TbUploadFileNewController|fileUpload 转换异常!!!!");
throw new BadRequestException("转换异常!!!"); throw new BadRequestException("转换异常!!!");
} }
String name=file.getOriginalFilename();
String name = file.getOriginalFilename();
String keyName = ""; String keyName = "";
String token = ""; String token = "";
HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest; HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest;
Cookie[] cookies = httpServletRequest.getCookies(); Cookie[] cookies = httpServletRequest.getCookies();
if (cookies != null){ if (cookies != null) {
for(Cookie cookie : cookies) { for (Cookie cookie : cookies) {
//获取cookie的名字 //获取cookie的名字
token=cookie.getValue(); token = cookie.getValue();
log.info("TbUploadFileNewController:fileUpload | token="+token); log.info("TbUploadFileNewController:fileUpload | token: {} ", token);
} }
} }
RedisParentDao redisParentDao = new RedisParentDao(); RedisParentDao redisParentDao = new RedisParentDao();
redisParentDao.setRedisTemplate(redisTemplate); redisParentDao.setRedisTemplate(redisTemplate);
keyName = token+TOKEN_NAME+name; String keyValue = redisParentDao.getValue(token + TOKEN_NAME + name);
String keyValue = redisParentDao.getValue(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);
} }
@ -170,30 +171,30 @@ public class TbUploadFileNewController {
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"))) {
redisParentDao.remove(keyName); redisParentDao.remove(keyName);
return new ResponseEntity<>(CommonResponse.createByError(ResponseCode.NO_FILE_FORMAT), HttpStatus.OK); return new ResponseEntity<>(CommonResponse.createByError(ResponseCode.NO_FILE_FORMAT), HttpStatus.OK);
} }
// 任务名称检验,为必填参数,且不能重复 // 任务名称检验,为必填参数,且不能重复
if (StringUtils.isNotBlank(taskName)){ if (StringUtils.isNotBlank(taskName)) {
// modify by x bug fix on POSTMAN request // modify by x bug fix on POSTMAN request
if (StringUtils.contains(taskName, FILE_PATH_SPLIT)){ if (StringUtils.contains(taskName, FILE_PATH_SPLIT)) {
taskName = taskName.substring(0, taskName.length()-1); taskName = taskName.substring(0, taskName.length() - 1);
} }
TbUploadFileNewQueryCriteria criteria = new TbUploadFileNewQueryCriteria(); TbUploadFileNewQueryCriteria criteria = new TbUploadFileNewQueryCriteria();
criteria.setUploadFileTaskName(taskName); criteria.setUploadFileTaskName(taskName);
List<TbUploadFileNewDto> uploadFileDtos = tbUploadFileNewService.queryAll(criteria); List<TbUploadFileNewDto> uploadFileDtos = tbUploadFileNewService.queryAll(criteria);
if (CollectionUtil.isNotEmpty(uploadFileDtos)){ if (CollectionUtil.isNotEmpty(uploadFileDtos)) {
return new ResponseEntity<>(CommonResponse.createByError(ResponseCode.TASK_NAME_IS_EXIST), HttpStatus.OK); return new ResponseEntity<>(CommonResponse.createByError(ResponseCode.TASK_NAME_IS_EXIST), HttpStatus.OK);
} }
}else { } else {
return new ResponseEntity<>(CommonResponse.createByError(ResponseCode.EMPTY_ARGUMENT), HttpStatus.OK); return new ResponseEntity<>(CommonResponse.createByError(ResponseCode.EMPTY_ARGUMENT), HttpStatus.OK);
} }
// 生成本地文件 // 生成本地文件
TbUploadFileNewDto tbUploadFileNewDto = tbUploadFileNewService.encryptDataAndSaveToFileNew(file, taskName, isEcryption); TbUploadFileNewDto tbUploadFileNewDto = tbUploadFileNewService.encryptDataAndSaveToFileNew(file, taskName, isEcryption);
// 如果临时生成失败就修改状态为失败 // 如果临时生成失败就修改状态为失败
if (Objects.isNull(tbUploadFileNewDto)){ if (Objects.isNull(tbUploadFileNewDto)) {
log.error("TbUploadFileNewController:fileUpload | Operation Fail.tbUploadFileNewDto is Null"); log.error("TbUploadFileNewController:fileUpload | Operation Fail.tbUploadFileNewDto is Null");
return new ResponseEntity<>(CommonResponse.createByError(ResponseCode.TASK_FILE_SAVE_FAIL), HttpStatus.OK); return new ResponseEntity<>(CommonResponse.createByError(ResponseCode.TASK_FILE_SAVE_FAIL), HttpStatus.OK);
} }
@ -202,12 +203,13 @@ public class TbUploadFileNewController {
redisParentDao.remove(keyName); redisParentDao.remove(keyName);
return new ResponseEntity<>(CommonResponse.createBySuccess(ResponseCode.SUCCESS), HttpStatus.OK); return new ResponseEntity<>(CommonResponse.createBySuccess(ResponseCode.SUCCESS), HttpStatus.OK);
} }
@Log("上传并加密任务") @Log("上传并加密任务")
@ApiOperation("上传并加密任务") @ApiOperation("上传并加密任务")
@AnonymousAccess @AnonymousAccess
@PostMapping("/aa") @PostMapping("/aa")
// @ResponseBody // @ResponseBody
public ResponseEntity<Object> aa(){ public ResponseEntity<Object> aa() {
RedisParentDao redisParentDao = new RedisParentDao(); RedisParentDao redisParentDao = new RedisParentDao();
redisParentDao.setRedisTemplate(redisTemplate); redisParentDao.setRedisTemplate(redisTemplate);
redisParentDao.cacheValue("111", "2222", 180000); redisParentDao.cacheValue("111", "2222", 180000);

@ -4,7 +4,7 @@ spring:
druid: druid:
db-type: com.alibaba.druid.pool.DruidDataSource db-type: com.alibaba.druid.pool.DruidDataSource
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
url: jdbc:log4jdbc:mysql://localhost:3306/eladmin1?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false url: jdbc:log4jdbc:mysql://localhost:3306/eladmin-plat2?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
username: root username: root
password: root password: root
# 初始连接数 # 初始连接数

@ -77,7 +77,7 @@
<root level="INFO"> <root level="INFO">
<!-- TODO prod 环境去掉std --> <!-- TODO prod 环境去掉std -->
<!--<appender-ref ref="stdAppender"/>--> <!-- <appender-ref ref="stdAppender"/>-->
<appender-ref ref="fileAppender"/> <appender-ref ref="fileAppender"/>
</root> </root>
</configuration> </configuration>
Loading…
Cancel
Save