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

@@ -1,8 +1,8 @@
package com.ai.da.service;
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.UserLikeSort;
import com.ai.da.model.dto.*;
import com.ai.da.model.vo.*;
import com.ai.da.python.vo.DesignPythonObjects;
@@ -61,7 +61,7 @@ public interface DesignService extends IService<Design> {
*/
DesignLikeVO like(DesignLikeDTO designLikeDTO);
UserLikeSort addCollectionSort(Long relationId, String relationType, Long projectId);
CollectionSort addCollectionSort(Long relationId, String relationType, Long projectId);
int getNextSort(Long projectId);
@@ -75,7 +75,7 @@ public interface DesignService extends IService<Design> {
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
@@ -121,7 +121,7 @@ public interface DesignService extends IService<Design> {
void processDesignBatch(Map<String, Object> designBatchResult);
Boolean sort(UserLikeSortDTO userLikeSortDTO);
Boolean sort(CollectionSortDTO userLikeSortDTO);
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 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;
@Resource
private UserLikeSortMapper userLikeSortMapper;
private CollectionSortMapper collectionSortMapper;
@Resource
private ProjectService projectService;
@Resource
@@ -1203,7 +1203,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
}
userLikeService.save(userLike);
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();
groupDetailId = userLike.getId();
String designUrl = designPythonOutfitMapper.selectById(userLike.getDesignOutfitId()).getDesignUrl();
@@ -1217,24 +1217,24 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
}
@Override
public UserLikeSort addCollectionSort(Long relationId, String relationType, Long projectId) {
public CollectionSort addCollectionSort(Long relationId, String relationType, Long projectId) {
int sort = getNextSort(projectId);
UserLikeSort userLikeSort = new UserLikeSort();
CollectionSort userLikeSort = new CollectionSort();
// userLikeSort.setUserLikeGroupId(userGroupId);
// userLikeSort.setUserLikeId(relationId);
userLikeSort.setProjectId(projectId);
userLikeSort.setRelationId(relationId);
userLikeSort.setRelationType(relationType);
userLikeSort.setSort(sort);
userLikeSortMapper.insert(userLikeSort);
collectionSortMapper.insert(userLikeSort);
return userLikeSort;
}
@Override
public int getNextSort(Long projectId) {
QueryWrapper<UserLikeSort> qw = new QueryWrapper<>();
qw.lambda().eq(UserLikeSort::getProjectId, projectId);
List<UserLikeSort> userLikeSorts = userLikeSortMapper.selectList(qw);
QueryWrapper<CollectionSort> qw = new QueryWrapper<>();
qw.lambda().eq(CollectionSort::getProjectId, projectId);
List<CollectionSort> userLikeSorts = collectionSortMapper.selectList(qw);
if (CollectionUtils.isEmpty(userLikeSorts)) {
return 1;
}
@@ -1328,30 +1328,30 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
@Override
public void deleteCollectionSort(Long relationId, String relationType, Long projectId) {
QueryWrapper<UserLikeSort> qw = new QueryWrapper<>();
qw.lambda().eq(UserLikeSort::getProjectId, projectId);
qw.lambda().orderByDesc(UserLikeSort::getSort);
List<UserLikeSort> userLikeSorts = userLikeSortMapper.selectList(qw);
UserLikeSort userLikeSort = getUserLikeSortByUserLikeId(relationId, relationType, projectId);
QueryWrapper<CollectionSort> qw = new QueryWrapper<>();
qw.lambda().eq(CollectionSort::getProjectId, projectId);
qw.lambda().orderByDesc(CollectionSort::getSort);
List<CollectionSort> userLikeSorts = collectionSortMapper.selectList(qw);
CollectionSort userLikeSort = getUserLikeSortByUserLikeId(relationId, relationType, projectId);
Long userLikeSortId = userLikeSort.getId();
for (UserLikeSort likeSort : userLikeSorts) {
for (CollectionSort likeSort : userLikeSorts) {
if (Objects.equals(likeSort.getId(), userLikeSortId)) {
userLikeSortMapper.deleteById(likeSort);
collectionSortMapper.deleteById(likeSort);
break;
}else {
likeSort.setSort(likeSort.getSort() - 1);
userLikeSortMapper.updateById(likeSort);
collectionSortMapper.updateById(likeSort);
}
}
}
@Override
public UserLikeSort getUserLikeSortByUserLikeId(Long userLikeId, String relationType, Long projectId) {
QueryWrapper<UserLikeSort> qw = new QueryWrapper<>();
qw.lambda().eq(UserLikeSort::getRelationId, userLikeId);
qw.lambda().eq(UserLikeSort::getRelationType, relationType);
qw.lambda().eq(UserLikeSort::getProjectId, projectId);
UserLikeSort userLikeSort = userLikeSortMapper.selectOne(qw);
public CollectionSort getUserLikeSortByUserLikeId(Long userLikeId, String relationType, Long projectId) {
QueryWrapper<CollectionSort> qw = new QueryWrapper<>();
qw.lambda().eq(CollectionSort::getRelationId, userLikeId);
qw.lambda().eq(CollectionSort::getRelationType, relationType);
qw.lambda().eq(CollectionSort::getProjectId, projectId);
CollectionSort userLikeSort = collectionSortMapper.selectOne(qw);
return userLikeSort;
}
@@ -2570,12 +2570,12 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
}
@Override
public Boolean sort(UserLikeSortDTO userLikeSortDTO) {
public Boolean sort(CollectionSortDTO userLikeSortDTO) {
// QueryWrapper<UserLikeSort> qw = new QueryWrapper<>();
// qw.lambda().eq(UserLikeSort::getUserLikeGroupId, userLikeSortDTO.getUserLikeGroupId());
// userLikeSortMapper.delete(qw);
for (UserLikeSort userLikeSort : userLikeSortDTO.getUserLikeSortList()) {
userLikeSortMapper.updateById(userLikeSort);
for (CollectionSort userLikeSort : userLikeSortDTO.getUserLikeSortList()) {
collectionSortMapper.updateById(userLikeSort);
}
return Boolean.TRUE;
}

View File

@@ -105,7 +105,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
@Resource
private ProductImageAttributeMapper productImageAttributeMapper;
@Resource
private UserLikeSortMapper userLikeSortMapper;
private CollectionSortMapper collectionSortMapper;
@Resource
private ClassificationService classificationService;
@Resource
@@ -201,17 +201,17 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
List<UserLikeVO> userLikeVOS = userLikeService.getGroupDetail(userGroupId);
String sex = null;
QueryWrapper<UserLikeSort> userLikeSortQw = new QueryWrapper<>();
userLikeSortQw.lambda().eq(UserLikeSort::getUserLikeGroupId, userGroupId);
List<UserLikeSort> userLikeSortList = userLikeSortMapper.selectList(userLikeSortQw);
QueryWrapper<CollectionSort> userLikeSortQw = new QueryWrapper<>();
userLikeSortQw.lambda().eq(CollectionSort::getUserLikeGroupId, userGroupId);
List<CollectionSort> userLikeSortList = collectionSortMapper.selectList(userLikeSortQw);
if (CollectionUtil.isEmpty(userLikeSortList)) {
Integer sort = 1;
for (UserLikeVO userLikeVO : userLikeVOS) {
UserLikeSort userLikeSort = new UserLikeSort();
CollectionSort userLikeSort = new CollectionSort();
userLikeSort.setUserLikeId(userLikeVO.getId());
userLikeSort.setUserLikeGroupId(userGroupId);
userLikeSort.setSort(sort);
userLikeSortMapper.insert(userLikeSort);
collectionSortMapper.insert(userLikeSort);
sort ++;
}
}
@@ -232,11 +232,11 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
o.setDesignOutfitId(tDesignPythonOutfit.getId());
}
QueryWrapper<UserLikeSort> userLikeSortQueryWrapper = new QueryWrapper<>();
userLikeSortQueryWrapper.lambda().eq(UserLikeSort::getUserLikeId, o.getId());
List<UserLikeSort> userLikeSorts = userLikeSortMapper.selectList(userLikeSortQueryWrapper);
QueryWrapper<CollectionSort> userLikeSortQueryWrapper = new QueryWrapper<>();
userLikeSortQueryWrapper.lambda().eq(CollectionSort::getUserLikeId, o.getId());
List<CollectionSort> userLikeSorts = collectionSortMapper.selectList(userLikeSortQueryWrapper);
if (CollectionUtil.isNotEmpty(userLikeSorts)) {
UserLikeSort userLikeSort = userLikeSorts.get(0);
CollectionSort userLikeSort = userLikeSorts.get(0);
o.setSort(userLikeSort.getSort());
o.setUserLikeSortId(userLikeSort.getId());
}
@@ -1520,16 +1520,16 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
moduleChooseVO.setSketchBoard(list);
}else if (module.equals(Module.design.name())) {
DesignModuleChooseVO vo = new DesignModuleChooseVO();
QueryWrapper<UserLikeSort> userLikeSortQueryWrapper = new QueryWrapper<>();
userLikeSortQueryWrapper.lambda().eq(UserLikeSort::getProjectId, projectDTO.getId());
userLikeSortQueryWrapper.lambda().orderByAsc(UserLikeSort::getSort);
List<UserLikeSort> userLikeSortList = userLikeSortMapper.selectList(userLikeSortQueryWrapper);
QueryWrapper<CollectionSort> userLikeSortQueryWrapper = new QueryWrapper<>();
userLikeSortQueryWrapper.lambda().eq(CollectionSort::getProjectId, projectDTO.getId());
userLikeSortQueryWrapper.lambda().orderByAsc(CollectionSort::getSort);
List<CollectionSort> userLikeSortList = collectionSortMapper.selectList(userLikeSortQueryWrapper);
if (CollectionUtils.isEmpty(userLikeSortList)) {
moduleChooseVO.setDesign(vo);
}else {
List<AllCollectionVO> list = new ArrayList<>();
for (UserLikeSort userLikeSort : userLikeSortList) {
for (CollectionSort userLikeSort : userLikeSortList) {
if (userLikeSort.getRelationType().equals(CollectionType.DESIGN.getValue())) {
UserLike userLike = userLikeMapper.selectById(userLikeSort.getRelationId());
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;
}
}