From 1fa2db32fe1f5cc336dea71b2453a40d21b23121 Mon Sep 17 00:00:00 2001 From: qyx <565485304@qq.com> Date: Sat, 24 Apr 2021 00:30:56 +0800 Subject: [PATCH] =?UTF-8?q?[Bug=E4=BF=AE=E5=A4=8D](master):=20Bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复些许Bug --- .../service/mapstruct/LogErrorMapperImpl.java | 4 +- .../service/mapstruct/LogSmallMapperImpl.java | 4 +- .../modules/upload/consts/SysConst.java | 4 +- .../rest/TbUploadFileNewController.java | 90 ++++++++++--------- .../main/resources/config/application-dev.yml | 2 +- eladmin-system/src/main/resources/logback.xml | 2 +- 6 files changed, 54 insertions(+), 52 deletions(-) diff --git a/eladmin-logging/target/generated-sources/annotations/me/zhengjie/service/mapstruct/LogErrorMapperImpl.java b/eladmin-logging/target/generated-sources/annotations/me/zhengjie/service/mapstruct/LogErrorMapperImpl.java index 840fdf4..c17c8f7 100644 --- a/eladmin-logging/target/generated-sources/annotations/me/zhengjie/service/mapstruct/LogErrorMapperImpl.java +++ b/eladmin-logging/target/generated-sources/annotations/me/zhengjie/service/mapstruct/LogErrorMapperImpl.java @@ -9,8 +9,8 @@ import org.springframework.stereotype.Component; @Generated( value = "org.mapstruct.ap.MappingProcessor", - date = "2021-04-20T11:01:39+0800", - comments = "version: 1.3.1.Final, compiler: javac, environment: Java 1.8.0_251 (Oracle Corporation)" + date = "2021-04-24T00:12:04+0800", + comments = "version: 1.3.1.Final, compiler: javac, environment: Java 1.8.0_261 (Oracle Corporation)" ) @Component public class LogErrorMapperImpl implements LogErrorMapper { diff --git a/eladmin-logging/target/generated-sources/annotations/me/zhengjie/service/mapstruct/LogSmallMapperImpl.java b/eladmin-logging/target/generated-sources/annotations/me/zhengjie/service/mapstruct/LogSmallMapperImpl.java index 24a103a..7e9cbf6 100644 --- a/eladmin-logging/target/generated-sources/annotations/me/zhengjie/service/mapstruct/LogSmallMapperImpl.java +++ b/eladmin-logging/target/generated-sources/annotations/me/zhengjie/service/mapstruct/LogSmallMapperImpl.java @@ -9,8 +9,8 @@ import org.springframework.stereotype.Component; @Generated( value = "org.mapstruct.ap.MappingProcessor", - date = "2021-04-20T11:01:39+0800", - comments = "version: 1.3.1.Final, compiler: javac, environment: Java 1.8.0_251 (Oracle Corporation)" + date = "2021-04-24T00:12:04+0800", + comments = "version: 1.3.1.Final, compiler: javac, environment: Java 1.8.0_261 (Oracle Corporation)" ) @Component public class LogSmallMapperImpl implements LogSmallMapper { diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/upload/consts/SysConst.java b/eladmin-system/src/main/java/me/zhengjie/modules/upload/consts/SysConst.java index 769ac2a..58e1cfc 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/upload/consts/SysConst.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/upload/consts/SysConst.java @@ -16,7 +16,7 @@ public class SysConst { // 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; @@ -30,7 +30,7 @@ public class SysConst { public static final String REMOTE_TRANS_DIR_PATH = "/home/"; // 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 = "测试用户"; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/uploadnew/rest/TbUploadFileNewController.java b/eladmin-system/src/main/java/me/zhengjie/modules/uploadnew/rest/TbUploadFileNewController.java index 5c2d792..6fd8050 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/uploadnew/rest/TbUploadFileNewController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/uploadnew/rest/TbUploadFileNewController.java @@ -1,18 +1,18 @@ /* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright 2019-2020 Zheng Jie + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package me.zhengjie.modules.uploadnew.rest; import cn.hutool.core.collection.CollectionUtil; @@ -56,10 +56,10 @@ import static me.zhengjie.modules.uploadnew.consts.SysConstNew.*; //import org.springframework.util.StringUtils; /** -* @website https://el-admin.vip -* @author weizhongxi -* @date 2021-04-14 -**/ + * @author weizhongxi + * @website https://el-admin.vip + * @date 2021-04-14 + **/ @RestController @RequiredArgsConstructor @Api(tags = "文件上传接口管理") @@ -87,23 +87,23 @@ public class TbUploadFileNewController { @Log("查询文件上传接口") @ApiOperation("查询文件上传接口") @PreAuthorize("@el.check('tbUploadFileNew:list')") - public ResponseEntity query(TbUploadFileNewQueryCriteria criteria, Pageable pageable){ - return new ResponseEntity<>(tbUploadFileNewService.queryAll(criteria,pageable),HttpStatus.OK); + public ResponseEntity query(TbUploadFileNewQueryCriteria criteria, Pageable pageable) { + return new ResponseEntity<>(tbUploadFileNewService.queryAll(criteria, pageable), HttpStatus.OK); } @PostMapping @Log("新增文件上传接口") @ApiOperation("新增文件上传接口") @PreAuthorize("@el.check('tbUploadFileNew:add')") - public ResponseEntity create(@Validated @RequestBody TbUploadFileNew resources){ - return new ResponseEntity<>(tbUploadFileNewService.create(resources),HttpStatus.CREATED); + public ResponseEntity create(@Validated @RequestBody TbUploadFileNew resources) { + return new ResponseEntity<>(tbUploadFileNewService.create(resources), HttpStatus.CREATED); } @PutMapping @Log("修改文件上传接口") @ApiOperation("修改文件上传接口") @PreAuthorize("@el.check('tbUploadFileNew:edit')") - public ResponseEntity update(@Validated @RequestBody TbUploadFileNew resources){ + public ResponseEntity update(@Validated @RequestBody TbUploadFileNew resources) { tbUploadFileNewService.update(resources); return new ResponseEntity<>(HttpStatus.NO_CONTENT); } @@ -133,67 +133,68 @@ public class TbUploadFileNewController { @RequestParam(value = "isEcryptionNew") String isEcryptionNew, 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); } - Integer isEcryption = 0; + + int isEcryption = 1; try { - isEcryption = Integer.parseInt(isEcryptionNew); + isEcryption = Integer.parseInt(isEcryptionNew); } catch (NumberFormatException e) { log.error("TbUploadFileNewController|fileUpload 转换异常!!!!"); throw new BadRequestException("转换异常!!!"); } - String name=file.getOriginalFilename(); + + String name = file.getOriginalFilename(); String keyName = ""; String token = ""; HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest; Cookie[] cookies = httpServletRequest.getCookies(); - if (cookies != null){ - for(Cookie cookie : cookies) { + if (cookies != null) { + for (Cookie cookie : cookies) { //获取cookie的名字 - token=cookie.getValue(); - log.info("TbUploadFileNewController:fileUpload | token="+token); + token = cookie.getValue(); + log.info("TbUploadFileNewController:fileUpload | token: {} ", token); } } RedisParentDao redisParentDao = new RedisParentDao(); redisParentDao.setRedisTemplate(redisTemplate); - keyName = token+TOKEN_NAME+name; - String keyValue = redisParentDao.getValue(keyName); + String keyValue = redisParentDao.getValue(token + TOKEN_NAME + name); //防止用户多次提交 - if (keyValue != null){ + if (keyValue != null) { return new ResponseEntity<>(CommonResponse.createByError(ResponseCode.TASK_STAETING), HttpStatus.OK); } redisParentDao.cacheValue(keyName, TOKEN_VALUE, EXP_TIME); int lastIndexOf = name.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); 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 - if (StringUtils.contains(taskName, FILE_PATH_SPLIT)){ - taskName = taskName.substring(0, taskName.length()-1); + if (StringUtils.contains(taskName, FILE_PATH_SPLIT)) { + taskName = taskName.substring(0, taskName.length() - 1); } TbUploadFileNewQueryCriteria criteria = new TbUploadFileNewQueryCriteria(); criteria.setUploadFileTaskName(taskName); List uploadFileDtos = tbUploadFileNewService.queryAll(criteria); - if (CollectionUtil.isNotEmpty(uploadFileDtos)){ + if (CollectionUtil.isNotEmpty(uploadFileDtos)) { return new ResponseEntity<>(CommonResponse.createByError(ResponseCode.TASK_NAME_IS_EXIST), HttpStatus.OK); } - }else { + } else { return new ResponseEntity<>(CommonResponse.createByError(ResponseCode.EMPTY_ARGUMENT), HttpStatus.OK); } // 生成本地文件 TbUploadFileNewDto tbUploadFileNewDto = tbUploadFileNewService.encryptDataAndSaveToFileNew(file, taskName, isEcryption); // 如果临时生成失败就修改状态为失败 - if (Objects.isNull(tbUploadFileNewDto)){ + if (Objects.isNull(tbUploadFileNewDto)) { log.error("TbUploadFileNewController:fileUpload | Operation Fail.tbUploadFileNewDto is Null"); return new ResponseEntity<>(CommonResponse.createByError(ResponseCode.TASK_FILE_SAVE_FAIL), HttpStatus.OK); } @@ -202,12 +203,13 @@ public class TbUploadFileNewController { redisParentDao.remove(keyName); return new ResponseEntity<>(CommonResponse.createBySuccess(ResponseCode.SUCCESS), HttpStatus.OK); } + @Log("上传并加密任务") @ApiOperation("上传并加密任务") @AnonymousAccess @PostMapping("/aa") // @ResponseBody - public ResponseEntity aa(){ + public ResponseEntity aa() { RedisParentDao redisParentDao = new RedisParentDao(); redisParentDao.setRedisTemplate(redisTemplate); redisParentDao.cacheValue("111", "2222", 180000); diff --git a/eladmin-system/src/main/resources/config/application-dev.yml b/eladmin-system/src/main/resources/config/application-dev.yml index c3ce0c4..cd10212 100644 --- a/eladmin-system/src/main/resources/config/application-dev.yml +++ b/eladmin-system/src/main/resources/config/application-dev.yml @@ -4,7 +4,7 @@ spring: druid: db-type: com.alibaba.druid.pool.DruidDataSource 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 password: root # 初始连接数 diff --git a/eladmin-system/src/main/resources/logback.xml b/eladmin-system/src/main/resources/logback.xml index dcf1306..4fd9306 100644 --- a/eladmin-system/src/main/resources/logback.xml +++ b/eladmin-system/src/main/resources/logback.xml @@ -77,7 +77,7 @@ - + \ No newline at end of file