You've already forked FrameTour-BE
feat(puzzle): 优化二维码生成与去重逻辑
- 避免重复上传已存在的微信小程序二维码 - 在去重检测中跳过 dateStr 字段以提高准确性 - 添加文件存在性检查,减少不必要的上传操作 - 记录并返回已存在文件的访问 URL - 提升 puzzle 服务的性能与资源利用率
This commit is contained in:
@@ -348,10 +348,12 @@ public class PuzzleGenerateServiceImpl implements IPuzzleGenerateService {
|
||||
|
||||
// 上传到OSS
|
||||
try (FileInputStream fis = new FileInputStream(qrcode)) {
|
||||
String fileName = String.format("qrcode_%d_%s.jpg",
|
||||
faceId,
|
||||
UUID.randomUUID().toString().replace("-", "").substring(0, 16));
|
||||
|
||||
String fileName = String.format("qrcode_%d.jpg", faceId);
|
||||
boolean exists = StorageFactory.use().isExists("puzzle", "wechat_qrcode", fileName);
|
||||
if (exists) {
|
||||
log.debug("微信小程序二维码已存在, 不重复上传: faceId={}, url={}", faceId, StorageFactory.use().getUrl("puzzle", "wechat_qrcode", fileName));
|
||||
return StorageFactory.use().getUrl("puzzle", "wechat_qrcode", fileName);
|
||||
}
|
||||
return StorageFactory.use().uploadFile(
|
||||
"image/jpeg",
|
||||
fis,
|
||||
|
||||
Reference in New Issue
Block a user