From 112294bd7baaa3c4c8b66f7bc2ce09a815d08c3e Mon Sep 17 00:00:00 2001 From: shahaibo <1023316923@qq.com> Date: Tue, 3 Jun 2025 11:23:13 +0800 Subject: [PATCH] =?UTF-8?q?TASK:collection=20sort=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ai/da/controller/DesignController.java | 3 +- .../controller/SavedCollectionController.java | 6 ++ .../mapper/primary/CollectionSortMapper.java | 7 +++ .../da/mapper/primary/UserLikeSortMapper.java | 7 --- ...{UserLikeSort.java => CollectionSort.java} | 2 +- .../da/model/dto/CollectionLikeUpdateDTO.java | 10 ++++ .../ai/da/model/dto/CollectionSortDTO.java | 13 +++++ .../com/ai/da/model/dto/UserLikeSortDTO.java | 13 ----- .../java/com/ai/da/service/DesignService.java | 8 +-- .../ai/da/service/UserLikeGroupService.java | 2 + .../ai/da/service/impl/DesignServiceImpl.java | 50 ++++++++--------- .../impl/UserLikeGroupServiceImpl.java | 55 ++++++++++++++----- 12 files changed, 110 insertions(+), 66 deletions(-) create mode 100644 src/main/java/com/ai/da/mapper/primary/CollectionSortMapper.java delete mode 100644 src/main/java/com/ai/da/mapper/primary/UserLikeSortMapper.java rename src/main/java/com/ai/da/mapper/primary/entity/{UserLikeSort.java => CollectionSort.java} (93%) create mode 100644 src/main/java/com/ai/da/model/dto/CollectionLikeUpdateDTO.java create mode 100644 src/main/java/com/ai/da/model/dto/CollectionSortDTO.java delete mode 100644 src/main/java/com/ai/da/model/dto/UserLikeSortDTO.java diff --git a/src/main/java/com/ai/da/controller/DesignController.java b/src/main/java/com/ai/da/controller/DesignController.java index ad3d1032..9ec1262c 100644 --- a/src/main/java/com/ai/da/controller/DesignController.java +++ b/src/main/java/com/ai/da/controller/DesignController.java @@ -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.Response; 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.vo.*; import com.ai.da.service.DesignService; @@ -76,7 +77,7 @@ public class DesignController { @ApiOperation(value = "Design sort") @PostMapping("/sort") - public Response sort(@Valid @RequestBody UserLikeSortDTO userLikeSortDTO) { + public Response sort(@Valid @RequestBody CollectionSortDTO userLikeSortDTO) { return Response.success(designService.sort(userLikeSortDTO)); } diff --git a/src/main/java/com/ai/da/controller/SavedCollectionController.java b/src/main/java/com/ai/da/controller/SavedCollectionController.java index e5995b22..d93c44fb 100644 --- a/src/main/java/com/ai/da/controller/SavedCollectionController.java +++ b/src/main/java/com/ai/da/controller/SavedCollectionController.java @@ -203,6 +203,12 @@ public class SavedCollectionController { return Response.success(userLikeGroupService.productImageLike(productImageLikeDTO)); } + @ApiOperation(value = "collectionLikeUpdate") + @PostMapping("/collectionLikeUpdate") + public Response collectionLikeUpdate(@Valid @RequestBody CollectionLikeUpdateDTO collectionLikeUpdateDTO) { + return Response.success(userLikeGroupService.collectionLikeUpdate(collectionLikeUpdateDTO)); + } + @ApiOperation(value = "productImageUnLike") @PostMapping("/productImageUnLike") public Response productImageUnLike(@Valid @RequestBody ProductImageLikeDTO productImageLikeDTO) { diff --git a/src/main/java/com/ai/da/mapper/primary/CollectionSortMapper.java b/src/main/java/com/ai/da/mapper/primary/CollectionSortMapper.java new file mode 100644 index 00000000..be6f335b --- /dev/null +++ b/src/main/java/com/ai/da/mapper/primary/CollectionSortMapper.java @@ -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 { +} diff --git a/src/main/java/com/ai/da/mapper/primary/UserLikeSortMapper.java b/src/main/java/com/ai/da/mapper/primary/UserLikeSortMapper.java deleted file mode 100644 index c6966249..00000000 --- a/src/main/java/com/ai/da/mapper/primary/UserLikeSortMapper.java +++ /dev/null @@ -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 { -} diff --git a/src/main/java/com/ai/da/mapper/primary/entity/UserLikeSort.java b/src/main/java/com/ai/da/mapper/primary/entity/CollectionSort.java similarity index 93% rename from src/main/java/com/ai/da/mapper/primary/entity/UserLikeSort.java rename to src/main/java/com/ai/da/mapper/primary/entity/CollectionSort.java index 0a474605..29aab074 100644 --- a/src/main/java/com/ai/da/mapper/primary/entity/UserLikeSort.java +++ b/src/main/java/com/ai/da/mapper/primary/entity/CollectionSort.java @@ -13,7 +13,7 @@ import java.util.Date; @EqualsAndHashCode(callSuper = false) @Accessors(chain = true) @TableName("collection_sort") -public class UserLikeSort implements Serializable { +public class CollectionSort implements Serializable { private static final long serialVersionUID = 1L; @TableId(value = "id", type = IdType.AUTO) diff --git a/src/main/java/com/ai/da/model/dto/CollectionLikeUpdateDTO.java b/src/main/java/com/ai/da/model/dto/CollectionLikeUpdateDTO.java new file mode 100644 index 00000000..7bf99ea5 --- /dev/null +++ b/src/main/java/com/ai/da/model/dto/CollectionLikeUpdateDTO.java @@ -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; +} diff --git a/src/main/java/com/ai/da/model/dto/CollectionSortDTO.java b/src/main/java/com/ai/da/model/dto/CollectionSortDTO.java new file mode 100644 index 00000000..6ad3e013 --- /dev/null +++ b/src/main/java/com/ai/da/model/dto/CollectionSortDTO.java @@ -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 userLikeSortList; +} diff --git a/src/main/java/com/ai/da/model/dto/UserLikeSortDTO.java b/src/main/java/com/ai/da/model/dto/UserLikeSortDTO.java deleted file mode 100644 index 9cf6dd8c..00000000 --- a/src/main/java/com/ai/da/model/dto/UserLikeSortDTO.java +++ /dev/null @@ -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 userLikeSortList; -} diff --git a/src/main/java/com/ai/da/service/DesignService.java b/src/main/java/com/ai/da/service/DesignService.java index 9de2ef13..1c5b742d 100644 --- a/src/main/java/com/ai/da/service/DesignService.java +++ b/src/main/java/com/ai/da/service/DesignService.java @@ -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 { */ 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 { 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 { void processDesignBatch(Map designBatchResult); - Boolean sort(UserLikeSortDTO userLikeSortDTO); + Boolean sort(CollectionSortDTO userLikeSortDTO); IPage cloudPage(CloudPageDTO cloudPageDTO); diff --git a/src/main/java/com/ai/da/service/UserLikeGroupService.java b/src/main/java/com/ai/da/service/UserLikeGroupService.java index 425ad6ae..017d6df4 100644 --- a/src/main/java/com/ai/da/service/UserLikeGroupService.java +++ b/src/main/java/com/ai/da/service/UserLikeGroupService.java @@ -113,4 +113,6 @@ public interface UserLikeGroupService extends IService { void toProductBatch(String taskId, String url, String progress); void relightBatch(String taskId, String url, String progress); + + Boolean collectionLikeUpdate(CollectionLikeUpdateDTO collectionLikeUpdateDTO); } diff --git a/src/main/java/com/ai/da/service/impl/DesignServiceImpl.java b/src/main/java/com/ai/da/service/impl/DesignServiceImpl.java index 5e8417e6..8bd2ba60 100644 --- a/src/main/java/com/ai/da/service/impl/DesignServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/DesignServiceImpl.java @@ -131,7 +131,7 @@ public class DesignServiceImpl extends ServiceImpl 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 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 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 qw = new QueryWrapper<>(); - qw.lambda().eq(UserLikeSort::getProjectId, projectId); - List userLikeSorts = userLikeSortMapper.selectList(qw); + QueryWrapper qw = new QueryWrapper<>(); + qw.lambda().eq(CollectionSort::getProjectId, projectId); + List userLikeSorts = collectionSortMapper.selectList(qw); if (CollectionUtils.isEmpty(userLikeSorts)) { return 1; } @@ -1328,30 +1328,30 @@ public class DesignServiceImpl extends ServiceImpl impleme @Override public void deleteCollectionSort(Long relationId, String relationType, Long projectId) { - QueryWrapper qw = new QueryWrapper<>(); - qw.lambda().eq(UserLikeSort::getProjectId, projectId); - qw.lambda().orderByDesc(UserLikeSort::getSort); - List userLikeSorts = userLikeSortMapper.selectList(qw); - UserLikeSort userLikeSort = getUserLikeSortByUserLikeId(relationId, relationType, projectId); + QueryWrapper qw = new QueryWrapper<>(); + qw.lambda().eq(CollectionSort::getProjectId, projectId); + qw.lambda().orderByDesc(CollectionSort::getSort); + List 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 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 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 impleme } @Override - public Boolean sort(UserLikeSortDTO userLikeSortDTO) { + public Boolean sort(CollectionSortDTO userLikeSortDTO) { // QueryWrapper 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; } diff --git a/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java b/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java index 9ff70562..6af6892f 100644 --- a/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java @@ -105,7 +105,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl userLikeVOS = userLikeService.getGroupDetail(userGroupId); String sex = null; - QueryWrapper userLikeSortQw = new QueryWrapper<>(); - userLikeSortQw.lambda().eq(UserLikeSort::getUserLikeGroupId, userGroupId); - List userLikeSortList = userLikeSortMapper.selectList(userLikeSortQw); + QueryWrapper userLikeSortQw = new QueryWrapper<>(); + userLikeSortQw.lambda().eq(CollectionSort::getUserLikeGroupId, userGroupId); + List 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 userLikeSortQueryWrapper = new QueryWrapper<>(); - userLikeSortQueryWrapper.lambda().eq(UserLikeSort::getUserLikeId, o.getId()); - List userLikeSorts = userLikeSortMapper.selectList(userLikeSortQueryWrapper); + QueryWrapper userLikeSortQueryWrapper = new QueryWrapper<>(); + userLikeSortQueryWrapper.lambda().eq(CollectionSort::getUserLikeId, o.getId()); + List 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 userLikeSortQueryWrapper = new QueryWrapper<>(); - userLikeSortQueryWrapper.lambda().eq(UserLikeSort::getProjectId, projectDTO.getId()); - userLikeSortQueryWrapper.lambda().orderByAsc(UserLikeSort::getSort); - List userLikeSortList = userLikeSortMapper.selectList(userLikeSortQueryWrapper); + QueryWrapper userLikeSortQueryWrapper = new QueryWrapper<>(); + userLikeSortQueryWrapper.lambda().eq(CollectionSort::getProjectId, projectDTO.getId()); + userLikeSortQueryWrapper.lambda().orderByAsc(CollectionSort::getSort); + List userLikeSortList = collectionSortMapper.selectList(userLikeSortQueryWrapper); if (CollectionUtils.isEmpty(userLikeSortList)) { moduleChooseVO.setDesign(vo); }else { List 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