fix:获取历史记录加入顾客id
All checks were successful
git commit 控制 连卡佛 back-java prod 分支构建部署 / build_and_deploy (push) Has been skipped

This commit is contained in:
litianxiang
2025-12-22 15:17:12 +08:00
parent 658149639f
commit 8eb42c9364
4 changed files with 67 additions and 59 deletions

View File

@@ -40,7 +40,7 @@ public class WebConfig implements WebMvcConfigurer {
registry.addInterceptor(jwtInterceptor)
.addPathPatterns("/api/**/**") // 保护这些路径
.excludePathPatterns(Arrays.asList("/api/auth/precheckEmail", "/api/auth/registerOrLogin",
"/api/auth/forgotPwd", "/api/style/callback", "/api/auth/parseGoogleAccessToken")); // 排除登录接口
"/api/auth/forgotPwd", "/api/style/callback", "/api/auth/parseGoogleAccessToken","/api/try-on-effects/getHistoricals")); // 排除登录接口
}
/**

View File

@@ -47,7 +47,7 @@ public class TryOnEffectController {
@GetMapping("/getHistoricals")
public ApiResponse<List<? extends BaseVO>> getHistoricals(
@Parameter(description = "服装ID", required = true)
@RequestBody HistoricalDTO historicalDTO) {
@ModelAttribute HistoricalDTO historicalDTO) {
if (CommonConstants.OUTFIT.equals(historicalDTO.getType())){
List<OutfitHisVO> outfitHisVOS = tryOnEffectService.getOutfitHistoricals(historicalDTO);
return ApiResponse.success(outfitHisVOS);

View File

@@ -5,6 +5,10 @@ import lombok.Data;
@Data
public class HistoricalDTO {
@Schema(description = "顾客ID",example = "1")
private Long customerId;
@Schema(description = "进店记录ID",example = "1")
private Long visitRecordId;

View File

@@ -40,7 +40,7 @@ import java.util.concurrent.TimeUnit;
*
* @author AI Assistant
* @since 2024-01-01
/**
* /**
* 试穿效果服务实现类
*/
@Service
@@ -85,7 +85,7 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
CustomerPhoto customerPhoto = customerPhotoService.getById(customerPhotoId);
String customerPhotoUrl = customerPhoto.getPhotoUrl();
if (customerPhotoUrl != null && !customerPhotoUrl.trim().isEmpty()) {
if (imageUrls.isEmpty()){
if (imageUrls.isEmpty()) {
throw BusinessException.parameterRequired("TryOn result");
}
//先放tryon图片后放脸
@@ -116,24 +116,24 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
for (Map<String, String> map : maps) {
String category = map.get("category");
sb.append("a ");
sb.append( category);
sb.append(category);
sb.append(",");
}
prompt = "A full-body, photorealistic professional studio shot of a **young " + outfitRequest.getGender() + "**, mid-20s, with **clear facial features and a confident expression**. The model is centered in the frame.They are **standing in a direct, static, full-view pose** on a **clean, pure white background** **The entire figure, from head to toe, should be in frame and occupy approximately 80% of the vertical space.**.\n" +
"\n" +
"**CRITICAL COMPOSITION INSTRUCTION:**\n" +
"Generate a single, seamless image of the model with a complete and fully visible head,**wearing ALL distinct items("+sb.toString()+")** from the uploaded image. **ALL items MUST be visible and correctly worn in the final outfit.**" +
"Generate a single, seamless image of the model with a complete and fully visible head,**wearing ALL distinct items(" + sb.toString() + ")** from the uploaded image. **ALL items MUST be visible and correctly worn in the final outfit.**" +
"\n" +
"**Placement Detail:** Outerwear must be worn on the outside, and if a bag is present, it must be visible.\n" +
"**Quality:** Ultra-high resolution, The figure should fill the frame as much as possible,studio photography quality. Emphasize **realistic fabric textures and sharp print fidelity**.\n" +
"**Negative Constraints (Exclude):** **NO text, NO borders, NO tables, NO multiple models, NO extra items.** **CRITICAL: NO cropping of the head or face.**";
aiRreultlogicalUrl = AITryOnEffect(prompt, imageUrls);
}else if (tryOnEffectDto.getIsRegenerated() == 1 && imageUrls.size() == 1){
} else if (tryOnEffectDto.getIsRegenerated() == 1 && imageUrls.size() == 1) {
//根据提示词修改图像
aiRreultlogicalUrl = AITryOnEffect(prompt, imageUrls);
}else if (tryOnEffectDto.getIsRegenerated() == 1 && imageUrls.size() > 1){
} else if (tryOnEffectDto.getIsRegenerated() == 1 && imageUrls.size() > 1) {
//换脸
aiRreultlogicalUrl = callFaceSwapAPI(imageUrls);
}
@@ -186,6 +186,7 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
/**
* 添加意见建议
*
* @param suggestion 意见建议实体
* @return 是否添加成功
*/
@@ -260,16 +261,17 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
@Override
public List<TryOnResultVO> getTryOnHistoricals(HistoricalDTO historicalDTO) {
LambdaQueryWrapper<TryOnEffect> tryOnEffectLambdaQueryWrapper = new LambdaQueryWrapper<TryOnEffect>()
.eq(TryOnEffect::getCustomerId, historicalDTO.getCustomerId())
.orderByDesc(TryOnEffect::getCreatedTime);
if (historicalDTO.getVisitRecordId() != null){
if (historicalDTO.getVisitRecordId() != null) {
tryOnEffectLambdaQueryWrapper.eq(TryOnEffect::getVisitRecordId, historicalDTO.getVisitRecordId());
}
if (historicalDTO.getIsLibrary() != null||historicalDTO.getIsLibrary()){
tryOnEffectLambdaQueryWrapper.eq(TryOnEffect::getIsFavorite,1);
if (historicalDTO.getIsLibrary() != null && historicalDTO.getIsLibrary()) {
tryOnEffectLambdaQueryWrapper.eq(TryOnEffect::getIsFavorite, 1);
}
if (CommonConstants.TRYON.equals(historicalDTO.getType())){
if (CommonConstants.TRYON.equals(historicalDTO.getType())) {
tryOnEffectLambdaQueryWrapper.eq(TryOnEffect::getIsRegenerated, 0);
}else if (CommonConstants.GENAI.equals(historicalDTO.getType())){
} else if (CommonConstants.GENAI.equals(historicalDTO.getType())) {
tryOnEffectLambdaQueryWrapper.eq(TryOnEffect::getIsRegenerated, 1);
}
List<TryOnEffect> tryOnEffects = this.list(tryOnEffectLambdaQueryWrapper);
@@ -301,11 +303,13 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
@Override
public List<OutfitHisVO> getOutfitHistoricals(HistoricalDTO historicalDTO) {
LambdaQueryWrapper<Style> styleLambdaQueryWrapper = new LambdaQueryWrapper<Style>().orderByDesc(Style::getCreatedTime);
if (historicalDTO.getVisitRecordId() != null){
LambdaQueryWrapper<Style> styleLambdaQueryWrapper = new LambdaQueryWrapper<Style>()
.eq(Style::getCustomerId, historicalDTO.getCustomerId())
.orderByDesc(Style::getCreatedTime);
if (historicalDTO.getVisitRecordId() != null) {
styleLambdaQueryWrapper.eq(Style::getVisitRecordId, historicalDTO.getVisitRecordId());
}
if (historicalDTO.getIsLibrary() != null||historicalDTO.getIsLibrary()){
if (historicalDTO.getIsLibrary() != null && historicalDTO.getIsLibrary()) {
styleLambdaQueryWrapper.eq(Style::getIsFavorite, 1);
}
List<Style> styles = styleService.list(styleLambdaQueryWrapper);
@@ -637,7 +641,7 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
String finishReason = candidate.getString("finishReason");
if (!"STOP".equals(finishReason)) {
String finishMessage = candidate.getString("finishMessage");
if (finishReason != null && finishReason.equals("IMAGE_SAFETY")){
if (finishReason != null && finishReason.equals("IMAGE_SAFETY")) {
if (finishMessage != null && finishMessage.contains("Try rephrasing the prompt")) {
finishMessage = "Try rephrasing the prompt.If you think this was an error, send feedback.";
throw new BusinessException(finishMessage, "请尝试重新表述提示词。若您认为这是误判,可提交反馈。", ResultEnum.ERROR.getCode());
@@ -684,6 +688,7 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
/**
* 调用换脸API
*
* @param imageUrls 图片URL列表第一个为源图片第二个为目标图片
* @return 换脸后的图片URL
*/
@@ -801,7 +806,6 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
log.info("换脸成功,图片路径: {}", imagePath);
// 下载图片并上传到MinIO
return imagePath;
} else {
@@ -812,7 +816,7 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
log.error("output字段不是数组格式: {}", outputObj);
throw new BusinessException("Invalid output format", "output字段格式不正确", ResultEnum.ERROR.getCode());
}
}else {
} else {
log.error("换脸API响应失败: {}", response);
throw new BusinessException("reface error", "换脸失败", ResultEnum.ERROR.getCode());
}