xiangpei
2025-05-26 0e066580ae71856470dd2b2f621cdad78fd0e608
浏览足迹表适配适配播放记录、视频表增加时长字段
11个文件已修改
2个文件已添加
174 ■■■■ 已修改文件
buyer-api/src/main/java/cn/lili/controller/lmk/VideoController.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/lmk/domain/entity/Video.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/lmk/domain/form/VideoFootPrintForm.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/lmk/domain/form/VideoForm.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/lmk/domain/vo/VideoVO.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/lmk/enums/general/ViewTypeEnum.java 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/lmk/service/VideoService.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoServiceImpl.java 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/member/entity/dos/FootPrint.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/member/entity/dto/FootPrintQueryParams.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/member/serviceimpl/FootprintServiceImpl.java 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/resources/mapper/lmk/VideoMapper.xml 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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);
    }
}
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());
        }
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;
framework/src/main/java/cn/lili/modules/lmk/domain/form/VideoFootPrintForm.java
New file
@@ -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:xp
 * @date:2025/5/26 15:15
 */
@Data
@ApiModel("浏览足迹-视频")
public class VideoFootPrintForm extends AbsForm {
    @ApiModelProperty("视频id")
    private String videoId;
    @ApiModelProperty("观看时长")
    private Long viewDuration;
}
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;
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;
framework/src/main/java/cn/lili/modules/lmk/enums/general/ViewTypeEnum.java
New file
@@ -0,0 +1,46 @@
package cn.lili.modules.lmk.enums.general;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;
/**
 * 浏览类型
 *
 * @author:xp
 * @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;
    }
}
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);
}
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();
    }
}
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;
}
    @ApiModelProperty(value = "浏览类型:goods商品、view视频")
    private String viewType;
    @ApiModelProperty(value = "观看时长:秒")
    private Long viewDuration;
}
framework/src/main/java/cn/lili/modules/member/entity/dto/FootPrintQueryParams.java
@@ -21,6 +21,9 @@
    @ApiModelProperty("店铺Id")
    private String storeId;
    @ApiModelProperty("浏览类型:goods商品、view视频")
    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;
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);
    }
}
}
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