zxl
9 天以前 f7e2789a576b2db4217d20d5cfdeb20249c83a5b
Merge remote-tracking branch 'origin/dev' into dev
9个文件已修改
161 ■■■■■ 已修改文件
framework/src/main/java/cn/lili/modules/lmk/mapper/VideoMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/lmk/service/VideoService.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoServiceImpl.java 82 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoTagServiceImpl.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/store/serviceimpl/FreightTemplateServiceImpl.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/resources/mapper/lmk/VideoMapper.xml 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
manager-api/src/main/java/cn/lili/controller/goods/GoodsManagerController.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
manager-api/src/main/java/cn/lili/controller/lmk/VideoController.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
manager-api/src/main/java/cn/lili/controller/lmk/VideoTagController.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/lmk/mapper/VideoMapper.java
@@ -47,6 +47,8 @@
     */
    IPage recommendVideo(IPage page, @Param("query") VideoQuery query);
    List<WxVideoVO> recommendVideoList(@Param("query") VideoQuery query);
    IPage recommendHealthVideo(IPage page, @Param("query") WxHealthVideoQuery query);
framework/src/main/java/cn/lili/modules/lmk/service/VideoService.java
@@ -62,7 +62,13 @@
     * @param form
     * @return
     */
    Result publish(WxVideoForm form);
    Result publish(WxVideoForm form);    /**
     * 发布视频
     *
     * @param form
     * @return
     */
    Result systemPublish(WxVideoForm form);
    /**
     * 平台端视频分页
framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoServiceImpl.java
@@ -4,6 +4,7 @@
import cn.lili.cache.CachePrefix;
import cn.lili.common.properties.RocketmqCustomProperties;
import cn.lili.common.security.context.UserContext;
import cn.lili.common.utils.CommonUtil;
import cn.lili.elasticsearch.EsSuffix;
import cn.lili.modules.lmk.constant.RedisKeyExpireConstant;
import cn.lili.modules.lmk.domain.dto.VideoEsUpdateDTO;
@@ -46,6 +47,7 @@
import org.springframework.data.elasticsearch.core.SearchHits;
import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import lombok.RequiredArgsConstructor;
import cn.lili.utils.PageUtil;
@@ -54,6 +56,8 @@
import org.springframework.util.Assert;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
@@ -201,6 +205,81 @@
                    videoTag = new VideoTag();
                    videoTag.setTagName(tag.getTagName());
                    videoTag.setCreateType(TagCreateTypeEnum.USER.getValue());
                    videoTagService.save(videoTag);
                    videoTagRef.setVideoTagId(videoTag.getId());
                }
            } else {
                videoTagRef.setVideoTagId(tag.getId());
            }
            SimpleVideoTagVO esTag = new SimpleVideoTagVO();
            esTag.setVideoId(video.getId());
            esTag.setTagName(tag.getTagName());
            esTag.setId(tag.getId());
            esTagList.add(esTag);
            return videoTagRef;
        }).collect(Collectors.toList());
        videoTagRefService.saveBatch(videoTagRefs);
        // 3. 保存视频文件信息
        lmkFileService.addByForm(form.getFileInfo());
        // 4. 处理选择的商品
        List<VideoGoods> videoGoods = new ArrayList<>(2);
        if (CollectionUtils.isNotEmpty(form.getGoodsList())) {
            for (int i = 0; i < form.getGoodsList().size(); i++) {
                VideoGoods e = new VideoGoods();
                e.setVideoId(video.getId());
                e.setGoodsId(form.getGoodsList().get(i).getGoodsId());
                e.setGoodsSkuId(form.getGoodsList().get(i).getGoodsSkuId());
                e.setGoodsNum(form.getGoodsList().get(i).getGoodsNum());
                e.setOrderNum(i);
                videoGoodsService.save(e);
            }
            videoGoodsService.saveBatch(videoGoods);
        }
        // 5. 构建es中数据,mq异步处理
        VideoIndex videoIndex = new VideoIndex();
        BeanUtils.copyProperties(video, videoIndex);
        videoIndex.setAuthorName(UserContext.getCurrentUser().getNickName());
        videoIndex.setAuthorAvatar(UserContext.getCurrentUser().getFace());
        videoIndex.setCoverFileKey(video.getCoverUrl());
        List<VideoGoodsDetailVO> esGoodsList = videoGoods.stream().map(goods -> {
            VideoGoodsDetailVO vo = new VideoGoodsDetailVO();
            BeanUtils.copyProperties(goods, vo);
            return vo;
        }).collect(Collectors.toList());
        videoIndex.setGoodsList(esGoodsList);
        videoIndex.setTagList(esTagList);
        String destination = rocketmqCustomProperties.getVideoTopic() + ":" + VideoTagsEnum.ES_DOC_ADD_OR_UPDATE.name();
        rocketMQTemplate.asyncSend(destination, JSON.toJSONString(videoIndex), RocketmqSendCallbackBuilder.commonCallback());
        return Result.ok("发布成功,视频审核中~");
    }    @Override
    @Transactional(rollbackFor = Exception.class)
    public Result systemPublish(WxVideoForm form) {
        // 1.保存视频
        Video video = WxVideoForm.getEntityByForm(form, null);
        video.setAuthorId(UserContext.getCurrentUserId());
        video.setStatus(VideoStatusEnum.PUBLISHED.getValue());
        video.setCoverUrl(form.getCover());
        video.setVideoType(VideoTypeEnum.VIDEO.getValue());
        video.setRecommend(Boolean.FALSE);
        if (VideoContentTypeEnum.IMG.getValue().equals(form.getVideoContentType())) {
            video.setVideoImgs(JSON.toJSONString(form.getVideoImgs()));
        }
        baseMapper.insert(video);
        // 2.处理标签
        List<SimpleVideoTagVO> esTagList = new ArrayList<>(2);
        List<VideoTagRef> videoTagRefs = form.getTags().stream().map(tag -> {
            VideoTagRef videoTagRef = new VideoTagRef();
            videoTagRef.setVideoId(video.getId());
            if (StringUtils.isBlank(tag.getId())) {
                VideoTag videoTag = new LambdaQueryChainWrapper<>(videoTagService.getBaseMapper())
                        .eq(VideoTag::getTagName, tag.getTagName())
                        .one();
                if (Objects.nonNull(videoTag)) {
                    videoTagRef.setVideoTagId(videoTag.getId());
                } else {
                    videoTag = new VideoTag();
                    videoTag.setTagName(tag.getTagName());
                    videoTag.setCreateType(TagCreateTypeEnum.SYSTEM.getValue());
                    videoTagService.save(videoTag);
                    videoTagRef.setVideoTagId(videoTag.getId());
                }
@@ -472,6 +551,9 @@
        switch (query.getVideoFrom()) {
            case "recommend":// 加载推荐视频
                baseMapper.recommendVideo(page, query);
                //推荐视频重新排序
                List<WxVideoVO> records = page.getRecords();
                Collections.shuffle(records);
                break;
            case "author":  // 加载视频主页我发布的视频
                AuthorVideoQuery query1 = new AuthorVideoQuery();
framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoTagServiceImpl.java
@@ -150,6 +150,7 @@
                        .list().stream().map(entity -> {
                            return WxVideoTagVO.getVoByEntity(entity, null);
                        }).collect(Collectors.toList());
                break;
            case "SEARCH":
                tags = new LambdaQueryChainWrapper<>(baseMapper)
                        .orderByDesc(VideoTag::getUseNum)
@@ -158,6 +159,7 @@
                        .list().stream().map(entity -> {
                            return WxVideoTagVO.getVoByEntity(entity, null);
                        }).collect(Collectors.toList());
                break;
        }
        return Result.ok().data(tags);
    }
framework/src/main/java/cn/lili/modules/store/serviceimpl/FreightTemplateServiceImpl.java
@@ -145,6 +145,7 @@
        List<FreightTemplateChild> list = new ArrayList<>();
        for (FreightTemplateChild freightTemplateChild : freightTemplateVO.getFreightTemplateChildList()) {
            freightTemplateChild.setFreightTemplateId(freightTemplate.getId());
            freightTemplateChild.setId(null);
            list.add(freightTemplateChild);
        }
        //添加模板子内容
framework/src/main/resources/mapper/lmk/VideoMapper.xml
@@ -267,6 +267,40 @@
        ORDER BY
            LV.create_time DESC
    </select>
    <select id="recommendVideoList" resultMap="WxResultMap">
        SELECT
            LV.author_id,
            LV.cover_url,
            LV.video_fit,
            LV.video_duration,
            LV.video_file_key,
            LV.title,
            LV.goods_view_num,
            LV.goods_order_num,
            LV.recommend,
            LV.status,
            LV.play_num,
            LV.comment_num,
            LV.collect_num,
            LV.thumbs_up_num,
            LV.weight,
            LV.audit_pass_time,
            LV.update_time,
            LV.create_time,
            LV.video_content_type,
            LV.video_type,
            LV.video_imgs,
            LV.id,
            LM.nick_name as authorName,
            LM.face as authorAvatar
        FROM
            lmk_video LV
            LEFT JOIN li_member LM ON LV.author_id = LM.id
        WHERE
            LV.delete_flag = 0 AND LV.status = '1' AND LV.video_type = #{query.videoType}
        ORDER BY
            LV.create_time DESC
    </select>
    <select id="goodsSimilarlyPage" resultMap="WxResultMap">
        SELECT
manager-api/src/main/java/cn/lili/controller/goods/GoodsManagerController.java
@@ -63,7 +63,14 @@
    @ApiOperation(value = "分页获取商品列表")
    @GetMapping(value = "/sku/list")
    public ResultMessage<IPage<GoodsSku>> getSkuByPage(GoodsSearchParams goodsSearchParams) {
        return ResultUtil.data(goodsSkuService.getGoodsSkuByPage(goodsSearchParams));
        IPage<GoodsSku> goodsSkuByPage = goodsSkuService.getGoodsSkuByPage(goodsSearchParams);
        goodsSkuByPage.getRecords().forEach(goodsSku -> {
            String thumbnail = goodsSku.getThumbnail();
            if (StringUtils.isNotBlank(thumbnail)&&!thumbnail.contains("http")) {
                goodsSku.setThumbnail(cosUtil.getPreviewUrl(goodsSku.getThumbnail()));
            }
        });
        return ResultUtil.data(goodsSkuByPage);
    }
    @ApiOperation(value = "分页获取待审核商品")
manager-api/src/main/java/cn/lili/controller/lmk/VideoController.java
@@ -37,7 +37,11 @@
    @Qualifier("videoEsServiceImpl")
    private final EsService esService;
    @PostMapping("/publish")
    @ApiOperation(value = "发布视频", notes = "发布视频")
    public Result publish(@RequestBody @Validated({Add.class}) WxVideoForm form) {
        return videoService.systemPublish(form);
    }
    @DeleteMapping("/{id}")
    @ApiOperation(value = "ID删除", notes = "ID删除")
    public Result removeById(@PathVariable("id") String id) {
manager-api/src/main/java/cn/lili/controller/lmk/VideoTagController.java
@@ -2,6 +2,11 @@
import cn.lili.group.Update;
import cn.lili.group.Add;
import cn.lili.modules.lmk.domain.form.WxVideoForm;
import cn.lili.modules.lmk.domain.query.VideoGoodsEsQuery;
import cn.lili.modules.lmk.domain.query.WxVideoTagQuery;
import cn.lili.modules.lmk.service.VideoService;
import cn.lili.modules.search.service.EsGoodsSearchService;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import lombok.RequiredArgsConstructor;
@@ -31,7 +36,17 @@
public class VideoTagController {
    private final VideoTagService videoTagService;
    private final EsGoodsSearchService goodsSearchService;
    @GetMapping("/recommend")
    @ApiOperation(value = "推荐标签", notes = "推荐标签")
    public Result recommend(WxVideoTagQuery query) {
        return videoTagService.recommend(query);
    }
    @ApiOperation(value = "商品分页-发布视频时关联商品")
    @GetMapping("/video/es")
    public Result videoGoodsEsPage(VideoGoodsEsQuery query) {
        return goodsSearchService.videoGoodsEsPage(query);
    }
    @PostMapping
    @ApiOperation(value = "添加", notes = "添加")
    public Result add(@RequestBody @Validated(Add.class) VideoTagForm form) {