|
|
|
@@ -1,6 +1,7 @@
|
|
|
|
package com.aida.lanecarford.service.impl;
|
|
|
|
package com.aida.lanecarford.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
|
|
|
|
|
import com.aida.lanecarford.common.PageResult;
|
|
|
|
import com.aida.lanecarford.common.constant.CommonConstants;
|
|
|
|
import com.aida.lanecarford.common.constant.CommonConstants;
|
|
|
|
import com.aida.lanecarford.config.MinioConfig;
|
|
|
|
import com.aida.lanecarford.config.MinioConfig;
|
|
|
|
import com.aida.lanecarford.config.FaceSwapConfig;
|
|
|
|
import com.aida.lanecarford.config.FaceSwapConfig;
|
|
|
|
@@ -22,6 +23,8 @@ import com.aida.lanecarford.vo.TryOnResultVO;
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
import com.google.auth.oauth2.GoogleCredentials;
|
|
|
|
import com.google.auth.oauth2.GoogleCredentials;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
@@ -48,12 +51,7 @@ import java.util.concurrent.TimeUnit;
|
|
|
|
public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOnEffect> implements TryOnEffectService {
|
|
|
|
public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOnEffect> implements TryOnEffectService {
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(TryOnEffectServiceImpl.class);
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(TryOnEffectServiceImpl.class);
|
|
|
|
private final StyleService styleService;
|
|
|
|
private final StyleService styleService;
|
|
|
|
private final ModelPhotoService modelPhotoService;
|
|
|
|
|
|
|
|
private final CustomerPhotoService customerPhotoService;
|
|
|
|
private final CustomerPhotoService customerPhotoService;
|
|
|
|
private final ImageCompositionService imageCompositionService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final CustomerMapper customerMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final MinioUtil minioUtil;
|
|
|
|
private final MinioUtil minioUtil;
|
|
|
|
private final MinioConfig minioConfig;
|
|
|
|
private final MinioConfig minioConfig;
|
|
|
|
private final FaceSwapConfig faceSwapConfig;
|
|
|
|
private final FaceSwapConfig faceSwapConfig;
|
|
|
|
@@ -80,6 +78,9 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
|
|
|
|
tryOnEffectDto.setStyleId(originalTryOn.getStyleId());
|
|
|
|
tryOnEffectDto.setStyleId(originalTryOn.getStyleId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String resultImageUrl = originalTryOn.getResultImageUrl();
|
|
|
|
String resultImageUrl = originalTryOn.getResultImageUrl();
|
|
|
|
|
|
|
|
if (tryOnEffectDto.getStyleId()==null){
|
|
|
|
|
|
|
|
tryOnEffectDto.setStyleId(originalTryOn.getStyleId());
|
|
|
|
|
|
|
|
}
|
|
|
|
imageUrls.add(resultImageUrl);
|
|
|
|
imageUrls.add(resultImageUrl);
|
|
|
|
|
|
|
|
|
|
|
|
Long customerPhotoId = tryOnEffectDto.getCustomerPhotoId();
|
|
|
|
Long customerPhotoId = tryOnEffectDto.getCustomerPhotoId();
|
|
|
|
@@ -262,7 +263,7 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<TryOnResultVO> getTryOnHistoricals(HistoricalDTO historicalDTO) {
|
|
|
|
public PageResult<TryOnResultVO> getTryOnHistoricals(HistoricalDTO historicalDTO) {
|
|
|
|
LambdaQueryWrapper<TryOnEffect> tryOnEffectLambdaQueryWrapper = new LambdaQueryWrapper<TryOnEffect>()
|
|
|
|
LambdaQueryWrapper<TryOnEffect> tryOnEffectLambdaQueryWrapper = new LambdaQueryWrapper<TryOnEffect>()
|
|
|
|
.eq(TryOnEffect::getCustomerId, historicalDTO.getCustomerId())
|
|
|
|
.eq(TryOnEffect::getCustomerId, historicalDTO.getCustomerId())
|
|
|
|
.orderByDesc(TryOnEffect::getCreatedTime);
|
|
|
|
.orderByDesc(TryOnEffect::getCreatedTime);
|
|
|
|
@@ -277,9 +278,14 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
|
|
|
|
} else if (CommonConstants.GENAI.equals(historicalDTO.getType())) {
|
|
|
|
} else if (CommonConstants.GENAI.equals(historicalDTO.getType())) {
|
|
|
|
tryOnEffectLambdaQueryWrapper.eq(TryOnEffect::getIsRegenerated, 1);
|
|
|
|
tryOnEffectLambdaQueryWrapper.eq(TryOnEffect::getIsRegenerated, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
List<TryOnEffect> tryOnEffects = this.list(tryOnEffectLambdaQueryWrapper);
|
|
|
|
|
|
|
|
|
|
|
|
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<>();
|
|
|
|
List<TryOnResultVO> tryOnResultVos = new ArrayList<>();
|
|
|
|
for (TryOnEffect tryOnEffect : tryOnEffects) {
|
|
|
|
for (TryOnEffect tryOnEffect : page.getRecords()) {
|
|
|
|
TryOnResultVO tryOnResultVo = new TryOnResultVO();
|
|
|
|
TryOnResultVO tryOnResultVo = new TryOnResultVO();
|
|
|
|
tryOnResultVo.setId(tryOnEffect.getId());
|
|
|
|
tryOnResultVo.setId(tryOnEffect.getId());
|
|
|
|
tryOnResultVo.setTryOnUrl(minioUtil.convertToPresignedUrl(
|
|
|
|
tryOnResultVo.setTryOnUrl(minioUtil.convertToPresignedUrl(
|
|
|
|
@@ -301,11 +307,11 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
|
|
|
|
tryOnResultVo.setIsFavorite(tryOnEffect.getIsFavorite());
|
|
|
|
tryOnResultVo.setIsFavorite(tryOnEffect.getIsFavorite());
|
|
|
|
tryOnResultVos.add(tryOnResultVo);
|
|
|
|
tryOnResultVos.add(tryOnResultVo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return tryOnResultVos;
|
|
|
|
return new PageResult<>(tryOnResultVos, page.getTotal(), page.getCurrent(), page.getSize());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<OutfitHisVO> getOutfitHistoricals(HistoricalDTO historicalDTO) {
|
|
|
|
public PageResult<OutfitHisVO> getOutfitHistoricals(HistoricalDTO historicalDTO) {
|
|
|
|
LambdaQueryWrapper<Style> styleLambdaQueryWrapper = new LambdaQueryWrapper<Style>()
|
|
|
|
LambdaQueryWrapper<Style> styleLambdaQueryWrapper = new LambdaQueryWrapper<Style>()
|
|
|
|
.eq(Style::getCustomerId, historicalDTO.getCustomerId())
|
|
|
|
.eq(Style::getCustomerId, historicalDTO.getCustomerId())
|
|
|
|
.eq(Style::getGenerationStatus, 1)
|
|
|
|
.eq(Style::getGenerationStatus, 1)
|
|
|
|
@@ -316,9 +322,14 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
|
|
|
|
if (historicalDTO.getIsLibrary() != null && historicalDTO.getIsLibrary()) {
|
|
|
|
if (historicalDTO.getIsLibrary() != null && historicalDTO.getIsLibrary()) {
|
|
|
|
styleLambdaQueryWrapper.eq(Style::getIsFavorite, 1);
|
|
|
|
styleLambdaQueryWrapper.eq(Style::getIsFavorite, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
List<Style> styles = styleService.list(styleLambdaQueryWrapper);
|
|
|
|
|
|
|
|
|
|
|
|
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<>();
|
|
|
|
List<OutfitHisVO> outfitHisVos = new ArrayList<>();
|
|
|
|
for (Style style : styles) {
|
|
|
|
for (Style style : page.getRecords()) {
|
|
|
|
OutfitHisVO outfitHisVo = new OutfitHisVO();
|
|
|
|
OutfitHisVO outfitHisVo = new OutfitHisVO();
|
|
|
|
outfitHisVo.setId(style.getId());
|
|
|
|
outfitHisVo.setId(style.getId());
|
|
|
|
outfitHisVo.setUrl(minioUtil.convertToPresignedUrl(
|
|
|
|
outfitHisVo.setUrl(minioUtil.convertToPresignedUrl(
|
|
|
|
@@ -328,7 +339,7 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
|
|
|
|
outfitHisVo.setIsFavorite(style.getIsFavorite());
|
|
|
|
outfitHisVo.setIsFavorite(style.getIsFavorite());
|
|
|
|
outfitHisVos.add(outfitHisVo);
|
|
|
|
outfitHisVos.add(outfitHisVo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return outfitHisVos;
|
|
|
|
return new PageResult<>(outfitHisVos, page.getTotal(), page.getCurrent(), page.getSize());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//目前用于customize your look页面点击finish后的显示
|
|
|
|
//目前用于customize your look页面点击finish后的显示
|
|
|
|
|