From 1b992addb4f4fc78b19748927bdefa32df239842 Mon Sep 17 00:00:00 2001
From: zxl <763096477@qq.com>
Date: 星期二, 29 七月 2025 11:37:23 +0800
Subject: [PATCH] 用户主页显示问题,活动列表查询问题
---
framework/src/main/java/cn/lili/modules/lmk/mapper/MyCollectMapper.java | 8 ----
buyer-api/src/main/java/cn/lili/controller/lmk/VideoController.java | 26 ++++++++++++
framework/src/main/resources/mapper/lmk/MyCollectMapper.xml | 12 ------
framework/src/main/java/cn/lili/modules/lmk/service/impl/MyCollectServiceImpl.java | 45 +++++++++++++++++++---
framework/src/main/resources/mapper/lmk/ActivityMapper.xml | 9 ++++
5 files changed, 72 insertions(+), 28 deletions(-)
diff --git a/buyer-api/src/main/java/cn/lili/controller/lmk/VideoController.java b/buyer-api/src/main/java/cn/lili/controller/lmk/VideoController.java
index 32fc3b6..b026d4d 100644
--- a/buyer-api/src/main/java/cn/lili/controller/lmk/VideoController.java
+++ b/buyer-api/src/main/java/cn/lili/controller/lmk/VideoController.java
@@ -8,15 +8,21 @@
import cn.lili.modules.lmk.domain.form.VideoHomePageInfoForm;
import cn.lili.modules.lmk.domain.form.WxVideoForm;
import cn.lili.modules.lmk.domain.query.*;
+import cn.lili.modules.lmk.domain.vo.WxVideoVO;
import cn.lili.modules.lmk.service.VideoService;
+import cn.lili.utils.COSUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
+import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotEmpty;
+import java.util.Collections;
import java.util.List;
+import java.util.Optional;
+import java.util.stream.Collectors;
/**
* 瑙嗛鍐呭 鍓嶇鎺у埗鍣�
@@ -32,6 +38,7 @@
public class VideoController {
private final VideoService videoService;
+ private COSUtil cOSUtil;
@PostMapping("/publish")
@ApiOperation(value = "鍙戝竷瑙嗛", notes = "鍙戝竷瑙嗛")
@@ -117,7 +124,24 @@
@GetMapping("/author-collect-video-page")
@ApiOperation(value = "鑾峰彇瑙嗛涓婚〉浣滆�呮敹钘忕殑瑙嗛鍒嗛〉", notes = "鑾峰彇瑙嗛涓婚〉浣滆�呮敹钘忕殑瑙嗛鍒嗛〉")
public Result getAuthorCollectVideoPage(AuthorVideoQuery query) {
- return videoService.getAuthorCollectVideoPage(query);
+ Result result = videoService.getAuthorCollectVideoPage(query);
+ List<WxVideoVO> list = Optional.ofNullable(result.get("data"))
+ .filter(data -> data instanceof List<?>)
+ .map(data -> (List<?>) data)
+ .orElse(Collections.emptyList())
+ .stream()
+ .filter(WxVideoVO.class::isInstance)
+ .map(WxVideoVO.class::cast)
+ .collect(Collectors.toList());
+ for (WxVideoVO wxVideoVO : list){
+ if (!CollectionUtils.isEmpty(wxVideoVO.getImgs())){
+ List<String> newImages = wxVideoVO
+ .getImgs().stream().map(item -> cOSUtil.getPreviewUrl(item)).collect(Collectors.toList());
+ wxVideoVO.setImgs(newImages);
+ }
+
+ }
+ return result;
}
@GetMapping("/author-like-video-page")
diff --git a/framework/src/main/java/cn/lili/modules/lmk/mapper/MyCollectMapper.java b/framework/src/main/java/cn/lili/modules/lmk/mapper/MyCollectMapper.java
index acfe0a0..23ac9b9 100644
--- a/framework/src/main/java/cn/lili/modules/lmk/mapper/MyCollectMapper.java
+++ b/framework/src/main/java/cn/lili/modules/lmk/mapper/MyCollectMapper.java
@@ -63,13 +63,5 @@
*/
IPage getStoreCollectPage(IPage page,@Param("userId")String userId);
- /**
- * 鑾峰緱鎴戠殑鏀惰棌 瑙嗛
- * @param page
- * @param userId
- * @return
- */
- IPage getVideoCollectPage(IPage page,@Param("userId")String userId);
-
IPage getGoodsCollectPage(IPage page,@Param("userId")String type);
}
diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/impl/MyCollectServiceImpl.java b/framework/src/main/java/cn/lili/modules/lmk/service/impl/MyCollectServiceImpl.java
index f4b64ea..d5cd650 100644
--- a/framework/src/main/java/cn/lili/modules/lmk/service/impl/MyCollectServiceImpl.java
+++ b/framework/src/main/java/cn/lili/modules/lmk/service/impl/MyCollectServiceImpl.java
@@ -4,10 +4,13 @@
import cn.lili.common.properties.RocketmqCustomProperties;
import cn.lili.common.security.context.UserContext;
import cn.lili.modules.goods.entity.vos.GoodsVO;
+import cn.lili.modules.lmk.domain.query.AuthorVideoQuery;
import cn.lili.modules.lmk.domain.vo.*;
+import cn.lili.modules.lmk.service.VideoService;
import cn.lili.rocketmq.RocketmqSendCallbackBuilder;
import cn.lili.rocketmq.tags.CommentTagsEnum;
import cn.lili.rocketmq.tags.VideoTagsEnum;
+import cn.lili.utils.COSUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.metadata.IPage;
import cn.lili.modules.lmk.domain.entity.MyCollect;
@@ -18,15 +21,21 @@
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.lili.modules.lmk.domain.form.MyCollectForm;
import cn.lili.modules.lmk.domain.query.MyCollectQuery;
+import com.xkcoding.http.util.StringUtil;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import lombok.RequiredArgsConstructor;
import cn.lili.utils.PageUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.util.Assert;
+import org.springframework.util.CollectionUtils;
+import org.springframework.util.StringUtils;
+import java.util.Collections;
import java.util.List;
import java.util.Objects;
+import java.util.Optional;
import java.util.stream.Collectors;
/**
@@ -43,6 +52,14 @@
private final RocketmqCustomProperties rocketmqCustomProperties;
private final LmkFileServiceImpl fileService;
private final RocketMQTemplate rocketMQTemplate;
+ private VideoService videoService; // 绉婚櫎浜唂inal
+ private COSUtil cOSUtil;
+
+ @Autowired
+ public void setVideoService(VideoService videoService) {
+ // 杩欓噷鍙互娣诲姞棰濆鐨勫垵濮嬪寲閫昏緫
+ this.videoService = videoService;
+ }
/**
@@ -179,14 +196,30 @@
activityVO.setUrl(fileService.getPreviewUrl(activityVO.getCover()));
}
}else if (CollectTypeEnum.video.getType().equals(query.getType())) {
- baseMapper.getVideoCollectPage(page, userId);
- List<VideoVO> videoList = page.getRecords().stream()
- .filter(obj -> obj instanceof VideoVO)
- .map(obj -> (VideoVO) obj)
+ AuthorVideoQuery videoQuery = new AuthorVideoQuery();
+ videoQuery.setAuthorId(UserContext.getCurrentUserId());
+ videoQuery.setAuthorSelf(true);
+ videoQuery.setPageSize(query.getPageSize());
+
+ videoQuery.setPageNumber(query.getPageNumber());
+ Result result = videoService.getAuthorCollectVideoPage(videoQuery);
+ List<WxVideoVO> list = Optional.ofNullable(result.get("data"))
+ .filter(data -> data instanceof List<?>)
+ .map(data -> (List<?>) data)
+ .orElse(Collections.emptyList())
+ .stream()
+ .filter(WxVideoVO.class::isInstance)
+ .map(WxVideoVO.class::cast)
.collect(Collectors.toList());
- for (VideoVO video : videoList) {
- video.setCoverUrl(fileService.getPreviewUrl(video.getCoverUrl()));
+ for (WxVideoVO wxVideoVO : list){
+ if (!CollectionUtils.isEmpty(wxVideoVO.getImgs())){
+ List<String> newImages = wxVideoVO
+ .getImgs().stream().map(item -> cOSUtil.getPreviewUrl(item)).collect(Collectors.toList());
+ wxVideoVO.setImgs(newImages);
+ }
+
}
+ return result;
}else if (CollectTypeEnum.goods.getType().equals(query.getType())) {
baseMapper.getGoodsCollectPage(page, userId);
diff --git a/framework/src/main/resources/mapper/lmk/ActivityMapper.xml b/framework/src/main/resources/mapper/lmk/ActivityMapper.xml
index 4ac053c..cd31bbf 100644
--- a/framework/src/main/resources/mapper/lmk/ActivityMapper.xml
+++ b/framework/src/main/resources/mapper/lmk/ActivityMapper.xml
@@ -241,10 +241,17 @@
LA.activity_location,
LA.activity_content
FROM
- lmk_activity LA inner join lmk_activity_audit_record LAAR ON LA.id = LAAR.activity_id and LAAR.delete_flag = 0 and LAAR.audit = 1
+ lmk_activity LA
WHERE
LA.delete_flag = 0
AND LA.publish = 1
+ AND EXISTS (
+ SELECT 1
+ FROM lmk_activity_audit_record LAAR
+ WHERE LA.id = LAAR.activity_id
+ AND LAAR.delete_flag = 0
+ AND LAAR.audit = 1
+ )
</select>
diff --git a/framework/src/main/resources/mapper/lmk/MyCollectMapper.xml b/framework/src/main/resources/mapper/lmk/MyCollectMapper.xml
index 9f89ba6..f589c1a 100644
--- a/framework/src/main/resources/mapper/lmk/MyCollectMapper.xml
+++ b/framework/src/main/resources/mapper/lmk/MyCollectMapper.xml
@@ -112,18 +112,6 @@
<result column="update_time" property="updateTime" />
</resultMap>
- <select id="getVideoCollectPage" resultMap="videoBaseResult">
- SELECT
- LV.*,
- LM.nick_name as authorName
- FROM lmk_my_collect LMC
- LEFT JOIN lmk_video LV
- ON LMC.ref_id = LV.id
- LEFT JOIN li_member LM ON LV.author_id = LM.id
- WHERE LMC.collect_type = 'video' and LMC.user_id = #{userId}
- and LV.delete_flag = 0 and LM.delete_flag= 0 and LMC.delete_flag =0
- </select>
-
<resultMap id="storeBaseResult" type="cn.lili.modules.store.entity.vos.StoreBasicInfoVO">
<id column="id" property="storeId"/>
<result column="store_name" property="storeName"/>
--
Gitblit v1.8.0