From 12b30922042aa261fd88fb103771fd8579dd9416 Mon Sep 17 00:00:00 2001 From: weizhongxi <2412380450@qq.com> Date: Thu, 22 Apr 2021 10:53:31 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E9=9F=A6=E5=BF=A0=E5=96=9C=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/me/zhengjie/modules/upload/consts/SysConst.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 b78c547..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 @@ -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://116.62.197.152: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 = "测试用户"; From ae6d6aab78df214227a0bcf4cf741494a38b634b Mon Sep 17 00:00:00 2001 From: weizhongxi <2412380450@qq.com> Date: Thu, 22 Apr 2021 17:44:08 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E9=9F=A6=E5=BF=A0=E5=96=9C=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../me/zhengjie/common/http/ResponseCode.java | 3 +++ .../sms/rest/TbTemplateController.java | 12 +++++++---- .../me/zhengjie/modules/sms/vo/SendNewVo.java | 21 +++++++++++++++++++ .../rest/TbUploadFileNewController.java | 18 +--------------- .../uploadnew/task/SaveToFileNewTask.java | 6 ++++-- 5 files changed, 37 insertions(+), 23 deletions(-) create mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/sms/vo/SendNewVo.java diff --git a/eladmin-common/src/main/java/me/zhengjie/common/http/ResponseCode.java b/eladmin-common/src/main/java/me/zhengjie/common/http/ResponseCode.java index 0f64059..3a00afa 100644 --- a/eladmin-common/src/main/java/me/zhengjie/common/http/ResponseCode.java +++ b/eladmin-common/src/main/java/me/zhengjie/common/http/ResponseCode.java @@ -21,6 +21,9 @@ public enum ResponseCode { EMPTY_ARGUMENT(1,"请求参数为空"), NO_MATCH_ARGUMENT_SET(1,"不能满足要求的参数设置"), NO_FILE_INPUT(1,"没有文件输入"), + + /** modeify by wzx + */ NO_WORD_INPUT(1,"短信和url链接不能为空!"), NO_FILE_FORMAT(1,"文件格式不对"), // 特殊需要进行前端返回说明的参数定义 diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/sms/rest/TbTemplateController.java b/eladmin-system/src/main/java/me/zhengjie/modules/sms/rest/TbTemplateController.java index 9910698..014bb72 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/sms/rest/TbTemplateController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/sms/rest/TbTemplateController.java @@ -24,6 +24,7 @@ import me.zhengjie.common.http.ResponseCode; import me.zhengjie.modules.sms.domain.TbTemplate; import me.zhengjie.modules.sms.service.TbTemplateService; import me.zhengjie.modules.sms.service.dto.TbTemplateQueryCriteria; +import me.zhengjie.modules.sms.vo.SendNewVo; import me.zhengjie.modules.sms.vo.SendVo; import org.springframework.data.domain.Pageable; import lombok.RequiredArgsConstructor; @@ -35,6 +36,7 @@ import org.springframework.web.bind.annotation.*; import io.swagger.annotations.*; import java.io.IOException; import java.sql.Timestamp; +import java.time.LocalDate; import java.util.Date; import javax.servlet.http.HttpServletResponse; @@ -104,17 +106,19 @@ public class TbTemplateController { @ApiOperation("接收短信内容和url") // @PreAuthorize("@el.check('taskRecord:list')") @PostMapping(value = "/getSmsInfo") - @AnonymousAccess // fixme 需要测试完成后进行去除和使用上面的权限注解 - public ResponseEntity getSmsInfo(@RequestBody SendVo sendVo){ + // @AnonymousAccess // fixme 需要测试完成后进行去除和使用上面的权限注解 + public ResponseEntity getSmsInfo(@RequestBody SendNewVo sendVo){ log.info("========== [TbTemplateController|getSmsInfo ========== SmsContent:"+sendVo.getSmsContent()+" LinkUrl:"+sendVo.getLinkUrl()); + if (sendVo == null){ + return new ResponseEntity<>(CommonResponse.createByError(ResponseCode.EMPTY_ARGUMENT), HttpStatus.OK); + } if (sendVo.getSmsContent() != null && sendVo.getLinkUrl() != null){ TbTemplate tbTemplate = new TbTemplate(); tbTemplate.setLinkUrl(sendVo.getLinkUrl()); tbTemplate.setTaskName(sendVo.getTaskName()); tbTemplate.setSendMessage(sendVo.getSmsContent()); tbTemplate.setReviewer(sendVo.getOperator()); - Date date = new Date(); - Timestamp nousedate = new Timestamp(date.getTime()); + Timestamp nousedate = new Timestamp(System.currentTimeMillis()); tbTemplate.setLastUpdateTime(nousedate); tbTemplate.setGmtModified(nousedate); tbTemplate.setGmtCreate(nousedate); diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/sms/vo/SendNewVo.java b/eladmin-system/src/main/java/me/zhengjie/modules/sms/vo/SendNewVo.java new file mode 100644 index 0000000..b59f236 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/sms/vo/SendNewVo.java @@ -0,0 +1,21 @@ +package me.zhengjie.modules.sms.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class SendNewVo { + @ApiModelProperty("发送链接") + private String linkUrl; + @ApiModelProperty("模板id") + private String sendMessage; + + @ApiModelProperty("短信内容") + private String smsContent; + + @ApiModelProperty("任务名称") + private String taskName; + + @ApiModelProperty("审核人") + private String operator; +} 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 a3dc458..09807b2 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 @@ -22,6 +22,7 @@ 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.exception.BadRequestException; import me.zhengjie.modules.security.security.TokenFilter; import me.zhengjie.modules.upload.service.dto.UploadFileDto; import me.zhengjie.modules.upload.service.dto.UploadFileQueryCriteria; @@ -196,22 +197,5 @@ public class TbUploadFileNewController { return new ResponseEntity<>(CommonResponse.createBySuccess(ResponseCode.SUCCESS), HttpStatus.OK); } - @PostMapping("/aa") - @Log("查询文件上传接口") - @ApiOperation("查询文件上传接口") - @AnonymousAccess - public ResponseEntity aa(){ - redisTemplate.opsForValue().set("key111", "value11"); - Object key111 = redisTemplate.opsForValue().get("key111"); - System.out.println("key111 = " + key111.toString()); - - redisTemplate.delete("key111"); - - Object aaaa = redisTemplate.opsForValue().get("key111"); - System.out.println("aaaa = " + aaaa); - - return new ResponseEntity<>(CommonResponse.createBySuccess(ResponseCode.SUCCESS), HttpStatus.OK); - } - } \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/uploadnew/task/SaveToFileNewTask.java b/eladmin-system/src/main/java/me/zhengjie/modules/uploadnew/task/SaveToFileNewTask.java index 01a5407..cc09bfd 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/uploadnew/task/SaveToFileNewTask.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/uploadnew/task/SaveToFileNewTask.java @@ -15,6 +15,7 @@ import com.alibaba.fastjson.JSONArray; import com.google.common.collect.Lists; import com.jcraft.jsch.Session; import lombok.extern.slf4j.Slf4j; +import me.zhengjie.exception.BadRequestException; import me.zhengjie.modules.upload.domain.UploadFile; import me.zhengjie.modules.upload.service.dto.UploadFileDto; import me.zhengjie.modules.upload.task.model.ResponseEncryptJsonContent; @@ -154,11 +155,11 @@ public class SaveToFileNewTask { list = TxtUtils.csvParseListByUrl(filePath); } }catch (Exception e){ - e.printStackTrace(); + log.error("SaveToFileTask|batchSendToEncrypt ready send json is : {}", ""); + throw new BadRequestException("解析文件异常"); } if (CollectionUtil.isNotEmpty(list)){ batchSendToEncrypt(filePath, list); - } // 加入一个全局控制开关 @@ -222,6 +223,7 @@ public class SaveToFileNewTask { Thread.sleep(3_0000); } catch (InterruptedException e) { log.error("SaveToFileTask|batchSendToEncrypt sleep ERROR. message is", e.getMessage(), e); + throw new BadRequestException("请求异常!!!"); } log.error("========== [SaveToFileTask|batchSendToEncrypt request fail, response is {} ] ==========", httpResponse.body()); } From e2d06c494465727f06334910f87c60009ebb9d4a Mon Sep 17 00:00:00 2001 From: weizhongxi <2412380450@qq.com> Date: Fri, 23 Apr 2021 08:36:55 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E9=9F=A6=E5=BF=A0=E5=96=9C=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/sms/rest/TbTemplateController.java | 2 +- .../java/me/zhengjie/modules/sms/vo/SendNewVo.java | 2 -- .../uploadnew/rest/TbUploadFileNewController.java | 14 ++++++++------ .../service/impl/TbUploadFileNewServiceImpl.java | 3 ++- .../modules/uploadnew/task/SaveToFileNewTask.java | 3 ++- .../modules/uploadnew/util/ExcelUtils.java | 4 ++-- 6 files changed, 15 insertions(+), 13 deletions(-) diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/sms/rest/TbTemplateController.java b/eladmin-system/src/main/java/me/zhengjie/modules/sms/rest/TbTemplateController.java index 014bb72..e3994e7 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/sms/rest/TbTemplateController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/sms/rest/TbTemplateController.java @@ -106,7 +106,7 @@ public class TbTemplateController { @ApiOperation("接收短信内容和url") // @PreAuthorize("@el.check('taskRecord:list')") @PostMapping(value = "/getSmsInfo") - // @AnonymousAccess // fixme 需要测试完成后进行去除和使用上面的权限注解 + @AnonymousAccess // fixme 需要测试完成后进行去除和使用上面的权限注解 public ResponseEntity getSmsInfo(@RequestBody SendNewVo sendVo){ log.info("========== [TbTemplateController|getSmsInfo ========== SmsContent:"+sendVo.getSmsContent()+" LinkUrl:"+sendVo.getLinkUrl()); if (sendVo == null){ diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/sms/vo/SendNewVo.java b/eladmin-system/src/main/java/me/zhengjie/modules/sms/vo/SendNewVo.java index b59f236..fef266b 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/sms/vo/SendNewVo.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/sms/vo/SendNewVo.java @@ -7,8 +7,6 @@ import lombok.Data; public class SendNewVo { @ApiModelProperty("发送链接") private String linkUrl; - @ApiModelProperty("模板id") - private String sendMessage; @ApiModelProperty("短信内容") private String smsContent; 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 09807b2..39f7f4a 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 @@ -137,12 +137,14 @@ public class TbUploadFileNewController { String token = ""; HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest; Cookie[] cookies = httpServletRequest.getCookies(); - for(Cookie cookie : cookies) { - //获取cookie的名字 - String cookieName = cookie.getName(); - token=cookie.getValue(); - System.out.println(cookieName); - System.out.println(cookieName+" : "+ cookie.getValue() ); + if (cookies != null){ + for(Cookie cookie : cookies) { + //获取cookie的名字 + String cookieName = cookie.getName(); + token=cookie.getValue(); + System.out.println(cookieName); + System.out.println(cookieName+" : "+ cookie.getValue() ); + } } keyName = token+"==="+name; Object keyValue = redisTemplate.opsForValue().get(keyName); diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/uploadnew/service/impl/TbUploadFileNewServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/uploadnew/service/impl/TbUploadFileNewServiceImpl.java index 275f434..4241f04 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/uploadnew/service/impl/TbUploadFileNewServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/uploadnew/service/impl/TbUploadFileNewServiceImpl.java @@ -176,7 +176,8 @@ public class TbUploadFileNewServiceImpl implements TbUploadFileNewService { try { if(nameStr.equals(".xlsx")||nameStr.equals(".xls")){ fileFormat = "excel文件"; - list = FileUtil.readLines(eachFilePath, "UTF-8"); + ExcelUtils excelUtils = new ExcelUtils(); + list = excelUtils.excelParseList(file.getInputStream()); }else if (nameStr.equals(".txt")){ fileFormat = "txt文件"; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/uploadnew/task/SaveToFileNewTask.java b/eladmin-system/src/main/java/me/zhengjie/modules/uploadnew/task/SaveToFileNewTask.java index cc09bfd..5359457 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/uploadnew/task/SaveToFileNewTask.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/uploadnew/task/SaveToFileNewTask.java @@ -148,7 +148,8 @@ public class SaveToFileNewTask { List list = null; try { if("excel文件".equals(tbUploadFileNewDto.getFileFormat())){ - list = ExcelUtils.excelParseListByUrl(filePath); + ExcelUtils excelUtils = new ExcelUtils(); + list = excelUtils.excelParseListByUrl(filePath); }else if ("txt文件".equals(tbUploadFileNewDto.getFileFormat())){ list = TxtUtils.txtParseListVyUrl(filePath); }else if ("csv文件".equals(tbUploadFileNewDto.getFileFormat())){ diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/uploadnew/util/ExcelUtils.java b/eladmin-system/src/main/java/me/zhengjie/modules/uploadnew/util/ExcelUtils.java index 0222f6d..e42be8a 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/uploadnew/util/ExcelUtils.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/uploadnew/util/ExcelUtils.java @@ -22,7 +22,7 @@ public class ExcelUtils { * @return * @throws IOException */ - public static List excelParseList(InputStream inputStream) throws IOException { + public List excelParseList(InputStream inputStream) throws IOException { List list = new ArrayList<>(); try { Workbook workbook = new XSSFWorkbook(inputStream); @@ -58,7 +58,7 @@ public class ExcelUtils { * @return * @throws IOException */ - public static List excelParseListByUrl(String url) throws IOException { + public List excelParseListByUrl(String url) throws IOException { List list = new ArrayList<>(); InputStream inputStream = new FileInputStream(new File(url)) ; try {