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