From 9911eefd300c7f1a9bb1030b94d03d7562cf7858 Mon Sep 17 00:00:00 2001
From: peng <peng.com>
Date: 星期二, 08 七月 2025 15:52:29 +0800
Subject: [PATCH] 商品发布
---
framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoServiceImpl.java | 86 ++++++++++++++++++++++++++++++++++++++----
1 files changed, 77 insertions(+), 9 deletions(-)
diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoServiceImpl.java b/framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoServiceImpl.java
index 4f22dc3..204b995 100644
--- a/framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoServiceImpl.java
+++ b/framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoServiceImpl.java
@@ -497,10 +497,16 @@
videoEsQuery.setPageNumber((int) query.getPageNumber());
videoEsQuery.setPageSize((int) query.getPageSize());
return this.esSearch(videoEsQuery);
- case "goodsSimilarly":
+ case "goodsSimilarly": // 鎮寕鐩稿悓鍟嗗搧鐨勬帹鑽愯棰�
GoodsSimilarlyQuery goodsSimilarlyQuery = new GoodsSimilarlyQuery();
BeanUtils.copyProperties(query, goodsSimilarlyQuery);
baseMapper.goodsSimilarlyPage(page, goodsSimilarlyQuery);
+ break;
+ case "history":
+ VideoHistoryQuery videoHistoryQuery = new VideoHistoryQuery();
+ BeanUtils.copyProperties(query, videoHistoryQuery);
+ videoHistoryQuery.setUserId(UserContext.getCurrentUserId());
+ baseMapper.getHistoryPage(page, videoHistoryQuery);
break;
default:
break;
@@ -525,6 +531,7 @@
v.setCommentNum(this.getCommentNum(v.getId(), v.getCommentNum()));
v.setCollectNum(this.getCollectNum(v.getId(), v.getCollectNum()));
v.setThumbsUpNum(this.getThumbsUpNum(v.getId(), v.getThumbsUpNum()));
+ v.setAuthorAvatar(cosUtil.getPreviewUrl(v.getAuthorAvatar()));
if (VideoContentTypeEnum.VIDEO.getValue().equals(v.getVideoContentType())) {
v.setVideoUrl(cosUtil.getPreviewUrl(v.getVideoFileKey()));
v.setCoverUrl(cosUtil.getPreviewUrl(v.getCoverFileKey()));
@@ -597,9 +604,10 @@
public Result healthRecommendVideo(WxHealthVideoQuery query) {
IPage<WxVideoVO> page = PageUtil.getPage(query, WxVideoVO.class);
//鑾峰彇澶у仴搴疯棰戝垪琛�
- baseMapper.recommendHealthVideo(page,query);
+ baseMapper.recommendHealthVideo(page,query);
if (page.getTotal() > 0) {
page.getRecords().forEach(v -> {
+ v.setAuthorAvatar(cosUtil.getPreviewUrl(v.getAuthorAvatar()));
if (VideoContentTypeEnum.VIDEO.getValue().equals(v.getVideoContentType())) {
v.setVideoUrl(cosUtil.getPreviewUrl(v.getVideoFileKey()));
v.setCoverUrl(cosUtil.getPreviewUrl(v.getCoverFileKey()));
@@ -622,6 +630,7 @@
IPage<WxVideoVO> page = PageUtil.getPage(query, WxVideoVO.class);
baseMapper.wxKitchenVideoQuery(page, query);
page.getRecords().forEach(v -> {
+ v.setAuthorAvatar(cosUtil.getPreviewUrl(v.getAuthorAvatar()));
if (VideoContentTypeEnum.VIDEO.getValue().equals(v.getVideoContentType())) {
v.setVideoUrl(cosUtil.getPreviewUrl(v.getVideoFileKey()));
v.setCoverUrl(cosUtil.getPreviewUrl(v.getCoverFileKey()));
@@ -672,13 +681,24 @@
@Override
public Result saveViewRecord(VideoFootPrintForm form) {
- FootPrint footPrint = new FootPrint();
- footPrint.setViewType(ViewTypeEnum.VIDEO.getValue());
- footPrint.setRefId(form.getVideoId());
- footPrint.setMemberId(UserContext.getCurrentUserId());
- footPrint.setViewDuration(form.getViewDuration());
- footPrint.setPlayAt(form.getPlayAt());
- footprintService.saveFootprint(footPrint);
+ FootPrint one = new LambdaQueryChainWrapper<>(footprintService.getBaseMapper())
+ .eq(FootPrint::getRefId, form.getVideoId())
+ .eq(FootPrint::getMemberId, UserContext.getCurrentUserId())
+ .eq(FootPrint::getViewType, ViewTypeEnum.VIDEO.getValue())
+ .one();
+ if (Objects.nonNull(one)) {
+ one.setViewDuration(one.getViewDuration() + form.getViewDuration());
+ one.setPlayAt(form.getPlayAt());
+ footprintService.updateById(one);
+ } else {
+ FootPrint footPrint = new FootPrint();
+ footPrint.setViewType(ViewTypeEnum.VIDEO.getValue());
+ footPrint.setRefId(form.getVideoId());
+ footPrint.setMemberId(UserContext.getCurrentUserId());
+ footPrint.setViewDuration(form.getViewDuration());
+ footPrint.setPlayAt(form.getPlayAt());
+ footprintService.saveFootprint(footPrint);
+ }
return Result.ok();
}
@@ -720,6 +740,7 @@
v.setCommentNum(this.getCommentNum(v.getId(), v.getCommentNum()));
v.setCollectNum(this.getCollectNum(v.getId(), v.getCollectNum()));
v.setThumbsUpNum(this.getThumbsUpNum(v.getId(), v.getThumbsUpNum()));
+ v.setAuthorAvatar(cosUtil.getPreviewUrl(v.getAuthorAvatar()));
if (VideoContentTypeEnum.VIDEO.getValue().equals(v.getVideoContentType())) {
v.setVideoUrl(cosUtil.getPreviewUrl(v.getVideoFileKey()));
v.setCoverUrl(cosUtil.getPreviewUrl(v.getCoverFileKey()));
@@ -758,6 +779,7 @@
v.setCommentNum(this.getCommentNum(v.getId(), v.getCommentNum()));
v.setCollectNum(this.getCollectNum(v.getId(), v.getCollectNum()));
v.setThumbsUpNum(this.getThumbsUpNum(v.getId(), v.getThumbsUpNum()));
+ v.setAuthorAvatar(cosUtil.getPreviewUrl(v.getAuthorAvatar()));
if (VideoContentTypeEnum.VIDEO.getValue().equals(v.getVideoContentType())) {
v.setVideoUrl(cosUtil.getPreviewUrl(v.getVideoFileKey()));
v.setCoverUrl(cosUtil.getPreviewUrl(v.getCoverFileKey()));
@@ -795,6 +817,7 @@
v.setCommentNum(this.getCommentNum(v.getId(), v.getCommentNum()));
v.setCollectNum(this.getCollectNum(v.getId(), v.getCollectNum()));
v.setThumbsUpNum(this.getThumbsUpNum(v.getId(), v.getThumbsUpNum()));
+ v.setAuthorAvatar(cosUtil.getPreviewUrl(v.getAuthorAvatar()));
if (VideoContentTypeEnum.VIDEO.getValue().equals(v.getVideoContentType())) {
v.setVideoUrl(cosUtil.getPreviewUrl(v.getVideoFileKey()));
v.setCoverUrl(cosUtil.getPreviewUrl(v.getCoverFileKey()));
@@ -1199,6 +1222,7 @@
// 鍒ゆ柇鏄惁鍏虫敞浣滆�呫�佹槸鍚︾偣璧炪�佹槸鍚︽敹钘�
wxVideoVO.setCollected(CollectionUtils.isNotEmpty(collectMap.get(wxVideoVO.getId())));
wxVideoVO.setThumbsUp(CollectionUtils.isNotEmpty(thumbsUpMap.get(wxVideoVO.getId())));
+ wxVideoVO.setAuthorAvatar(cosUtil.getPreviewUrl(wxVideoVO.getAuthorAvatar()));
if (UserContext.getCurrentUserId().equals(wxVideoVO.getAuthorId())) {
wxVideoVO.setSubscribeThisAuthor(Boolean.TRUE);
} else {
@@ -1216,4 +1240,48 @@
return Result.ok().data(vos).total(searchHits.getTotalHits());
}
+ @Override
+ public Result getHistoryPage(VideoHistoryQuery query) {
+ query.setUserId(UserContext.getCurrentUserId());
+ IPage<VideoHistoryVO> page = PageUtil.getPage(query, VideoHistoryVO.class);
+ baseMapper.getHistoryPage(page, query);
+ if (CollectionUtils.isNotEmpty(page.getRecords())) {
+ if (page.getTotal() > 0) {
+ List<String> videoIds = page.getRecords().stream().map(VideoHistoryVO::getId).collect(Collectors.toList());
+ Map<String, List<SimpleVideoTagVO>> tagMap = videoTagRefService.getTagsByVideoIds(videoIds)
+ .stream()
+ .collect(Collectors.groupingBy(SimpleVideoTagVO::getVideoId));
+ Map<String, List<SimpleMyCollectVO>> collectMap = myCollectService.getCollectsByVideoIds(videoIds)
+ .stream()
+ .collect(Collectors.groupingBy(SimpleMyCollectVO::getRefId));
+ Map<String, List<SimpleMyThumbsUpVO>> thumbsUpMap = thumbsUpRecordService.getThumbssByVideoIds(videoIds)
+ .stream()
+ .collect(Collectors.groupingBy(SimpleMyThumbsUpVO::getRefId));
+ List<String> subscribes = mySubscribeService.getSubscribesByUserId(UserContext.getCurrentUserId());
+ // 3. 鑾峰彇瑙嗛涓存椂璁块棶鍦板潃銆佽缃棰戞爣绛俱�佹垜鏄惁鏀惰棌銆佹槸鍚︾偣璧炪�佷綔鑰呮槸鍚﹀叧娉�
+ page.getRecords().forEach(v -> {
+ v.setTagList(tagMap.get(v.getId()));
+ v.setCollected(CollectionUtils.isNotEmpty(collectMap.get(v.getId())));
+ v.setThumbsUp(CollectionUtils.isNotEmpty(thumbsUpMap.get(v.getId())));
+ v.setCommentNum(this.getCommentNum(v.getId(), v.getCommentNum()));
+ v.setCollectNum(this.getCollectNum(v.getId(), v.getCollectNum()));
+ v.setThumbsUpNum(this.getThumbsUpNum(v.getId(), v.getThumbsUpNum()));
+ v.setAuthorAvatar(cosUtil.getPreviewUrl(v.getAuthorAvatar()));
+ if (VideoContentTypeEnum.VIDEO.getValue().equals(v.getVideoContentType())) {
+ v.setVideoUrl(cosUtil.getPreviewUrl(v.getVideoFileKey()));
+ v.setCoverUrl(cosUtil.getPreviewUrl(v.getCoverFileKey()));
+ } else if (VideoContentTypeEnum.IMG.getValue().equals(v.getVideoContentType()) && StringUtils.isNotBlank(v.getVideoImgs())) {
+ v.setImgs(JSON.parseArray(v.getVideoImgs(), String.class).stream().map(fileKey -> cosUtil.getPreviewUrl(fileKey)).collect(Collectors.toList()));
+ }
+ if (CollectionUtils.isNotEmpty(v.getGoodsList())) {
+ v.getGoodsList().stream().forEach(goods -> {
+ goods.setThumbnail(cosUtil.getPreviewUrl(goods.getThumbnail()));
+ });
+ }
+ v.setSubscribeThisAuthor(subscribes.contains(v.getAuthorId()));
+ });
+ }
+ }
+ return Result.ok().data(page.getRecords()).total(page.getTotal());
+ }
}
--
Gitblit v1.8.0