diff --git a/src/main/java/com/aida/lanecarford/config/WebConfig.java b/src/main/java/com/aida/lanecarford/config/WebConfig.java index bfa9505..7e66fb4 100644 --- a/src/main/java/com/aida/lanecarford/config/WebConfig.java +++ b/src/main/java/com/aida/lanecarford/config/WebConfig.java @@ -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")); // 排除登录接口 } /** diff --git a/src/main/java/com/aida/lanecarford/controller/TryOnEffectController.java b/src/main/java/com/aida/lanecarford/controller/TryOnEffectController.java index ba1e079..5abdbd1 100644 --- a/src/main/java/com/aida/lanecarford/controller/TryOnEffectController.java +++ b/src/main/java/com/aida/lanecarford/controller/TryOnEffectController.java @@ -47,7 +47,7 @@ public class TryOnEffectController { @GetMapping("/getHistoricals") public ApiResponse> getHistoricals( @Parameter(description = "服装ID", required = true) - @RequestBody HistoricalDTO historicalDTO) { + @ModelAttribute HistoricalDTO historicalDTO) { if (CommonConstants.OUTFIT.equals(historicalDTO.getType())){ List outfitHisVOS = tryOnEffectService.getOutfitHistoricals(historicalDTO); return ApiResponse.success(outfitHisVOS); diff --git a/src/main/java/com/aida/lanecarford/dto/HistoricalDTO.java b/src/main/java/com/aida/lanecarford/dto/HistoricalDTO.java index 731dad3..0dc9490 100644 --- a/src/main/java/com/aida/lanecarford/dto/HistoricalDTO.java +++ b/src/main/java/com/aida/lanecarford/dto/HistoricalDTO.java @@ -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; diff --git a/src/main/java/com/aida/lanecarford/service/impl/TryOnEffectServiceImpl.java b/src/main/java/com/aida/lanecarford/service/impl/TryOnEffectServiceImpl.java index 754256a..919b85d 100644 --- a/src/main/java/com/aida/lanecarford/service/impl/TryOnEffectServiceImpl.java +++ b/src/main/java/com/aida/lanecarford/service/impl/TryOnEffectServiceImpl.java @@ -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 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); + 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 0) { log.info("意见建议添加成功 - id: {}", suggestion.getId()); return true; @@ -236,7 +237,7 @@ public class TryOnEffectServiceImpl extends ServiceImpl getTryOnHistoricals(HistoricalDTO historicalDTO) { - LambdaQueryWrapper tryOnEffectLambdaQueryWrapper = new LambdaQueryWrapper() - .orderByDesc(TryOnEffect::getCreatedTime); - if (historicalDTO.getVisitRecordId() != null){ - tryOnEffectLambdaQueryWrapper.eq(TryOnEffect::getVisitRecordId, historicalDTO.getVisitRecordId()); - } - if (historicalDTO.getIsLibrary() != null||historicalDTO.getIsLibrary()){ - tryOnEffectLambdaQueryWrapper.eq(TryOnEffect::getIsFavorite,1); - } - if (CommonConstants.TRYON.equals(historicalDTO.getType())){ - tryOnEffectLambdaQueryWrapper.eq(TryOnEffect::getIsRegenerated, 0); - }else if (CommonConstants.GENAI.equals(historicalDTO.getType())){ - tryOnEffectLambdaQueryWrapper.eq(TryOnEffect::getIsRegenerated, 1); - } - List tryOnEffects = this.list(tryOnEffectLambdaQueryWrapper); - List tryOnResultVos = new ArrayList<>(); - for (TryOnEffect tryOnEffect : tryOnEffects) { - TryOnResultVO tryOnResultVo = new TryOnResultVO(); - tryOnResultVo.setId(tryOnEffect.getId()); - tryOnResultVo.setTryOnUrl(minioUtil.convertToPresignedUrl( - tryOnEffect.getResultImageUrl(), + LambdaQueryWrapper tryOnEffectLambdaQueryWrapper = new LambdaQueryWrapper() + .eq(TryOnEffect::getCustomerId, historicalDTO.getCustomerId()) + .orderByDesc(TryOnEffect::getCreatedTime); + if (historicalDTO.getVisitRecordId() != null) { + tryOnEffectLambdaQueryWrapper.eq(TryOnEffect::getVisitRecordId, historicalDTO.getVisitRecordId()); + } + if (historicalDTO.getIsLibrary() != null && historicalDTO.getIsLibrary()) { + tryOnEffectLambdaQueryWrapper.eq(TryOnEffect::getIsFavorite, 1); + } + if (CommonConstants.TRYON.equals(historicalDTO.getType())) { + tryOnEffectLambdaQueryWrapper.eq(TryOnEffect::getIsRegenerated, 0); + } else if (CommonConstants.GENAI.equals(historicalDTO.getType())) { + tryOnEffectLambdaQueryWrapper.eq(TryOnEffect::getIsRegenerated, 1); + } + List tryOnEffects = this.list(tryOnEffectLambdaQueryWrapper); + List tryOnResultVos = new ArrayList<>(); + for (TryOnEffect tryOnEffect : tryOnEffects) { + TryOnResultVO tryOnResultVo = new TryOnResultVO(); + tryOnResultVo.setId(tryOnEffect.getId()); + tryOnResultVo.setTryOnUrl(minioUtil.convertToPresignedUrl( + tryOnEffect.getResultImageUrl(), + CommonConstants.MINIO_PATH_TIMEOUT + )); + // 如果是原始效果,则获取对应的style图片 + if (tryOnEffect.getIsRegenerated() == 0) { + LambdaQueryWrapper