From 2226679bda25ddf977f12367a9a37fcf4e377249 Mon Sep 17 00:00:00 2001 From: xiangpei <xiangpei@timesnew.cn> Date: 星期二, 17 六月 2025 11:00:53 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev --- seller-api/src/main/java/cn/lili/controller/goods/GoodsStoreController.java | 15 ++++ framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java | 33 ++++++++++ manager-api/src/main/java/cn/lili/controller/goods/GoodsManagerController.java | 20 ++++++ framework/src/main/resources/mapper/lmk/VideoMapper.xml | 31 ++++++++++ framework/src/main/java/cn/lili/modules/goods/entity/dos/Goods.java | 6 ++ buyer-api/src/main/java/cn/lili/controller/lmk/VideoController.java | 7 ++ framework/src/main/java/cn/lili/modules/lmk/service/VideoService.java | 2 framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoServiceImpl.java | 23 +++++++ framework/src/main/java/cn/lili/modules/lmk/mapper/VideoMapper.java | 2 framework/src/main/java/cn/lili/modules/lmk/domain/query/WxHealthVideoQuery.java | 25 ++++++++ 10 files changed, 158 insertions(+), 6 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 dec98a3..b790050 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 @@ -6,6 +6,8 @@ import cn.lili.modules.lmk.domain.form.VideoHomePageInfoForm; import cn.lili.modules.lmk.domain.form.WxVideoForm; import cn.lili.modules.lmk.domain.query.AuthorVideoQuery; +import cn.lili.modules.lmk.domain.query.HealthVideoQuery; +import cn.lili.modules.lmk.domain.query.WxHealthVideoQuery; import org.springframework.validation.annotation.Validated; import lombok.RequiredArgsConstructor; import java.util.List; @@ -67,6 +69,11 @@ public Result recommendVideo(VideoQuery query) { return videoService.recommendVideo(query); } + @GetMapping("/health/recommend") + @ApiOperation(value = "澶у仴搴疯棰戞帹鑽�", notes = "澶у仴搴疯棰戞帹鑽�") + public Result healthRecommendVideo(WxHealthVideoQuery query) { + return videoService.healthRecommendVideo(query); + } @GetMapping("/goods/detail/{videoId}") @ApiOperation(value = "瑙嗛鍟嗗搧鏌ョ湅", notes = "瑙嗛鍟嗗搧鏌ョ湅") diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dos/Goods.java b/framework/src/main/java/cn/lili/modules/goods/entity/dos/Goods.java index 029a66c..d8b663a 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dos/Goods.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dos/Goods.java @@ -14,6 +14,8 @@ import cn.lili.modules.goods.entity.enums.GoodsStatusEnum; import cn.lili.modules.goods.entity.enums.GoodsTypeEnum; import cn.lili.mybatis.BaseEntity; +import com.baomidou.mybatisplus.annotation.FieldStrategy; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import com.xkcoding.http.util.StringUtil; import io.swagger.annotations.ApiModel; @@ -87,12 +89,15 @@ private Double grade; @ApiModelProperty(value = "缂╃暐鍥捐矾寰�") + @TableField(updateStrategy = FieldStrategy.IGNORED) private String thumbnail; @ApiModelProperty(value = "灏忓浘璺緞") + @TableField(updateStrategy = FieldStrategy.IGNORED) private String small; @ApiModelProperty(value = "鍘熷浘璺緞") + @TableField(updateStrategy = FieldStrategy.IGNORED) private String original; @ApiModelProperty(value = "搴楅摵鍒嗙被id") @@ -129,6 +134,7 @@ private String mobileIntro; @ApiModelProperty(value = "鍟嗗搧瑙嗛") + @TableField(updateStrategy = FieldStrategy.IGNORED) private String goodsVideo; diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java index 6909add..8465e1b 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java @@ -41,11 +41,13 @@ import cn.lili.mybatis.util.PageUtil; import cn.lili.rocketmq.RocketmqSendCallbackBuilder; import cn.lili.rocketmq.tags.GoodsTagsEnum; +import cn.lili.utils.COSUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.rocketmq.spring.core.RocketMQTemplate; @@ -121,6 +123,9 @@ @Autowired private Cache<GoodsVO> cache; + @Autowired + private COSUtil cosUtil; + @Override public List<Goods> getByBrandIds(List<String> brandIds) { LambdaQueryWrapper<Goods> lambdaQueryWrapper = new LambdaQueryWrapper<>(); @@ -172,7 +177,7 @@ //妫�鏌ュ晢鍝� this.checkGoods(goods); //鍚慻oods鍔犲叆鍥剧墖 - if (goodsOperationDTO.getGoodsGalleryList().size() > 0) { + if (goodsOperationDTO.getGoodsGalleryList()!=null&& !goodsOperationDTO.getGoodsGalleryList().isEmpty()) { this.setGoodsGalleryParam(goodsOperationDTO.getGoodsGalleryList().get(0), goods); } //娣诲姞鍟嗗搧鍙傛暟 @@ -201,7 +206,14 @@ //妫�鏌ュ晢鍝佷俊鎭� this.checkGoods(goods); //鍚慻oods鍔犲叆鍥剧墖 - this.setGoodsGalleryParam(goodsOperationDTO.getGoodsGalleryList().get(0), goods); + if (goodsOperationDTO.getGoodsGalleryList() != null&& !goodsOperationDTO.getGoodsGalleryList().isEmpty()) { + this.setGoodsGalleryParam(goodsOperationDTO.getGoodsGalleryList().get(0), goods); + }else { + goods.setOriginal(null); + goods.setSmall(null); + goods.setThumbnail(null); + goodsGalleryService.removeByGoodsId(goodsId); + } //娣诲姞鍟嗗搧鍙傛暟 if (goodsOperationDTO.getGoodsParamsDTOList() != null && !goodsOperationDTO.getGoodsParamsDTOList().isEmpty()) { goods.setParams(JSONUtil.toJsonStr(goodsOperationDTO.getGoodsParamsDTOList())); @@ -227,6 +239,17 @@ //缂撳瓨鑾峰彇锛屽鏋滄病鏈夊垯璇诲彇缂撳瓨 GoodsVO goodsVO = cache.get(CachePrefix.GOODS.getPrefix() + goodsId); if (goodsVO != null) { +// List<String> goodsGalleryList = goodsVO.getGoodsGalleryList(); +// if (goodsGalleryList != null && !goodsGalleryList.isEmpty()) { +// List<String> galleryList = goodsGalleryList.stream().map(item -> { +// if (StringUtils.isNotBlank(item)&&!item.contains("http")) { +// return cosUtil.getPreviewUrl(item); +// }else { +// return item; +// } +// }).collect(Collectors.toList()); +// goodsVO.setGoodsGalleryList(galleryList); +// } return goodsVO; } //鏌ヨ鍟嗗搧淇℃伅 @@ -245,6 +268,12 @@ List<GoodsGallery> galleryList = goodsGalleryService.goodsGalleryList(goodsId); for (GoodsGallery goodsGallery : galleryList) { images.add(goodsGallery.getOriginal()); +// String original = goodsGallery.getOriginal(); +// if (StringUtils.isNotBlank(original)&&!original.contains("http")) { +// images.add(cosUtil.getPreviewUrl(original)); +// }else { +// images.add(goodsGallery.getOriginal()); +// } } goodsVO.setGoodsGalleryList(images); //鍟嗗搧sku璧嬪�� diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/query/WxHealthVideoQuery.java b/framework/src/main/java/cn/lili/modules/lmk/domain/query/WxHealthVideoQuery.java new file mode 100644 index 0000000..dc2111f --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/lmk/domain/query/WxHealthVideoQuery.java @@ -0,0 +1,25 @@ +package cn.lili.modules.lmk.domain.query; + +import cn.lili.base.AbsQuery; +import cn.lili.modules.lmk.enums.general.VideoTypeEnum; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * 寰俊灏忕▼搴忓ぇ鍋ュ悍鏌ヨ鍙傛暟 + * + * @author wp + * @since 2025-05-16 + */ +@Data +@ApiModel(value = "寰俊灏忕▼搴忓ぇ鍋ュ悍鏌ヨ鍙傛暟", description = "寰俊灏忕▼搴忓ぇ鍋ュ悍鏌ヨ鍙傛暟") +public class WxHealthVideoQuery extends AbsQuery { + + /** + * @see VideoTypeEnum + */ + @ApiModelProperty("瑙嗛绫诲瀷锛氳棰戙�佸ぇ鍋ュ悍銆佺鍘紝榛樿涓嶄紶鏌ヨ棰�") + private String videoType = VideoTypeEnum.HEALTH.getValue(); +} + diff --git a/framework/src/main/java/cn/lili/modules/lmk/mapper/VideoMapper.java b/framework/src/main/java/cn/lili/modules/lmk/mapper/VideoMapper.java index 988a2c4..a7396bd 100644 --- a/framework/src/main/java/cn/lili/modules/lmk/mapper/VideoMapper.java +++ b/framework/src/main/java/cn/lili/modules/lmk/mapper/VideoMapper.java @@ -46,6 +46,8 @@ */ IPage recommendVideo(IPage page, @Param("query") VideoQuery query); + IPage recommendHealthVideo(IPage page, @Param("query") WxHealthVideoQuery query); + /** * 鎵归噺鏇存柊瑙嗛鏀惰棌鏁伴噺 * 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 73fe761..8e44942 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 @@ -124,6 +124,8 @@ */ Result recommendVideo(VideoQuery query); + Result healthRecommendVideo(WxHealthVideoQuery query); + /** * 鎵归噺鏇存柊瑙嗛鏀惰棌鏁伴噺 * 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 7e79858..4fee572 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 @@ -317,8 +317,8 @@ v.setTagList(tagMap.get(v.getId())); v.setCollected(CollectionUtils.isNotEmpty(collectMap.get(v.getId()))); if (VideoContentTypeEnum.VIDEO.getValue().equals(v.getVideoContentType())) { - // v.setVideoUrl(cosUtil.getPreviewUrl(v.getVideoFileKey())); - v.setVideoUrl("https://videos.pexels.com/video-files/13602965/13602965-hd_1920_1080_30fps.mp4"); + v.setVideoUrl(cosUtil.getPreviewUrl(v.getVideoFileKey())); +// v.setVideoUrl("https://videos.pexels.com/video-files/13602965/13602965-hd_1920_1080_30fps.mp4"); } 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())); } @@ -330,6 +330,25 @@ } @Override + public Result healthRecommendVideo(WxHealthVideoQuery query) { + IPage<WxVideoVO> page = PageUtil.getPage(query, WxVideoVO.class); + //鑾峰彇澶у仴搴疯棰戝垪琛� + baseMapper.recommendHealthVideo(page,query); + if (page.getTotal() > 0) { + page.getRecords().forEach(v -> { + if (VideoContentTypeEnum.VIDEO.getValue().equals(v.getVideoContentType())) { + v.setVideoUrl(cosUtil.getPreviewUrl(v.getVideoFileKey())); +// v.setVideoUrl("https://videos.pexels.com/video-files/13602965/13602965-hd_1920_1080_30fps.mp4"); + } else if (VideoContentTypeEnum.IMG.getValue().equals(v.getVideoContentType()) && StringUtils.isNotBlank(v.getVideoImgs())) { + v.setImgs(JSON.parseArray(v.getVideoImgs(), String.class).stream().map(cosUtil::getPreviewUrl).collect(Collectors.toList())); + } + v.setCoverUrl(cosUtil.getPreviewUrl(v.getCoverFileKey())); + }); + } + return Result.ok().data(page.getRecords()); + } + + @Override @Transactional(rollbackFor = Exception.class) public void updateCollectNumBatch(List<CollectTypeNumVO> numList) { // 鎸�500鏉℃暟鎹繘琛屾媶鍒� diff --git a/framework/src/main/resources/mapper/lmk/VideoMapper.xml b/framework/src/main/resources/mapper/lmk/VideoMapper.xml index 840e91f..3d8c9d5 100644 --- a/framework/src/main/resources/mapper/lmk/VideoMapper.xml +++ b/framework/src/main/resources/mapper/lmk/VideoMapper.xml @@ -231,6 +231,37 @@ WHERE LV.delete_flag = 0 AND LV.status = '1' AND LV.video_type = #{query.videoType} </select> + <select id="recommendHealthVideo" 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.weight, + LV.audit_pass_time, + LV.update_time, + LV.video_content_type, + LV.video_type, + LV.video_imgs, + LV.id, + LAU.nick_name AS authorName, + LAU.avatar AS authorAvatar + FROM + lmk_video LV + LEFT JOIN li_admin_user LAU ON LV.author_id = LAU.id + WHERE + LV.delete_flag = 0 AND LV.status = '1' AND LV.video_type = #{query.videoType} + AND LV.video_content_type = 'video' + </select> <update id="updateCollectNumBatch"> diff --git a/manager-api/src/main/java/cn/lili/controller/goods/GoodsManagerController.java b/manager-api/src/main/java/cn/lili/controller/goods/GoodsManagerController.java index 18d8248..b252dab 100644 --- a/manager-api/src/main/java/cn/lili/controller/goods/GoodsManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/goods/GoodsManagerController.java @@ -5,6 +5,7 @@ import cn.lili.common.enums.ResultCode; import cn.lili.common.enums.ResultUtil; import cn.lili.common.exception.ServiceException; +import cn.lili.common.utils.StringUtils; import cn.lili.common.vo.ResultMessage; import cn.lili.modules.goods.entity.dos.Goods; import cn.lili.modules.goods.entity.dos.GoodsSku; @@ -14,6 +15,7 @@ import cn.lili.modules.goods.entity.vos.GoodsVO; import cn.lili.modules.goods.service.GoodsService; import cn.lili.modules.goods.service.GoodsSkuService; +import cn.lili.utils.COSUtil; import com.baomidou.mybatisplus.core.metadata.IPage; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -25,6 +27,8 @@ import javax.validation.constraints.NotEmpty; import java.util.Arrays; import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; /** * 绠$悊绔�,鍟嗗搧绠$悊鎺ュ彛 @@ -47,6 +51,9 @@ @Autowired private GoodsSkuService goodsSkuService; + @Autowired + private COSUtil cosUtil; + @ApiOperation(value = "鍒嗛〉鑾峰彇") @GetMapping(value = "/list") public ResultMessage<IPage<Goods>> getByPage(GoodsSearchParams goodsSearchParams) { @@ -63,7 +70,18 @@ @GetMapping(value = "/auth/list") public ResultMessage<IPage<Goods>> getAuthPage(GoodsSearchParams goodsSearchParams) { goodsSearchParams.setAuthFlag(GoodsAuthEnum.TOBEAUDITED.name()); - return ResultUtil.data(goodsService.queryByParams(goodsSearchParams)); + IPage<Goods> page = goodsService.queryByParams(goodsSearchParams); + page.getRecords().forEach(item -> { + String original = item.getOriginal(); + String goodsVideo = item.getGoodsVideo(); + if (StringUtils.isNotBlank(original)&&!original.contains("http")) { + item.setOriginal(cosUtil.getPreviewUrl(original)); + } + if (StringUtils.isNotBlank(goodsVideo)&&!goodsVideo.contains("http")) { + item.setGoodsVideo(cosUtil.getPreviewUrl(goodsVideo)); + } + }); + return ResultUtil.data(page); } @PreventDuplicateSubmissions diff --git a/seller-api/src/main/java/cn/lili/controller/goods/GoodsStoreController.java b/seller-api/src/main/java/cn/lili/controller/goods/GoodsStoreController.java index 48a9b03..8142cdf 100644 --- a/seller-api/src/main/java/cn/lili/controller/goods/GoodsStoreController.java +++ b/seller-api/src/main/java/cn/lili/controller/goods/GoodsStoreController.java @@ -8,6 +8,7 @@ import cn.lili.common.exception.ServiceException; import cn.lili.common.security.OperationalJudgment; import cn.lili.common.security.context.UserContext; +import cn.lili.common.utils.StringUtils; import cn.lili.common.vo.ResultMessage; import cn.lili.modules.goods.entity.dos.Goods; import cn.lili.modules.goods.entity.dos.GoodsSku; @@ -25,6 +26,7 @@ import cn.lili.modules.statistics.aop.enums.PageViewEnum; import cn.lili.modules.store.entity.dos.StoreDetail; import cn.lili.modules.store.service.StoreDetailService; +import cn.lili.utils.COSUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -70,6 +72,8 @@ */ @Autowired private GoodsSkuService goodsSkuService; + @Autowired + private COSUtil cosUtil; @ApiOperation(value = "鍒嗛〉鑾峰彇鍟嗗搧鍒楄〃") @@ -78,7 +82,16 @@ //鑾峰彇褰撳墠鐧诲綍鍟嗗璐﹀彿 String storeId = Objects.requireNonNull(UserContext.getCurrentUser()).getStoreId(); goodsSearchParams.setStoreId(storeId); - return ResultUtil.data(goodsService.queryByParams(goodsSearchParams)); + IPage<Goods> page = goodsService.queryByParams(goodsSearchParams); + page.getRecords().forEach(goodsVO -> { + if (StringUtils.isNotBlank(goodsVO.getOriginal())&& !goodsVO.getOriginal().contains("http")) { + goodsVO.setOriginal(cosUtil.getPreviewUrl(goodsVO.getOriginal())); + } + if (StringUtils.isNotBlank(goodsVO.getGoodsVideo())&& !goodsVO.getGoodsVideo().contains("http")) { + goodsVO.setGoodsVideo(cosUtil.getPreviewUrl(goodsVO.getGoodsVideo())); + } + }); + return ResultUtil.data(page); } @ApiOperation(value = "鍒嗛〉鑾峰彇鍟嗗搧Sku鍒楄〃") -- Gitblit v1.8.0