19 Commits

Author SHA1 Message Date
litianxiang
318309c770 Merge remote-tracking branch 'origin/dev/dev-ltx' into prod/release_1.0
All checks were successful
git commit 控制 连卡佛 back-java prod 分支构建部署 / build_and_deploy (push) Has been skipped
2025-12-24 11:50:59 +08:00
litianxiang
4f149263a5 修改用户信息 2025-12-24 11:49:39 +08:00
fecf9bcb61 更新 docker-compose.yml
All checks were successful
git commit 控制 连卡佛 back-java prod 分支构建部署 / build_and_deploy (push) Has been skipped
2025-12-24 10:46:35 +08:00
litianxiang
190a57c855 Merge branch 'dev/dev' into prod/release_1.0
All checks were successful
git commit 控制 连卡佛 back-java prod 分支构建部署 / build_and_deploy (push) Has been skipped
2025-12-23 14:58:19 +08:00
litianxiang
fd6be37bc5 获取历史数据加入分页 2025-12-23 14:57:36 +08:00
278510aa21 Merge branch 'dev/dev-xp' into prod/release_1.0
All checks were successful
git commit 控制 连卡佛 back-java prod 分支构建部署 / build_and_deploy (push) Has been skipped
2025-12-23 14:31:19 +08:00
f7f221ae62 Merge remote-tracking branch 'origin/prod/release_1.0' into prod/release_1.0
All checks were successful
git commit 控制 连卡佛 back-java prod 分支构建部署 / build_and_deploy (push) Has been skipped
# Conflicts:
#	src/main/java/com/aida/lanecarford/controller/StyleController.java
#	src/main/java/com/aida/lanecarford/service/StyleService.java
#	src/main/java/com/aida/lanecarford/service/impl/StyleServiceImpl.java
2025-12-23 11:46:19 +08:00
litianxiang
76cd268d0e debug:换脸请求参数log
All checks were successful
git commit 控制 连卡佛 back-java prod 分支构建部署 / build_and_deploy (push) Has been skipped
2025-12-23 10:08:10 +08:00
litianxiang
e25f8e0844 fix:适配新的生成,没有styleid的情况
All checks were successful
git commit 控制 连卡佛 back-java prod 分支构建部署 / build_and_deploy (push) Has been skipped
2025-12-22 17:35:34 +08:00
litianxiang
f4bb4b27a2 fix:获取历史记录加入判断条件,只查询成功生成的
All checks were successful
git commit 控制 连卡佛 back-java prod 分支构建部署 / build_and_deploy (push) Has been skipped
2025-12-22 15:37:16 +08:00
litianxiang
10d39ac0c4 Revert "fix:获取历史记录加入判断条件,只查询成功生成的"
This reverts commit 6687d0b5ff.
2025-12-22 15:35:50 +08:00
litianxiang
6687d0b5ff fix:获取历史记录加入判断条件,只查询成功生成的 2025-12-22 15:35:23 +08:00
litianxiang
8eb42c9364 fix:获取历史记录加入顾客id
All checks were successful
git commit 控制 连卡佛 back-java prod 分支构建部署 / build_and_deploy (push) Has been skipped
2025-12-22 15:17:12 +08:00
litianxiang
658149639f Merge remote-tracking branch 'origin/dev/dev' into prod/release_1.0
All checks were successful
git commit 控制 连卡佛 back-java prod 分支构建部署 / build_and_deploy (push) Has been skipped
2025-12-22 14:31:36 +08:00
litianxiang
3df8767c47 Merge remote-tracking branch 'origin/dev/dev-ltx' into dev/dev 2025-12-22 14:30:44 +08:00
litianxiang
3352bc82d9 style表新增喜欢字段 2025-12-22 14:29:06 +08:00
litianxiang
23cb45062f 修改查询历史生成记录的接口,新增outfit点赞接口 2025-12-22 14:28:27 +08:00
3561cd098a Merge branch 'dev/dev-xp' into dev/dev 2025-12-17 11:33:00 +08:00
litianxiang
dba7f09cd9 修改google调用失败提示词 2025-12-15 17:23:11 +08:00
17 changed files with 373 additions and 68 deletions

View File

@@ -4,6 +4,9 @@ services:
build: .
volumes:
# 日志目录映射
- ./log:/log
- ./log:/app/log
ports:
- '10095:8080'
networks:
back_default:
driver: bridge

View File

