From 0e066580ae71856470dd2b2f621cdad78fd0e608 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期一, 26 五月 2025 18:12:53 +0800
Subject: [PATCH] 浏览足迹表适配适配播放记录、视频表增加时长字段
---
framework/src/main/java/cn/lili/modules/member/entity/dto/FootPrintQueryParams.java | 6 ++
framework/src/main/java/cn/lili/modules/lmk/domain/form/VideoForm.java | 3 +
framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java | 3
framework/src/main/java/cn/lili/modules/lmk/domain/vo/VideoVO.java | 3 +
buyer-api/src/main/java/cn/lili/controller/lmk/VideoController.java | 7 ++
framework/src/main/java/cn/lili/modules/lmk/domain/form/VideoFootPrintForm.java | 22 +++++++
framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoServiceImpl.java | 20 +++++-
framework/src/main/java/cn/lili/modules/member/entity/dos/FootPrint.java | 12 +++-
framework/src/main/java/cn/lili/modules/lmk/domain/entity/Video.java | 4 +
framework/src/main/java/cn/lili/modules/member/serviceimpl/FootprintServiceImpl.java | 18 -----
framework/src/main/resources/mapper/lmk/VideoMapper.xml | 17 +++--
framework/src/main/java/cn/lili/modules/lmk/enums/general/ViewTypeEnum.java | 46 +++++++++++++++
framework/src/main/java/cn/lili/modules/lmk/service/VideoService.java | 13 +++-
13 files changed, 140 insertions(+), 34 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 ec8ab0d..c3d16d2 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
@@ -3,6 +3,8 @@
import cn.lili.base.AbsQuery;
import cn.lili.group.Update;
import cn.lili.group.Add;
+import cn.lili.modules.lmk.domain.form.VideoFootPrintForm;
+import cn.lili.modules.member.entity.dos.FootPrint;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import lombok.RequiredArgsConstructor;
@@ -70,4 +72,9 @@
return videoService.recommendVideo(query);
}
+ @PostMapping("/view/record")
+ @ApiOperation(value = "淇濆瓨瑙傜湅璁板綍", notes = "淇濆瓨瑙傜湅璁板綍")
+ public Result saveViewRecord(VideoFootPrintForm form) {
+ return videoService.saveViewRecord(form);
+ }
}
diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java
index b71b1ea..adc30c3 100644
--- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java
+++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java
@@ -37,6 +37,7 @@
import cn.lili.modules.goods.service.WholesaleService;
import cn.lili.modules.goods.sku.GoodsSkuBuilder;
import cn.lili.modules.goods.sku.render.SalesModelRender;
+import cn.lili.modules.lmk.enums.general.ViewTypeEnum;
import cn.lili.modules.member.entity.dos.FootPrint;
import cn.lili.modules.promotion.entity.dos.Coupon;
import cn.lili.modules.promotion.entity.dos.PromotionGoods;
@@ -365,7 +366,7 @@
//璁板綍鐢ㄦ埛瓒宠抗
if (currentUser != null) {
- FootPrint footPrint = new FootPrint(currentUser.getId(), goodsIndex.getStoreId(), goodsId, skuId);
+ FootPrint footPrint = new FootPrint(currentUser.getId(), goodsIndex.getStoreId(), goodsId, skuId, ViewTypeEnum.GOODS.getValue(), null);
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.VIEW_GOODS.name();
rocketMQTemplate.asyncSend(destination, footPrint, RocketmqSendCallbackBuilder.commonCallback());
}
diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/entity/Video.java b/framework/src/main/java/cn/lili/modules/lmk/domain/entity/Video.java
index 5956199..c385ca4 100644
--- a/framework/src/main/java/cn/lili/modules/lmk/domain/entity/Video.java
+++ b/framework/src/main/java/cn/lili/modules/lmk/domain/entity/Video.java
@@ -37,6 +37,10 @@
/** 瑙嗛濉厖妯″紡 */
private String videoFit;
+ @TableField("video_duration")
+ /** 瑙嗛闀垮害(绉�) */
+ private Long videoDuration;
+
@TableField("title")
/** 瑙嗛鏍囬 */
private String title;
diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/form/VideoFootPrintForm.java b/framework/src/main/java/cn/lili/modules/lmk/domain/form/VideoFootPrintForm.java
new file mode 100644
index 0000000..aa5b957
--- /dev/null
+++ b/framework/src/main/java/cn/lili/modules/lmk/domain/form/VideoFootPrintForm.java
@@ -0,0 +1,22 @@
+package cn.lili.modules.lmk.domain.form;
+
+import cn.lili.base.AbsForm;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @author锛歺p
+ * @date锛�2025/5/26 15:15
+ */
+@Data
+@ApiModel("娴忚瓒宠抗-瑙嗛")
+public class VideoFootPrintForm extends AbsForm {
+
+ @ApiModelProperty("瑙嗛id")
+ private String videoId;
+
+ @ApiModelProperty("瑙傜湅鏃堕暱")
+ private Long viewDuration;
+
+}
diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/form/VideoForm.java b/framework/src/main/java/cn/lili/modules/lmk/domain/form/VideoForm.java
index a349f7e..cccd50b 100644
--- a/framework/src/main/java/cn/lili/modules/lmk/domain/form/VideoForm.java
+++ b/framework/src/main/java/cn/lili/modules/lmk/domain/form/VideoForm.java
@@ -49,6 +49,9 @@
@ApiModelProperty("瑙嗛濉厖妯″紡")
private String videoFit;
+ @ApiModelProperty("瑙嗛闀垮害锛氱")
+ private Long videoDuration;
+
@ApiModelProperty("鏂囦欢淇℃伅")
@Valid
private FileInfoForm fileInfo;
diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/vo/VideoVO.java b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/VideoVO.java
index 8f82ae3..a862552 100644
--- a/framework/src/main/java/cn/lili/modules/lmk/domain/vo/VideoVO.java
+++ b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/VideoVO.java
@@ -42,6 +42,9 @@
@ApiModelProperty("瑙嗛濉厖妯″紡")
private String videoFit;
+ @ApiModelProperty("瑙嗛闀垮害锛氱")
+ private Long videoDuration;
+
/** 瑙嗛鏍囬 */
@ApiModelProperty("瑙嗛鏍囬")
private String title;
diff --git a/framework/src/main/java/cn/lili/modules/lmk/enums/general/ViewTypeEnum.java b/framework/src/main/java/cn/lili/modules/lmk/enums/general/ViewTypeEnum.java
new file mode 100644
index 0000000..10ede6e
--- /dev/null
+++ b/framework/src/main/java/cn/lili/modules/lmk/enums/general/ViewTypeEnum.java
@@ -0,0 +1,46 @@
+package cn.lili.modules.lmk.enums.general;
+
+import lombok.Getter;
+import org.apache.commons.lang3.StringUtils;
+
+/**
+ * 娴忚绫诲瀷
+ *
+ * @author锛歺p
+ * @date锛�2025/5/14 10:30
+ */
+@Getter
+public enum ViewTypeEnum {
+
+ VIDEO("video", "瑙嗛"),
+ GOODS("goods", "鍟嗗搧"),
+ ;
+
+ private final String value;
+
+
+ private final String desc;
+
+ ViewTypeEnum(String value, String desc) {
+ this.value = value;
+ this.desc = desc;
+ }
+
+ /**
+ * 鑾峰彇鍚箟
+ *
+ * @param value
+ * @return
+ */
+ public static String getDescByValue(String value) {
+ if (StringUtils.isBlank(value)) {
+ return null;
+ }
+ for (ViewTypeEnum e : ViewTypeEnum.values()){
+ if (value.equals(e.getValue())) {
+ return e.getDesc();
+ }
+ }
+ return null;
+ }
+}
diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/VideoService.java b/framework/src/main/java/cn/lili/modules/lmk/service/VideoService.java
index 5f0ce49..a781e88 100644
--- a/framework/src/main/java/cn/lili/modules/lmk/service/VideoService.java
+++ b/framework/src/main/java/cn/lili/modules/lmk/service/VideoService.java
@@ -2,14 +2,11 @@
import cn.lili.base.AbsQuery;
import cn.lili.modules.lmk.domain.entity.Video;
-import cn.lili.modules.lmk.domain.form.VideoAuditingForm;
-import cn.lili.modules.lmk.domain.form.VideoDownForm;
-import cn.lili.modules.lmk.domain.form.VideoRecommendForm;
+import cn.lili.modules.lmk.domain.form.*;
import cn.lili.modules.lmk.domain.query.ManagerVideoQuery;
import cn.lili.modules.lmk.domain.vo.CollectTypeNumVO;
import com.baomidou.mybatisplus.extension.service.IService;
import cn.lili.base.Result;
-import cn.lili.modules.lmk.domain.form.VideoForm;
import cn.lili.modules.lmk.domain.query.VideoQuery;
import java.util.List;
@@ -130,4 +127,12 @@
* @param numList
*/
void updateCollectNumBatch(List<CollectTypeNumVO> numList);
+
+ /**
+ * 淇濆瓨瑙嗛瑙傜湅璁板綍
+ *
+ * @param form
+ * @return
+ */
+ Result saveViewRecord(VideoFootPrintForm form);
}
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 053fbfc..68137f4 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
@@ -5,14 +5,15 @@
import cn.lili.modules.lmk.domain.entity.VideoAuditRecord;
import cn.lili.modules.lmk.domain.entity.VideoTag;
import cn.lili.modules.lmk.domain.entity.VideoTagRef;
-import cn.lili.modules.lmk.domain.form.VideoAuditingForm;
-import cn.lili.modules.lmk.domain.form.VideoDownForm;
-import cn.lili.modules.lmk.domain.form.VideoRecommendForm;
+import cn.lili.modules.lmk.domain.form.*;
import cn.lili.modules.lmk.domain.query.ManagerVideoQuery;
import cn.lili.modules.lmk.domain.vo.*;
import cn.lili.modules.lmk.enums.general.TagCreateTypeEnum;
import cn.lili.modules.lmk.enums.general.VideoStatusEnum;
+import cn.lili.modules.lmk.enums.general.ViewTypeEnum;
import cn.lili.modules.lmk.service.*;
+import cn.lili.modules.member.entity.dos.FootPrint;
+import cn.lili.modules.member.service.FootprintService;
import cn.lili.utils.COSUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import cn.lili.modules.lmk.domain.entity.Video;
@@ -21,7 +22,6 @@
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import cn.lili.modules.lmk.domain.form.VideoForm;
import cn.lili.modules.lmk.domain.query.VideoQuery;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.ListUtils;
@@ -53,6 +53,7 @@
private final VideoAuditRecordService videoAuditRecordService;
private final MyCollectService myCollectService;
private final COSUtil cosUtil;
+ private final FootprintService footprintService;
/**
* 娣诲姞
@@ -289,4 +290,15 @@
baseMapper.updateCollectNumBatch(chunk);
}
}
+
+ @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());
+ footprintService.saveFootprint(footPrint);
+ return Result.ok();
+ }
}
diff --git a/framework/src/main/java/cn/lili/modules/member/entity/dos/FootPrint.java b/framework/src/main/java/cn/lili/modules/member/entity/dos/FootPrint.java
index 355df4a..513d979 100644
--- a/framework/src/main/java/cn/lili/modules/member/entity/dos/FootPrint.java
+++ b/framework/src/main/java/cn/lili/modules/member/entity/dos/FootPrint.java
@@ -33,10 +33,16 @@
@ApiModelProperty(value = "搴楅摵Id")
private String storeId;
- @ApiModelProperty(value = "鍟嗗搧ID")
- private String goodsId;
+ @ApiModelProperty(value = "鍟嗗搧ID/瑙嗛ID")
+ private String refId;
@ApiModelProperty(value = "瑙勬牸ID")
private String skuId;
-}
\ No newline at end of file
+ @ApiModelProperty(value = "娴忚绫诲瀷锛歡oods鍟嗗搧銆乿iew瑙嗛")
+ private String viewType;
+
+ @ApiModelProperty(value = "瑙傜湅鏃堕暱锛氱")
+ private Long viewDuration;
+
+}
diff --git a/framework/src/main/java/cn/lili/modules/member/entity/dto/FootPrintQueryParams.java b/framework/src/main/java/cn/lili/modules/member/entity/dto/FootPrintQueryParams.java
index d2a5ec5..6d5d41d 100644
--- a/framework/src/main/java/cn/lili/modules/member/entity/dto/FootPrintQueryParams.java
+++ b/framework/src/main/java/cn/lili/modules/member/entity/dto/FootPrintQueryParams.java
@@ -21,6 +21,9 @@
@ApiModelProperty("搴楅摵Id")
private String storeId;
+ @ApiModelProperty("娴忚绫诲瀷锛歡oods鍟嗗搧銆乿iew瑙嗛")
+ private String viewType;
+
public <T> QueryWrapper<T> queryWrapper() {
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
if (CharSequenceUtil.isNotEmpty(memberId)) {
@@ -29,6 +32,9 @@
if (CharSequenceUtil.isNotEmpty(storeId)) {
queryWrapper.eq("store_id", storeId);
}
+ if (CharSequenceUtil.isNotEmpty(viewType)) {
+ queryWrapper.eq("view_type", viewType);
+ }
queryWrapper.eq("delete_flag",false);
queryWrapper.orderByDesc("create_time");
return queryWrapper;
diff --git a/framework/src/main/java/cn/lili/modules/member/serviceimpl/FootprintServiceImpl.java b/framework/src/main/java/cn/lili/modules/member/serviceimpl/FootprintServiceImpl.java
index 714157a..f74fd3f 100644
--- a/framework/src/main/java/cn/lili/modules/member/serviceimpl/FootprintServiceImpl.java
+++ b/framework/src/main/java/cn/lili/modules/member/serviceimpl/FootprintServiceImpl.java
@@ -39,21 +39,7 @@
@Override
public FootPrint saveFootprint(FootPrint footPrint) {
- LambdaQueryWrapper<FootPrint> queryWrapper = Wrappers.lambdaQuery();
- queryWrapper.eq(FootPrint::getMemberId, footPrint.getMemberId());
- queryWrapper.eq(FootPrint::getGoodsId, footPrint.getGoodsId());
- //濡傛灉宸插瓨鍦ㄦ煇鍟嗗搧璁板綍锛屽垯鏇存柊鍏朵慨鏀规椂闂�
- //濡傛灉涓嶅瓨鍦ㄥ垯娣诲姞璁板綍
- //涓轰簡淇濊瘉瓒宠抗鐨勬帓搴�,灏嗗師鏈冻杩瑰垹闄ゅ悗閲嶆柊娣诲姞
- List<FootPrint> oldPrints = list(queryWrapper);
- if (oldPrints != null && !oldPrints.isEmpty()) {
- FootPrint oldPrint = oldPrints.get(0);
- this.removeById(oldPrint.getId());
- }
- footPrint.setCreateTime(new Date());
this.save(footPrint);
- //鍒犻櫎瓒呰繃100鏉″悗鐨勮褰�
- this.baseMapper.deleteLastFootPrint(footPrint.getMemberId());
return footPrint;
}
@@ -68,7 +54,7 @@
public boolean deleteByIds(List<String> ids) {
LambdaQueryWrapper<FootPrint> lambdaQueryWrapper = Wrappers.lambdaQuery();
lambdaQueryWrapper.eq(FootPrint::getMemberId, UserContext.getCurrentUser().getId());
- lambdaQueryWrapper.in(FootPrint::getGoodsId, ids);
+ lambdaQueryWrapper.in(FootPrint::getRefId, ids);
return this.remove(lambdaQueryWrapper);
}
@@ -112,4 +98,4 @@
lambdaQueryWrapper.eq(FootPrint::getDeleteFlag, false);
return this.count(lambdaQueryWrapper);
}
-}
\ No newline at end of file
+}
diff --git a/framework/src/main/resources/mapper/lmk/VideoMapper.xml b/framework/src/main/resources/mapper/lmk/VideoMapper.xml
index 6259ce8..12e953f 100644
--- a/framework/src/main/resources/mapper/lmk/VideoMapper.xml
+++ b/framework/src/main/resources/mapper/lmk/VideoMapper.xml
@@ -13,6 +13,7 @@
<result column="title" property="title" />
<result column="goods_id" property="goodsId" />
<result column="goods_view_num" property="goodsViewNum" />
+ <result column="video_duration" property="videoDuration" />
<result column="goods_order_num" property="goodsOrderNum" />
<result column="recommend" property="recommend" />
<result column="status" property="status" />
@@ -44,6 +45,7 @@
LV.author_id,
LV.cover_url,
LV.video_fit,
+ LV.video_duration,
LV.video_file_key,
LV.title,
LV.goods_id,
@@ -72,6 +74,7 @@
LV.author_id,
LV.cover_url,
LV.video_fit,
+ LV.video_duration,
LV.video_file_key,
LV.title,
LV.goods_id,
@@ -80,13 +83,13 @@
LV.recommend,
LV.status,
LV.play_num,
+ LV.collect_num,
LV.comment_num,
LV.weight,
LV.audit_pass_time,
LV.update_time,
LV.id,
- LM.nick_name as authorName,
- (SELECT COUNT(*) FROM lmk_my_collect WHERE ref_id = LV.id AND collect_type = 'video' AND delete_flag = 0) as collect_num
+ LM.nick_name as authorName
FROM
lmk_video LV
LEFT JOIN li_member LM ON LV.author_id = LM.id
@@ -100,6 +103,7 @@
LV.author_id,
LV.cover_url,
LV.video_fit,
+ LV.video_duration,
LV.video_file_key,
LV.title,
LV.goods_id,
@@ -108,13 +112,13 @@
LV.recommend,
LV.status,
LV.play_num,
+ LV.collect_num,
LV.comment_num,
LV.weight,
LV.audit_pass_time,
LV.update_time,
LV.id,
- LM.nick_name as authorName,
- (SELECT COUNT(*) FROM lmk_my_collect WHERE ref_id = LV.id AND collect_type = 'video' AND delete_flag = 0) as collect_num
+ LM.nick_name as authorName
FROM
lmk_video LV
LEFT JOIN li_member LM ON LV.author_id = LM.id
@@ -139,6 +143,7 @@
LV.author_id,
LV.cover_url,
LV.video_fit,
+ LV.video_duration,
LV.video_file_key,
LV.title,
LV.goods_id,
@@ -148,13 +153,13 @@
LV.status,
LV.play_num,
LV.comment_num,
+ LV.collect_num,
LV.weight,
LV.audit_pass_time,
LV.update_time,
LV.id,
LM.nick_name as authorName,
- LM.face as authorAvatar,
- (SELECT COUNT(*) FROM lmk_my_collect WHERE ref_id = LV.id AND collect_type = 'video' AND delete_flag = 0) as collect_num
+ LM.face as authorAvatar
FROM
lmk_video LV
LEFT JOIN li_member LM ON LV.author_id = LM.id
--
Gitblit v1.8.0