|
|
@@ -602,14 +602,14 @@ public class UserService {
|
|
|
public String shareImg(Long userId) throws IOException, WxErrorException {
|
|
|
User user = userRepo.findById(userId).orElseThrow(new BusinessException("用户不存在"));
|
|
|
if (!(StringUtils.isNotEmpty(user.getShareImg()) && user.getShareImg().contains("/v2/"))) {
|
|
|
- String url = createShareImg(userId, true, null);
|
|
|
+ String url =storageService.uploadFromInputStream(createShareImg(userId, true, null), "share_img/v2/" + userId + ".jpg");
|
|
|
user.setShareImg(url);
|
|
|
userRepo.save(user);
|
|
|
}
|
|
|
return user.getShareImg();
|
|
|
}
|
|
|
|
|
|
- public String createShareImg(Long userId, boolean home, Map<String, Object> map) throws IOException, WxErrorException {
|
|
|
+ public ByteArrayInputStream createShareImg(Long userId, boolean home, Map<String, Object> map) throws IOException, WxErrorException {
|
|
|
User user = userRepo.findById(userId).orElseThrow(new BusinessException("用户不存在"));
|
|
|
BufferedImage shareImg = ImageIO.read(this.getClass().getResourceAsStream("/static/shareImg.png"));
|
|
|
if (!home) {
|
|
|
@@ -659,11 +659,8 @@ public class UserService {
|
|
|
.outputQuality(.9f)
|
|
|
.outputFormat("jpg")
|
|
|
.toOutputStream(out);
|
|
|
- ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
|
|
- if (!home) {
|
|
|
- return new BufferedReader(new InputStreamReader(in))
|
|
|
- .lines().parallel().collect(Collectors.joining(System.lineSeparator()));
|
|
|
- }
|
|
|
- return storageService.uploadFromInputStream(in, "share_img/v2/" + userId + ".jpg");
|
|
|
+// ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
|
|
+ return new ByteArrayInputStream(out.toByteArray());
|
|
|
+// return storageService.uploadFromInputStream(in, "share_img/v2/" + userId + ".jpg");
|
|
|
}
|
|
|
}
|