From b3bdc131a50234de457d1a7515758b2a169ba038 Mon Sep 17 00:00:00 2001 From: peng <peng.com> Date: 星期五, 13 六月 2025 11:08:08 +0800 Subject: [PATCH] insert insert 完成大健康后台页面接口(增删改查/上架/下架) --- framework/src/main/java/cn/lili/modules/lmk/domain/form/HealthVideoForm.java | 54 ++++++++++ framework/src/main/resources/mapper/lmk/VideoMapper.xml | 41 ++++++++ manager-api/src/main/java/cn/lili/controller/lmk/HealthController.java | 44 ++++++++ framework/src/main/java/cn/lili/modules/lmk/domain/vo/VideoVO.java | 4 framework/src/main/java/cn/lili/modules/lmk/service/VideoService.java | 30 ++++++ framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoServiceImpl.java | 57 +++++++++++ framework/src/main/java/cn/lili/modules/lmk/domain/query/HealthVideoQuery.java | 39 +++++++ framework/src/main/java/cn/lili/modules/lmk/mapper/VideoMapper.java | 9 + 8 files changed, 277 insertions(+), 1 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/form/HealthVideoForm.java b/framework/src/main/java/cn/lili/modules/lmk/domain/form/HealthVideoForm.java new file mode 100644 index 0000000..d372d82 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/lmk/domain/form/HealthVideoForm.java @@ -0,0 +1,54 @@ +package cn.lili.modules.lmk.domain.form; + +import cn.lili.common.security.context.UserContext; +import cn.lili.group.Add; +import cn.lili.group.Update; +import cn.lili.mybatis.BaseEntity; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.util.Date; + +/** + * 澶у仴搴疯棰戝唴瀹� + * + * @author wp + * @since 2025-06-12 + */ +@Data +@ApiModel(value = "澶у仴搴疯棰戝唴瀹�", description = "澶у仴搴疯棰戝唴瀹�") +public class HealthVideoForm extends BaseEntity { + + private static final long serialVersionUID = 1L; + + /** 浣滆�卛d */ + @ApiModelProperty(value = "涓婚敭id") + private String id; + + @ApiModelProperty(value = "鍥剧墖灏侀潰") + /** 鍥剧墖灏侀潰 */ + @NotBlank(message = "灏侀潰鍥剧墖涓嶈兘涓虹┖", groups = {Add.class, Update.class}) + private String coverUrl; + + @TableField("video_file_key") + /** 瑙嗛鍦板潃 */ + @NotBlank(message = "瑙嗛鍦板潃涓嶈兘涓虹┖", groups = {Add.class, Update.class}) + private String videoFileKey; + + + /** 瑙嗛闀垮害(绉�) */ +// @NotNull(message = "瑙嗛闀垮害涓嶈兘涓虹┖", groups = {Add.class, Update.class}) + private Long videoDuration; + + /** 瑙嗛鏍囬 */ + @NotBlank(message = "鏍囬涓嶈兘涓虹┖", groups = {Add.class, Update.class}) + private String title; + + + +} diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/query/HealthVideoQuery.java b/framework/src/main/java/cn/lili/modules/lmk/domain/query/HealthVideoQuery.java new file mode 100644 index 0000000..47b29b2 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/lmk/domain/query/HealthVideoQuery.java @@ -0,0 +1,39 @@ +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; + +import java.util.List; + +/** + * 瑙嗛鍐呭鏌ヨ + * + * @author xp + * @since 2025-05-16 + */ +@Data +@ApiModel(value = "骞冲彴绔疺ideo鏌ヨ鍙傛暟", description = "瑙嗛鍐呭鏌ヨ鍙傛暟") +public class HealthVideoQuery extends AbsQuery { + + @ApiModelProperty("鏍囬") + private String title; + + @ApiModelProperty("瑙嗛鏍囩") + private List<String> tagList; + + @ApiModelProperty("浣滆��") + private String authorId; + + @ApiModelProperty("鐘舵��") + private String status; + + /** + * @see VideoTypeEnum + */ + @ApiModelProperty("瑙嗛绫诲瀷锛氳棰戙�佸ぇ鍋ュ悍銆佺鍘紝榛樿涓嶄紶鏌ヨ棰�") + private String videoType = VideoTypeEnum.HEALTH.getValue(); +} + 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 fae271e..8c217e8 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 @@ -30,6 +30,10 @@ @ApiModelProperty("鍥剧墖灏侀潰") private String coverUrl; + /** 灏侀潰鏄剧ず鍦板潃 */ + @ApiModelProperty("灏侀潰鏄剧ず鍦板潃") + private String coverShowUrl; + /** 瑙嗛鍦板潃 */ @ApiModelProperty("瑙嗛鍦板潃") private String videoFileKey; 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 4b2675f..19e10ae 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 @@ -2,6 +2,7 @@ import cn.lili.modules.lmk.domain.entity.Video; import cn.lili.modules.lmk.domain.query.AuthorVideoQuery; +import cn.lili.modules.lmk.domain.query.HealthVideoQuery; import cn.lili.modules.lmk.domain.query.ManagerVideoQuery; import cn.lili.modules.lmk.domain.query.VideoQuery; import cn.lili.modules.lmk.domain.vo.CollectTypeNumVO; @@ -112,4 +113,12 @@ * @return */ WxEditVideoVO wxDetail(@Param("id") String id); + + /** + * 澶у仴搴疯棰戝垎椤� + * + * @param page + * @param query + */ + IPage healthPage(IPage page, @Param("query") HealthVideoQuery 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 0a4b93d..8e600ac 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 @@ -3,6 +3,7 @@ import cn.lili.modules.lmk.domain.entity.Video; import cn.lili.modules.lmk.domain.form.*; import cn.lili.modules.lmk.domain.query.AuthorVideoQuery; +import cn.lili.modules.lmk.domain.query.HealthVideoQuery; import cn.lili.modules.lmk.domain.query.ManagerVideoQuery; import cn.lili.modules.lmk.domain.vo.CollectTypeNumVO; import com.baomidou.mybatisplus.extension.service.IService; @@ -183,4 +184,33 @@ * @return */ Result wxDetail(String id); + + /** + * 澶у仴搴疯棰戝彂甯� + * + * @param form + * @return + */ + Result healthVideo(HealthVideoForm form); + /** + * 淇敼澶у仴搴疯棰� + * + * @param form + * @return + */ + Result updateHealthVideo(HealthVideoForm form); + /** + * 澶у仴搴疯棰戝垪琛� + * + * @param query + * @return + */ + Result healthPage(HealthVideoQuery query); + /** + * 鍒犻櫎澶у仴搴疯棰� + + * @param id 涓婚敭id + * @return + */ + Result delHealth(String id); } 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 a9875df..c2b7097 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 @@ -4,6 +4,7 @@ import cn.lili.modules.lmk.domain.entity.*; import cn.lili.modules.lmk.domain.form.*; import cn.lili.modules.lmk.domain.query.AuthorVideoQuery; +import cn.lili.modules.lmk.domain.query.HealthVideoQuery; import cn.lili.modules.lmk.domain.query.ManagerVideoQuery; import cn.lili.modules.lmk.domain.vo.*; import cn.lili.modules.lmk.enums.general.*; @@ -413,4 +414,60 @@ vo.setTags(tags); return Result.ok().data(vo); } + + @Override + public Result healthVideo(HealthVideoForm form) { + Video video = new Video(); + BeanUtils.copyProperties(form, video); + video.setAuthorId(UserContext.getCurrentUserId()); + video.setVideoType(VideoTypeEnum.HEALTH.getValue()); + //璁剧疆濉厖妯″紡 淇濇寔姣斾緥锛屽畬鏁存樉绀� + video.setVideoFit("contain"); + video.setVideoContentType(VideoContentTypeEnum.VIDEO.getValue()); + video.setStatus(VideoStatusEnum.PUBLISHED.getValue()); + baseMapper.insert(video); + return Result.ok("娣诲姞鎴愬姛"); + } + + @Override + public Result healthPage(HealthVideoQuery query) { + IPage<VideoVO> page = PageUtil.getPage(query, VideoVO.class); + // 1. 鍏堟煡鍑鸿棰戜俊鎭� + baseMapper.healthPage(page, query); + // 2. 鍗曠嫭鏌ュ嚭鏍囩淇℃伅 + if (page.getTotal() > 0) { + Map<String, List<SimpleVideoTagVO>> tagMap = videoTagRefService.getTagsByVideoIds( + page.getRecords().stream().map(VideoVO::getId).collect(Collectors.toList()) + ).stream().collect(Collectors.groupingBy(SimpleVideoTagVO::getVideoId));; + // 3. 鑾峰彇瑙嗛涓存椂璁块棶鍦板潃銆佽缃棰戞爣绛� + page.getRecords().forEach(v -> { + v.setTagList(tagMap.get(v.getId())); + v.setVideoUrl(cosUtil.getPreviewUrl(v.getVideoFileKey())); + v.setCoverShowUrl(cosUtil.getPreviewUrl(v.getCoverUrl())); + }); + } + return Result.ok().data(page.getRecords()).total(page.getTotal()); + } + + @Override + public Result updateHealthVideo(HealthVideoForm form) { + Video entity = baseMapper.selectById(form.getId()); + Assert.notNull(entity, "璁板綍涓嶅瓨鍦�"); + BeanUtils.copyProperties(form, entity); + baseMapper.updateById(entity); + return Result.ok("淇敼鎴愬姛"); + } + + @Override + public Result delHealth(String id) { + Video entity = baseMapper.selectById(id); + Assert.notNull(entity, "璁板綍涓嶅瓨鍦�"); + String videoType = entity.getVideoType(); + if (!VideoTypeEnum.HEALTH.getValue().equals(videoType)) { + log.error("鍒犻櫎闈炲ぇ鍋ュ悍瑙嗛瑙嗛id涓�------->"+id); + return Result.error("鍒犻櫎澶辫触"); + } + baseMapper.deleteById(id); + return Result.ok("鍒犻櫎鎴愬姛"); + } } diff --git a/framework/src/main/resources/mapper/lmk/VideoMapper.xml b/framework/src/main/resources/mapper/lmk/VideoMapper.xml index c9ae243..8a3e44e 100644 --- a/framework/src/main/resources/mapper/lmk/VideoMapper.xml +++ b/framework/src/main/resources/mapper/lmk/VideoMapper.xml @@ -350,5 +350,44 @@ WHERE LV.delete_flag = 0 AND LV.id = #{id} </select> - + <select id="healthPage" resultMap="BaseResultMap"> + 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.collect_num, + LV.comment_num, + LV.weight, + LV.audit_pass_time, + LV.update_time, + LV.video_content_type, + LV.video_type, + LV.video_imgs, + LV.id, + LM.nick_name as authorName + FROM + lmk_video LV + LEFT JOIN li_member LM ON LV.author_id = LM.id + <if test="query.tagList != null and query.tagList.size > 0"> + INNER JOIN ( + SELECT DISTINCT video_id + FROM lmk_video_tag_ref + WHERE video_tag_id IN + <foreach collection="query.tagList" open="(" item="tagId" close=")" separator=",">#{tagId}</foreach> + ) AS LVT ON LV.id = LVT.video_id + </if> + WHERE + LV.delete_flag = 0 AND LV.video_type = #{query.videoType} + <if test="query.title != null and query.title != ''">AND LV.title LIKE CONCAT('%', #{query.title}, '%')</if> + <if test="query.authorId != null and query.authorId != ''">AND LV.author_id = #{query.authorId}</if> + <if test="query.status != null and query.status != ''">AND LV.status = #{query.status}</if> + </select> </mapper> diff --git a/manager-api/src/main/java/cn/lili/controller/lmk/HealthController.java b/manager-api/src/main/java/cn/lili/controller/lmk/HealthController.java new file mode 100644 index 0000000..f983a29 --- /dev/null +++ b/manager-api/src/main/java/cn/lili/controller/lmk/HealthController.java @@ -0,0 +1,44 @@ +package cn.lili.controller.lmk; + +import cn.lili.base.Result; +import cn.lili.group.Add; +import cn.lili.group.Update; +import cn.lili.modules.lmk.domain.form.HealthVideoForm; +import cn.lili.modules.lmk.domain.query.HealthVideoQuery; +import cn.lili.modules.lmk.service.VideoService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +@Validated +@RequiredArgsConstructor +@Api(value = "澶у仴搴�", tags = "澶у仴搴�") +@RestController +@RequestMapping("/manager/lkm/health") +public class HealthController { + private final VideoService videoService; + + @PostMapping("/healthVideo") + @ApiOperation(value = "澶у仴搴疯棰戝彂甯�", notes = "澶у仴搴疯棰戝彂甯�") + public Result healthVideo(@RequestBody @Validated(Add.class) HealthVideoForm form) { + return videoService.healthVideo(form); + } + @PostMapping("/updateHealthVideo") + @ApiOperation(value = "澶у仴搴疯棰戝彂甯�", notes = "澶у仴搴疯棰戝彂甯�") + public Result updateHealthVideo(@RequestBody @Validated(Update.class) HealthVideoForm form) { + return videoService.updateHealthVideo(form); + } + @PostMapping("/page") + @ApiOperation(value = "澶у仴搴疯棰戝垪琛�", notes = "澶у仴搴疯棰戝垪琛�") + public Result page(@RequestBody HealthVideoQuery query) { + return videoService.healthPage(query); + } + //鍒犻櫎澶у帹绁炶棰� + @PostMapping("/del/{id}") + @ApiOperation(value = "鍒犻櫎澶у帹绁炶棰�", notes = "鍒犻櫎澶у帹绁炶棰�") + public Result delHealth(@PathVariable("id") String id) { + return videoService.delHealth(id); + } +} -- Gitblit v1.8.0