Merge remote-tracking branch 'origin/dev/dev' into prod/release_1.0
This commit is contained in:
@@ -1,10 +1,13 @@
|
|||||||
package com.aida.lanecarford.controller;
|
package com.aida.lanecarford.controller;
|
||||||
|
|
||||||
import com.aida.lanecarford.common.ApiResponse;
|
import com.aida.lanecarford.common.ApiResponse;
|
||||||
|
import com.aida.lanecarford.common.response.ResultEnum;
|
||||||
import com.aida.lanecarford.entity.Suggestion;
|
import com.aida.lanecarford.entity.Suggestion;
|
||||||
import com.aida.lanecarford.entity.TryOnEffect;
|
import com.aida.lanecarford.entity.TryOnEffect;
|
||||||
|
import com.aida.lanecarford.exception.BusinessException;
|
||||||
import com.aida.lanecarford.service.TryOnEffectService;
|
import com.aida.lanecarford.service.TryOnEffectService;
|
||||||
import com.aida.lanecarford.vo.TryOnResultVo;
|
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.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
@@ -12,6 +15,7 @@ import jakarta.validation.Valid;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -88,4 +92,29 @@ public class TryOnEffectController {
|
|||||||
tryOnEffectService.addComment(suggestion);
|
tryOnEffectService.addComment(suggestion);
|
||||||
return ApiResponse.success();
|
return ApiResponse.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 首页默认图换脸演示
|
||||||
|
*/
|
||||||
|
@Operation(summary = "首页点击换脸", description = "传入上传顾客照片后得到的ID")
|
||||||
|
@PostMapping("/reFace")
|
||||||
|
public ApiResponse<Void> reFace(@Nullable @RequestParam Long customerPhotoId,
|
||||||
|
@Nullable @RequestParam String prompt,
|
||||||
|
@Nullable @RequestParam String tryonUrl) {
|
||||||
|
if (customerPhotoId == null&& StringUtil.isNullOrEmpty(prompt)&& StringUtil.isNullOrEmpty(tryonUrl)){
|
||||||
|
return ApiResponse.error("system error:Parameter null");
|
||||||
|
}
|
||||||
|
String result = "";
|
||||||
|
if (StringUtil.isNullOrEmpty(prompt)){
|
||||||
|
//换脸
|
||||||
|
result = tryOnEffectService.reFace(customerPhotoId);
|
||||||
|
}else {
|
||||||
|
if (StringUtil.isNullOrEmpty(tryonUrl)){
|
||||||
|
return ApiResponse.error("system error:Parameter null");
|
||||||
|
}
|
||||||
|
//根据提示词修改图像
|
||||||
|
result = tryOnEffectService.generateUrl(prompt,tryonUrl);
|
||||||
|
}
|
||||||
|
return ApiResponse.success(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -40,4 +40,8 @@ public interface TryOnEffectService extends IService<TryOnEffect> {
|
|||||||
* @return 是否添加成功
|
* @return 是否添加成功
|
||||||
*/
|
*/
|
||||||
boolean addComment(Suggestion suggestion);
|
boolean addComment(Suggestion suggestion);
|
||||||
|
|
||||||
|
String reFace(Long customerPhotoId);
|
||||||
|
|
||||||
|
String generateUrl(String prompt, String tryonUrl);
|
||||||
}
|
}
|
||||||
@@ -206,6 +206,43 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String reFace(Long customerPhotoId) {
|
||||||
|
|
||||||
|
List<String> imageUrls = new ArrayList<>();
|
||||||
|
//默认展示图片
|
||||||
|
imageUrls.add("lanecarford/try_on_result/default.jpg");
|
||||||
|
|
||||||
|
if (customerPhotoId != null) {
|
||||||
|
//根据id查到对应customerurl
|
||||||
|
CustomerPhoto customerPhoto = customerPhotoService.getById(customerPhotoId);
|
||||||
|
String customerPhotoUrl = customerPhoto.getPhotoUrl();
|
||||||
|
if (customerPhotoUrl != null && !customerPhotoUrl.trim().isEmpty()) {
|
||||||
|
imageUrls.add(customerPhotoUrl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String aiRreultlogicalUrl = callFaceSwapAPI(imageUrls);
|
||||||
|
String presignedUrl = minioUtil.getPresignedUrl(aiRreultlogicalUrl, CommonConstants.MINIO_PATH_TIMEOUT);
|
||||||
|
return presignedUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String generateUrl(String prompt, String tryonUrl) {
|
||||||
|
int startIndex = tryonUrl.indexOf("lanecarford");
|
||||||
|
String aiRreultlogicalUrl = "";
|
||||||
|
if (startIndex != -1) {
|
||||||
|
// 找到jpg的位置并加上jpg的长度
|
||||||
|
int endIndex = tryonUrl.indexOf(".jpg") + ".jpg".length();
|
||||||
|
if (endIndex != -1) {
|
||||||
|
String resultString = tryonUrl.substring(startIndex, endIndex);
|
||||||
|
aiRreultlogicalUrl = AITryOnEffect(prompt, Arrays.asList(resultString));
|
||||||
|
} else {
|
||||||
|
log.error("不是换脸后的url或者换脸结果有误");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return minioUtil.convertToPresignedUrl(aiRreultlogicalUrl, CommonConstants.MINIO_PATH_TIMEOUT);
|
||||||
|
}
|
||||||
|
|
||||||
//目前用于customize your look页面点击finish后的显示
|
//目前用于customize your look页面点击finish后的显示
|
||||||
@Override
|
@Override
|
||||||
public List<TryOnResultVo> getTryOnEffectsByStyleId(Long styleId) {
|
public List<TryOnResultVo> getTryOnEffectsByStyleId(Long styleId) {
|
||||||
|
|||||||
Reference in New Issue
Block a user