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") 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); } 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; // 移除了final 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); 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> 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"/>