TASK:collection sort;

This commit is contained in:
shahaibo
2025-06-03 11:23:13 +08:00
parent 3bfbd8abc1
commit 112294bd7b
12 changed files with 110 additions and 66 deletions

View File

@@ -4,6 +4,7 @@ import com.ai.da.common.config.exception.BusinessException;
import com.ai.da.common.response.PageBaseResponse; import com.ai.da.common.response.PageBaseResponse;
import com.ai.da.common.response.Response; import com.ai.da.common.response.Response;
import com.ai.da.mapper.primary.entity.CloudTask; import com.ai.da.mapper.primary.entity.CloudTask;
import com.ai.da.mapper.primary.entity.CollectionSort;
import com.ai.da.model.dto.*; import com.ai.da.model.dto.*;
import com.ai.da.model.vo.*; import com.ai.da.model.vo.*;
import com.ai.da.service.DesignService; import com.ai.da.service.DesignService;
@@ -76,7 +77,7 @@ public class DesignController {
@ApiOperation(value = "Design sort") @ApiOperation(value = "Design sort")
@PostMapping("/sort") @PostMapping("/sort")
public Response<Boolean> sort(@Valid @RequestBody UserLikeSortDTO userLikeSortDTO) { public Response<Boolean> sort(@Valid @RequestBody CollectionSortDTO userLikeSortDTO) {
return Response.success(designService.sort(userLikeSortDTO)); return Response.success(designService.sort(userLikeSortDTO));
} }

View File

@@ -203,6 +203,12 @@ public class SavedCollectionController {
return Response.success(userLikeGroupService.productImageLike(productImageLikeDTO)); return Response.success(userLikeGroupService.productImageLike(productImageLikeDTO));
} }
@ApiOperation(value = "collectionLikeUpdate")
@PostMapping("/collectionLikeUpdate")
public Response<Boolean> collectionLikeUpdate(@Valid @RequestBody CollectionLikeUpdateDTO collectionLikeUpdateDTO) {
return Response.success(userLikeGroupService.collectionLikeUpdate(collectionLikeUpdateDTO));
}
@ApiOperation(value = "productImageUnLike") @ApiOperation(value = "productImageUnLike")
@PostMapping("/productImageUnLike") @PostMapping("/productImageUnLike")
public Response<Boolean> productImageUnLike(@Valid @RequestBody ProductImageLikeDTO productImageLikeDTO) { public Response<Boolean> productImageUnLike(@Valid @RequestBody ProductImageLikeDTO productImageLikeDTO) {

View File

@@ -0,0 +1,7 @@
package com.ai.da.mapper.primary;
import com.ai.da.common.config.mybatis.plus.CommonMapper;
import com.ai.da.mapper.primary.entity.CollectionSort;
public interface CollectionSortMapper extends CommonMapper<CollectionSort> {
}

View File

@@ -1,7 +0,0 @@
package com.ai.da.mapper.primary;
import com.ai.da.common.config.mybatis.plus.CommonMapper;
import com.ai.da.mapper.primary.entity.UserLikeSort;
public interface UserLikeSortMapper extends CommonMapper<UserLikeSort> {
}

View File

@@ -13,7 +13,7 @@ import java.util.Date;
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
@Accessors(chain = true) @Accessors(chain = true)
@TableName("collection_sort") @TableName("collection_sort")
public class UserLikeSort implements Serializable { public class CollectionSort implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO) @TableId(value = "id", type = IdType.AUTO)

View File

@@ -0,0 +1,10 @@
package com.ai.da.model.dto;
import lombok.Data;
@Data
public class CollectionLikeUpdateDTO {
private Long userLikeSortId;
private Long relationId;
private String relationType;
}

View File

@@ -0,0 +1,13 @@
package com.ai.da.model.dto;
import com.ai.da.mapper.primary.entity.CollectionSort;
import lombok.Data;
import java.util.List;
@Data
public class CollectionSortDTO{
private Long userLikeGroupId;
List<CollectionSort> userLikeSortList;
}

View File

@@ -1,13 +0,0 @@
package com.ai.da.model.dto;
import com.ai.da.mapper.primary.entity.UserLikeSort;
import lombok.Data;
import java.util.List;
@Data
public class UserLikeSortDTO{
private Long userLikeGroupId;
List<UserLikeSort> userLikeSortList;
}

View File

@@ -1,8 +1,8 @@
package com.ai.da.service; package com.ai.da.service;
import com.ai.da.common.response.PageBaseResponse; import com.ai.da.common.response.PageBaseResponse;
import com.ai.da.mapper.primary.entity.CollectionSort;
import com.ai.da.mapper.primary.entity.Design; import com.ai.da.mapper.primary.entity.Design;
import com.ai.da.mapper.primary.entity.UserLikeSort;
import com.ai.da.model.dto.*; import com.ai.da.model.dto.*;
import com.ai.da.model.vo.*; import com.ai.da.model.vo.*;
import com.ai.da.python.vo.DesignPythonObjects; import com.ai.da.python.vo.DesignPythonObjects;
@@ -61,7 +61,7 @@ public interface DesignService extends IService<Design> {
*/ */
DesignLikeVO like(DesignLikeDTO designLikeDTO); DesignLikeVO like(DesignLikeDTO designLikeDTO);
UserLikeSort addCollectionSort(Long relationId, String relationType, Long projectId); CollectionSort addCollectionSort(Long relationId, String relationType, Long projectId);
int getNextSort(Long projectId); int getNextSort(Long projectId);
@@ -75,7 +75,7 @@ public interface DesignService extends IService<Design> {
void deleteCollectionSort(Long relationId, String relationType, Long projectId); void deleteCollectionSort(Long relationId, String relationType, Long projectId);
UserLikeSort getUserLikeSortByUserLikeId(Long userLikeId, String relationType, Long projectId); CollectionSort getUserLikeSortByUserLikeId(Long userLikeId, String relationType, Long projectId);
/** /**
* generateHighDesign * generateHighDesign
@@ -121,7 +121,7 @@ public interface DesignService extends IService<Design> {
void processDesignBatch(Map<String, Object> designBatchResult); void processDesignBatch(Map<String, Object> designBatchResult);
Boolean sort(UserLikeSortDTO userLikeSortDTO); Boolean sort(CollectionSortDTO userLikeSortDTO);
IPage<CloudTaskVO> cloudPage(CloudPageDTO cloudPageDTO); IPage<CloudTaskVO> cloudPage(CloudPageDTO cloudPageDTO);

View File

@@ -113,4 +113,6 @@ public interface UserLikeGroupService extends IService<UserLikeGroup> {
void toProductBatch(String taskId, String url, String progress); void toProductBatch(String taskId, String url, String progress);
void relightBatch(String taskId, String url, String progress); void relightBatch(String taskId, String url, String progress);
Boolean collectionLikeUpdate(CollectionLikeUpdateDTO collectionLikeUpdateDTO);
} }

View File

@@ -131,7 +131,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
private DesignBatchMapper designBatchMapper; private DesignBatchMapper designBatchMapper;
@Resource @Resource
private UserLikeSortMapper userLikeSortMapper; private CollectionSortMapper collectionSortMapper;
@Resource @Resource
private ProjectService projectService; private ProjectService projectService;
@Resource @Resource
@@ -1203,7 +1203,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
} }
userLikeService.save(userLike); userLikeService.save(userLike);
Long userLikeSortId; Long userLikeSortId;
UserLikeSort userLikeSort = addCollectionSort(userLike.getId(), CollectionType.DESIGN.getValue(), designLikeDTO.getProjectId()); CollectionSort userLikeSort = addCollectionSort(userLike.getId(), CollectionType.DESIGN.getValue(), designLikeDTO.getProjectId());
userLikeSortId = userLikeSort.getId(); userLikeSortId = userLikeSort.getId();
groupDetailId = userLike.getId(); groupDetailId = userLike.getId();
String designUrl = designPythonOutfitMapper.selectById(userLike.getDesignOutfitId()).getDesignUrl(); String designUrl = designPythonOutfitMapper.selectById(userLike.getDesignOutfitId()).getDesignUrl();
@@ -1217,24 +1217,24 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
} }
@Override @Override
public UserLikeSort addCollectionSort(Long relationId, String relationType, Long projectId) { public CollectionSort addCollectionSort(Long relationId, String relationType, Long projectId) {
int sort = getNextSort(projectId); int sort = getNextSort(projectId);
UserLikeSort userLikeSort = new UserLikeSort(); CollectionSort userLikeSort = new CollectionSort();
// userLikeSort.setUserLikeGroupId(userGroupId); // userLikeSort.setUserLikeGroupId(userGroupId);
// userLikeSort.setUserLikeId(relationId); // userLikeSort.setUserLikeId(relationId);
userLikeSort.setProjectId(projectId); userLikeSort.setProjectId(projectId);
userLikeSort.setRelationId(relationId); userLikeSort.setRelationId(relationId);
userLikeSort.setRelationType(relationType); userLikeSort.setRelationType(relationType);
userLikeSort.setSort(sort); userLikeSort.setSort(sort);
userLikeSortMapper.insert(userLikeSort); collectionSortMapper.insert(userLikeSort);
return userLikeSort; return userLikeSort;
} }
@Override @Override
public int getNextSort(Long projectId) { public int getNextSort(Long projectId) {
QueryWrapper<UserLikeSort> qw = new QueryWrapper<>(); QueryWrapper<CollectionSort> qw = new QueryWrapper<>();
qw.lambda().eq(UserLikeSort::getProjectId, projectId); qw.lambda().eq(CollectionSort::getProjectId, projectId);
List<UserLikeSort> userLikeSorts = userLikeSortMapper.selectList(qw); List<CollectionSort> userLikeSorts = collectionSortMapper.selectList(qw);
if (CollectionUtils.isEmpty(userLikeSorts)) { if (CollectionUtils.isEmpty(userLikeSorts)) {
return 1; return 1;
} }
@@ -1328,30 +1328,30 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
@Override @Override
public void deleteCollectionSort(Long relationId, String relationType, Long projectId) { public void deleteCollectionSort(Long relationId, String relationType, Long projectId) {
QueryWrapper<UserLikeSort> qw = new QueryWrapper<>(); QueryWrapper<CollectionSort> qw = new QueryWrapper<>();
qw.lambda().eq(UserLikeSort::getProjectId, projectId); qw.lambda().eq(CollectionSort::getProjectId, projectId);
qw.lambda().orderByDesc(UserLikeSort::getSort); qw.lambda().orderByDesc(CollectionSort::getSort);
List<UserLikeSort> userLikeSorts = userLikeSortMapper.selectList(qw); List<CollectionSort> userLikeSorts = collectionSortMapper.selectList(qw);
UserLikeSort userLikeSort = getUserLikeSortByUserLikeId(relationId, relationType, projectId); CollectionSort userLikeSort = getUserLikeSortByUserLikeId(relationId, relationType, projectId);
Long userLikeSortId = userLikeSort.getId(); Long userLikeSortId = userLikeSort.getId();
for (UserLikeSort likeSort : userLikeSorts) { for (CollectionSort likeSort : userLikeSorts) {
if (Objects.equals(likeSort.getId(), userLikeSortId)) { if (Objects.equals(likeSort.getId(), userLikeSortId)) {
userLikeSortMapper.deleteById(likeSort); collectionSortMapper.deleteById(likeSort);
break; break;
}else { }else {
likeSort.setSort(likeSort.getSort() - 1); likeSort.setSort(likeSort.getSort() - 1);
userLikeSortMapper.updateById(likeSort); collectionSortMapper.updateById(likeSort);
} }
} }
} }
@Override @Override
public UserLikeSort getUserLikeSortByUserLikeId(Long userLikeId, String relationType, Long projectId) { public CollectionSort getUserLikeSortByUserLikeId(Long userLikeId, String relationType, Long projectId) {
QueryWrapper<UserLikeSort> qw = new QueryWrapper<>(); QueryWrapper<CollectionSort> qw = new QueryWrapper<>();
qw.lambda().eq(UserLikeSort::getRelationId, userLikeId); qw.lambda().eq(CollectionSort::getRelationId, userLikeId);
qw.lambda().eq(UserLikeSort::getRelationType, relationType); qw.lambda().eq(CollectionSort::getRelationType, relationType);
qw.lambda().eq(UserLikeSort::getProjectId, projectId); qw.lambda().eq(CollectionSort::getProjectId, projectId);
UserLikeSort userLikeSort = userLikeSortMapper.selectOne(qw); CollectionSort userLikeSort = collectionSortMapper.selectOne(qw);
return userLikeSort; return userLikeSort;
} }
@@ -2570,12 +2570,12 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
} }
@Override @Override
public Boolean sort(UserLikeSortDTO userLikeSortDTO) { public Boolean sort(CollectionSortDTO userLikeSortDTO) {
// QueryWrapper<UserLikeSort> qw = new QueryWrapper<>(); // QueryWrapper<UserLikeSort> qw = new QueryWrapper<>();
// qw.lambda().eq(UserLikeSort::getUserLikeGroupId, userLikeSortDTO.getUserLikeGroupId()); // qw.lambda().eq(UserLikeSort::getUserLikeGroupId, userLikeSortDTO.getUserLikeGroupId());
// userLikeSortMapper.delete(qw); // userLikeSortMapper.delete(qw);
for (UserLikeSort userLikeSort : userLikeSortDTO.getUserLikeSortList()) { for (CollectionSort userLikeSort : userLikeSortDTO.getUserLikeSortList()) {
userLikeSortMapper.updateById(userLikeSort); collectionSortMapper.updateById(userLikeSort);
} }
return Boolean.TRUE; return Boolean.TRUE;
} }

View File

@@ -105,7 +105,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
@Resource @Resource
private ProductImageAttributeMapper productImageAttributeMapper; private ProductImageAttributeMapper productImageAttributeMapper;
@Resource @Resource
private UserLikeSortMapper userLikeSortMapper; private CollectionSortMapper collectionSortMapper;
@Resource @Resource
private ClassificationService classificationService; private ClassificationService classificationService;
@Resource @Resource
@@ -201,17 +201,17 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
List<UserLikeVO> userLikeVOS = userLikeService.getGroupDetail(userGroupId); List<UserLikeVO> userLikeVOS = userLikeService.getGroupDetail(userGroupId);
String sex = null; String sex = null;
QueryWrapper<UserLikeSort> userLikeSortQw = new QueryWrapper<>(); QueryWrapper<CollectionSort> userLikeSortQw = new QueryWrapper<>();
userLikeSortQw.lambda().eq(UserLikeSort::getUserLikeGroupId, userGroupId); userLikeSortQw.lambda().eq(CollectionSort::getUserLikeGroupId, userGroupId);
List<UserLikeSort> userLikeSortList = userLikeSortMapper.selectList(userLikeSortQw); List<CollectionSort> userLikeSortList = collectionSortMapper.selectList(userLikeSortQw);
if (CollectionUtil.isEmpty(userLikeSortList)) { if (CollectionUtil.isEmpty(userLikeSortList)) {
Integer sort = 1; Integer sort = 1;
for (UserLikeVO userLikeVO : userLikeVOS) { for (UserLikeVO userLikeVO : userLikeVOS) {
UserLikeSort userLikeSort = new UserLikeSort(); CollectionSort userLikeSort = new CollectionSort();
userLikeSort.setUserLikeId(userLikeVO.getId()); userLikeSort.setUserLikeId(userLikeVO.getId());
userLikeSort.setUserLikeGroupId(userGroupId); userLikeSort.setUserLikeGroupId(userGroupId);
userLikeSort.setSort(sort); userLikeSort.setSort(sort);
userLikeSortMapper.insert(userLikeSort); collectionSortMapper.insert(userLikeSort);
sort ++; sort ++;
} }
} }
@@ -232,11 +232,11 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
o.setDesignOutfitId(tDesignPythonOutfit.getId()); o.setDesignOutfitId(tDesignPythonOutfit.getId());
} }
QueryWrapper<UserLikeSort> userLikeSortQueryWrapper = new QueryWrapper<>(); QueryWrapper<CollectionSort> userLikeSortQueryWrapper = new QueryWrapper<>();
userLikeSortQueryWrapper.lambda().eq(UserLikeSort::getUserLikeId, o.getId()); userLikeSortQueryWrapper.lambda().eq(CollectionSort::getUserLikeId, o.getId());
List<UserLikeSort> userLikeSorts = userLikeSortMapper.selectList(userLikeSortQueryWrapper); List<CollectionSort> userLikeSorts = collectionSortMapper.selectList(userLikeSortQueryWrapper);
if (CollectionUtil.isNotEmpty(userLikeSorts)) { if (CollectionUtil.isNotEmpty(userLikeSorts)) {
UserLikeSort userLikeSort = userLikeSorts.get(0); CollectionSort userLikeSort = userLikeSorts.get(0);
o.setSort(userLikeSort.getSort()); o.setSort(userLikeSort.getSort());
o.setUserLikeSortId(userLikeSort.getId()); o.setUserLikeSortId(userLikeSort.getId());
} }
@@ -1520,16 +1520,16 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
moduleChooseVO.setSketchBoard(list); moduleChooseVO.setSketchBoard(list);
}else if (module.equals(Module.design.name())) { }else if (module.equals(Module.design.name())) {
DesignModuleChooseVO vo = new DesignModuleChooseVO(); DesignModuleChooseVO vo = new DesignModuleChooseVO();
QueryWrapper<UserLikeSort> userLikeSortQueryWrapper = new QueryWrapper<>(); QueryWrapper<CollectionSort> userLikeSortQueryWrapper = new QueryWrapper<>();
userLikeSortQueryWrapper.lambda().eq(UserLikeSort::getProjectId, projectDTO.getId()); userLikeSortQueryWrapper.lambda().eq(CollectionSort::getProjectId, projectDTO.getId());
userLikeSortQueryWrapper.lambda().orderByAsc(UserLikeSort::getSort); userLikeSortQueryWrapper.lambda().orderByAsc(CollectionSort::getSort);
List<UserLikeSort> userLikeSortList = userLikeSortMapper.selectList(userLikeSortQueryWrapper); List<CollectionSort> userLikeSortList = collectionSortMapper.selectList(userLikeSortQueryWrapper);
if (CollectionUtils.isEmpty(userLikeSortList)) { if (CollectionUtils.isEmpty(userLikeSortList)) {
moduleChooseVO.setDesign(vo); moduleChooseVO.setDesign(vo);
}else { }else {
List<AllCollectionVO> list = new ArrayList<>(); List<AllCollectionVO> list = new ArrayList<>();
for (UserLikeSort userLikeSort : userLikeSortList) { for (CollectionSort userLikeSort : userLikeSortList) {
if (userLikeSort.getRelationType().equals(CollectionType.DESIGN.getValue())) { if (userLikeSort.getRelationType().equals(CollectionType.DESIGN.getValue())) {
UserLike userLike = userLikeMapper.selectById(userLikeSort.getRelationId()); UserLike userLike = userLikeMapper.selectById(userLikeSort.getRelationId());
UserLikeVO o = CopyUtil.copyObject(userLike, UserLikeVO.class); UserLikeVO o = CopyUtil.copyObject(userLike, UserLikeVO.class);
@@ -2466,4 +2466,29 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
} }
} }
} }
@Override
@Transactional
public Boolean collectionLikeUpdate(CollectionLikeUpdateDTO collectionLikeUpdateDTO) {
CollectionSort collectionSort = collectionSortMapper.selectById(collectionLikeUpdateDTO.getUserLikeSortId());
Long relationIdOld = collectionSort.getRelationId();
collectionSort.setRelationId(collectionLikeUpdateDTO.getRelationId());
collectionSortMapper.updateById(collectionSort);
if (collectionLikeUpdateDTO.getRelationType().equals(CollectionType.TO_PRODUCT_IMAGE.getValue()) || collectionLikeUpdateDTO.getRelationType().equals(CollectionType.RELIGHT.getValue())) {
ToProductImageResult toProductImageResult = toProductImageResultMapper.selectById(collectionLikeUpdateDTO.getRelationId());
toProductImageResult.setIsLike(1);
toProductImageResultMapper.updateById(toProductImageResult);
ToProductImageResult toProductImageResultOld = toProductImageResultMapper.selectById(relationIdOld);
toProductImageResultOld.setIsLike(0);
toProductImageResultMapper.updateById(toProductImageResultOld);
}else if (collectionLikeUpdateDTO.getRelationType().equals(CollectionType.POSE_TRANSFORM.getValue())) {
PoseTransformation poseTransformation = poseTransformationMapper.selectById(collectionLikeUpdateDTO.getRelationId());
poseTransformation.setIsLiked((byte) 1);
poseTransformationMapper.updateById(poseTransformation);
PoseTransformation poseTransformationOld = poseTransformationMapper.selectById(relationIdOld);
poseTransformationOld.setIsLiked((byte) 0);
poseTransformationMapper.updateById(poseTransformationOld);
}
return Boolean.TRUE;
}
} }