Compare commits
2 Commits
dev/dev
...
278510aa21
| Author | SHA1 | Date | |
|---|---|---|---|
| 278510aa21 | |||
| 91eb21aa84 |
@@ -2,7 +2,6 @@ package com.aida.lanecarford.common.security;
|
||||
|
||||
import com.aida.lanecarford.common.security.config.JwtProperties;
|
||||
import com.aida.lanecarford.common.security.context.UserContext;
|
||||
import com.aida.lanecarford.exception.BusinessException;
|
||||
import com.aida.lanecarford.util.CacheUtil;
|
||||
import com.aida.lanecarford.vo.AuthPrincipalVO;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@@ -25,7 +24,7 @@ public class JwtInterceptor implements HandlerInterceptor {
|
||||
private final JwtProperties jwtProperties;
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
|
||||
if ("OPTIONS".equalsIgnoreCase(request.getMethod())) {
|
||||
return true;
|
||||
}
|
||||
@@ -41,7 +40,8 @@ public class JwtInterceptor implements HandlerInterceptor {
|
||||
String extracted = jwtUtil.extractUserinfo(jwtToken);
|
||||
if (StringUtil.isNullOrEmpty(extracted)) {
|
||||
log.warn("TOKEN已过期,请重新登录!(token without userInfo)");
|
||||
throw new BusinessException("Token has expired, please log in again.");
|
||||
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
||||
// throw new BusinessException("Token has expired, please log in again.");
|
||||
}
|
||||
|
||||
AuthPrincipalVO authPrincipalVO = JSONObject.parseObject(extracted, AuthPrincipalVO.class);
|
||||
@@ -54,10 +54,12 @@ public class JwtInterceptor implements HandlerInterceptor {
|
||||
|
||||
if (Objects.isNull(token)) {
|
||||
log.warn("TOKEN已过期,请重新登录!(local cache empty)");
|
||||
throw new BusinessException("Token has expired, please log in again.");
|
||||
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
||||
// throw new BusinessException("Token has expired, please log in again.");
|
||||
} else if (!token.toString().equals(jwtToken)) {
|
||||
log.warn("TOKEN已过期,请重新登录!(token not match local cache)");
|
||||
throw new BusinessException("Token has expired, please log in again.");
|
||||
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
||||
// throw new BusinessException("Token has expired, please log in again.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
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;
|
||||
@@ -44,16 +43,16 @@ public class TryOnEffectController {
|
||||
return ApiResponse.success(tryOnResultVo);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取历史生成记录", description = "根据type,进店记录id,是否收藏来决定返回的数据,支持分页")
|
||||
@Operation(summary = "获取历史生成记录", description = "根据type,进店记录id,是否收藏来决定返回的数据")
|
||||
@GetMapping("/getHistoricals")
|
||||
public ApiResponse<PageResult<? extends BaseVO>> getHistoricals(
|
||||
@Parameter(description = "历史记录查询参数", required = true)
|
||||
public ApiResponse<List<? extends BaseVO>> getHistoricals(
|
||||
@Parameter(description = "服装ID", required = true)
|
||||
@ModelAttribute HistoricalDTO historicalDTO) {
|
||||
if (CommonConstants.OUTFIT.equals(historicalDTO.getType())) {
|
||||
PageResult<OutfitHisVO> outfitHisVOS = tryOnEffectService.getOutfitHistoricals(historicalDTO);
|
||||
if (CommonConstants.OUTFIT.equals(historicalDTO.getType())){
|
||||
List<OutfitHisVO> outfitHisVOS = tryOnEffectService.getOutfitHistoricals(historicalDTO);
|
||||
return ApiResponse.success(outfitHisVOS);
|
||||
} else {
|
||||
PageResult<TryOnResultVO> tryOnResultVos = tryOnEffectService.getTryOnHistoricals(historicalDTO);
|
||||
}else {
|
||||
List<TryOnResultVO> tryOnResultVos = tryOnEffectService.getTryOnHistoricals(historicalDTO);
|
||||
return ApiResponse.success(tryOnResultVos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,22 +6,16 @@ import lombok.Data;
|
||||
@Data
|
||||
public class HistoricalDTO {
|
||||
|
||||
@Schema(description = "顾客ID", example = "1")
|
||||
@Schema(description = "顾客ID",example = "1")
|
||||
private Long customerId;
|
||||
|
||||
@Schema(description = "进店记录ID", example = "1")
|
||||
@Schema(description = "进店记录ID",example = "1")
|
||||
private Long visitRecordId;
|
||||
|
||||
@Schema(description = "类型", example = "Outfit , Try-on , Gen-AI")
|
||||
@Schema(description = "类型",example = "Outfit , Try-on , Gen-AI")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "是否是收藏", example = "true")
|
||||
@Schema(description = "是否是收藏",example = "true")
|
||||
private Boolean isLibrary;
|
||||
|
||||
@Schema(description = "当前页码,从1开始", example = "1")
|
||||
private Integer pageNum;
|
||||
|
||||
@Schema(description = "每页大小", example = "10")
|
||||
private Integer pageSize;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
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;
|
||||
@@ -48,7 +47,7 @@ public interface TryOnEffectService extends IService<TryOnEffect> {
|
||||
|
||||
String generateUrl(String prompt, String tryonUrl);
|
||||
|
||||
PageResult<TryOnResultVO> getTryOnHistoricals(HistoricalDTO historicalDTO);
|
||||
List<TryOnResultVO> getTryOnHistoricals(HistoricalDTO historicalDTO);
|
||||
|
||||
PageResult<OutfitHisVO> getOutfitHistoricals(HistoricalDTO historicalDTO);
|
||||
List<OutfitHisVO> getOutfitHistoricals(HistoricalDTO historicalDTO);
|
||||
}
|
||||
@@ -108,6 +108,8 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
||||
customer.setCreatedTime(LocalDateTime.now());
|
||||
|
||||
save(customer);
|
||||
} else {
|
||||
throw new BusinessException("VIP ID'" + vipId + "' already exists.Please proceed directly to check-in.");
|
||||
}
|
||||
|
||||
return customer;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
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;
|
||||
@@ -23,8 +22,6 @@ 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;
|
||||
@@ -51,7 +48,12 @@ 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;
|
||||
@@ -78,9 +80,6 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
|
||||
tryOnEffectDto.setStyleId(originalTryOn.getStyleId());
|
||||
}
|
||||
String resultImageUrl = originalTryOn.getResultImageUrl();
|
||||
if (tryOnEffectDto.getStyleId()==null){
|
||||
tryOnEffectDto.setStyleId(originalTryOn.getStyleId());
|
||||
}
|
||||
imageUrls.add(resultImageUrl);
|
||||
|
||||
Long customerPhotoId = tryOnEffectDto.getCustomerPhotoId();
|
||||
@@ -263,7 +262,7 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<TryOnResultVO> getTryOnHistoricals(HistoricalDTO historicalDTO) {
|
||||
public List<TryOnResultVO> getTryOnHistoricals(HistoricalDTO historicalDTO) {
|
||||
LambdaQueryWrapper<TryOnEffect> tryOnEffectLambdaQueryWrapper = new LambdaQueryWrapper<TryOnEffect>()
|
||||
.eq(TryOnEffect::getCustomerId, historicalDTO.getCustomerId())
|
||||
.orderByDesc(TryOnEffect::getCreatedTime);
|
||||
@@ -278,14 +277,9 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
|
||||
} 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<TryOnEffect> tryOnEffects = this.list(tryOnEffectLambdaQueryWrapper);
|
||||
List<TryOnResultVO> tryOnResultVos = new ArrayList<>();
|
||||
for (TryOnEffect tryOnEffect : page.getRecords()) {
|
||||
for (TryOnEffect tryOnEffect : tryOnEffects) {
|
||||
TryOnResultVO tryOnResultVo = new TryOnResultVO();
|
||||
tryOnResultVo.setId(tryOnEffect.getId());
|
||||
tryOnResultVo.setTryOnUrl(minioUtil.convertToPresignedUrl(
|
||||
@@ -307,11 +301,11 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
|
||||
tryOnResultVo.setIsFavorite(tryOnEffect.getIsFavorite());
|
||||
tryOnResultVos.add(tryOnResultVo);
|
||||
}
|
||||
return new PageResult<>(tryOnResultVos, page.getTotal(), page.getCurrent(), page.getSize());
|
||||
return tryOnResultVos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<OutfitHisVO> getOutfitHistoricals(HistoricalDTO historicalDTO) {
|
||||
public List<OutfitHisVO> getOutfitHistoricals(HistoricalDTO historicalDTO) {
|
||||
LambdaQueryWrapper<Style> styleLambdaQueryWrapper = new LambdaQueryWrapper<Style>()
|
||||
.eq(Style::getCustomerId, historicalDTO.getCustomerId())
|
||||
.eq(Style::getGenerationStatus, 1)
|
||||
@@ -322,14 +316,9 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
|
||||
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<Style> styles = styleService.list(styleLambdaQueryWrapper);
|
||||
List<OutfitHisVO> outfitHisVos = new ArrayList<>();
|
||||
for (Style style : page.getRecords()) {
|
||||
for (Style style : styles) {
|
||||
OutfitHisVO outfitHisVo = new OutfitHisVO();
|
||||
outfitHisVo.setId(style.getId());
|
||||
outfitHisVo.setUrl(minioUtil.convertToPresignedUrl(
|
||||
@@ -339,7 +328,7 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
|
||||
outfitHisVo.setIsFavorite(style.getIsFavorite());
|
||||
outfitHisVos.add(outfitHisVo);
|
||||
}
|
||||
return new PageResult<>(outfitHisVos, page.getTotal(), page.getCurrent(), page.getSize());
|
||||
return outfitHisVos;
|
||||
}
|
||||
|
||||
//目前用于customize your look页面点击finish后的显示
|
||||
|
||||
Reference in New Issue
Block a user