From d900bdc7b712666cdeafe36f01e485f4672e4651 Mon Sep 17 00:00:00 2001
From: zxl <763096477@qq.com>
Date: 星期一, 17 十一月 2025 15:14:33 +0800
Subject: [PATCH] 修改奖品bug
---
framework/src/main/java/cn/lili/modules/lmk/service/impl/MyCollectServiceImpl.java | 114 ++++++++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 97 insertions(+), 17 deletions(-)
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 2b513d9..9ef1d35 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
@@ -1,7 +1,21 @@
package cn.lili.modules.lmk.service.impl;
+import cn.lili.common.enums.CollectTypeEnum;
+import cn.lili.common.properties.RocketmqCustomProperties;
import cn.lili.common.security.context.UserContext;
-import cn.lili.modules.lmk.domain.vo.SimpleMyCollectVO;
+import cn.lili.common.vo.PageVO;
+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.MySubscribeService;
+import cn.lili.modules.lmk.service.VideoService;
+import cn.lili.modules.member.entity.vo.GoodsCollectionVO;
+import cn.lili.modules.member.service.GoodsCollectionService;
+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;
import cn.lili.modules.lmk.mapper.MyCollectMapper;
@@ -10,16 +24,20 @@
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.lili.modules.lmk.domain.form.MyCollectForm;
-import cn.lili.modules.lmk.domain.vo.MyCollectVO;
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.context.annotation.Lazy;
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.List;
-import java.util.Objects;
+import java.util.*;
import java.util.stream.Collectors;
/**
@@ -33,27 +51,42 @@
public class MyCollectServiceImpl extends ServiceImpl<MyCollectMapper, MyCollect> implements MyCollectService {
private final MyCollectMapper myCollectMapper;
+ private final RocketmqCustomProperties rocketmqCustomProperties;
+ private final LmkFileServiceImpl fileService;
+ private final RocketMQTemplate rocketMQTemplate;
+ private final VideoServiceMakeUpImpl serviceMakeUp;
+ private final GoodsCollectionService goodsCollectionService;
/**
- * 娣诲姞
+ * 鏀惰棌/鍙栨秷鏀惰棌
* @param form
* @return
*/
@Override
public Result change(MyCollectForm form) {
- MyCollect myCollect = new LambdaQueryChainWrapper<>(baseMapper)
- .eq(MyCollect::getCollectType, form.getCollectType())
- .eq(MyCollect::getRefId, form.getRefId())
- .eq(MyCollect::getUserId, UserContext.getCurrentUserId())
- .one();
- if (Objects.nonNull(myCollect)) {
- baseMapper.deleteById(myCollect.getId());
+ // 瑙嗛鏀惰棌璧癿q
+ if (CollectTypeEnum.video.getType().equals(form.getCollectType())) {
+ MyCollect collect = new MyCollect();
+ collect.setRefId(form.getRefId());
+ collect.setCollectType(form.getCollectType());
+ collect.setUserId(UserContext.getCurrentUserId());
+ String destination = rocketmqCustomProperties.getVideoTopic() + ":" + VideoTagsEnum.COLLECT.name();
+ rocketMQTemplate.asyncSend(destination, JSON.toJSONString(collect), RocketmqSendCallbackBuilder.commonCallback());
} else {
- myCollect = new MyCollect();
- myCollect.setRefId(form.getRefId());
- myCollect.setCollectType(form.getCollectType());
- myCollect.setUserId(UserContext.getCurrentUserId());
- baseMapper.insert(myCollect);
+ MyCollect myCollect = new LambdaQueryChainWrapper<>(baseMapper)
+ .eq(MyCollect::getCollectType, form.getCollectType())
+ .eq(MyCollect::getRefId, form.getRefId())
+ .eq(MyCollect::getUserId, UserContext.getCurrentUserId())
+ .one();
+ if (Objects.nonNull(myCollect)) {
+ baseMapper.deleteById(myCollect.getId());
+ } else {
+ myCollect = new MyCollect();
+ myCollect.setRefId(form.getRefId());
+ myCollect.setCollectType(form.getCollectType());
+ myCollect.setUserId(UserContext.getCurrentUserId());
+ baseMapper.insert(myCollect);
+ }
}
return Result.ok("鎿嶄綔鎴愬姛");
}
@@ -135,6 +168,53 @@
@Override
public List<SimpleMyCollectVO> getCollectsByVideoIds(List<String> videoIds) {
+ if (videoIds == null || videoIds.isEmpty()) {
+ return new ArrayList<>();
+ }
return baseMapper.getCollectsByVideoIds(videoIds, UserContext.getCurrentUserId());
}
+
+ @Override
+ public List<CollectTypeNumVO> countNumGroupByVideo() {
+ return baseMapper.countNumGroupByVideo();
+ }
+
+
+ @Override
+ public Result getMyCollectList(MyCollectQuery query) {
+ String userId = UserContext.getCurrentUserId();
+ IPage<Object> page = PageUtil.getPage(query, Object.class);
+ if (CollectTypeEnum.activity.getType().equals(query.getType())){
+ baseMapper.getActivityCollectPage(page, userId);
+ List<ActivityVO> activityVOS = page.getRecords().stream()
+ .filter(obj -> obj instanceof ActivityVO)
+ .map(obj -> (ActivityVO) obj)
+ .collect(Collectors.toList());
+ for (ActivityVO activityVO : activityVOS) {
+ activityVO.setUrl(fileService.getPreviewUrl(activityVO.getCover()));
+ }
+ }else if (CollectTypeEnum.video.getType().equals(query.getType())) {
+ AuthorVideoQuery videoQuery = new AuthorVideoQuery();
+ videoQuery.setAuthorId(UserContext.getCurrentUserId());
+ videoQuery.setAuthorSelf(true);
+ videoQuery.setPageSize(query.getPageSize());
+
+ videoQuery.setPageNumber(query.getPageNumber());
+ return serviceMakeUp.getAuthorCollectVideoPage(videoQuery);
+ }else if (CollectTypeEnum.goods.getType().equals(query.getType())) {
+ PageVO pageVo = new PageVO();
+ pageVo.setPageSize((int) query.getPageSize());
+ pageVo.setPageNumber((int) query.getPageNumber());
+
+ IPage<GoodsCollectionVO> goodsCollectionVOIPage = goodsCollectionService.goodsCollection(pageVo);
+ for (GoodsCollectionVO goodsCollectionVO : goodsCollectionVOIPage.getRecords()) {
+ goodsCollectionVO.setImage(fileService.getPreviewUrl(goodsCollectionVO.getImage()));
+ }
+ return Result.ok().data(goodsCollectionVOIPage.getRecords()).total(goodsCollectionVOIPage.getTotal());
+
+ }
+
+ return Result.ok().data(page.getRecords()).total(page.getTotal());
+ }
+
}
--
Gitblit v1.8.0