From fa742360358fc5ca424297f83be5be162341791e Mon Sep 17 00:00:00 2001 From: litianxiang Date: Tue, 16 Sep 2025 11:07:54 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BA=8C=E5=88=9B=E6=8A=A5?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/primary/CollectionSortMapper.java | 7 + .../da/service/impl/PortfolioServiceImpl.java | 469 ++++++++++-------- 2 files changed, 272 insertions(+), 204 deletions(-) diff --git a/src/main/java/com/ai/da/mapper/primary/CollectionSortMapper.java b/src/main/java/com/ai/da/mapper/primary/CollectionSortMapper.java index a9b6fde9..1173a2ab 100644 --- a/src/main/java/com/ai/da/mapper/primary/CollectionSortMapper.java +++ b/src/main/java/com/ai/da/mapper/primary/CollectionSortMapper.java @@ -3,8 +3,11 @@ package com.ai.da.mapper.primary; import com.ai.da.common.config.mybatis.plus.CommonMapper; import com.ai.da.mapper.primary.entity.CollectionSort; import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Update; +import java.util.List; + public interface CollectionSortMapper extends CommonMapper { @Update("UPDATE collection_sort SET sort = sort + 1 " + "WHERE parent_id = #{parentId} " + @@ -15,4 +18,8 @@ public interface CollectionSortMapper extends CommonMapper { @Param("relationType") String relationType, @Param("originalSort") int originalSort ); + + @Select("SELECT * FROM collection_sort WHERE parent_id IN (SELECT id FROM collection_sort WHERE relation_id = #{relationId})") + List queryCollectionSortsIsNotDesignByUserLikeRelationId(@Param("relationId") Long relationId); + } diff --git a/src/main/java/com/ai/da/service/impl/PortfolioServiceImpl.java b/src/main/java/com/ai/da/service/impl/PortfolioServiceImpl.java index 1c2fcbad..124dd3de 100644 --- a/src/main/java/com/ai/da/service/impl/PortfolioServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/PortfolioServiceImpl.java @@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil; import com.ai.da.common.config.exception.BusinessException; import com.ai.da.common.constant.CommonConstant; import com.ai.da.common.context.UserContext; +import com.ai.da.common.enums.CollectionLevel1TypeEnum; import com.ai.da.common.response.PageBaseResponse; import com.ai.da.common.response.ResultEnum; import com.ai.da.common.utils.CopyUtil; @@ -13,6 +14,7 @@ import com.ai.da.mapper.primary.*; import com.ai.da.mapper.primary.entity.*; import com.ai.da.mapper.primary.entity.Collection; import com.ai.da.model.dto.*; +import com.ai.da.model.enums.CollectionType; import com.ai.da.model.enums.DesignProcess; import com.ai.da.model.enums.Position; import com.ai.da.model.enums.Sex; @@ -57,6 +59,8 @@ public class PortfolioServiceImpl extends ServiceImpl().eq("project_id", portfolioDTO.getProjectId())); - if (Objects.isNull(likeGroup)){ + if (Objects.isNull(likeGroup)) { return null; } userLikeGroupId = likeGroup.getId(); @@ -447,13 +460,13 @@ public class PortfolioServiceImpl extends ServiceImpl userLikeList = projectSnapshot.getUserLikeList(); - if (userLikeList != null && !userLikeList.isEmpty()){ + if (userLikeList != null && !userLikeList.isEmpty()) { List list = new ArrayList<>(); for (UserLikeSnapshot userLikeSnapshot : userLikeList) { TDesignPythonOutfit designPythonOutfit = userLikeSnapshot.getDesignPythonOutfit(); @@ -556,19 +569,19 @@ public class PortfolioServiceImpl extends ServiceImpl getSelectedQw = new QueryWrapper<>(); - getSelectedQw.lambda().eq(UserLikeGroup::getAccountId, portfolioDTO.getAccountId()); + getSelectedQw.lambda().eq(UserLikeGroup::getAccountId, userHolder.getId()); getSelectedQw.lambda().eq(UserLikeGroup::getOriginalPortfolioId, vo.getId()); List userLikeGroups = userLikeGroupMapper.selectList(getSelectedQw); if (CollectionUtils.isEmpty(userLikeGroups)) { @@ -616,18 +629,17 @@ public class PortfolioServiceImpl extends ServiceImpl collectionElementListOld = projectSnapshot.getCollectionElementList(); + UserLikeGroup userLikeGroupOld = projectSnapshot.getUserLikeGroup(); + List userLikeListOld = projectSnapshot.getUserLikeList(); + Project project = CopyUtil.copyObject(projectOld, Project.class); project.setCreateTime(LocalDateTime.now()); project.setId(null); @@ -653,182 +665,230 @@ public class PortfolioServiceImpl extends ServiceImpl collectionElementListOld = projectSnapshot.getCollectionElementList(); - Long collectionIdNew; - if (collectionElementListOld.isEmpty()){ - throw new BusinessException("No elements in collection."); - } else { - Long collectionIdOld = collectionElementListOld.get(0).getCollectionId(); - Collection collection = collectionMapper.selectById(collectionIdOld); - if (Objects.nonNull(collection) && Objects.nonNull(collection.getMoodTemplateId())){ - CollectionElement moodTemplateElement = collectionElementMapper.selectById(collection.getMoodTemplateId()); - if (Objects.nonNull(moodTemplateElement)){ - moodTemplateElement.setId(null); - moodTemplateElement.setAccountId(accountId); - moodTemplateElement.setProjectId(projectIdNew); - moodTemplateElement.setCreateDate(new Date()); - collectionElementMapper.insert(moodTemplateElement); - - collection.setMoodTemplateId(String.valueOf(moodTemplateElement.getId())); - } - } - collection.setId(null); - collection.setAccountId(accountId); - collection.setCreateDate(new Date()); - collectionMapper.insert(collection); - - collectionIdNew = collection.getId(); - } - - Design design = new Design(); - design.setCollectionId(collectionIdNew); - design.setAccountId(authPrincipalVo.getId()); - if (workspace.getSex().equals(Sex.FEMALE.getValue())) { - design.setTemplateId(workspace.getMannequinFemaleId()); - design.setModelType(workspace.getMannequinFemaleType()); - } else { - design.setTemplateId(workspace.getMannequinMaleId()); - design.setModelType(workspace.getMannequinMaleType()); - } - design.setSystemScale(BigDecimal.valueOf(workspace.getSystemDesignerPercentage())); - if (workspace.getPosition().equals(Position.OVERALL.getValue())) { - design.setSingleOverall("overall"); - design.setSwitchCategory(""); - project.setProcess(DesignProcess.SERIES_DESIGN.name()); - } else { - design.setSingleOverall("single"); - design.setSwitchCategory(workspace.getPosition()); - project.setProcess(DesignProcess.SINGLE_DESIGN.name()); - } - design.setCreateDate(new Date()); - designMapper.insert(design); - projectMapper.updateById(project); + workspaceOld.setAccountId(accountId); + workspaceOld.setProjectId(projectIdNew); + workspaceOld.setId(null); + workspaceMapper.insert(workspaceOld); + // 复制collectionElement for (CollectionElement element : collectionElementListOld) { - element.setCollectionId(collectionIdNew); - element.setProjectId(projectIdNew); - element.setId(null); - element.setCreateDate(new Date()); - element.setUpdateDate(null); - collectionElementMapper.insert(element); + if (element.getLevel1Type().equals(CollectionLevel1TypeEnum.MODEL.getRealName())) { + LambdaQueryWrapper relModelLambdaQueryWrapper = new LambdaQueryWrapper<>(); + relModelLambdaQueryWrapper.eq(CollectionElementRelModel::getCollectionElementId, element.getId()); + CollectionElementRelModel collectionElementRelModelCopy = collectionElementRelModelMapper.selectOne(relModelLambdaQueryWrapper); +// element.setCollectionId(collectionIdNew); + element.setId(null); + element.setCreateDate(new Date()); + element.setUpdateDate(null); + element.setAccountId(accountId); + element.setProjectId(projectIdNew); + collectionElementMapper.insert(element); + Long collectionElementNewID = element.getId(); + if (collectionElementRelModelCopy != null) { + collectionElementRelModelCopy.setId(null); + collectionElementRelModelCopy.setCollectionElementId(collectionElementNewID); + collectionElementRelModelMapper.insert(collectionElementRelModelCopy); + } + ; + } else { +// element.setCollectionId(collectionIdNew); + element.setId(null); + element.setCreateDate(new Date()); + element.setUpdateDate(null); + element.setAccountId(accountId); + element.setProjectId(projectIdNew); + collectionElementMapper.insert(element); + } + } - if (Objects.nonNull(userLikeGroup)) { - Long portfolioUserLikeGroupId = userLikeGroup.getId(); - UserLikeGroup userLikeGroupNew = projectSnapshot.getUserLikeGroup(); - userLikeGroupNew.setId(null); - userLikeGroupNew.setCollectionId(collectionIdNew); - userLikeGroupNew.setCreateDate(new Date()); - userLikeGroupNew.setProjectId(projectIdNew); + if (userLikeGroupOld != null) { + + Long collectionIdOld = userLikeGroupOld.getCollectionId(); + Collection collectionCopy = collectionMapper.selectById(collectionIdOld); + collectionCopy.setId(null); + collectionCopy.setAccountId(accountId); + collectionCopy.setCreateDate(new Date()); + collectionMapper.insert(collectionCopy); + Long collectionIdNew = collectionCopy.getId(); + + userLikeGroupOld.setId(null); + userLikeGroupOld.setCollectionId(collectionIdNew); + userLikeGroupOld.setCreateDate(new Date()); + userLikeGroupOld.setProjectId(projectIdNew); if (portfolio.getOriginal() == 1) { if (Objects.equals(portfolio.getAccountId(), accountId)) { - userLikeGroupNew.setOriginal(1); + userLikeGroupOld.setOriginal(1); } else { - userLikeGroupNew.setOriginal(0); - userLikeGroupNew.setOriginalAccountId(portfolio.getAccountId()); - userLikeGroupNew.setOriginalPortfolioId(portfolio.getId()); + userLikeGroupOld.setOriginal(0); + userLikeGroupOld.setOriginalAccountId(portfolio.getAccountId()); + userLikeGroupOld.setOriginalPortfolioId(portfolio.getId()); } } else { - userLikeGroupNew.setOriginal(0); - userLikeGroupNew.setOriginalAccountId(portfolio.getOriginalAccountId()); - userLikeGroupNew.setOriginalPortfolioId(portfolio.getId()); + userLikeGroupOld.setOriginal(0); + userLikeGroupOld.setOriginalAccountId(portfolio.getOriginalAccountId()); + userLikeGroupOld.setOriginalPortfolioId(portfolio.getId()); } - userLikeGroupNew.setAccountId(accountId); - userLikeGroupNew.setUpdateDate(new Date()); - userLikeGroupMapper.insert(userLikeGroupNew); + userLikeGroupOld.setAccountId(accountId); + userLikeGroupOld.setUpdateDate(new Date()); + userLikeGroupMapper.insert(userLikeGroupOld); + Long userLikeGroupIdNew = userLikeGroupOld.getId(); - List userLikeList = projectSnapshot.getUserLikeList(); - if (CollectionUtil.isNotEmpty(userLikeList)) { - for (UserLikeSnapshot userLike : userLikeList) { - Long designOutfitIdOld = userLike.getDesignOutfitId(); - TDesignPythonOutfit designPythonOutfit = userLike.getDesignPythonOutfit(); - designPythonOutfit.setDesignId(design.getId()); - designPythonOutfit.setDesignItemId(-1L); - designPythonOutfit.setCollectionId(collectionIdNew); - designPythonOutfit.setCreateDate(LocalDateTime.now()); - designPythonOutfit.setId(null); - // 这里插入的accountId是原作者的(二创),是否需要修改? - designPythonOutfitMapper.insert(designPythonOutfit); - Long designOutfitIdNew = designPythonOutfit.getId(); - userLike.setDesignOutfitId(designOutfitIdNew); + //根据designId进行分组 + Map> userLikeMapByDesignId = userLikeListOld.stream() + .filter(userLikeSnapshot -> userLikeSnapshot.getDesignItem() != null) + .collect(Collectors.groupingBy(userLikeSnapshot -> userLikeSnapshot.getDesignItem().getDesignId())); + userLikeMapByDesignId.forEach((designId, userLikeListOld1) -> { + Design design = designMapper.selectById(designId); + design.setId(null); + design.setCollectionId(collectionIdNew); + design.setAccountId(accountId); + design.setCreateDate(new Date()); + designMapper.insert(design); - QueryWrapper qw = new QueryWrapper<>(); - qw.lambda().eq(TDesignPythonOutfitDetail::getDesignPythonOutfitId, designOutfitIdOld); - List tDesignPythonOutfitDetails = userLike.getTDesignPythonOutfitDetailList(); - if (CollectionUtil.isNotEmpty(tDesignPythonOutfitDetails)){ - for (TDesignPythonOutfitDetail tDesignPythonOutfitDetail : tDesignPythonOutfitDetails) { - tDesignPythonOutfitDetail.setId(null); - tDesignPythonOutfitDetail.setUserId(accountId); - tDesignPythonOutfitDetail.setDesignId(design.getId()); - tDesignPythonOutfitDetail.setDesignPythonOutfitId(designOutfitIdNew); - tDesignPythonOutfitDetail.setCreateDate(LocalDateTime.now()); - designPythonOutfitDetailMapper.insert(tDesignPythonOutfitDetail); - } - } + for (UserLikeSnapshot userLikeSnapshot : userLikeListOld1) { - DesignItem designItemOld = userLike.getDesignItem(); - designItemOld.setId(null); - designItemOld.setAccountId(accountId); - designItemOld.setDesignId(design.getId()); - designItemOld.setCollectionId(collectionIdNew); - designItemOld.setCreateDate(new Date()); - designItemMapper.insert(designItemOld); - Long designItemIdNew = designItemOld.getId(); - designPythonOutfit.setDesignItemId(designItemIdNew); - designPythonOutfitMapper.updateById(designPythonOutfit); + // 4. 处理DesignItem数据 + DesignItem designItem = userLikeSnapshot.getDesignItem(); + if (designItem != null) { + designItem.setId(null); + designItem.setAccountId(accountId); + designItem.setDesignId(design.getId()); + designItem.setCollectionId(collectionIdNew); + designItem.setCreateDate(new Date()); + designItemMapper.insert(designItem); - userLike.setDesignItemId(designItemIdNew); - userLike.setId(null); - userLike.setDesignId(design.getId()); - userLike.setUserLikeGroupId(userLikeGroupNew.getId()); - userLike.setCreateDate(new Date()); - userLikeMapper.insert(userLike); + // 5. 处理DesignItemDetailSnapshot数据 + List itemDetailSnapshots = userLikeSnapshot.getDesignItemDetailList(); + if (itemDetailSnapshots != null && !itemDetailSnapshots.isEmpty()) { + for (DesignItemDetailSnapshot itemDetailSnapshot : itemDetailSnapshots) { + //只复制未删除的 + if (itemDetailSnapshot.getIsDeleted() == 1) { + continue; + } + // 转换为原实体类 + DesignItemDetail designItemDetail = CopyUtil.copyObject(itemDetailSnapshot, DesignItemDetail.class); + designItemDetail.setId(null); + // 更新外键为新插入的designItem的ID + designItemDetail.setDesignItemId(designItem.getId()); + designItemDetail.setDesignId(design.getId()); + designItemDetail.setCreateDate(new Date()); + designItemDetail.setAccountId(accountId); + designItemDetailMapper.insert(designItemDetail); - // 加入collection_sort表 - collectionSortService.addCollectionSort(userLike.getId(), "Design", projectIdNew, null); - - List designItemDetailList = userLike.getDesignItemDetailList(); - if (CollectionUtil.isNotEmpty(designItemDetailList)) { - for (DesignItemDetailSnapshot designItemDetailOld : designItemDetailList) { - designItemDetailOld.setId(null); - designItemDetailOld.setAccountId(accountId); - designItemDetailOld.setDesignId(design.getId()); - designItemDetailOld.setDesignItemId(designItemIdNew); - designItemDetailOld.setCreateDate(new Date()); - designItemDetailMapper.insert(designItemDetailOld); - Long designItemDetailIdNew = designItemDetailOld.getId(); - - List designItemDetailPrintList = designItemDetailOld.getDesignItemDetailPrintList(); - if (CollectionUtil.isNotEmpty(designItemDetailPrintList)) { - for (DesignItemDetailPrint designItemDetailPrint : designItemDetailPrintList) { - designItemDetailPrint.setId(null); - designItemDetailPrint.setDesignItemDetailId(designItemDetailIdNew); - designItemDetailPrint.setCreateDate(LocalDateTime.now()); - designItemDetailPrintMapper.insert(designItemDetailPrint); + // 6. 处理DesignItemDetailPrint数据 + List prints = itemDetailSnapshot.getDesignItemDetailPrintList(); + if (prints != null && !prints.isEmpty()) { + for (DesignItemDetailPrint print : prints) { + print.setId(null); + print.setCreateDate(LocalDateTime.now()); + // 更新外键为新插入的designItemDetail的ID + print.setDesignItemDetailId(designItemDetail.getId()); + designItemDetailPrintMapper.insert(print); + } } } } } + + + // 2. 处理DesignPythonOutfit数据 + TDesignPythonOutfit outfit = userLikeSnapshot.getDesignPythonOutfit(); + if (outfit != null) { + // 清除原有ID,使用新ID插入 + outfit.setId(null); + outfit.setDesignId(design.getId()); + outfit.setCollectionId(collectionIdNew); + outfit.setCreateDate(LocalDateTime.now()); + outfit.setDesignItemId(designItem.getId()); + designPythonOutfitMapper.insert(outfit); + + // 3. 处理TDesignPythonOutfitDetail数据 + List outfitDetails = userLikeSnapshot.getTDesignPythonOutfitDetailList(); + if (outfitDetails != null && !outfitDetails.isEmpty()) { + for (TDesignPythonOutfitDetail detail : outfitDetails) { + detail.setId(null); + // 更新外键为新插入的outfit的ID + detail.setDesignPythonOutfitId(outfit.getId()); + detail.setCreateDate(LocalDateTime.now()); + detail.setUpdateDate(LocalDateTime.now()); + detail.setUserId(accountId); + detail.setDesignId(design.getId()); + designPythonOutfitDetailMapper.insert(detail); + } + } + } + + UserLike userLike = CopyUtil.copyObject(userLikeSnapshot, UserLike.class); + + userLike.setId(null); + userLike.setDesignId(design.getId()); + userLike.setUserLikeGroupId(userLikeGroupIdNew); + userLike.setDesignItemId(designItem.getId()); + userLike.setDesignOutfitId(outfit.getId()); + userLikeService.save(userLike); + CollectionSort collectionSortDesign = new CollectionSort(); + collectionSortDesign.setProjectId(project.getId()); + collectionSortDesign.setRelationId(userLike.getId()); + collectionSortDesign.setRelationType(CollectionType.DESIGN.getValue()); + collectionSortDesign.setCreateTime(LocalDateTime.now()); + int nextSort = collectionSortService.getNextSort(projectIdNew, null); + collectionSortDesign.setSort(nextSort); + collectionSortMapper.insert(collectionSortDesign); + + //此集合为根据UserLikeId查询到的非Design类型的集合 + List collectionSorts = collectionSortMapper.queryCollectionSortsIsNotDesignByUserLikeRelationId(userLikeSnapshot.getId()); + if (collectionSorts != null && !collectionSorts.isEmpty()) { + for (CollectionSort collectionSort : collectionSorts) { + + CollectionSort collectionSortNew = new CollectionSort(); + if (collectionSort.getRelationType().equals(CollectionType.TO_PRODUCT_IMAGE.getValue()) || collectionSort.getRelationType().equals(CollectionType.RELIGHT.getValue())) { + ToProductImageResult toProductImageResult = toProductImageResultMapper.selectById(collectionSort.getRelationId()); + ToProductImageRecord toProductImageRecord = toProductImageRecordMapper.selectById(toProductImageResult.getToProductImageRecordId()); + toProductImageRecord.setId(null); + toProductImageRecord.setProjectId(projectIdNew); + toProductImageRecord.setCreateTime(LocalDateTime.now()); + toProductImageRecord.setUserLikeGroupId(userLikeGroupIdNew); + toProductImageRecordMapper.insert(toProductImageRecord); + toProductImageResult.setId(null); + toProductImageResult.setProjectId(projectIdNew); + toProductImageResult.setToProductImageRecordId(toProductImageRecord.getId()); + toProductImageResult.setCreateTime(LocalDateTime.now()); + toProductImageResult.setUserLikeGroupId(userLikeGroupIdNew); + toProductImageResultMapper.insert(toProductImageResult); + collectionSortNew.setRelationId(toProductImageResult.getId()); + } else if (collectionSort.getRelationType().equals(CollectionType.POSE_TRANSFORM.getValue())) { + PoseTransformation poseTransformation = poseTransformationMapper.selectById(collectionSort.getRelationId()); + poseTransformation.setId(null); + poseTransformation.setProjectId(projectIdNew); + poseTransformation.setCreateTime(LocalDateTime.now()); + poseTransformation.setUpdateTime(LocalDateTime.now()); + poseTransformation.setAccountId(accountId); + poseTransformationMapper.insert(poseTransformation); + collectionSortNew.setRelationId(poseTransformation.getId()); + + } + collectionSortNew.setProjectId(project.getId()); + collectionSortNew.setRelationType(collectionSort.getRelationType()); + collectionSortNew.setCreateTime(LocalDateTime.now()); + collectionSortNew.setParentId(collectionSortDesign.getId()); + int nextSort2 = collectionSortService.getNextSort(projectIdNew, collectionSortDesign.getId()); + collectionSortNew.setSort(nextSort2); + collectionSortMapper.insert(collectionSortNew); + } + } + } - } + }); + + } - - ProjectDTO projectDTO = new ProjectDTO(); projectDTO.setId(project.getId()); - return userLikeGroupService.choose(projectDTO); } @@ -1045,7 +1105,7 @@ public class PortfolioServiceImpl extends ServiceImpl tags, Long portfolioId, Long userLikeGroupId) { List collect = tags.stream().map(Tags::getTagName).collect(Collectors.toList()); - if (!collect.contains(CommonConstant.RCA_WORKSHOP_TAG)){ + if (!collect.contains(CommonConstant.RCA_WORKSHOP_TAG)) { return false; - }else { + } else { UserLikeGroup userLikeGroup = userLikeGroupService.getById(userLikeGroupId); // 不是原创的作品不能参与活动 - if (userLikeGroup.getOriginal().equals(0)){ + if (userLikeGroup.getOriginal().equals(0)) { throw new BusinessException("only.original.works.can.participate.in.the.event", ResultEnum.PROMPT.getCode()); } List byTag = baseMapper.getByTag(accountId, CommonConstant.RCA_WORKSHOP_TAG); - if (byTag.isEmpty()){ + if (byTag.isEmpty()) { return false; - }else if (!Objects.isNull(portfolioId)){ + } else if (!Objects.isNull(portfolioId)) { boolean contains = byTag.stream().map(Portfolio::getId).collect(Collectors.toList()).contains(portfolioId); return !contains; - }else { + } else { return true; } } @@ -1084,10 +1144,10 @@ public class PortfolioServiceImpl extends ServiceImpl { Long tagId; - if (Objects.isNull(tag.getId())){ + if (Objects.isNull(tag.getId())) { Tags tags = tagsService.addTag(tag.getTagName()); tagId = tags.getId(); - }else { + } else { tagId = tag.getId(); } portfolioTagsMapper.insertIgnore(portfolioId, tagId, LocalDateTime.now()); @@ -1096,12 +1156,12 @@ public class PortfolioServiceImpl extends ServiceImpl queryPortfolioByTag(String tagName, Long tagId, Integer page, Integer size) { long bestMatchTagId; - if (Objects.isNull(tagId)){ + if (Objects.isNull(tagId)) { List> matchingTags = tagsMapper.getMatchingTags(tagName); Map tagMap = matchingTags.get(0); bestMatchTagId = Long.parseLong(tagMap.get("id")); - }else { + } else { bestMatchTagId = tagId; } @@ -1111,7 +1171,7 @@ public class PortfolioServiceImpl extends ServiceImpl portfolioTags = portfolioTagsMapper.selectList(queryWrapper); List portfolioIdList = portfolioTags.stream().map(PortfolioTags::getPortfolioId).collect(Collectors.toList()); - if (!portfolioIdList.isEmpty()){ + if (!portfolioIdList.isEmpty()) { QueryWrapper qw = new QueryWrapper<>(); qw.in("id", portfolioIdList); Page portfolioPage = baseMapper.selectPage(new Page<>(page, size), qw); @@ -1134,7 +1194,7 @@ public class PortfolioServiceImpl extends ServiceImpl()); } @@ -1194,16 +1254,16 @@ public class PortfolioServiceImpl extends ServiceImpl followeeList; if (!StringUtil.isNullOrEmpty(getFollowListDTO.getSearchByName())) { - followeeList = userFollowMapper.getFolloweeListByName(getFollowListDTO.getSearchByName(), accountId); - }else { + followeeList = userFollowMapper.getFolloweeListByName(getFollowListDTO.getSearchByName(), accountId); + } else { // 2、查全部 分页查询 String order = StringUtil.isNullOrEmpty(getFollowListDTO.getOrder()) ? "DESC" : getFollowListDTO.getOrder().equals("DESC") ? "DESC" : "ASC"; - Integer limit= getFollowListDTO.getSize() > 0 ? getFollowListDTO.getSize() : 20; + Integer limit = getFollowListDTO.getSize() > 0 ? getFollowListDTO.getSize() : 20; Integer offset = getFollowListDTO.getPage() > 0 ? (getFollowListDTO.getPage() - 1) * getFollowListDTO.getSize() : 0; followeeList = userFollowMapper.getFolloweeListByFollower(accountId, limit, offset, order); } - if (!followeeList.isEmpty()){ + if (!followeeList.isEmpty()) { followeeList.forEach(followee -> { String avatar = StringUtil.isNullOrEmpty(followee.getAvatar()) ? CommonConstant.DEFAULT_AVATAR : followee.getAvatar(); followee.setAvatar(minioUtil.getPreSignedUrl(avatar, CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); @@ -1225,7 +1285,7 @@ public class PortfolioServiceImpl extends ServiceImpl qw = new QueryWrapper<>(); - qw.eq("follower_id", accountId).select("followee_id","create_time"); + qw.eq("follower_id", accountId).select("followee_id", "create_time"); List userFollows = userFollowMapper.selectList(qw); Map followeeMap = userFollows.stream().collect(Collectors.toMap(UserFollow::getFolloweeId, UserFollow::getCreateTime)); @@ -1233,15 +1293,15 @@ public class PortfolioServiceImpl extends ServiceImpl 0 ? getFollowListDTO.getSize() : 20; + Integer limit = getFollowListDTO.getSize() > 0 ? getFollowListDTO.getSize() : 20; Integer offset = getFollowListDTO.getPage() > 0 ? (getFollowListDTO.getPage() - 1) * getFollowListDTO.getSize() : 0; - followerList = userFollowMapper.getFollowerListByFollowee(accountId, limit,offset, order); + followerList = userFollowMapper.getFollowerListByFollowee(accountId, limit, offset, order); } - if (!followerList.isEmpty()){ + if (!followerList.isEmpty()) { // 判断当前用户是否与粉丝互关 followerList.forEach(follower -> { String avatar = StringUtil.isNullOrEmpty(follower.getAvatar()) ? CommonConstant.DEFAULT_AVATAR : follower.getAvatar(); @@ -1271,10 +1331,11 @@ public class PortfolioServiceImpl extends ServiceImpl getFolloweeList(Long accountId){ + public List getFolloweeList(Long accountId) { QueryWrapper qw = new QueryWrapper<>(); qw.eq("follower_id", accountId).select("followee_id"); @@ -1282,22 +1343,22 @@ public class PortfolioServiceImpl extends ServiceImpl