|
@@ -3,12 +3,9 @@ package thyyxxk.webserver.service.managedoctorinfo;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.commons.codec.binary.Base64;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
-import sun.misc.BASE64Decoder;
|
|
|
-import sun.misc.BASE64Encoder;
|
|
|
import thyyxxk.webserver.config.exception.ExceptionEnum;
|
|
|
import thyyxxk.webserver.constants.Capacity;
|
|
|
import thyyxxk.webserver.dao.his.managedoctorinfo.ManageDoctorInfoDao;
|
|
@@ -20,6 +17,10 @@ import thyyxxk.webserver.entity.mangedoctorinfo.QueryParam;
|
|
|
import thyyxxk.webserver.utils.ResultVoUtil;
|
|
|
import thyyxxk.webserver.utils.TokenUtil;
|
|
|
|
|
|
+import java.util.Base64;
|
|
|
+import java.util.Base64.Encoder;
|
|
|
+import java.util.Base64.Decoder;
|
|
|
+
|
|
|
import javax.imageio.ImageIO;
|
|
|
import java.awt.*;
|
|
|
import java.awt.image.BufferedImage;
|
|
@@ -80,7 +81,7 @@ public class ManageDoctorInfoService {
|
|
|
int type = BufferedImage.SCALE_SMOOTH;
|
|
|
BufferedImage resizedImage = new BufferedImage(120, 160, type);
|
|
|
Graphics2D g = resizedImage.createGraphics();
|
|
|
- Map<RenderingHints.Key, Object> m = new HashMap<RenderingHints.Key, Object>();
|
|
|
+ Map<RenderingHints.Key, Object> m = new HashMap<>();
|
|
|
m.put(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
|
|
|
m.put(RenderingHints.KEY_ALPHA_INTERPOLATION , RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
|
|
|
m.put(RenderingHints.KEY_COLOR_RENDERING , RenderingHints.VALUE_COLOR_RENDER_QUALITY);
|
|
@@ -94,7 +95,7 @@ public class ManageDoctorInfoService {
|
|
|
}
|
|
|
|
|
|
private static String imageToBase64(BufferedImage bufferedImage) {
|
|
|
- Base64 encoder = new Base64();
|
|
|
+ Encoder encoder = Base64.getEncoder();
|
|
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
|
try {
|
|
|
ImageIO.write(bufferedImage, "jpg", baos);
|
|
@@ -118,8 +119,8 @@ public class ManageDoctorInfoService {
|
|
|
private static InputStream baseToInputStream(String base64string){
|
|
|
ByteArrayInputStream stream = null;
|
|
|
try {
|
|
|
- BASE64Decoder decoder = new BASE64Decoder();
|
|
|
- byte[] bytes1 = decoder.decodeBuffer(base64string);
|
|
|
+ Decoder decoder = Base64.getDecoder();
|
|
|
+ byte[] bytes1 = decoder.decode(base64string);
|
|
|
stream = new ByteArrayInputStream(bytes1);
|
|
|
} catch (Exception e) {
|
|
|
log.error("base64转inputStream出错", e);
|
|
@@ -163,8 +164,8 @@ public class ManageDoctorInfoService {
|
|
|
return null;
|
|
|
}
|
|
|
try {
|
|
|
- BASE64Encoder encoder = new BASE64Encoder();
|
|
|
- ret = encoder.encode(file.getBytes());
|
|
|
+ Encoder encoder = Base64.getEncoder();
|
|
|
+ ret = encoder.encodeToString(file.getBytes());
|
|
|
} catch (IOException e) {
|
|
|
log.error("将图片文件转base64出错", e);
|
|
|
}
|