This commit is contained in:
@@ -86,6 +86,28 @@ public class CultureClockInController {
|
|||||||
return ActionResult.success(new Base64ImageVo(pair.getLeft(), base64Img));
|
return ActionResult.success(new Base64ImageVo(pair.getLeft(), base64Img));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打卡分享 - 获取随机图片[base64]
|
||||||
|
* @param lastCombo 上次组合
|
||||||
|
* @param response HttpServletResponse
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/random-preview/create")
|
||||||
|
public ActionResult<Base64ImageVo> getRandomPicPreviewBase64(@RequestParam(value = "lastCombo", required = false) String lastCombo, HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||||
|
|
||||||
|
MutablePair<String, BufferedImage> pair = cultureClockInService.getRandomPicPreview(lastCombo, requestUrl);
|
||||||
|
if (pair == null || pair.getRight() == null) {
|
||||||
|
throw new Exception("获取图片失败,请重试");
|
||||||
|
}
|
||||||
|
byte[] bytes;
|
||||||
|
try (ByteArrayOutputStream output = new ByteArrayOutputStream()) {
|
||||||
|
ImageIO.write(pair.getRight(), "png", output);
|
||||||
|
bytes = output.toByteArray();
|
||||||
|
}
|
||||||
|
String base64 = Base64.getEncoder().encodeToString(bytes);
|
||||||
|
String base64Img = "data:image/png;base64," + base64;
|
||||||
|
return ActionResult.success(new Base64ImageVo(pair.getLeft(), base64Img));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 打卡分享 - 打卡
|
* 打卡分享 - 打卡
|
||||||
* @param currentCombo 当前组合
|
* @param currentCombo 当前组合
|
||||||
|
|||||||
Reference in New Issue
Block a user