From 5b2f2985eed558e80720e2f67d1b2e6da3965c30 Mon Sep 17 00:00:00 2001 From: gongzhenkun <1658878546@qq.com> Date: Fri, 19 Aug 2022 15:21:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8C=BB=E7=94=9F=E6=89=A7=E7=85=A7=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E5=9C=B0=E5=9D=80=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/utils/file/FileUploadUtils.java | 2 +- .../ruoyi/common/utils/file/FileUtils.java | 25 +++++++++++++++++++ .../web/service/SysLoginService.java | 2 +- .../service/impl/WechatServiceImpl.java | 2 +- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java index bf7dfd5..e8830ba 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java @@ -296,6 +296,6 @@ public class FileUploadUtils logger.error("code IOException:", e); e.printStackTrace(); } - return path + picPath; + return picPath; } } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java index faf8b41..164885e 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java @@ -9,6 +9,7 @@ import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; +import java.util.Base64; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -316,4 +317,28 @@ public class FileUtils throw new ServiceException(imageName + " :Base64转图片错误"); } } + + public static String GenerateImage(String imgStr) + { + + Base64.Decoder decoder = Base64.getDecoder(); + try + { + //Base64解码 + byte[] b = decoder.decode(imgStr); + for (int i = 0; i < b.length; ++i) + { + if (b[i] < 0) + { + b[i] += 256; + } + } + return writeImportBytes(b); + + } + catch (Exception e) + { + throw new ServiceException("Base64转图片错误,message is " + e.getMessage()); + } + } } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java index a94ed69..ca68bb0 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java @@ -151,7 +151,7 @@ public class SysLoginService public AjaxResult loginForAppFillInfo(AppRegisterReq req) { if (StringUtils.isNotEmpty(req.getMedicalLicense())) { log.info("MedicalLicense is not null."); - req.setMedicalLicense(FileUtils.GenerateImage(req.getMedicalLicense(), "医生执照")); + req.setMedicalLicense(FileUtils.GenerateImage(req.getMedicalLicense())); } log.info("login for app fill info req :{}", req); // 查询sys_user数据 diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/WechatServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/WechatServiceImpl.java index 288fbc3..d07bcb1 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/WechatServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/WechatServiceImpl.java @@ -152,7 +152,7 @@ public class WechatServiceImpl implements IWechatService { // 查询手机号是否存在医生信息 TDoctor tDoctor = new TDoctor(); if (StringUtils.isNotEmpty(req.getMedicalLicense())) { - req.setMedicalLicense(FileUtils.GenerateImage(req.getMedicalLicense(), "医生执照")); + req.setMedicalLicense(FileUtils.GenerateImage(req.getMedicalLicense())); } BeanUtils.copyProperties(req, tDoctor); TDoctor currentDoctor = tDoctorMapper.selectTDoctorByPhone(req.getPhone());