@@ -10,5 +10,9 @@ public class CommonConstants {
public static final int CONN_TIMEOUT = 30000; // milliseconds
public static final String OUTFIT = "Outfit";
public static final String TRYON = "Try-on";
public static final String GENAI = "Gen-AI";
}

View File

@@ -121,4 +121,12 @@ public class LoginController {
return ApiResponse.success(loginService.parseGoogleAccessToken(accessToken));
}
//修改用户信息
@Operation(summary = "修改用户信息",
description = "传usernameemailpassword三个值password要加密")
@PostMapping("/updateUserInfo")
public ApiResponse<String> updateUserInfo(@RequestBody User user) {
return ApiResponse.success(loginService.updateUserInfo(user));
}
}

View File

@@ -78,6 +78,30 @@ public class StyleController {
return ApiResponse.success(styleService.getOutfitResult(requestIDs));
}
/**
* 设置喜欢的风格
*/
@Operation(summary = "设置喜欢的outfit", description = "将指定风格设置为收藏")
@PostMapping("/set-favorite/{styleId}")
public ApiResponse<Void> setFavoriteStyle(
@Parameter(description = "风格ID", required = true)
@PathVariable Long styleId) {
styleService.setFavoriteStyle(styleId);
return ApiResponse.success();
}
/**
* 取消喜欢的风格
*/
@Operation(summary = "取消喜欢的outfit", description = "取消指定风格的收藏")
@PostMapping("/cancel-favorite/{styleId}")
public ApiResponse<Void> cancelFavoriteStyle(
@Parameter(description = "风格ID", required = true)
@PathVariable Long styleId) {
styleService.cancelFavoriteStyle(styleId);
return ApiResponse.success();
}
@Operation(
summary = "回溯历史对话,重新生成搭配图",
description = "根据当前的穿搭结果,回溯历史穿搭请求数据及历史对话,重新生成搭配"

View File

@@ -1,10 +1,15 @@
package com.aida.lanecarford.controller;
import com.aida.lanecarford.common.ApiResponse;
import com.aida.lanecarford.common.PageResult;
import com.aida.lanecarford.common.constant.CommonConstants;
import com.aida.lanecarford.dto.HistoricalDTO;
import com.aida.lanecarford.entity.Suggestion;
import com.aida.lanecarford.entity.TryOnEffect;
import com.aida.lanecarford.service.TryOnEffectService;
import com.aida.lanecarford.vo.TryOnResultVo;
import com.aida.lanecarford.vo.BaseVO;
import com.aida.lanecarford.vo.OutfitHisVO;
import com.aida.lanecarford.vo.TryOnResultVO;
import io.netty.util.internal.StringUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
@@ -32,29 +37,25 @@ public class TryOnEffectController {
@Operation(summary = "生成试穿效果", description = "根据服装模特照片生成试穿效果其中styleId是必选当二次生成时要带上相关参数比如顾客照片")
@PostMapping("/generate")
public ApiResponse<TryOnResultVo> generateTryOnEffect(
public ApiResponse<TryOnResultVO> generateTryOnEffect(
@Parameter(description = "试穿效果请求参数", required = true)
@Valid @RequestBody TryOnEffect tryOnEffectDto) {
TryOnResultVo tryOnResultVo = tryOnEffectService.generateTryOnEffect(tryOnEffectDto);
TryOnResultVO tryOnResultVo = tryOnEffectService.generateTryOnEffect(tryOnEffectDto);
return ApiResponse.success(tryOnResultVo);
}
@Operation(summary = "获取收藏的试穿效果", description = "对应library页面点击details后的显示参数为进店记录id")
@GetMapping("/favorites/{visitRecordId}")
public ApiResponse<List<TryOnResultVo>> getFavoriteTryOnEffects(
@Parameter(description = "进店记录ID", required = true)
@PathVariable Long visitRecordId) {
List<TryOnResultVo> tryOnResultVos = tryOnEffectService.getFavoriteTryOnEffects(visitRecordId);
@Operation(summary = "获取历史生成记录", description = "根据type进店记录id是否收藏来决定返回的数据支持分页")
@GetMapping("/getHistoricals")
public ApiResponse<PageResult<? extends BaseVO>> getHistoricals(
@Parameter(description = "历史记录查询参数", required = true)
@ModelAttribute HistoricalDTO historicalDTO) {
if (CommonConstants.OUTFIT.equals(historicalDTO.getType())) {
PageResult<OutfitHisVO> outfitHisVOS = tryOnEffectService.getOutfitHistoricals(historicalDTO);
return ApiResponse.success(outfitHisVOS);
} else {
PageResult<TryOnResultVO> tryOnResultVos = tryOnEffectService.getTryOnHistoricals(historicalDTO);
return ApiResponse.success(tryOnResultVos);
}
@GetMapping("/style/{styleId}")
@Operation(summary = "获取某套服装的所有生成结果", description = "对应customize your look页面点击finish后的显示")
public ApiResponse<List<TryOnResultVo>> getTryOnEffectsByStyleId(
@Parameter(description = "服装ID", required = true)
@PathVariable Long styleId) {
List<TryOnResultVo> tryOnResultVos = tryOnEffectService.getTryOnEffectsByStyleId(styleId);
return ApiResponse.success(tryOnResultVos);
}
/**

View File

@@ -0,0 +1,27 @@
package com.aida.lanecarford.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
public class HistoricalDTO {
@Schema(description = "顾客ID", example = "1")
private Long customerId;
@Schema(description = "进店记录ID", example = "1")
private Long visitRecordId;
@Schema(description = "类型", example = "Outfit , Try-on , Gen-AI")
private String type;
@Schema(description = "是否是收藏", example = "true")
private Boolean isLibrary;
@Schema(description = "当前页码从1开始", example = "1")
private Integer pageNum;
@Schema(description = "每页大小", example = "10")
private Integer pageSize;
}

View File

@@ -1,6 +1,7 @@
package com.aida.lanecarford.entity;
import com.baomidou.mybatisplus.annotation.*;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -76,4 +77,11 @@ public class Style extends BaseEntity {
private String errorMessage;
// 注意createdTime、updatedTime 字段已在 BaseEntity 中定义
/**
* 是否喜欢(0-否,1-是)
*/
@Schema(description = "是否喜欢(0-否,1-是)", example = "1", required = false)
@TableField("is_favorite")
private Integer isFavorite;
}

View File

@@ -36,4 +36,6 @@ public interface LoginService extends IService<User> {
LoginVO parseGoogleCredential(String credential) throws ParseException, JOSEException, IOException;
LoginVO parseGoogleAccessToken(String accessToken);
String updateUserInfo(User user);
}

View File

@@ -19,6 +19,18 @@ public interface StyleService extends IService<Style> {
List<OutfitResultVO> getOutfitResult(List<String> requestIDs);
/**
* 设置风格为收藏
* @param styleId 风格ID
*/
void setFavoriteStyle(Long styleId);
/**
* 取消风格的收藏
* @param styleId 风格ID
*/
void cancelFavoriteStyle(Long styleId);
List<String> retrieveAndRegenerate(Long tryOnEffectsId);
}

View File

@@ -1,8 +1,11 @@
package com.aida.lanecarford.service;
import com.aida.lanecarford.common.PageResult;
import com.aida.lanecarford.dto.HistoricalDTO;
import com.aida.lanecarford.entity.Suggestion;
import com.aida.lanecarford.entity.TryOnEffect;
import com.aida.lanecarford.vo.TryOnResultVo;
import com.aida.lanecarford.vo.OutfitHisVO;
import com.aida.lanecarford.vo.TryOnResultVO;
import com.baomidou.mybatisplus.extension.service.IService;
import jakarta.validation.Valid;
@@ -16,9 +19,9 @@ import java.util.List;
*/
public interface TryOnEffectService extends IService<TryOnEffect> {
TryOnResultVo generateTryOnEffect(@Valid TryOnEffect tryOnEffectDto);
TryOnResultVO generateTryOnEffect(@Valid TryOnEffect tryOnEffectDto);
List<TryOnResultVo> getFavoriteTryOnEffects(Long visitRecordId);
List<TryOnResultVO> getFavoriteTryOnEffects(Long visitRecordId);
/**
* 设置试穿效果为收藏
@@ -32,7 +35,7 @@ public interface TryOnEffectService extends IService<TryOnEffect> {
*/
void cancelFavoriteTryOnEffect(Long tryOnId);
List<TryOnResultVo> getTryOnEffectsByStyleId(Long styleId);
List<TryOnResultVO> getTryOnEffectsByStyleId(Long styleId);
/**
* 添加意见建议
@@ -44,4 +47,8 @@ public interface TryOnEffectService extends IService<TryOnEffect> {
String reFace(Long customerPhotoId);
String generateUrl(String prompt, String tryonUrl);
PageResult<TryOnResultVO> getTryOnHistoricals(HistoricalDTO historicalDTO);
PageResult<OutfitHisVO> getOutfitHistoricals(HistoricalDTO historicalDTO);
}

View File

@@ -353,6 +353,66 @@ public class LoginServiceImpl extends ServiceImpl<UserMapper, User> implements L
}
}
@Override
public String updateUserInfo(User user) {
// 1. 获取当前登录用户ID
AuthPrincipalVO userHolder = UserContext.getUserHolder();
if (Objects.isNull(userHolder)) {
throw new BusinessException("User not logged in", "用户未登录", ResultEnum.ERROR.getCode());
}
Long userId = userHolder.getId();
// 2. 验证用户是否存在
User existingUser = getById(userId);
if (Objects.isNull(existingUser)) {
throw new BusinessException("User not found", "用户不存在", ResultEnum.ERROR.getCode());
}
// 3. 构建更新条件,只更新有值的字段
UpdateWrapper<User> updateWrapper = new UpdateWrapper<>();
updateWrapper.lambda().eq(User::getId, userId);
boolean hasUpdate = false;
// 如果username有值则更新
if (!StringUtil.isNullOrEmpty(user.getUsername())) {
updateWrapper.lambda().set(User::getUsername, user.getUsername());
hasUpdate = true;
}
// 如果email有值则更新
if (!StringUtil.isNullOrEmpty(user.getEmail())) {
updateWrapper.lambda().set(User::getEmail, user.getEmail());
hasUpdate = true;
}
// 如果password有值则更新
if (!StringUtil.isNullOrEmpty(user.getPassword())) {
updateWrapper.lambda().set(User::getPassword, user.getPassword());
hasUpdate = true;
}
// 4. 如果没有需要更新的字段,返回提示信息
if (!hasUpdate) {
return "No fields to update";
}
// 5. 执行更新
boolean updated = update(updateWrapper);
if (updated) {
log.info("用户信息更新成功 userId={}, updatedFields=username:{}, email:{}, password:{}",
userId,
!StringUtil.isNullOrEmpty(user.getUsername()),
!StringUtil.isNullOrEmpty(user.getEmail()),
!StringUtil.isNullOrEmpty(user.getPassword()));
return "User information updated successfully";
} else {
throw new BusinessException("Failed to update user information", "更新用户信息失败", ResultEnum.ERROR.getCode());
}
}
private static final String TOKEN_URL = "https://oauth2.googleapis.com/token";
public GoogleUser getGoogleUserFromCode(String code) {

View File

@@ -4,6 +4,7 @@ import com.aida.lanecarford.common.constant.CommonConstants;
import com.aida.lanecarford.common.constant.RedisURIConstants;
import com.aida.lanecarford.common.enums.StatusEnum;
import com.aida.lanecarford.common.enums.StylistPathEnum;
import com.aida.lanecarford.common.response.ResultEnum;
import com.aida.lanecarford.dto.OutfitCallbackDTO;
import com.aida.lanecarford.dto.RequestOutfitDTO;
import com.aida.lanecarford.entity.OutfitRequest;
@@ -231,6 +232,40 @@ public class StyleServiceImpl extends ServiceImpl<StyleMapper, Style> implements
return resultVOS;
}
@Override
public void setFavoriteStyle(Long styleId) {
if (styleId == null) {
throw new BusinessException("Style ID is required", "风格ID不能为空", ResultEnum.PARAMETER_ERROR.getCode());
}
Style style = this.getById(styleId);
if (style == null) {
throw new BusinessException("Style not found", "风格不存在", ResultEnum.FAIL.getCode());
}
// 设置为收藏
style.setIsFavorite(1);
this.updateById(style);
log.info("风格ID: {} 已设置为收藏", styleId);
}
@Override
public void cancelFavoriteStyle(Long styleId) {
if (styleId == null) {
throw new BusinessException("Style ID is required", "风格ID不能为空", ResultEnum.PARAMETER_ERROR.getCode());
}
Style style = this.getById(styleId);
if (style == null) {
throw new BusinessException("Style not found", "风格不存在", ResultEnum.FAIL.getCode());
}
// 取消收藏
style.setIsFavorite(0);
this.updateById(style);
log.info("风格ID: {} 已取消收藏", styleId);
}
public SessionRecord saveOrUpdateSession(String sessionId, Long visitsId, String summary, List<String> occasion) {
// 判断同一次进店记录中当前会话id是否已存在
QueryWrapper<SessionRecord> queryWrapper = new QueryWrapper<>();

View File

@@ -1,11 +1,13 @@
package com.aida.lanecarford.service.impl;
import cn.hutool.json.JSONObject;
import com.aida.lanecarford.common.PageResult;
import com.aida.lanecarford.common.constant.CommonConstants;
import com.aida.lanecarford.config.MinioConfig;
import com.aida.lanecarford.config.FaceSwapConfig;
import com.aida.lanecarford.common.response.ResultEnum;
import com.aida.lanecarford.common.constant.MinioFileConstants;
import com.aida.lanecarford.dto.HistoricalDTO;
import com.aida.lanecarford.entity.*;
import com.aida.lanecarford.exception.BusinessException;
import com.aida.lanecarford.mapper.CustomerMapper;
@@ -16,10 +18,13 @@ import com.aida.lanecarford.service.*;
import com.aida.lanecarford.entity.Suggestion;
import com.aida.lanecarford.util.MinioUtil;
import com.aida.lanecarford.util.StringListConverter;
import com.aida.lanecarford.vo.TryOnResultVo;
import com.aida.lanecarford.vo.OutfitHisVO;
import com.aida.lanecarford.vo.TryOnResultVO;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.auth.oauth2.GoogleCredentials;
import lombok.RequiredArgsConstructor;
@@ -38,7 +43,7 @@ import java.util.concurrent.TimeUnit;
*
* @author AI Assistant
* @since 2024-01-01
/**
* /**
* 试穿效果服务实现类
*/
@Service
@@ -46,12 +51,7 @@ import java.util.concurrent.TimeUnit;
public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOnEffect> implements TryOnEffectService {
private static final Logger log = LoggerFactory.getLogger(TryOnEffectServiceImpl.class);
private final StyleService styleService;
private final ModelPhotoService modelPhotoService;
private final CustomerPhotoService customerPhotoService;
private final ImageCompositionService imageCompositionService;
private final CustomerMapper customerMapper;
private final MinioUtil minioUtil;
private final MinioConfig minioConfig;
private final FaceSwapConfig faceSwapConfig;
@@ -59,7 +59,7 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
private final OutfitRequestMapper outfitRequestMapper;
@Override
public TryOnResultVo generateTryOnEffect(TryOnEffect tryOnEffectDto) {
public TryOnResultVO generateTryOnEffect(TryOnEffect tryOnEffectDto) {
Integer isRegenerated = tryOnEffectDto.getIsRegenerated();
String toAIlogicalUrl = null;
String prompt = null;
@@ -74,7 +74,13 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
throw BusinessException.parameterRequired("originalTryOnId");
}
TryOnEffect originalTryOn = this.getById(originalTryOnId);
if (tryOnEffectDto.getStyleId()==null){
tryOnEffectDto.setStyleId(originalTryOn.getStyleId());
}
String resultImageUrl = originalTryOn.getResultImageUrl();
if (tryOnEffectDto.getStyleId()==null){
tryOnEffectDto.setStyleId(originalTryOn.getStyleId());
}
imageUrls.add(resultImageUrl);
Long customerPhotoId = tryOnEffectDto.getCustomerPhotoId();
@@ -140,8 +146,8 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
tryOnEffectDto.setGenerationStatus("completed");
this.saveOrUpdate(tryOnEffectDto);
TryOnResultVo tryOnResultVo = new TryOnResultVo();
tryOnResultVo.setTryOnId(tryOnEffectDto.getId());
TryOnResultVO tryOnResultVo = new TryOnResultVO();
tryOnResultVo.setId(tryOnEffectDto.getId());
tryOnResultVo.setTryOnUrl(minioUtil.convertToPresignedUrl(aiRreultlogicalUrl, CommonConstants.MINIO_PATH_TIMEOUT));
@@ -150,15 +156,15 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
//library页面点击details后的显示
@Override
public List<TryOnResultVo> getFavoriteTryOnEffects(Long visitRecordId) {
public List<TryOnResultVO> getFavoriteTryOnEffects(Long visitRecordId) {
List<TryOnEffect> tryOnEffects = this.list(new LambdaQueryWrapper<TryOnEffect>()
.eq(TryOnEffect::getVisitRecordId, visitRecordId)
.eq(TryOnEffect::getIsFavorite, 1)
.orderByAsc(TryOnEffect::getCreatedTime));
List<TryOnResultVo> tryOnResultVos = new ArrayList<>();
.orderByDesc(TryOnEffect::getCreatedTime));
List<TryOnResultVO> tryOnResultVos = new ArrayList<>();
for (TryOnEffect tryOnEffect : tryOnEffects) {
TryOnResultVo tryOnResultVo = new TryOnResultVo();
tryOnResultVo.setTryOnId(tryOnEffect.getId());
TryOnResultVO tryOnResultVo = new TryOnResultVO();
tryOnResultVo.setId(tryOnEffect.getId());
// 使用新的API获取预签名URL数据库存储的是逻辑URL
tryOnResultVo.setTryOnUrl(minioUtil.convertToPresignedUrl(
tryOnEffect.getResultImageUrl(),
@@ -184,6 +190,7 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
/**
* 添加意见建议
*
* @param suggestion 意见建议实体
* @return 是否添加成功
*/
@@ -255,16 +262,96 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
return minioUtil.convertToPresignedUrl(aiRreultlogicalUrl, CommonConstants.MINIO_PATH_TIMEOUT);
}
@Override
public PageResult<TryOnResultVO> getTryOnHistoricals(HistoricalDTO historicalDTO) {
LambdaQueryWrapper<TryOnEffect> tryOnEffectLambdaQueryWrapper = new LambdaQueryWrapper<TryOnEffect>()
.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);
}
long current = historicalDTO.getPageNum() == null || historicalDTO.getPageNum() <= 0 ? 1L : historicalDTO.getPageNum();
long size = historicalDTO.getPageSize() == null || historicalDTO.getPageSize() <= 0 ? 10L : historicalDTO.getPageSize();
IPage<TryOnEffect> page = this.page(new Page<>(current, size), tryOnEffectLambdaQueryWrapper);
List<TryOnResultVO> tryOnResultVos = new ArrayList<>();
for (TryOnEffect tryOnEffect : page.getRecords()) {
TryOnResultVO tryOnResultVo = new TryOnResultVO();
tryOnResultVo.setId(tryOnEffect.getId());
tryOnResultVo.setTryOnUrl(minioUtil.convertToPresignedUrl(
tryOnEffect.getResultImageUrl(),
CommonConstants.MINIO_PATH_TIMEOUT
));
// 如果是原始效果则获取对应的style图片
if (tryOnEffect.getIsRegenerated() == 0) {
LambdaQueryWrapper<Style> styleLambdaQueryWrapper = new LambdaQueryWrapper<>();
styleLambdaQueryWrapper.eq(Style::getId, tryOnEffect.getStyleId()).select(Style::getStyleImageUrl);
Style style = styleService.getOne(styleLambdaQueryWrapper);
tryOnResultVo.setStyleUrl(minioUtil.convertToPresignedUrl(
style.getStyleImageUrl(),
CommonConstants.MINIO_PATH_TIMEOUT
));
}
tryOnResultVo.setIsRegenerated(tryOnEffect.getIsRegenerated());
tryOnResultVo.setIsFavorite(tryOnEffect.getIsFavorite());
tryOnResultVos.add(tryOnResultVo);
}
return new PageResult<>(tryOnResultVos, page.getTotal(), page.getCurrent(), page.getSize());
}
@Override
public PageResult<OutfitHisVO> getOutfitHistoricals(HistoricalDTO historicalDTO) {
LambdaQueryWrapper<Style> styleLambdaQueryWrapper = new LambdaQueryWrapper<Style>()
.eq(Style::getCustomerId, historicalDTO.getCustomerId())
.eq(Style::getGenerationStatus, 1)
.orderByDesc(Style::getCreatedTime);
if (historicalDTO.getVisitRecordId() != null) {
styleLambdaQueryWrapper.eq(Style::getVisitRecordId, historicalDTO.getVisitRecordId());
}
if (historicalDTO.getIsLibrary() != null && historicalDTO.getIsLibrary()) {
styleLambdaQueryWrapper.eq(Style::getIsFavorite, 1);
}
long current = historicalDTO.getPageNum() == null || historicalDTO.getPageNum() <= 0 ? 1L : historicalDTO.getPageNum();
long size = historicalDTO.getPageSize() == null || historicalDTO.getPageSize() <= 0 ? 10L : historicalDTO.getPageSize();
IPage<Style> page = styleService.page(new Page<>(current, size), styleLambdaQueryWrapper);
List<OutfitHisVO> outfitHisVos = new ArrayList<>();
for (Style style : page.getRecords()) {
OutfitHisVO outfitHisVo = new OutfitHisVO();
outfitHisVo.setId(style.getId());
outfitHisVo.setUrl(minioUtil.convertToPresignedUrl(
style.getStyleImageUrl(),
CommonConstants.MINIO_PATH_TIMEOUT
));
outfitHisVo.setIsFavorite(style.getIsFavorite());
outfitHisVos.add(outfitHisVo);
}
return new PageResult<>(outfitHisVos, page.getTotal(), page.getCurrent(), page.getSize());
}
//目前用于customize your look页面点击finish后的显示
@Override
public List<TryOnResultVo> getTryOnEffectsByStyleId(Long styleId) {
public List<TryOnResultVO> getTryOnEffectsByStyleId(Long styleId) {
List<TryOnEffect> tryOnEffects = this.list(new LambdaQueryWrapper<TryOnEffect>()
.eq(TryOnEffect::getStyleId, styleId)
.orderByAsc(TryOnEffect::getCreatedTime));
List<TryOnResultVo> tryOnResultVos = new ArrayList<>();
.orderByDesc(TryOnEffect::getCreatedTime));
List<TryOnResultVO> tryOnResultVos = new ArrayList<>();
for (TryOnEffect tryOnEffect : tryOnEffects) {
TryOnResultVo tryOnResultVo = new TryOnResultVo();
tryOnResultVo.setTryOnId(tryOnEffect.getId());
TryOnResultVO tryOnResultVo = new TryOnResultVO();
tryOnResultVo.setId(tryOnEffect.getId());
// 使用新的API获取预签名URL数据库存储的是逻辑URL
tryOnResultVo.setTryOnUrl(minioUtil.convertToPresignedUrl(
tryOnEffect.getResultImageUrl(),
@@ -402,7 +489,7 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
return processGoogleAPIResponse(response);
} catch (Exception e) {
log.error("调用Google API失败: {}", e.getMessage(), e);
throw new BusinessException("Google API call failed", "Google API调用失败", ResultEnum.ERROR.getCode());
throw new BusinessException("Generation timed out. Please try again later.", "生成超时,请稍后再试", ResultEnum.ERROR.getCode());
}
}
@@ -616,6 +703,7 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
/**
* 调用换脸API
*
* @param imageUrls 图片URL列表第一个为源图片第二个为目标图片
* @return 换脸后的图片URL
*/
@@ -638,9 +726,11 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
requestBody.put("input_face", inputFaceUrl);
requestBody.put("threshold", 0.2);
log.info("换脸API请求体: {}", requestBody.toString());
// 调用换脸API
String response = sendFaceSwapRequest(faceSwapConfig.getRefaceUrl(), requestBody.toString());
// 处理响应
return processFaceSwapResponse(response);
@@ -733,7 +823,6 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
log.info("换脸成功,图片路径: {}", imagePath);
// 下载图片并上传到MinIO
return imagePath;
} else {

View File

@@ -0,0 +1,15 @@
package com.aida.lanecarford.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
@Data
public class BaseVO implements Serializable {
private static final long serialVersionUID = 10007L;
@Schema(description = "ID")
private Long id;
}

View File

@@ -0,0 +1,11 @@
package com.aida.lanecarford.vo;
import lombok.Data;
@Data
public class OutfitHisVO extends BaseVO {
private String url;
private Integer isFavorite;
}

View File

@@ -3,9 +3,7 @@ package com.aida.lanecarford.vo;
import lombok.Data;
@Data
public class TryOnResultVo {
private Long tryOnId;
public class TryOnResultVO extends BaseVO {
private String tryOnUrl;

View File

@@ -71,6 +71,7 @@ CREATE TABLE `styles` (
`style_image_url` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '风格图片URL',
`python_request_id` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Python请求ID',
`generation_status` tinyint DEFAULT '0' COMMENT '生成状态(0-处理中,1-已完成,2-失败)',
`is_favorite` tinyint NOT NULL DEFAULT '0' COMMENT '是否喜欢(0-否,1-是)',
`items` json DEFAULT NULL COMMENT '单品唯一标识',
`error_message` text COLLATE utf8mb4_unicode_ci COMMENT '错误信息',
`created_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',