|
@@ -602,16 +602,20 @@ 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 = createShareImg(userId);
|
|
|
|
|
|
|
+ String url = createShareImg(userId, true, null);
|
|
|
user.setShareImg(url);
|
|
user.setShareImg(url);
|
|
|
userRepo.save(user);
|
|
userRepo.save(user);
|
|
|
}
|
|
}
|
|
|
return user.getShareImg();
|
|
return user.getShareImg();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public String createShareImg(Long userId) throws IOException, WxErrorException {
|
|
|
|
|
|
|
+ public String 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) {
|
|
|
|
|
+ shareImg = ImageIO.read(new URL(String.valueOf(map.get("poster"))).openStream());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
BufferedImage result = new BufferedImage(shareImg.getWidth(), shareImg.getHeight(), BufferedImage.TYPE_INT_RGB);
|
|
BufferedImage result = new BufferedImage(shareImg.getWidth(), shareImg.getHeight(), BufferedImage.TYPE_INT_RGB);
|
|
|
Graphics2D g = result.createGraphics();
|
|
Graphics2D g = result.createGraphics();
|
|
|
g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
|
|
g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
|
|
@@ -622,6 +626,11 @@ public class UserService {
|
|
|
|
|
|
|
|
byte[] bytes = wxMaService.getQrcodeService()
|
|
byte[] bytes = wxMaService.getQrcodeService()
|
|
|
.createWxaCodeUnlimitBytes("expert=true&invitor=" + userId, "pages/home", 94 * 2, false, new WxMaCodeLineColor("0", "0", "0"), true);
|
|
.createWxaCodeUnlimitBytes("expert=true&invitor=" + userId, "pages/home", 94 * 2, false, new WxMaCodeLineColor("0", "0", "0"), true);
|
|
|
|
|
+ if (!home) {
|
|
|
|
|
+ bytes = wxMaService.getQrcodeService()
|
|
|
|
|
+ .createWxaCodeUnlimitBytes("expert=true&invitor=" + userId + "&id=" + map
|
|
|
|
|
+ .get("id"), "pages/detail", 94 * 2, false, new WxMaCodeLineColor("0", "0", "0"), true);
|
|
|
|
|
+ }
|
|
|
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes);
|
|
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes);
|
|
|
BufferedImage codeImg = ImageIO.read(byteArrayInputStream);
|
|
BufferedImage codeImg = ImageIO.read(byteArrayInputStream);
|
|
|
|
|
|