You've already forked FrameTour-BE
refactor(puzzle): 重构拼图功能实现会员拼图关联管理
- 移除原有的图片裁切功能和userArea字段 - 删除originalImageUrl字段,统一使用resultImageUrl - 添加MemberPuzzleEntity实体类管理会员拼图关联关系 - 创建MemberPuzzleMapper接口及XML映射文件 - 实现PuzzleRelationProcessor处理器负责关联记录创建 - 在拼图生成完成后自动创建会员拼图关联记录 - 添加景区配置中的免费拼图数量设置 - 实现免费拼图逻辑控制 - 更新拼图模板和生成记录的数据结构 - 修改AppPuzzleController中图片URL的获取方式 - 优化PuzzleEdgeRenderTaskService中的图片处理流程
This commit is contained in:
@@ -147,8 +147,8 @@ public class AppPuzzleController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 检查是否有图片URL
|
// 检查是否有图片URL
|
||||||
String originalImageUrl = record.getOriginalImageUrl();
|
String imageUrl = record.getResultImageUrl();
|
||||||
if (originalImageUrl == null || originalImageUrl.isEmpty()) {
|
if (imageUrl == null || imageUrl.isEmpty()) {
|
||||||
return ApiResponse.fail("该拼图记录没有可用的图片URL");
|
return ApiResponse.fail("该拼图记录没有可用的图片URL");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,7 +163,7 @@ public class AppPuzzleController {
|
|||||||
face.getMemberId(),
|
face.getMemberId(),
|
||||||
face.getScenicId(),
|
face.getScenicId(),
|
||||||
record.getFaceId(),
|
record.getFaceId(),
|
||||||
originalImageUrl,
|
imageUrl,
|
||||||
0L // 打印特有
|
0L // 打印特有
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.ycwl.basic.model.pc.puzzle.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员拼图关联实体
|
||||||
|
* 记录人脸与拼图生成记录的关联关系,包含免费和购买状态
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("member_puzzle")
|
||||||
|
public class MemberPuzzleEntity {
|
||||||
|
private Long id;
|
||||||
|
private Long memberId;
|
||||||
|
private Long scenicId;
|
||||||
|
private Long faceId;
|
||||||
|
private Long recordId;
|
||||||
|
private Integer isBuy;
|
||||||
|
private Long orderId;
|
||||||
|
private Integer isFree;
|
||||||
|
}
|
||||||
@@ -88,11 +88,6 @@ public class PuzzleTemplateDTO {
|
|||||||
*/
|
*/
|
||||||
private Integer canPrint;
|
private Integer canPrint;
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户查看区域(裁切区域),格式:x,y,w,h
|
|
||||||
*/
|
|
||||||
private String userArea;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 元素列表
|
* 元素列表
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -71,11 +71,6 @@ public class TemplateCreateRequest {
|
|||||||
*/
|
*/
|
||||||
private Integer canPrint;
|
private Integer canPrint;
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户查看区域(裁切区域),格式:x,y,w,h
|
|
||||||
*/
|
|
||||||
private String userArea;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 状态:0-禁用 1-启用
|
* 状态:0-禁用 1-启用
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import com.ycwl.basic.puzzle.entity.PuzzleGenerationRecordEntity;
|
|||||||
import com.ycwl.basic.puzzle.entity.PuzzleTemplateEntity;
|
import com.ycwl.basic.puzzle.entity.PuzzleTemplateEntity;
|
||||||
import com.ycwl.basic.puzzle.mapper.PuzzleGenerationRecordMapper;
|
import com.ycwl.basic.puzzle.mapper.PuzzleGenerationRecordMapper;
|
||||||
import com.ycwl.basic.puzzle.repository.PuzzleRepository;
|
import com.ycwl.basic.puzzle.repository.PuzzleRepository;
|
||||||
|
import com.ycwl.basic.service.pc.processor.PuzzleRelationProcessor;
|
||||||
import com.ycwl.basic.service.printer.PrinterService;
|
import com.ycwl.basic.service.printer.PrinterService;
|
||||||
import com.ycwl.basic.storage.StorageFactory;
|
import com.ycwl.basic.storage.StorageFactory;
|
||||||
import com.ycwl.basic.storage.adapters.IStorageAdapter;
|
import com.ycwl.basic.storage.adapters.IStorageAdapter;
|
||||||
@@ -134,6 +135,7 @@ public class PuzzleEdgeRenderTaskService {
|
|||||||
private final PuzzleGenerationRecordMapper recordMapper;
|
private final PuzzleGenerationRecordMapper recordMapper;
|
||||||
private final PuzzleRepository puzzleRepository;
|
private final PuzzleRepository puzzleRepository;
|
||||||
private final PrinterService printerService;
|
private final PrinterService printerService;
|
||||||
|
private final PuzzleRelationProcessor puzzleRelationProcessor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 固定的 workerId,用于标识通过 IP CIDR 验证的 worker
|
* 固定的 workerId,用于标识通过 IP CIDR 验证的 worker
|
||||||
@@ -205,10 +207,7 @@ public class PuzzleEdgeRenderTaskService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IStorageAdapter storage = StorageFactory.use();
|
IStorageAdapter storage = StorageFactory.use();
|
||||||
String originalImageUrl = storage.getUrl(task.getOriginalObjectKey());
|
String resultImageUrl = storage.getUrl(task.getOriginalObjectKey());
|
||||||
String resultImageUrl = StrUtil.isNotBlank(task.getCroppedObjectKey())
|
|
||||||
? storage.getUrl(task.getCroppedObjectKey())
|
|
||||||
: originalImageUrl;
|
|
||||||
|
|
||||||
Long resultFileSize = req != null ? req.getResultFileSize() : null;
|
Long resultFileSize = req != null ? req.getResultFileSize() : null;
|
||||||
Integer resultWidth = req != null ? req.getResultWidth() : null;
|
Integer resultWidth = req != null ? req.getResultWidth() : null;
|
||||||
@@ -218,7 +217,6 @@ public class PuzzleEdgeRenderTaskService {
|
|||||||
recordMapper.updateSuccess(
|
recordMapper.updateSuccess(
|
||||||
record.getId(),
|
record.getId(),
|
||||||
resultImageUrl,
|
resultImageUrl,
|
||||||
originalImageUrl,
|
|
||||||
resultFileSize,
|
resultFileSize,
|
||||||
resultWidth,
|
resultWidth,
|
||||||
resultHeight,
|
resultHeight,
|
||||||
@@ -228,6 +226,14 @@ public class PuzzleEdgeRenderTaskService {
|
|||||||
// 清除生成记录缓存(状态已更新)
|
// 清除生成记录缓存(状态已更新)
|
||||||
puzzleRepository.clearRecordCache(record.getId(), record.getFaceId());
|
puzzleRepository.clearRecordCache(record.getId(), record.getFaceId());
|
||||||
|
|
||||||
|
// 创建member_puzzle关联记录(使用INSERT IGNORE避免重复)
|
||||||
|
puzzleRelationProcessor.createPuzzleRelation(
|
||||||
|
record.getUserId(),
|
||||||
|
record.getScenicId(),
|
||||||
|
record.getFaceId(),
|
||||||
|
record.getId()
|
||||||
|
);
|
||||||
|
|
||||||
// 通知等待方任务完成
|
// 通知等待方任务完成
|
||||||
completeWaitFuture(taskId, TaskWaitResult.success(resultImageUrl));
|
completeWaitFuture(taskId, TaskWaitResult.success(resultImageUrl));
|
||||||
|
|
||||||
@@ -238,7 +244,7 @@ public class PuzzleEdgeRenderTaskService {
|
|||||||
record.getUserId(),
|
record.getUserId(),
|
||||||
record.getScenicId(),
|
record.getScenicId(),
|
||||||
record.getFaceId(),
|
record.getFaceId(),
|
||||||
originalImageUrl,
|
resultImageUrl,
|
||||||
0L // 打印特有
|
0L // 打印特有
|
||||||
);
|
);
|
||||||
log.info("自动添加到打印队列成功: recordId={}, printRecordId={}", record.getId(), printRecordId);
|
log.info("自动添加到打印队列成功: recordId={}, printRecordId={}", record.getId(), printRecordId);
|
||||||
@@ -421,9 +427,6 @@ public class PuzzleEdgeRenderTaskService {
|
|||||||
String fileName = UUID.randomUUID().toString().replace("-", "") + "." + ext;
|
String fileName = UUID.randomUUID().toString().replace("-", "") + "." + ext;
|
||||||
|
|
||||||
String originalObjectKey = String.format("puzzle/%s/%s", template.getCode(), fileName);
|
String originalObjectKey = String.format("puzzle/%s/%s", template.getCode(), fileName);
|
||||||
String croppedObjectKey = StrUtil.isNotBlank(template.getUserArea())
|
|
||||||
? String.format("puzzle/%s_cropped/%s", template.getCode(), fileName)
|
|
||||||
: null;
|
|
||||||
|
|
||||||
Map<String, Object> payload = new HashMap<>();
|
Map<String, Object> payload = new HashMap<>();
|
||||||
payload.put("recordId", record.getId());
|
payload.put("recordId", record.getId());
|
||||||
@@ -436,7 +439,6 @@ public class PuzzleEdgeRenderTaskService {
|
|||||||
templatePayload.put("backgroundType", template.getBackgroundType());
|
templatePayload.put("backgroundType", template.getBackgroundType());
|
||||||
templatePayload.put("backgroundColor", template.getBackgroundColor());
|
templatePayload.put("backgroundColor", template.getBackgroundColor());
|
||||||
templatePayload.put("backgroundImage", template.getBackgroundImage());
|
templatePayload.put("backgroundImage", template.getBackgroundImage());
|
||||||
templatePayload.put("userArea", template.getUserArea());
|
|
||||||
payload.put("template", templatePayload);
|
payload.put("template", templatePayload);
|
||||||
|
|
||||||
List<Map<String, Object>> elementPayloadList = new ArrayList<>();
|
List<Map<String, Object>> elementPayloadList = new ArrayList<>();
|
||||||
@@ -476,7 +478,7 @@ public class PuzzleEdgeRenderTaskService {
|
|||||||
task.setOutputFormat(normalizedFormat);
|
task.setOutputFormat(normalizedFormat);
|
||||||
task.setOutputQuality(outputQuality);
|
task.setOutputQuality(outputQuality);
|
||||||
task.setOriginalObjectKey(originalObjectKey);
|
task.setOriginalObjectKey(originalObjectKey);
|
||||||
task.setCroppedObjectKey(croppedObjectKey);
|
task.setCroppedObjectKey(null);
|
||||||
task.setPayloadJson(JacksonUtil.toJson(payload));
|
task.setPayloadJson(JacksonUtil.toJson(payload));
|
||||||
|
|
||||||
Long taskId = taskIdSequence.incrementAndGet();
|
Long taskId = taskIdSequence.incrementAndGet();
|
||||||
|
|||||||
@@ -76,12 +76,6 @@ public class PuzzleGenerationRecordEntity {
|
|||||||
@TableField("result_image_url")
|
@TableField("result_image_url")
|
||||||
private String resultImageUrl;
|
private String resultImageUrl;
|
||||||
|
|
||||||
/**
|
|
||||||
* 原始图片URL(未裁切的图片,用于打印)
|
|
||||||
*/
|
|
||||||
@TableField("original_image_url")
|
|
||||||
private String originalImageUrl;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件大小(字节)
|
* 文件大小(字节)
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -109,12 +109,6 @@ public class PuzzleTemplateEntity {
|
|||||||
@TableField("can_print")
|
@TableField("can_print")
|
||||||
private Integer canPrint;
|
private Integer canPrint;
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户查看区域(裁切区域),格式:x,y,w,h
|
|
||||||
*/
|
|
||||||
@TableField("user_area")
|
|
||||||
private String userArea;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建时间
|
* 创建时间
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package com.ycwl.basic.puzzle.mapper;
|
||||||
|
|
||||||
|
import com.ycwl.basic.model.pc.puzzle.entity.MemberPuzzleEntity;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员拼图关联Mapper接口
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface MemberPuzzleMapper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加关联记录
|
||||||
|
*/
|
||||||
|
int addRelation(MemberPuzzleEntity entity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量添加关联记录
|
||||||
|
*/
|
||||||
|
int addRelations(@Param("list") List<MemberPuzzleEntity> list);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据人脸ID查询关联列表
|
||||||
|
*/
|
||||||
|
List<MemberPuzzleEntity> listByFaceId(@Param("faceId") Long faceId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据人脸ID统计免费数量
|
||||||
|
*/
|
||||||
|
int countFreeByFaceId(@Param("faceId") Long faceId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新关联记录(购买状态、订单ID等)
|
||||||
|
*/
|
||||||
|
int updateRelation(MemberPuzzleEntity entity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量标记为免费
|
||||||
|
*/
|
||||||
|
int freeRelations(@Param("ids") List<Long> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据人脸ID和记录ID查询
|
||||||
|
*/
|
||||||
|
MemberPuzzleEntity getByFaceAndRecord(@Param("faceId") Long faceId, @Param("recordId") Long recordId);
|
||||||
|
}
|
||||||
@@ -52,7 +52,6 @@ public interface PuzzleGenerationRecordMapper {
|
|||||||
*/
|
*/
|
||||||
int updateSuccess(@Param("id") Long id,
|
int updateSuccess(@Param("id") Long id,
|
||||||
@Param("resultImageUrl") String resultImageUrl,
|
@Param("resultImageUrl") String resultImageUrl,
|
||||||
@Param("originalImageUrl") String originalImageUrl,
|
|
||||||
@Param("resultFileSize") Long resultFileSize,
|
@Param("resultFileSize") Long resultFileSize,
|
||||||
@Param("resultWidth") Integer resultWidth,
|
@Param("resultWidth") Integer resultWidth,
|
||||||
@Param("resultHeight") Integer resultHeight,
|
@Param("resultHeight") Integer resultHeight,
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import com.ycwl.basic.puzzle.service.IPuzzleGenerateService;
|
|||||||
import com.ycwl.basic.puzzle.util.PuzzleDuplicationDetector;
|
import com.ycwl.basic.puzzle.util.PuzzleDuplicationDetector;
|
||||||
import com.ycwl.basic.puzzle.util.PuzzleImageRenderer;
|
import com.ycwl.basic.puzzle.util.PuzzleImageRenderer;
|
||||||
import com.ycwl.basic.repository.ScenicRepository;
|
import com.ycwl.basic.repository.ScenicRepository;
|
||||||
|
import com.ycwl.basic.service.pc.processor.PuzzleRelationProcessor;
|
||||||
import com.ycwl.basic.service.printer.PrinterService;
|
import com.ycwl.basic.service.printer.PrinterService;
|
||||||
import com.ycwl.basic.storage.StorageFactory;
|
import com.ycwl.basic.storage.StorageFactory;
|
||||||
import com.ycwl.basic.utils.WxMpUtil;
|
import com.ycwl.basic.utils.WxMpUtil;
|
||||||
@@ -58,6 +59,7 @@ public class PuzzleGenerateServiceImpl implements IPuzzleGenerateService {
|
|||||||
private final PrinterService printerService;
|
private final PrinterService printerService;
|
||||||
private final PuzzleEdgeRenderTaskService puzzleEdgeRenderTaskService;
|
private final PuzzleEdgeRenderTaskService puzzleEdgeRenderTaskService;
|
||||||
private final FaceStatusManager faceStatusManager;
|
private final FaceStatusManager faceStatusManager;
|
||||||
|
private final PuzzleRelationProcessor puzzleRelationProcessor;
|
||||||
|
|
||||||
public PuzzleGenerateServiceImpl(
|
public PuzzleGenerateServiceImpl(
|
||||||
PuzzleRepository puzzleRepository,
|
PuzzleRepository puzzleRepository,
|
||||||
@@ -68,7 +70,8 @@ public class PuzzleGenerateServiceImpl implements IPuzzleGenerateService {
|
|||||||
@Lazy PuzzleDuplicationDetector duplicationDetector,
|
@Lazy PuzzleDuplicationDetector duplicationDetector,
|
||||||
@Lazy PrinterService printerService,
|
@Lazy PrinterService printerService,
|
||||||
PuzzleEdgeRenderTaskService puzzleEdgeRenderTaskService,
|
PuzzleEdgeRenderTaskService puzzleEdgeRenderTaskService,
|
||||||
@Lazy FaceStatusManager faceStatusManager) {
|
@Lazy FaceStatusManager faceStatusManager,
|
||||||
|
@Lazy PuzzleRelationProcessor puzzleRelationProcessor) {
|
||||||
this.puzzleRepository = puzzleRepository;
|
this.puzzleRepository = puzzleRepository;
|
||||||
this.recordMapper = recordMapper;
|
this.recordMapper = recordMapper;
|
||||||
this.imageRenderer = imageRenderer;
|
this.imageRenderer = imageRenderer;
|
||||||
@@ -78,6 +81,7 @@ public class PuzzleGenerateServiceImpl implements IPuzzleGenerateService {
|
|||||||
this.printerService = printerService;
|
this.printerService = printerService;
|
||||||
this.puzzleEdgeRenderTaskService = puzzleEdgeRenderTaskService;
|
this.puzzleEdgeRenderTaskService = puzzleEdgeRenderTaskService;
|
||||||
this.faceStatusManager = faceStatusManager;
|
this.faceStatusManager = faceStatusManager;
|
||||||
|
this.puzzleRelationProcessor = puzzleRelationProcessor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -206,6 +210,14 @@ public class PuzzleGenerateServiceImpl implements IPuzzleGenerateService {
|
|||||||
faceStatusManager.markPuzzleSourceVersion(request.getFaceId(), template.getId(), 0);
|
faceStatusManager.markPuzzleSourceVersion(request.getFaceId(), template.getId(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 创建member_puzzle关联记录
|
||||||
|
puzzleRelationProcessor.createPuzzleRelation(
|
||||||
|
request.getUserId(),
|
||||||
|
resolvedScenicId,
|
||||||
|
request.getFaceId(),
|
||||||
|
record.getId()
|
||||||
|
);
|
||||||
|
|
||||||
// 重新查询记录获取完整信息(边缘渲染回调已更新)
|
// 重新查询记录获取完整信息(边缘渲染回调已更新)
|
||||||
PuzzleGenerationRecordEntity updatedRecord = recordMapper.getById(record.getId());
|
PuzzleGenerationRecordEntity updatedRecord = recordMapper.getById(record.getId());
|
||||||
if (updatedRecord != null && updatedRecord.getResultImageUrl() != null) {
|
if (updatedRecord != null && updatedRecord.getResultImageUrl() != null) {
|
||||||
@@ -456,43 +468,27 @@ public class PuzzleGenerateServiceImpl implements IPuzzleGenerateService {
|
|||||||
// 渲染图片
|
// 渲染图片
|
||||||
BufferedImage resultImage = imageRenderer.render(template, elements, finalDynamicData);
|
BufferedImage resultImage = imageRenderer.render(template, elements, finalDynamicData);
|
||||||
|
|
||||||
// 上传原图到OSS(未裁切)
|
// 上传图片到OSS
|
||||||
String originalImageUrl = uploadImage(resultImage, template.getCode(), request.getOutputFormat(), request.getQuality());
|
String imageUrl = uploadImage(resultImage, template.getCode(), request.getOutputFormat(), request.getQuality());
|
||||||
log.info("原图上传成功: url={}", originalImageUrl);
|
log.info("图片上传成功: url={}", imageUrl);
|
||||||
|
|
||||||
// 处理用户区域裁切
|
|
||||||
String finalImageUrl = originalImageUrl;
|
|
||||||
BufferedImage finalImage = resultImage;
|
|
||||||
|
|
||||||
if (StrUtil.isNotBlank(template.getUserArea())) {
|
|
||||||
try {
|
|
||||||
BufferedImage croppedImage = cropImage(resultImage, template.getUserArea());
|
|
||||||
finalImageUrl = uploadImage(croppedImage, template.getCode() + "_cropped", request.getOutputFormat(), request.getQuality());
|
|
||||||
finalImage = croppedImage;
|
|
||||||
log.info("裁切后图片上传成功: userArea={}, url={}", template.getUserArea(), finalImageUrl);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("图片裁切失败,使用原图: userArea={}", template.getUserArea(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 更新记录为成功
|
// 更新记录为成功
|
||||||
long duration = System.currentTimeMillis() - startTime;
|
long duration = System.currentTimeMillis() - startTime;
|
||||||
long fileSize = estimateFileSize(finalImage, request.getOutputFormat());
|
long fileSize = estimateFileSize(resultImage, request.getOutputFormat());
|
||||||
recordMapper.updateSuccess(
|
recordMapper.updateSuccess(
|
||||||
record.getId(),
|
record.getId(),
|
||||||
finalImageUrl,
|
imageUrl,
|
||||||
originalImageUrl,
|
|
||||||
fileSize,
|
fileSize,
|
||||||
finalImage.getWidth(),
|
resultImage.getWidth(),
|
||||||
finalImage.getHeight(),
|
resultImage.getHeight(),
|
||||||
(int) duration
|
(int) duration
|
||||||
);
|
);
|
||||||
|
|
||||||
// 清除生成记录缓存(状态已更新)
|
// 清除生成记录缓存(状态已更新)
|
||||||
puzzleRepository.clearRecordCache(record.getId(), request.getFaceId());
|
puzzleRepository.clearRecordCache(record.getId(), request.getFaceId());
|
||||||
|
|
||||||
log.info("拼图生成成功: recordId={}, originalUrl={}, finalUrl={}, duration={}ms",
|
log.info("拼图生成成功: recordId={}, imageUrl={}, duration={}ms",
|
||||||
record.getId(), originalImageUrl, finalImageUrl, duration);
|
record.getId(), imageUrl, duration);
|
||||||
|
|
||||||
// 检查是否自动添加到打印队列
|
// 检查是否自动添加到打印队列
|
||||||
if (template.getAutoAddPrint() != null && template.getAutoAddPrint() == 1) {
|
if (template.getAutoAddPrint() != null && template.getAutoAddPrint() == 1) {
|
||||||
@@ -501,7 +497,7 @@ public class PuzzleGenerateServiceImpl implements IPuzzleGenerateService {
|
|||||||
request.getUserId(),
|
request.getUserId(),
|
||||||
resolvedScenicId,
|
resolvedScenicId,
|
||||||
request.getFaceId(),
|
request.getFaceId(),
|
||||||
originalImageUrl,
|
imageUrl,
|
||||||
0L // 打印特有
|
0L // 打印特有
|
||||||
);
|
);
|
||||||
log.info("自动添加到打印队列成功: recordId={}, printRecordId={}", record.getId(), printRecordId);
|
log.info("自动添加到打印队列成功: recordId={}, printRecordId={}", record.getId(), printRecordId);
|
||||||
@@ -511,10 +507,10 @@ public class PuzzleGenerateServiceImpl implements IPuzzleGenerateService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return PuzzleGenerateResponse.success(
|
return PuzzleGenerateResponse.success(
|
||||||
finalImageUrl,
|
imageUrl,
|
||||||
fileSize,
|
fileSize,
|
||||||
finalImage.getWidth(),
|
resultImage.getWidth(),
|
||||||
finalImage.getHeight(),
|
resultImage.getHeight(),
|
||||||
(int) duration,
|
(int) duration,
|
||||||
record.getId(),
|
record.getId(),
|
||||||
false,
|
false,
|
||||||
@@ -761,43 +757,4 @@ public class PuzzleGenerateServiceImpl implements IPuzzleGenerateService {
|
|||||||
|
|
||||||
return templateScenicId;
|
return templateScenicId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 裁切图片
|
|
||||||
* @param image 原图
|
|
||||||
* @param userArea 裁切区域,格式:x,y,w,h
|
|
||||||
* @return 裁切后的图片
|
|
||||||
*/
|
|
||||||
private BufferedImage cropImage(BufferedImage image, String userArea) {
|
|
||||||
if (StrUtil.isBlank(userArea)) {
|
|
||||||
return image;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
String[] parts = userArea.split(",");
|
|
||||||
if (parts.length != 4) {
|
|
||||||
throw new IllegalArgumentException("userArea格式错误,应为:x,y,w,h");
|
|
||||||
}
|
|
||||||
|
|
||||||
int x = Integer.parseInt(parts[0].trim());
|
|
||||||
int y = Integer.parseInt(parts[1].trim());
|
|
||||||
int w = Integer.parseInt(parts[2].trim());
|
|
||||||
int h = Integer.parseInt(parts[3].trim());
|
|
||||||
|
|
||||||
// 边界检查
|
|
||||||
if (x < 0 || y < 0 || w <= 0 || h <= 0) {
|
|
||||||
throw new IllegalArgumentException("裁切区域参数必须为正数");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (x + w > image.getWidth() || y + h > image.getHeight()) {
|
|
||||||
throw new IllegalArgumentException("裁切区域超出图片边界");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 执行裁切
|
|
||||||
return image.getSubimage(x, y, w, h);
|
|
||||||
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
throw new IllegalArgumentException("userArea格式错误,参数必须为数字", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -168,6 +168,23 @@ public class ScenicConfigFacade {
|
|||||||
return config.getInteger("photo_free_num");
|
return config.getInteger("photo_free_num");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ==================== 拼图相关配置 ====================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取免费拼图数量
|
||||||
|
* 新用户首次识别时赠送的免费拼图数量
|
||||||
|
*
|
||||||
|
* @param scenicId 景区ID
|
||||||
|
* @return 免费拼图数量,null 或 0 表示不赠送
|
||||||
|
*/
|
||||||
|
public Integer getPuzzleFreeNum(Long scenicId) {
|
||||||
|
ScenicConfigManager config = getConfig(scenicId);
|
||||||
|
if (config == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return config.getInteger("puzzle_free_num");
|
||||||
|
}
|
||||||
|
|
||||||
// ==================== 游玩时间相关配置 ====================
|
// ==================== 游玩时间相关配置 ====================
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,84 @@
|
|||||||
|
package com.ycwl.basic.service.pc.processor;
|
||||||
|
|
||||||
|
import com.ycwl.basic.constant.FreeStatus;
|
||||||
|
import com.ycwl.basic.model.pc.puzzle.entity.MemberPuzzleEntity;
|
||||||
|
import com.ycwl.basic.puzzle.mapper.MemberPuzzleMapper;
|
||||||
|
import com.ycwl.basic.service.pc.helper.ScenicConfigFacade;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拼图关联记录处理器
|
||||||
|
* 负责创建和管理member_puzzle关联记录
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class PuzzleRelationProcessor {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MemberPuzzleMapper memberPuzzleMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ScenicConfigFacade scenicConfigFacade;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建拼图关联记录
|
||||||
|
*
|
||||||
|
* @param memberId 会员ID
|
||||||
|
* @param scenicId 景区ID
|
||||||
|
* @param faceId 人脸ID
|
||||||
|
* @param recordId 拼图生成记录ID
|
||||||
|
*/
|
||||||
|
public void createPuzzleRelation(Long memberId, Long scenicId, Long faceId, Long recordId) {
|
||||||
|
if (faceId == null || recordId == null) {
|
||||||
|
log.warn("创建拼图关联记录失败:faceId或recordId为空, faceId={}, recordId={}", faceId, recordId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MemberPuzzleEntity entity = new MemberPuzzleEntity();
|
||||||
|
entity.setMemberId(memberId);
|
||||||
|
entity.setScenicId(scenicId);
|
||||||
|
entity.setFaceId(faceId);
|
||||||
|
entity.setRecordId(recordId);
|
||||||
|
entity.setIsBuy(0);
|
||||||
|
|
||||||
|
// 处理免费逻辑
|
||||||
|
Integer isFree = processFreeLogic(scenicId, faceId);
|
||||||
|
entity.setIsFree(isFree);
|
||||||
|
|
||||||
|
try {
|
||||||
|
memberPuzzleMapper.addRelation(entity);
|
||||||
|
log.debug("创建拼图关联记录成功: faceId={}, recordId={}, isFree={}", faceId, recordId, isFree);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("创建拼图关联记录失败: faceId={}, recordId={}", faceId, recordId, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理免费逻辑
|
||||||
|
* 根据景区配置的puzzle_free_num决定是否免费
|
||||||
|
*
|
||||||
|
* @param scenicId 景区ID
|
||||||
|
* @param faceId 人脸ID
|
||||||
|
* @return 免费状态码
|
||||||
|
*/
|
||||||
|
private Integer processFreeLogic(Long scenicId, Long faceId) {
|
||||||
|
Integer puzzleFreeNum = scenicConfigFacade.getPuzzleFreeNum(scenicId);
|
||||||
|
|
||||||
|
if (puzzleFreeNum == null || puzzleFreeNum <= 0) {
|
||||||
|
return FreeStatus.PAID.getCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 统计已有的免费拼图数量
|
||||||
|
int existingFreeCount = memberPuzzleMapper.countFreeByFaceId(faceId);
|
||||||
|
|
||||||
|
if (existingFreeCount < puzzleFreeNum) {
|
||||||
|
log.debug("免费拼图逻辑: scenicId={}, faceId={}, 配置免费数量={}, 已免费={}, 本次免费",
|
||||||
|
scenicId, faceId, puzzleFreeNum, existingFreeCount);
|
||||||
|
return FreeStatus.FREE.getCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
return FreeStatus.PAID.getCode();
|
||||||
|
}
|
||||||
|
}
|
||||||
70
src/main/resources/mapper/MemberPuzzleMapper.xml
Normal file
70
src/main/resources/mapper/MemberPuzzleMapper.xml
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.ycwl.basic.puzzle.mapper.MemberPuzzleMapper">
|
||||||
|
|
||||||
|
<resultMap id="BaseResultMap" type="com.ycwl.basic.model.pc.puzzle.entity.MemberPuzzleEntity">
|
||||||
|
<id column="id" property="id"/>
|
||||||
|
<result column="member_id" property="memberId"/>
|
||||||
|
<result column="scenic_id" property="scenicId"/>
|
||||||
|
<result column="face_id" property="faceId"/>
|
||||||
|
<result column="record_id" property="recordId"/>
|
||||||
|
<result column="is_buy" property="isBuy"/>
|
||||||
|
<result column="order_id" property="orderId"/>
|
||||||
|
<result column="is_free" property="isFree"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
id, member_id, scenic_id, face_id, record_id, is_buy, order_id, is_free
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<insert id="addRelation" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
INSERT IGNORE INTO member_puzzle(scenic_id, face_id, member_id, record_id, is_buy, order_id, is_free)
|
||||||
|
VALUES (#{scenicId}, #{faceId}, #{memberId}, #{recordId}, #{isBuy}, #{orderId}, #{isFree})
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<insert id="addRelations">
|
||||||
|
INSERT IGNORE INTO member_puzzle(scenic_id, face_id, member_id, record_id, is_buy, order_id, is_free)
|
||||||
|
VALUES
|
||||||
|
<foreach collection="list" item="item" separator=",">
|
||||||
|
(#{item.scenicId}, #{item.faceId}, #{item.memberId}, #{item.recordId}, #{item.isBuy}, #{item.orderId}, #{item.isFree})
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<select id="listByFaceId" resultMap="BaseResultMap">
|
||||||
|
SELECT <include refid="Base_Column_List"/>
|
||||||
|
FROM member_puzzle
|
||||||
|
WHERE face_id = #{faceId}
|
||||||
|
ORDER BY id DESC
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="countFreeByFaceId" resultType="int">
|
||||||
|
SELECT COUNT(*) FROM member_puzzle
|
||||||
|
WHERE face_id = #{faceId} AND is_free = 1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<update id="updateRelation">
|
||||||
|
UPDATE member_puzzle
|
||||||
|
<set>
|
||||||
|
<if test="isBuy != null">is_buy = #{isBuy},</if>
|
||||||
|
<if test="orderId != null">order_id = #{orderId},</if>
|
||||||
|
<if test="isFree != null">is_free = #{isFree},</if>
|
||||||
|
</set>
|
||||||
|
WHERE id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<update id="freeRelations">
|
||||||
|
UPDATE member_puzzle SET is_free = 1
|
||||||
|
WHERE id IN
|
||||||
|
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<select id="getByFaceAndRecord" resultMap="BaseResultMap">
|
||||||
|
SELECT <include refid="Base_Column_List"/>
|
||||||
|
FROM member_puzzle
|
||||||
|
WHERE face_id = #{faceId} AND record_id = #{recordId}
|
||||||
|
LIMIT 1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@@ -14,7 +14,6 @@
|
|||||||
<result column="generation_params" property="generationParams"/>
|
<result column="generation_params" property="generationParams"/>
|
||||||
<result column="content_hash" property="contentHash"/>
|
<result column="content_hash" property="contentHash"/>
|
||||||
<result column="result_image_url" property="resultImageUrl"/>
|
<result column="result_image_url" property="resultImageUrl"/>
|
||||||
<result column="original_image_url" property="originalImageUrl"/>
|
|
||||||
<result column="result_file_size" property="resultFileSize"/>
|
<result column="result_file_size" property="resultFileSize"/>
|
||||||
<result column="result_width" property="resultWidth"/>
|
<result column="result_width" property="resultWidth"/>
|
||||||
<result column="result_height" property="resultHeight"/>
|
<result column="result_height" property="resultHeight"/>
|
||||||
@@ -33,7 +32,7 @@
|
|||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
id, template_id, template_code, user_id, face_id, business_type,
|
id, template_id, template_code, user_id, face_id, business_type,
|
||||||
generation_params, content_hash,
|
generation_params, content_hash,
|
||||||
result_image_url, original_image_url, result_file_size, result_width, result_height,
|
result_image_url, result_file_size, result_width, result_height,
|
||||||
status, error_message, generation_duration, retry_count,
|
status, error_message, generation_duration, retry_count,
|
||||||
scenic_id, client_ip, user_agent, create_time, update_time
|
scenic_id, client_ip, user_agent, create_time, update_time
|
||||||
</sql>
|
</sql>
|
||||||
@@ -78,13 +77,13 @@
|
|||||||
INSERT INTO puzzle_generation_record (
|
INSERT INTO puzzle_generation_record (
|
||||||
template_id, template_code, user_id, face_id, business_type,
|
template_id, template_code, user_id, face_id, business_type,
|
||||||
generation_params, content_hash,
|
generation_params, content_hash,
|
||||||
result_image_url, original_image_url, result_file_size, result_width, result_height,
|
result_image_url, result_file_size, result_width, result_height,
|
||||||
status, error_message, generation_duration, retry_count,
|
status, error_message, generation_duration, retry_count,
|
||||||
scenic_id, client_ip, user_agent, create_time, update_time
|
scenic_id, client_ip, user_agent, create_time, update_time
|
||||||
) VALUES (
|
) VALUES (
|
||||||
#{templateId}, #{templateCode}, #{userId}, #{faceId}, #{businessType},
|
#{templateId}, #{templateCode}, #{userId}, #{faceId}, #{businessType},
|
||||||
#{generationParams}, #{contentHash},
|
#{generationParams}, #{contentHash},
|
||||||
#{resultImageUrl}, #{originalImageUrl}, #{resultFileSize}, #{resultWidth}, #{resultHeight},
|
#{resultImageUrl}, #{resultFileSize}, #{resultWidth}, #{resultHeight},
|
||||||
#{status}, #{errorMessage}, #{generationDuration}, #{retryCount},
|
#{status}, #{errorMessage}, #{generationDuration}, #{retryCount},
|
||||||
#{scenicId}, #{clientIp}, #{userAgent}, NOW(), NOW()
|
#{scenicId}, #{clientIp}, #{userAgent}, NOW(), NOW()
|
||||||
)
|
)
|
||||||
@@ -95,7 +94,6 @@
|
|||||||
UPDATE puzzle_generation_record
|
UPDATE puzzle_generation_record
|
||||||
<set>
|
<set>
|
||||||
<if test="resultImageUrl != null">result_image_url = #{resultImageUrl},</if>
|
<if test="resultImageUrl != null">result_image_url = #{resultImageUrl},</if>
|
||||||
<if test="originalImageUrl != null">original_image_url = #{originalImageUrl},</if>
|
|
||||||
<if test="resultFileSize != null">result_file_size = #{resultFileSize},</if>
|
<if test="resultFileSize != null">result_file_size = #{resultFileSize},</if>
|
||||||
<if test="resultWidth != null">result_width = #{resultWidth},</if>
|
<if test="resultWidth != null">result_width = #{resultWidth},</if>
|
||||||
<if test="resultHeight != null">result_height = #{resultHeight},</if>
|
<if test="resultHeight != null">result_height = #{resultHeight},</if>
|
||||||
@@ -113,7 +111,6 @@
|
|||||||
UPDATE puzzle_generation_record
|
UPDATE puzzle_generation_record
|
||||||
SET status = 1,
|
SET status = 1,
|
||||||
result_image_url = #{resultImageUrl},
|
result_image_url = #{resultImageUrl},
|
||||||
original_image_url = #{originalImageUrl},
|
|
||||||
result_file_size = #{resultFileSize},
|
result_file_size = #{resultFileSize},
|
||||||
result_width = #{resultWidth},
|
result_width = #{resultWidth},
|
||||||
result_height = #{resultHeight},
|
result_height = #{resultHeight},
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
<result column="scenic_id" property="scenicId"/>
|
<result column="scenic_id" property="scenicId"/>
|
||||||
<result column="auto_add_print" property="autoAddPrint"/>
|
<result column="auto_add_print" property="autoAddPrint"/>
|
||||||
<result column="can_print" property="canPrint"/>
|
<result column="can_print" property="canPrint"/>
|
||||||
<result column="user_area" property="userArea"/>
|
|
||||||
<result column="create_time" property="createTime"/>
|
<result column="create_time" property="createTime"/>
|
||||||
<result column="update_time" property="updateTime"/>
|
<result column="update_time" property="updateTime"/>
|
||||||
<result column="deleted" property="deleted"/>
|
<result column="deleted" property="deleted"/>
|
||||||
@@ -31,7 +30,7 @@
|
|||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
id, name, code, canvas_width, canvas_height, background_type, background_color,
|
id, name, code, canvas_width, canvas_height, background_type, background_color,
|
||||||
background_image, cover_image, description, category, status, scenic_id,
|
background_image, cover_image, description, category, status, scenic_id,
|
||||||
auto_add_print, can_print, user_area, create_time, update_time, deleted, deleted_at
|
auto_add_print, can_print, create_time, update_time, deleted, deleted_at
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<!-- 根据ID查询 -->
|
<!-- 根据ID查询 -->
|
||||||
@@ -73,11 +72,11 @@
|
|||||||
INSERT INTO puzzle_template (
|
INSERT INTO puzzle_template (
|
||||||
name, code, canvas_width, canvas_height, background_type, background_color,
|
name, code, canvas_width, canvas_height, background_type, background_color,
|
||||||
background_image, cover_image, description, category, status, scenic_id,
|
background_image, cover_image, description, category, status, scenic_id,
|
||||||
auto_add_print, can_print, user_area, create_time, update_time, deleted
|
auto_add_print, can_print, create_time, update_time, deleted
|
||||||
) VALUES (
|
) VALUES (
|
||||||
#{name}, #{code}, #{canvasWidth}, #{canvasHeight}, #{backgroundType}, #{backgroundColor},
|
#{name}, #{code}, #{canvasWidth}, #{canvasHeight}, #{backgroundType}, #{backgroundColor},
|
||||||
#{backgroundImage}, #{coverImage}, #{description}, #{category}, #{status}, #{scenicId},
|
#{backgroundImage}, #{coverImage}, #{description}, #{category}, #{status}, #{scenicId},
|
||||||
#{autoAddPrint}, #{canPrint}, #{userArea}, NOW(), NOW(), 0
|
#{autoAddPrint}, #{canPrint}, NOW(), NOW(), 0
|
||||||
)
|
)
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
@@ -99,7 +98,6 @@
|
|||||||
<if test="scenicId != null">scenic_id = #{scenicId},</if>
|
<if test="scenicId != null">scenic_id = #{scenicId},</if>
|
||||||
<if test="autoAddPrint != null">auto_add_print = #{autoAddPrint},</if>
|
<if test="autoAddPrint != null">auto_add_print = #{autoAddPrint},</if>
|
||||||
<if test="canPrint != null">can_print = #{canPrint},</if>
|
<if test="canPrint != null">can_print = #{canPrint},</if>
|
||||||
<if test="userArea != null">user_area = #{userArea},</if>
|
|
||||||
update_time = NOW()
|
update_time = NOW()
|
||||||
</set>
|
</set>
|
||||||
WHERE id = #{id} AND deleted = 0
|
WHERE id = #{id} AND deleted = 0
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ class PuzzleGenerateServiceDeduplicationTest {
|
|||||||
}).when(recordMapper).insert(any());
|
}).when(recordMapper).insert(any());
|
||||||
|
|
||||||
// Mock更新成功
|
// Mock更新成功
|
||||||
when(recordMapper.updateSuccess(anyLong(), anyString(), anyString(), anyLong(), anyInt(), anyInt(), anyInt()))
|
when(recordMapper.updateSuccess(anyLong(), anyString(), anyLong(), anyInt(), anyInt(), anyInt()))
|
||||||
.thenReturn(1);
|
.thenReturn(1);
|
||||||
|
|
||||||
// 执行
|
// 执行
|
||||||
@@ -119,7 +119,7 @@ class PuzzleGenerateServiceDeduplicationTest {
|
|||||||
assertNull(response.getOriginalRecordId());
|
assertNull(response.getOriginalRecordId());
|
||||||
verify(imageRenderer, times(1)).render(any(), any(), any()); // 确实进行了渲染
|
verify(imageRenderer, times(1)).render(any(), any(), any()); // 确实进行了渲染
|
||||||
verify(recordMapper, times(1)).insert(any()); // 插入了一条记录
|
verify(recordMapper, times(1)).insert(any()); // 插入了一条记录
|
||||||
verify(recordMapper, times(1)).updateSuccess(anyLong(), anyString(), anyString(), anyLong(), anyInt(), anyInt(), anyInt());
|
verify(recordMapper, times(1)).updateSuccess(anyLong(), anyString(), anyLong(), anyInt(), anyInt(), anyInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -157,7 +157,7 @@ class PuzzleGenerateServiceDeduplicationTest {
|
|||||||
assertEquals("https://example.com/old-image.jpg", response.getImageUrl()); // 复用的URL
|
assertEquals("https://example.com/old-image.jpg", response.getImageUrl()); // 复用的URL
|
||||||
verify(imageRenderer, never()).render(any(), any(), any()); // 没有进行渲染
|
verify(imageRenderer, never()).render(any(), any(), any()); // 没有进行渲染
|
||||||
verify(recordMapper, never()).insert(any()); // 没有插入新记录
|
verify(recordMapper, never()).insert(any()); // 没有插入新记录
|
||||||
verify(recordMapper, never()).updateSuccess(anyLong(), anyString(), anyString(), anyLong(), anyInt(), anyInt(), anyInt());
|
verify(recordMapper, never()).updateSuccess(anyLong(), anyString(), anyLong(), anyInt(), anyInt(), anyInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -234,7 +234,7 @@ class PuzzleGenerateServiceDeduplicationTest {
|
|||||||
return 1;
|
return 1;
|
||||||
}).when(recordMapper).insert(any());
|
}).when(recordMapper).insert(any());
|
||||||
|
|
||||||
when(recordMapper.updateSuccess(anyLong(), anyString(), anyString(), anyLong(), anyInt(), anyInt(), anyInt()))
|
when(recordMapper.updateSuccess(anyLong(), anyString(), anyLong(), anyInt(), anyInt(), anyInt()))
|
||||||
.thenReturn(1);
|
.thenReturn(1);
|
||||||
|
|
||||||
// 执行两次生成
|
// 执行两次生成
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ class PuzzleGenerateServiceImplTest {
|
|||||||
record.setId(555L);
|
record.setId(555L);
|
||||||
return 1;
|
return 1;
|
||||||
}).when(recordMapper).insert(any());
|
}).when(recordMapper).insert(any());
|
||||||
when(recordMapper.updateSuccess(anyLong(), anyString(), anyString(), anyLong(), anyInt(), anyInt(), anyInt())).thenReturn(1);
|
when(recordMapper.updateSuccess(anyLong(), anyString(), anyLong(), anyInt(), anyInt(), anyInt())).thenReturn(1);
|
||||||
|
|
||||||
PuzzleGenerateRequest request = new PuzzleGenerateRequest();
|
PuzzleGenerateRequest request = new PuzzleGenerateRequest();
|
||||||
request.setTemplateCode("ticket");
|
request.setTemplateCode("ticket");
|
||||||
@@ -131,7 +131,7 @@ class PuzzleGenerateServiceImplTest {
|
|||||||
record.setId(777L);
|
record.setId(777L);
|
||||||
return 1;
|
return 1;
|
||||||
}).when(recordMapper).insert(any());
|
}).when(recordMapper).insert(any());
|
||||||
when(recordMapper.updateSuccess(anyLong(), anyString(), anyString(), anyLong(), anyInt(), anyInt(), anyInt())).thenReturn(1);
|
when(recordMapper.updateSuccess(anyLong(), anyString(), anyLong(), anyInt(), anyInt(), anyInt())).thenReturn(1);
|
||||||
|
|
||||||
PuzzleGenerateRequest request = new PuzzleGenerateRequest();
|
PuzzleGenerateRequest request = new PuzzleGenerateRequest();
|
||||||
request.setTemplateCode("ticket");
|
request.setTemplateCode("ticket");
|
||||||
|
|||||||
Reference in New Issue
Block a user