From d128ef42c1b956e823051b3fdb7edb259e9ce443 Mon Sep 17 00:00:00 2001 From: liujiang <569804566@qq.com> Date: Sat, 12 Jul 2025 20:29:20 +0800 Subject: [PATCH] =?UTF-8?q?master=EF=BC=9AAPP=20=E5=AE=9E=E5=8A=9B?= =?UTF-8?q?=E8=B4=A8=E9=80=A0=E8=B0=83=E4=BC=98=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/strength/APPStrengthStoreFileDTO.java | 23 ++++++++++++++++ .../xkt/mapper/StoreProductFileMapper.java | 8 ++++++ .../impl/UserSubscriptionsServiceImpl.java | 9 ++++--- .../service/impl/WebsiteAPPServiceImpl.java | 5 +++- .../mapper/StoreProductFileMapper.xml | 27 +++++++++++++++++++ 5 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 xkt/src/main/java/com/ruoyi/xkt/dto/advertRound/app/strength/APPStrengthStoreFileDTO.java diff --git a/xkt/src/main/java/com/ruoyi/xkt/dto/advertRound/app/strength/APPStrengthStoreFileDTO.java b/xkt/src/main/java/com/ruoyi/xkt/dto/advertRound/app/strength/APPStrengthStoreFileDTO.java new file mode 100644 index 000000000..cf4b5ccac --- /dev/null +++ b/xkt/src/main/java/com/ruoyi/xkt/dto/advertRound/app/strength/APPStrengthStoreFileDTO.java @@ -0,0 +1,23 @@ +package com.ruoyi.xkt.dto.advertRound.app.strength; + +import com.fasterxml.jackson.annotation.JsonInclude; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * @author liujiang + * @version v1.0 + * @date 2025/3/27 15:12 + */ +@Data +@Accessors(chain = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class APPStrengthStoreFileDTO { + + @ApiModelProperty(value = "档口ID") + private Long storeId; + @ApiModelProperty(value = "商品第一张主图路径") + private String mainPicUrl; + +} diff --git a/xkt/src/main/java/com/ruoyi/xkt/mapper/StoreProductFileMapper.java b/xkt/src/main/java/com/ruoyi/xkt/mapper/StoreProductFileMapper.java index 4ff983678..96cbd9b5d 100644 --- a/xkt/src/main/java/com/ruoyi/xkt/mapper/StoreProductFileMapper.java +++ b/xkt/src/main/java/com/ruoyi/xkt/mapper/StoreProductFileMapper.java @@ -2,6 +2,7 @@ package com.ruoyi.xkt.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.xkt.domain.StoreProductFile; +import com.ruoyi.xkt.dto.advertRound.app.strength.APPStrengthStoreFileDTO; import com.ruoyi.xkt.dto.storeProductFile.StoreProdFileLatestFourProdDTO; import com.ruoyi.xkt.dto.storeProductFile.StoreProdFilePicSpaceResDTO; import com.ruoyi.xkt.dto.storeProductFile.StoreProdFileResDTO; @@ -75,4 +76,11 @@ public interface StoreProductFileMapper extends BaseMapper { */ List selectVideoAndMainPicList(Long storeProdId); + /** + * 筛选档口随机主图 + * + * @param storeIdList 档口ID列表 + * @return List + */ + List selectRandomStoreFileList(@Param("storeIdList") List storeIdList); } diff --git a/xkt/src/main/java/com/ruoyi/xkt/service/impl/UserSubscriptionsServiceImpl.java b/xkt/src/main/java/com/ruoyi/xkt/service/impl/UserSubscriptionsServiceImpl.java index 927085c3c..99810d3dd 100644 --- a/xkt/src/main/java/com/ruoyi/xkt/service/impl/UserSubscriptionsServiceImpl.java +++ b/xkt/src/main/java/com/ruoyi/xkt/service/impl/UserSubscriptionsServiceImpl.java @@ -67,16 +67,19 @@ public class UserSubscriptionsServiceImpl implements IUserSubscriptionsService { @Transactional public Integer create(UserSubscDTO subscDTO) { // 获取当前登录用户 - LoginUser loginUser = SecurityUtils.getLoginUser(); + Long userId = SecurityUtils.getUserIdSafe(); + if (ObjectUtils.isEmpty(userId)) { + throw new ServiceException("用户未登录或不存在,请登录后关注档口!", HttpStatus.ERROR); + } // 判断是否已关注过 UserSubscriptions exist = this.userSubMapper.selectOne(new LambdaQueryWrapper() - .eq(UserSubscriptions::getUserId, loginUser.getUserId()).eq(UserSubscriptions::getStoreId, subscDTO.getStoreId()) + .eq(UserSubscriptions::getUserId, userId).eq(UserSubscriptions::getStoreId, subscDTO.getStoreId()) .eq(UserSubscriptions::getDelFlag, Constants.UNDELETED)); if (ObjectUtils.isNotEmpty(exist)) { throw new ServiceException("已关注过当前档口!", HttpStatus.ERROR); } UserSubscriptions userSubscriptions = new UserSubscriptions(); - userSubscriptions.setUserId(loginUser.getUserId()); + userSubscriptions.setUserId(userId); userSubscriptions.setStoreId(subscDTO.getStoreId()); int count = this.userSubMapper.insert(userSubscriptions); Store store = Optional.ofNullable(this.storeMapper.selectOne(new LambdaQueryWrapper() diff --git a/xkt/src/main/java/com/ruoyi/xkt/service/impl/WebsiteAPPServiceImpl.java b/xkt/src/main/java/com/ruoyi/xkt/service/impl/WebsiteAPPServiceImpl.java index e1b3dff79..a5ea508ee 100644 --- a/xkt/src/main/java/com/ruoyi/xkt/service/impl/WebsiteAPPServiceImpl.java +++ b/xkt/src/main/java/com/ruoyi/xkt/service/impl/WebsiteAPPServiceImpl.java @@ -28,6 +28,7 @@ import com.ruoyi.xkt.dto.advertRound.app.prod.APPProdCateTop3DTO; import com.ruoyi.xkt.dto.advertRound.app.prod.APPProdSaleDTO; import com.ruoyi.xkt.dto.advertRound.app.strength.APPStrengthProdDTO; import com.ruoyi.xkt.dto.advertRound.app.strength.APPStrengthStoreDTO; +import com.ruoyi.xkt.dto.advertRound.app.strength.APPStrengthStoreFileDTO; import com.ruoyi.xkt.dto.dailyStoreProd.DailyStoreProdSaleDTO; import com.ruoyi.xkt.dto.es.ESProductDTO; import com.ruoyi.xkt.dto.storeProduct.StoreProdPriceAndMainPicAndTagDTO; @@ -372,6 +373,8 @@ public class WebsiteAPPServiceImpl implements IWebsiteAPPService { if (CollectionUtils.isEmpty(storeList)) { return Page.empty(searchDTO.getPageSize(), searchDTO.getPageNum()); } + List storeRandomFileList = this.prodFileMapper.selectRandomStoreFileList(storeIdList); + Map storeFileMap = storeRandomFileList.stream().collect(Collectors.toMap(APPStrengthStoreFileDTO::getStoreId, APPStrengthStoreFileDTO::getMainPicUrl)); // 当前登录人有哪些档口已关注 Long userId = SecurityUtils.getUserIdSafe(); Map focusStoreIdMap = ObjectUtils.isEmpty(userId) ? new HashMap<>() @@ -380,7 +383,7 @@ public class WebsiteAPPServiceImpl implements IWebsiteAPPService { .eq(UserSubscriptions::getDelFlag, Constants.UNDELETED)).stream() .collect(Collectors.toMap(UserSubscriptions::getStoreId, UserSubscriptions::getStoreId)); List list = storeList.stream().map(store -> BeanUtil.toBean(store, APPStrengthStoreDTO.class) - .setFocus(focusStoreIdMap.containsKey(store.getId()))) + .setFocus(focusStoreIdMap.containsKey(store.getId())).setMainPicUrl(storeFileMap.get(store.getId()))) .collect(Collectors.toList()); // 设置档口会员等级 list.forEach(x -> { diff --git a/xkt/src/main/resources/mapper/StoreProductFileMapper.xml b/xkt/src/main/resources/mapper/StoreProductFileMapper.xml index 46ece7342..1a5158439 100644 --- a/xkt/src/main/resources/mapper/StoreProductFileMapper.xml +++ b/xkt/src/main/resources/mapper/StoreProductFileMapper.xml @@ -151,5 +151,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND spf.file_type IN (1,2) + + \ No newline at end of file