TASK: to product、relight、pose未like的数据也需要返回parentId
This commit is contained in:
@@ -7,6 +7,8 @@ public interface CollectionSortService {
|
|||||||
|
|
||||||
CollectionSort addCollectionSort(Long relationId, String relationType, Long projectId, Long collectionSortParentId);
|
CollectionSort addCollectionSort(Long relationId, String relationType, Long projectId, Long collectionSortParentId);
|
||||||
|
|
||||||
|
CollectionSort queryCollectionSortByRelation(Long relationId, String relationType, Long projectId);
|
||||||
|
|
||||||
int getNextSort(Long projectId, Long parentId);
|
int getNextSort(Long projectId, Long parentId);
|
||||||
|
|
||||||
void deleteCollectionSort(Long relationId, String relationType, Long projectId, Long parentId);
|
void deleteCollectionSort(Long relationId, String relationType, Long projectId, Long parentId);
|
||||||
|
|||||||
@@ -121,4 +121,6 @@ public interface UserLikeGroupService extends IService<UserLikeGroup> {
|
|||||||
Boolean toProductImageElementDelete(Long id);
|
Boolean toProductImageElementDelete(Long id);
|
||||||
|
|
||||||
ToProductElementVO convertRelightElement(Long id);
|
ToProductElementVO convertRelightElement(Long id);
|
||||||
|
|
||||||
|
Long getUnlikedResultParentId(ToProductImageResult toProductImageResult, String url);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,4 +31,6 @@ public interface UserLikeService extends IService<UserLike> {
|
|||||||
UserLikeGroup getUserLikeGroupByProjectId(Long id);
|
UserLikeGroup getUserLikeGroupByProjectId(Long id);
|
||||||
|
|
||||||
List<UserLike> getByUserLikeGroupId(Long id);
|
List<UserLike> getByUserLikeGroupId(Long id);
|
||||||
|
|
||||||
|
UserLike getByDesignOutfitId(Long designOutfitId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,6 +125,8 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
private AccountService accountService;
|
private AccountService accountService;
|
||||||
@Resource
|
@Resource
|
||||||
private APIGenerateService apiGenerateService;
|
private APIGenerateService apiGenerateService;
|
||||||
|
@Resource
|
||||||
|
private UserLikeGroupService userLikeGroupService;
|
||||||
|
|
||||||
@Value("${redis.key.orderForGenerate}")
|
@Value("${redis.key.orderForGenerate}")
|
||||||
private String consumptionOrderKey;
|
private String consumptionOrderKey;
|
||||||
@@ -1513,10 +1515,12 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
poseTransformation.setIsLiked((byte) 1);
|
poseTransformation.setIsLiked((byte) 1);
|
||||||
poseTransformation.setUpdateTime(LocalDateTime.now());
|
poseTransformation.setUpdateTime(LocalDateTime.now());
|
||||||
poseTransformationMapper.updateById(poseTransformation);
|
poseTransformationMapper.updateById(poseTransformation);
|
||||||
Integer sort = addPoseTransferLike(poseTransformDTO, poseTransformation.getId());
|
CollectionSort collectionSort = addPoseTransferLike(poseTransformDTO, poseTransformation.getId());
|
||||||
Integer reSort = collectionSortService.rearrangeChildSort(poseTransformation.getId(), CollectionType.POSE_TRANSFORM.getValue(),
|
Integer reSort = collectionSortService.rearrangeChildSort(poseTransformation.getId(), CollectionType.POSE_TRANSFORM.getValue(),
|
||||||
poseTransformDTO.getParentId(), poseTransformDTO.getUserLikeSortId());
|
poseTransformDTO.getParentId(), poseTransformDTO.getUserLikeSortId());
|
||||||
toProductImageResultVO.setSort(Objects.isNull(reSort) ? sort : reSort);
|
toProductImageResultVO.setSort(Objects.isNull(reSort) ? Objects.isNull(collectionSort) ? null : collectionSort.getSort() : reSort);
|
||||||
|
toProductImageResultVO.setParentId(poseTransformDTO.getParentId());
|
||||||
|
toProductImageResultVO.setUserLikeSortId(Objects.isNull(collectionSort) ? null : collectionSort.getId());
|
||||||
} else if (Objects.nonNull(poseTransformDTO.getIsDefaultLike()) && Objects.nonNull(poseTransformDTO.getParentId())) {
|
} else if (Objects.nonNull(poseTransformDTO.getIsDefaultLike()) && Objects.nonNull(poseTransformDTO.getParentId())) {
|
||||||
toProductImageResultVO.setParentId(poseTransformDTO.getParentId());
|
toProductImageResultVO.setParentId(poseTransformDTO.getParentId());
|
||||||
}
|
}
|
||||||
@@ -1534,12 +1538,11 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
throw new BusinessException("pose transformation error", ResultEnum.ERROR.getCode());
|
throw new BusinessException("pose transformation error", ResultEnum.ERROR.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Integer addPoseTransferLike(PoseTransformDTO poseTransformDTO, Long poseTransformationId) {
|
private CollectionSort addPoseTransferLike(PoseTransformDTO poseTransformDTO, Long poseTransformationId) {
|
||||||
if (Objects.nonNull(poseTransformDTO.getParentId())
|
if (Objects.nonNull(poseTransformDTO.getParentId())
|
||||||
&& !poseTransformDTO.getParentId().equals(0L)) {
|
&& !poseTransformDTO.getParentId().equals(0L)) {
|
||||||
CollectionSort collectionSort = disOrLikePose(poseTransformationId, "like",
|
return disOrLikePose(poseTransformationId, "like",
|
||||||
poseTransformDTO.getProjectId(), poseTransformDTO.getParentId());
|
poseTransformDTO.getProjectId(), poseTransformDTO.getParentId());
|
||||||
return collectionSort.getSort();
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -1693,6 +1696,9 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
if (productResult != null) {
|
if (productResult != null) {
|
||||||
Long parentId = collectionSortService.getParentIdByElementIdAndElementType(
|
Long parentId = collectionSortService.getParentIdByElementIdAndElementType(
|
||||||
productResult.getId(), CollectionType.TO_PRODUCT_IMAGE.getValue());
|
productResult.getId(), CollectionType.TO_PRODUCT_IMAGE.getValue());
|
||||||
|
if (Objects.isNull(parentId)){
|
||||||
|
parentId = userLikeGroupService.getUnlikedResultParentId(null, poseTransformation.getProductImage());
|
||||||
|
}
|
||||||
vo.setParentId(parentId);
|
vo.setParentId(parentId);
|
||||||
vo.setId(poseTransformation.getId());
|
vo.setId(poseTransformation.getId());
|
||||||
vo.setModelName(poseTransformation.getModelName());
|
vo.setModelName(poseTransformation.getModelName());
|
||||||
|
|||||||
@@ -520,12 +520,14 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
// 先判断是否需要默认like
|
// 先判断是否需要默认like
|
||||||
if (Objects.nonNull(toProductImageDTO.getIsDefaultLike()) && toProductImageDTO.getIsDefaultLike()){
|
if (Objects.nonNull(toProductImageDTO.getIsDefaultLike()) && toProductImageDTO.getIsDefaultLike()){
|
||||||
// 满足条件情况下默认添加到like
|
// 满足条件情况下默认添加到like
|
||||||
Integer sort = addToProductLike(toProductImageVO.getParentId(), toProductImageResult.getId(), toProductImageDTO.getProjectId());
|
CollectionSort collectionSort = addToProductLike(toProductImageVO.getParentId(), toProductImageResult.getId(), toProductImageDTO.getProjectId());
|
||||||
// 重新排序
|
// 重新排序
|
||||||
Integer reSort = collectionSortService.rearrangeChildSort(toProductImageResult.getId(), CollectionType.TO_PRODUCT_IMAGE.getValue(),
|
Integer reSort = collectionSortService.rearrangeChildSort(toProductImageResult.getId(), CollectionType.TO_PRODUCT_IMAGE.getValue(),
|
||||||
toProductImageVO.getParentId(), toProductImageVO.getUserLikeSortId());
|
toProductImageVO.getParentId(), toProductImageVO.getUserLikeSortId());
|
||||||
// 将生成结果的排序返回
|
// 将生成结果的排序返回
|
||||||
toProductImageResult.setSort(Objects.isNull(reSort) ? sort : reSort);
|
toProductImageResult.setSort(Objects.isNull(reSort) ? Objects.isNull(collectionSort) ? null : collectionSort.getSort() : reSort);
|
||||||
|
toProductImageResult.setParentId(toProductImageVO.getParentId());
|
||||||
|
toProductImageResult.setUserLikeSortId(Objects.isNull(collectionSort) ? null : collectionSort.getId());
|
||||||
}else if (Objects.nonNull(toProductImageDTO.getIsDefaultLike()) && Objects.nonNull(toProductImageVO.getParentId())){
|
}else if (Objects.nonNull(toProductImageDTO.getIsDefaultLike()) && Objects.nonNull(toProductImageVO.getParentId())){
|
||||||
toProductImageResult.setParentId(toProductImageVO.getParentId());
|
toProductImageResult.setParentId(toProductImageVO.getParentId());
|
||||||
// 默认不添加到like,但是需要有parentId,所以这里添加到collectionSort表中
|
// 默认不添加到like,但是需要有parentId,所以这里添加到collectionSort表中
|
||||||
@@ -575,12 +577,14 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
// 先判断是否需要默认like
|
// 先判断是否需要默认like
|
||||||
if (Objects.nonNull(toProductImageDTO.getIsDefaultLike()) && toProductImageDTO.getIsDefaultLike()){
|
if (Objects.nonNull(toProductImageDTO.getIsDefaultLike()) && toProductImageDTO.getIsDefaultLike()){
|
||||||
// 满足条件情况下默认添加到like
|
// 满足条件情况下默认添加到like
|
||||||
Integer sort = addToProductLike(toProductImageVO.getParentId(), toProductImageResult.getId(), toProductImageDTO.getProjectId());
|
CollectionSort collectionSort = addToProductLike(toProductImageVO.getParentId(), toProductImageResult.getId(), toProductImageDTO.getProjectId());
|
||||||
// 重新排序
|
// 重新排序
|
||||||
Integer reSort = collectionSortService.rearrangeChildSort(toProductImageResult.getId(), CollectionType.TO_PRODUCT_IMAGE.getValue(),
|
Integer reSort = collectionSortService.rearrangeChildSort(toProductImageResult.getId(), CollectionType.TO_PRODUCT_IMAGE.getValue(),
|
||||||
toProductImageVO.getParentId(), toProductImageVO.getUserLikeSortId());
|
toProductImageVO.getParentId(), toProductImageVO.getUserLikeSortId());
|
||||||
// 将生成结果的排序返回
|
// 将生成结果的排序返回
|
||||||
toProductImageResult.setSort(Objects.isNull(reSort) ? sort : reSort);
|
toProductImageResult.setSort(Objects.isNull(reSort) ? Objects.isNull(collectionSort) ? null : collectionSort.getSort() : reSort);
|
||||||
|
toProductImageResult.setParentId(toProductImageVO.getParentId());
|
||||||
|
toProductImageResult.setUserLikeSortId(Objects.isNull(collectionSort) ? null : collectionSort.getId());
|
||||||
}else if (Objects.nonNull(toProductImageDTO.getIsDefaultLike()) && Objects.nonNull(toProductImageVO.getParentId())){
|
}else if (Objects.nonNull(toProductImageDTO.getIsDefaultLike()) && Objects.nonNull(toProductImageVO.getParentId())){
|
||||||
toProductImageResult.setParentId(toProductImageVO.getParentId());
|
toProductImageResult.setParentId(toProductImageVO.getParentId());
|
||||||
// 默认不添加到like,但是需要有parentId,所以这里添加到collectionSort表中
|
// 默认不添加到like,但是需要有parentId,所以这里添加到collectionSort表中
|
||||||
@@ -600,11 +604,10 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Integer addToProductLike(Long parentId, Long toProductImageResultId, Long projectId){
|
private CollectionSort addToProductLike(Long parentId, Long toProductImageResultId, Long projectId){
|
||||||
if (Objects.nonNull(parentId) && !parentId.equals(0L)){
|
if (Objects.nonNull(parentId) && !parentId.equals(0L)){
|
||||||
CollectionSort collectionSort = productImageLike(new ProductImageLikeDTO(Collections.singletonList(toProductImageResultId),
|
return productImageLike(new ProductImageLikeDTO(Collections.singletonList(toProductImageResultId),
|
||||||
projectId, parentId));
|
projectId, parentId));
|
||||||
return Objects.nonNull(collectionSort) ? collectionSort.getSort() : null;
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -1167,12 +1170,14 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
// 先判断是否需要默认like
|
// 先判断是否需要默认like
|
||||||
if (Objects.nonNull(toProductImageDTO.getIsDefaultLike()) && toProductImageDTO.getIsDefaultLike()){
|
if (Objects.nonNull(toProductImageDTO.getIsDefaultLike()) && toProductImageDTO.getIsDefaultLike()){
|
||||||
// 满足条件情况下默认添加到like
|
// 满足条件情况下默认添加到like
|
||||||
Integer sort = addToProductLike(toProductImageVO.getParentId(), toProductImageResult.getId(), toProductImageDTO.getProjectId());
|
CollectionSort collectionSort = addToProductLike(toProductImageVO.getParentId(), toProductImageResult.getId(), toProductImageDTO.getProjectId());
|
||||||
// 重新排序
|
// 重新排序
|
||||||
Integer reSort = collectionSortService.rearrangeChildSort(toProductImageResult.getId(), CollectionType.RELIGHT.getValue(),
|
Integer reSort = collectionSortService.rearrangeChildSort(toProductImageResult.getId(), CollectionType.RELIGHT.getValue(),
|
||||||
toProductImageVO.getParentId(), toProductImageVO.getUserLikeSortId());
|
toProductImageVO.getParentId(), toProductImageVO.getUserLikeSortId());
|
||||||
// 将生成结果的排序返回
|
// 将生成结果的排序返回
|
||||||
toProductImageResult.setSort(Objects.isNull(reSort) ? sort : reSort);
|
toProductImageResult.setSort(Objects.isNull(reSort) ? Objects.isNull(collectionSort) ? null : collectionSort.getSort() : reSort);
|
||||||
|
toProductImageResult.setParentId(toProductImageVO.getParentId());
|
||||||
|
toProductImageResult.setUserLikeSortId(Objects.isNull(collectionSort) ? null : collectionSort.getId());
|
||||||
}else if (Objects.nonNull(toProductImageDTO.getIsDefaultLike()) && Objects.nonNull(toProductImageVO.getParentId())){
|
}else if (Objects.nonNull(toProductImageDTO.getIsDefaultLike()) && Objects.nonNull(toProductImageVO.getParentId())){
|
||||||
toProductImageResult.setParentId(toProductImageVO.getParentId());
|
toProductImageResult.setParentId(toProductImageVO.getParentId());
|
||||||
// 默认不添加到like,但是需要有parentId,所以这里添加到collectionSort表中
|
// 默认不添加到like,但是需要有parentId,所以这里添加到collectionSort表中
|
||||||
@@ -1212,12 +1217,14 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
// 先判断是否需要默认like
|
// 先判断是否需要默认like
|
||||||
if (Objects.nonNull(toProductImageDTO.getIsDefaultLike()) && toProductImageDTO.getIsDefaultLike()){
|
if (Objects.nonNull(toProductImageDTO.getIsDefaultLike()) && toProductImageDTO.getIsDefaultLike()){
|
||||||
// 满足条件情况下默认添加到like
|
// 满足条件情况下默认添加到like
|
||||||
Integer sort = addToProductLike(toProductImageVO.getParentId(), toProductImageResult.getId(), toProductImageDTO.getProjectId());
|
CollectionSort collectionSort = addToProductLike(toProductImageVO.getParentId(), toProductImageResult.getId(), toProductImageDTO.getProjectId());
|
||||||
// 重新排序
|
// 重新排序
|
||||||
Integer reSort = collectionSortService.rearrangeChildSort(toProductImageResult.getId(), CollectionType.RELIGHT.getValue(),
|
Integer reSort = collectionSortService.rearrangeChildSort(toProductImageResult.getId(), CollectionType.RELIGHT.getValue(),
|
||||||
toProductImageVO.getParentId(), toProductImageVO.getUserLikeSortId());
|
toProductImageVO.getParentId(), toProductImageVO.getUserLikeSortId());
|
||||||
// 将生成结果的排序返回
|
// 将生成结果的排序返回
|
||||||
toProductImageResult.setSort(Objects.isNull(reSort) ? sort : reSort);
|
toProductImageResult.setSort(Objects.isNull(reSort) ? Objects.isNull(collectionSort) ? null : collectionSort.getSort() : reSort);
|
||||||
|
toProductImageResult.setParentId(toProductImageVO.getParentId());
|
||||||
|
toProductImageResult.setUserLikeSortId(Objects.isNull(collectionSort) ? null : collectionSort.getId());
|
||||||
}else if (Objects.nonNull(toProductImageDTO.getIsDefaultLike()) && Objects.nonNull(toProductImageVO.getParentId())){
|
}else if (Objects.nonNull(toProductImageDTO.getIsDefaultLike()) && Objects.nonNull(toProductImageVO.getParentId())){
|
||||||
toProductImageResult.setParentId(toProductImageVO.getParentId());
|
toProductImageResult.setParentId(toProductImageVO.getParentId());
|
||||||
// 默认不添加到like,但是需要有parentId,所以这里添加到collectionSort表中
|
// 默认不添加到like,但是需要有parentId,所以这里添加到collectionSort表中
|
||||||
@@ -2111,6 +2118,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
if (Objects.nonNull(toProductImageRecord)){
|
if (Objects.nonNull(toProductImageRecord)){
|
||||||
vo.setPrompt(toProductImageRecord.getPrompt());
|
vo.setPrompt(toProductImageRecord.getPrompt());
|
||||||
}
|
}
|
||||||
|
vo.setParentId(getUnlikedResultParentId(result, null));
|
||||||
// 按isLike分类
|
// 按isLike分类
|
||||||
if (result.getIsLike() != null && result.getIsLike() == 1) {
|
if (result.getIsLike() != null && result.getIsLike() == 1) {
|
||||||
likedList.add(vo);
|
likedList.add(vo);
|
||||||
@@ -2240,6 +2248,57 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
return duration.toHours() >= 1;
|
return duration.toHours() >= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取未被like的to product\relight的parentId
|
||||||
|
public Long getUnlikedResultParentId(ToProductImageResult toProductImageResult, String url) {
|
||||||
|
// 卫语句处理null情况
|
||||||
|
if (toProductImageResult == null && StringUtil.isNullOrEmpty(url)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果需要查询结果对象
|
||||||
|
if (toProductImageResult == null) {
|
||||||
|
toProductImageResult = toProductImageResultMapper.selectOne(
|
||||||
|
new QueryWrapper<ToProductImageResult>().eq("url", url));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 卫语句处理查询结果为空的情况
|
||||||
|
if (toProductImageResult == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据不同类型处理
|
||||||
|
String elementType = toProductImageResult.getElementType();
|
||||||
|
if ("DesignOutfit".equals(elementType)) {
|
||||||
|
return handleDesignOutfitCase(toProductImageResult);
|
||||||
|
} else if ("ToProductImage".equals(elementType)) {
|
||||||
|
// 两种情况 resultType : ToProductImage | Relight
|
||||||
|
return handleToProductImageCase(toProductImageResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Long handleDesignOutfitCase(ToProductImageResult result) {
|
||||||
|
UserLike userLike = userLikeService.getByDesignOutfitId(result.getElementId());
|
||||||
|
if (userLike == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
CollectionSort collectionSort = collectionSortService.queryCollectionSortByRelation(
|
||||||
|
userLike.getId(), "Design", result.getProjectId());
|
||||||
|
return collectionSort != null ? collectionSort.getId() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Long handleToProductImageCase(ToProductImageResult result) {
|
||||||
|
CollectionSort collectionSort = collectionSortService.queryCollectionSortByRelation(
|
||||||
|
result.getElementId(), result.getResultType(), result.getProjectId());
|
||||||
|
if (Objects.isNull(collectionSort) && result.getElementType().equals("ToProductImage")){
|
||||||
|
ToProductImageResult toProductImageResult = toProductImageResultMapper.selectById(result.getElementId());
|
||||||
|
return getUnlikedResultParentId(toProductImageResult, null);
|
||||||
|
}
|
||||||
|
return collectionSort != null ? collectionSort.getParentId() : null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public ModuleChooseVO saveModuleContent(ModuleSaveDTO moduleSaveDTO) {
|
public ModuleChooseVO saveModuleContent(ModuleSaveDTO moduleSaveDTO) {
|
||||||
|
|||||||
@@ -122,4 +122,16 @@ public class UserLikeServiceImpl extends ServiceImpl<UserLikeMapper, UserLike> i
|
|||||||
return userLikeList;
|
return userLikeList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserLike getByDesignOutfitId(Long designOutfitId){
|
||||||
|
QueryWrapper<UserLike> qw = new QueryWrapper<>();
|
||||||
|
qw.lambda().eq(UserLike::getDesignOutfitId, designOutfitId);
|
||||||
|
// 有脏数据
|
||||||
|
List<UserLike> userLikes = baseMapper.selectList(qw);
|
||||||
|
if (!userLikes.isEmpty()){
|
||||||
|
return userLikes.get(0);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user