From b1383a4dcd8c1b228174e28fb8331ee078115cb8 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期三, 18 六月 2025 17:56:41 +0800
Subject: [PATCH] 小程序端视频编辑、下架、删除接口
---
framework/src/main/java/cn/lili/modules/lmk/domain/vo/WxEditVideoVO.java | 14 +++
framework/src/main/resources/mapper/lmk/VideoMapper.xml | 15 ---
framework/src/main/java/cn/lili/modules/lmk/domain/form/WxVideoForm.java | 5
framework/src/main/java/cn/lili/modules/lmk/domain/vo/WxVideoTagVO.java | 36 +++++++++
buyer-api/src/main/java/cn/lili/controller/lmk/VideoController.java | 8 +
framework/src/main/java/cn/lili/modules/lmk/service/VideoService.java | 16 ++++
framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoServiceImpl.java | 80 +++++++++++++++++++
framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoTagServiceImpl.java | 7 +
framework/src/main/java/cn/lili/modules/lmk/enums/general/VideoSupportOpEnum.java | 4
9 files changed, 160 insertions(+), 25 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 b790050..9ae68b3 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
@@ -43,7 +43,7 @@
@PutMapping
@ApiOperation(value = "淇敼", notes = "淇敼")
public Result update(@RequestBody @Validated(Update.class) WxVideoForm form) {
- return videoService.update(form);
+ return videoService.updatePublish(form);
}
@DeleteMapping("/{id}")
@@ -52,6 +52,12 @@
return videoService.removeById(id);
}
+ @PostMapping("/down/{id}")
+ @ApiOperation(value = "鐢ㄦ埛涓嬫灦瑙嗛", notes = "鐢ㄦ埛涓嬫灦瑙嗛")
+ public Result downVideo(@PathVariable("id") String id) {
+ return videoService.buyerDownVideo(id);
+ }
+
@DeleteMapping("/batch")
@ApiOperation(value = "鎵归噺鍒犻櫎", notes = "鎵归噺鍒犻櫎")
public Result remove(@RequestBody @NotEmpty(message = "璇烽�夋嫨鏁版嵁") List<String> ids) {
diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/form/WxVideoForm.java b/framework/src/main/java/cn/lili/modules/lmk/domain/form/WxVideoForm.java
index 4a884ca..4ef60fe 100644
--- a/framework/src/main/java/cn/lili/modules/lmk/domain/form/WxVideoForm.java
+++ b/framework/src/main/java/cn/lili/modules/lmk/domain/form/WxVideoForm.java
@@ -5,12 +5,11 @@
import cn.lili.base.AbsForm;
import cn.lili.modules.lmk.domain.entity.Video;
import cn.lili.modules.lmk.domain.vo.VideoGoodsPublishVO;
-import cn.lili.modules.lmk.domain.vo.VideoGoodsVO;
-import org.hibernate.validator.constraints.Length;
import org.springframework.beans.BeanUtils;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.Size;
import org.springframework.lang.NonNull;
import io.swagger.annotations.ApiModel;
@@ -51,7 +50,7 @@
private List<String> videoImgs;
@ApiModelProperty("瑙嗛鏍囩")
- @Length(max = 5, message = "鏈�澶氬彧鑳芥坊鍔犱簲涓爣绛�")
+ @Size(max = 5, message = "鏈�澶氬彧鑳芥坊鍔犱簲涓爣绛�", groups = {Add.class, Update.class})
private List<WxVideoTagForm> tags = new ArrayList<>(2);
// @NotBlank(message = "鍟嗗搧id涓嶈兘涓虹┖", groups = {Add.class, Update.class})
diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/vo/WxEditVideoVO.java b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/WxEditVideoVO.java
index 1c74bc9..943f81e 100644
--- a/framework/src/main/java/cn/lili/modules/lmk/domain/vo/WxEditVideoVO.java
+++ b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/WxEditVideoVO.java
@@ -35,6 +35,18 @@
@ApiModelProperty("瑙嗛鏍囩")
private List<WxVideoTagForm> tags;
+ @ApiModelProperty("鍥鹃泦-json鏁扮粍")
+ private String videoImgs;
+
+ @ApiModelProperty("鍥鹃泦")
+ private List<String> imgs;
+
+ /**
+ * @see cn.lili.modules.lmk.enums.general.VideoContentTypeEnum
+ */
+ @ApiModelProperty("瑙嗛鍐呭绫诲瀷锛氳棰戙�佸浘鐗�")
+ private String videoContentType;
+
/** 瑙嗛濉厖妯″紡 */
@ApiModelProperty("瑙嗛濉厖妯″紡")
private String videoFit;
@@ -45,7 +57,7 @@
/** 鍟嗗搧淇℃伅 */
@ApiModelProperty("鍟嗗搧淇℃伅")
- private String goodsId;
+ private List<VideoGoodsDetailVO> goodsList;
@ApiModelProperty("瑙嗛闀垮害锛氱")
private Long videoDuration;
diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/vo/WxVideoTagVO.java b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/WxVideoTagVO.java
new file mode 100644
index 0000000..c8bc182
--- /dev/null
+++ b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/WxVideoTagVO.java
@@ -0,0 +1,36 @@
+package cn.lili.modules.lmk.domain.vo;
+
+import cn.lili.base.AbsVo;
+import cn.lili.modules.lmk.domain.entity.VideoTag;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springframework.beans.BeanUtils;
+import org.springframework.lang.NonNull;
+
+/**
+ * 瑙嗛鏍囩灞曠ず
+ *
+ * @author xp
+ * @since 2025-05-13
+ */
+@Data
+@ApiModel(value = "瑙嗛鏍囩鍝嶅簲鏁版嵁", description = "瑙嗛鏍囩鍝嶅簲鏁版嵁")
+public class WxVideoTagVO {
+
+ private String id;
+
+ /** 鏍囩鍚嶇О */
+ @ApiModelProperty("鏍囩鍚嶇О")
+ private String tagName;
+
+
+ public static WxVideoTagVO getVoByEntity(@NonNull VideoTag entity, WxVideoTagVO vo) {
+ if(vo == null) {
+ vo = new WxVideoTagVO();
+ }
+ BeanUtils.copyProperties(entity, vo);
+ return vo;
+ }
+
+}
diff --git a/framework/src/main/java/cn/lili/modules/lmk/enums/general/VideoSupportOpEnum.java b/framework/src/main/java/cn/lili/modules/lmk/enums/general/VideoSupportOpEnum.java
index a339215..36a9b22 100644
--- a/framework/src/main/java/cn/lili/modules/lmk/enums/general/VideoSupportOpEnum.java
+++ b/framework/src/main/java/cn/lili/modules/lmk/enums/general/VideoSupportOpEnum.java
@@ -17,7 +17,7 @@
@Getter
public enum VideoSupportOpEnum {
- UP("UP", "鍙戝竷"),
+// UP("UP", "鍙戝竷"),
DOWN("DOWN", "涓嬫灦"),
DELETE("DELETE", "鍒犻櫎"),
EDIT("EDIT", "缂栬緫"),
@@ -43,7 +43,7 @@
if (VideoStatusEnum.AUDITING.getValue().equals(status)) {
return Arrays.asList(new VideoOption(EDIT.value, EDIT.desc), new VideoOption(DELETE.value, DELETE.desc));
} else if (VideoStatusEnum.DISABLE.getValue().equals(status)) {
- return Arrays.asList(new VideoOption(EDIT.value, EDIT.desc), new VideoOption(UP.value, UP.desc), new VideoOption(DELETE.value, DELETE.desc));
+ return Arrays.asList(new VideoOption(EDIT.value, EDIT.desc), new VideoOption(DELETE.value, DELETE.desc));
} else if (VideoStatusEnum.PUBLISHED.getValue().equals(status)) {
return Arrays.asList(new VideoOption(EDIT.value, EDIT.desc), new VideoOption(DOWN.value, DOWN.desc), new VideoOption(DELETE.value, DELETE.desc));
} else if (VideoStatusEnum.REJECT.getValue().equals(status)) {
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 8e44942..8b8f5c4 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
@@ -237,4 +237,20 @@
* @return
*/
Result getGoodsDetail(String videoId);
+
+ /**
+ * 鐢ㄦ埛涓嬫灦瑙嗛
+ *
+ * @param id
+ * @return
+ */
+ Result buyerDownVideo(String id);
+
+ /**
+ * 淇敼瑙嗛
+ *
+ * @param form
+ * @return
+ */
+ Result updatePublish(WxVideoForm 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 b3cb333..b56d9ba 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
@@ -206,6 +206,68 @@
return Result.ok("鍙戝竷鎴愬姛锛岃棰戝鏍镐腑~");
}
+ @Override
+ public Result updatePublish(WxVideoForm form) {
+ Video video = baseMapper.selectById(form.getId());
+ if (Objects.isNull(video)) {
+ return Result.error("淇敼瑙嗛涓嶅瓨鍦�");
+ }
+ // 1.淇敼瑙嗛
+ WxVideoForm.getEntityByForm(form, video);
+ video.setAuthorId(UserContext.getCurrentUserId());
+ video.setStatus(VideoStatusEnum.AUDITING.getValue());
+ video.setCoverUrl(form.getCover());
+ video.setVideoType(VideoTypeEnum.VIDEO.getValue());
+ if (VideoContentTypeEnum.IMG.getValue().equals(form.getVideoContentType())) {
+ video.setVideoImgs(JSON.toJSONString(form.getVideoImgs()));
+ }
+ baseMapper.updateById(video);
+ // 2.澶勭悊鏍囩---鍒犻櫎涔嬪墠鐨勮棰戞爣绛惧叧绯伙紝鍐嶆柊澧�
+ new LambdaUpdateChainWrapper<>(videoTagRefService.getBaseMapper())
+ .eq(VideoTagRef::getVideoId, video.getId())
+ .remove();
+ 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.USER.getValue());
+ videoTagService.save(videoTag);
+ videoTagRef.setVideoTagId(videoTag.getId());
+ }
+ } else {
+ videoTagRef.setVideoTagId(tag.getId());
+ }
+ return videoTagRef;
+ }).collect(Collectors.toList());
+ videoTagRefService.saveBatch(videoTagRefs);
+ // 3. 淇濆瓨瑙嗛鏂囦欢淇℃伅
+ lmkFileService.addByForm(form.getFileInfo());
+ // 4. 澶勭悊閫夋嫨鐨勫晢鍝侊紝鍏堝垹闄や箣鍓嶇殑鍐嶆柊澧�
+ new LambdaUpdateChainWrapper<>(videoGoodsService.getBaseMapper())
+ .eq(VideoGoods::getVideoId, video.getId())
+ .remove();
+ if (CollectionUtils.isNotEmpty(form.getGoodsList())) {
+ List<VideoGoods> videoGoods = new ArrayList<>(2);
+ 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.setGoodsNum(form.getGoodsList().get(i).getGoodsNum());
+ e.setOrderNum(i);
+ videoGoods.add(e);
+ }
+ videoGoodsService.saveBatch(videoGoods);
+ }
+ return Result.ok("鍙戝竷鎴愬姛锛岃棰戝鏍镐腑~");
+ }
@Override
public Result managerPage(ManagerVideoQuery query) {
@@ -279,6 +341,15 @@
.set(Video::getStatus, VideoStatusEnum.DISABLE.getValue())
.update();
// TODO 灏嗕笅鏋跺師鍥犱互閫氱煡鐨勬柟寮忓憡鐭ョ敤鎴�
+ return Result.ok("涓嬫灦鎴愬姛");
+ }
+
+ @Override
+ public Result buyerDownVideo(String id) {
+ new LambdaUpdateChainWrapper<>(baseMapper)
+ .eq(Video::getId, id)
+ .set(Video::getStatus, VideoStatusEnum.DISABLE.getValue())
+ .update();
return Result.ok("涓嬫灦鎴愬姛");
}
@@ -455,9 +526,12 @@
if (Objects.isNull(vo)) {
return Result.error("瑙嗛涓嶅瓨鍦�");
}
- vo.setCoverUrl(cosUtil.getPreviewUrl(vo.getCoverFileKey()));
-// vo.setVideoUrl(cosUtil.getPreviewUrl(vo.getVideoFileKey()));
- vo.setVideoUrl("https://videos.pexels.com/video-files/13602965/13602965-hd_1920_1080_30fps.mp4");
+ if (VideoContentTypeEnum.VIDEO.getValue().equals(vo.getVideoContentType())) {
+ vo.setVideoUrl(cosUtil.getPreviewUrl(vo.getVideoFileKey()));
+ vo.setCoverUrl(cosUtil.getPreviewUrl(vo.getCoverFileKey()));
+ } else if (VideoContentTypeEnum.IMG.getValue().equals(vo.getVideoContentType()) && StringUtils.isNotBlank(vo.getVideoImgs())) {
+ vo.setImgs(JSON.parseArray(vo.getVideoImgs(), String.class).stream().map(fileKey -> cosUtil.getPreviewUrl(fileKey)).collect(Collectors.toList()));
+ }
List<WxVideoTagForm> tags = videoTagRefService.getTagsByVideoIds(Arrays.asList(vo.getId()))
.stream()
.map(i -> {
diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoTagServiceImpl.java b/framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoTagServiceImpl.java
index 85474dd..75a473a 100644
--- a/framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoTagServiceImpl.java
+++ b/framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoTagServiceImpl.java
@@ -2,6 +2,7 @@
import cn.lili.modules.lmk.domain.query.WxVideoTagQuery;
import cn.lili.modules.lmk.domain.vo.SimpleVideoTagVO;
+import cn.lili.modules.lmk.domain.vo.WxVideoTagVO;
import cn.lili.modules.lmk.enums.general.TagCreateTypeEnum;
import com.baomidou.mybatisplus.core.metadata.IPage;
import cn.lili.modules.lmk.domain.entity.VideoTag;
@@ -139,7 +140,7 @@
@Override
public Result recommend(WxVideoTagQuery query) {
- List<VideoTagVO> tags = new ArrayList<>(3);
+ List<WxVideoTagVO> tags = new ArrayList<>(3);
switch (query.getSearchType()) {
case "HOT":
// TODO 鐑棬鏍囩閫氳繃瀹氭椂浠诲姟缁熻琛╨mk_video_tag_ref鏁伴噺鍒發mk_video_tag涓�
@@ -147,7 +148,7 @@
.orderByDesc(VideoTag::getUseNum)
.last("limit 3")
.list().stream().map(entity -> {
- return VideoTagVO.getVoByEntity(entity, null);
+ return WxVideoTagVO.getVoByEntity(entity, null);
}).collect(Collectors.toList());
case "SEARCH":
tags = new LambdaQueryChainWrapper<>(baseMapper)
@@ -155,7 +156,7 @@
.like(VideoTag::getTagName, query.getTagName())
.last("limit 3")
.list().stream().map(entity -> {
- return VideoTagVO.getVoByEntity(entity, null);
+ return WxVideoTagVO.getVoByEntity(entity, null);
}).collect(Collectors.toList());
}
return Result.ok().data(tags);
diff --git a/framework/src/main/resources/mapper/lmk/VideoMapper.xml b/framework/src/main/resources/mapper/lmk/VideoMapper.xml
index 3d8c9d5..523d764 100644
--- a/framework/src/main/resources/mapper/lmk/VideoMapper.xml
+++ b/framework/src/main/resources/mapper/lmk/VideoMapper.xml
@@ -404,28 +404,19 @@
<result column="video_fit" property="videoFit" />
<result column="title" property="title" />
<result column="video_duration" property="videoDuration" />
+ <result column="video_imgs" property="videoImgs" />
+ <result column="video_content_type" property="videoContentType" />
+ <collection property="goodsList" column="id" select="getVideoGoods" ofType="cn.lili.modules.lmk.domain.vo.VideoGoodsDetailVO"/>
</resultMap>
<select id="wxDetail" resultMap="WxEditResultMap">
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
FROM
--
Gitblit v1.8.0