xiangpei
2025-05-22 0d9214d780c5093165f566f3e6f0c60f5d8aead7
视频管理功能
17个文件已修改
13个文件已添加
736 ■■■■■ 已修改文件
common-api/src/main/java/cn/lili/controller/lmk/LmkFileController.java 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/config/CorsConfig.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/lmk/domain/entity/Video.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/lmk/domain/entity/VideoAuditRecord.java 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/lmk/domain/form/FileKey.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/lmk/domain/form/VideoAuditingForm.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/lmk/domain/form/VideoDownForm.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/lmk/domain/form/VideoRecommendForm.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/lmk/domain/query/ManagerVideoQuery.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/lmk/domain/vo/SimpleVideoTagVO.java 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/lmk/domain/vo/VideoAuditRecordVO.java 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/lmk/domain/vo/VideoVO.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/lmk/enums/general/VideoStatusEnum.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/lmk/mapper/VideoAuditRecordMapper.java 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/lmk/mapper/VideoMapper.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/lmk/mapper/VideoTagRefMapper.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/lmk/service/VideoAuditRecordService.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/lmk/service/VideoService.java 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/lmk/service/VideoTagRefService.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/lmk/service/VideoTagService.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoAuditRecordServiceImpl.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoServiceImpl.java 100 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoTagRefServiceImpl.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoTagServiceImpl.java 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/mybatis/mybatisplus/MyMetaObjectHandler.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/resources/mapper/lmk/VideoAuditRecordMapper.xml 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/resources/mapper/lmk/VideoMapper.xml 56 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/resources/mapper/lmk/VideoTagRefMapper.xml 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
manager-api/src/main/java/cn/lili/controller/lmk/VideoController.java 36 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
manager-api/src/main/java/cn/lili/controller/lmk/VideoTagController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
common-api/src/main/java/cn/lili/controller/lmk/LmkFileController.java
@@ -1,6 +1,7 @@
package cn.lili.controller.lmk;
import cn.lili.base.Result;
import cn.lili.modules.lmk.domain.form.FileKey;
import cn.lili.modules.lmk.service.LmkFileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -61,10 +62,10 @@
     * @param fileKey oss文件名
     * @return
     */
    @Delete("/delete/{file_key}")
    @Delete("/delete}")
    @ApiOperation(value = "删除某个文件")
    public Result deleteObject(@PathVariable(value = "file_key") String fileKey) {
        return lmkFileService.deleteObject(fileKey);
    public Result deleteObject(@RequestBody FileKey fileKey) {
        return lmkFileService.deleteObject(fileKey.getFileKey());
    }
    /**
@@ -85,10 +86,10 @@
     * @param fileKey
     * @return
     */
    @GetMapping("/download/{file_key}")
    @PostMapping("/download")
    @ApiOperation(value = "下载文件")
    public void downloadFile(@PathVariable(value = "file_key") String fileKey, HttpServletResponse response) {
        lmkFileService.downloadObject(fileKey, response);
    public void downloadFile(@RequestBody FileKey fileKey, HttpServletResponse response) {
        lmkFileService.downloadObject(fileKey.getFileKey(), response);
    }
    /**
@@ -97,10 +98,10 @@
     * @param fileKey
     * @return
     */
    @GetMapping("/preview/{file_key}")
    @PostMapping("/preview")
    @ApiOperation(value = "获取文件预览url(链接存在时效)")
    public Result getPreviewUrl(@PathVariable(value = "file_key") String fileKey) {
        return Result.ok().data(lmkFileService.getPreviewUrl(fileKey));
    public Result getPreviewUrl(@RequestBody FileKey fileKey) {
        return Result.ok().data(lmkFileService.getPreviewUrl(fileKey.getFileKey()));
    }
framework/src/main/java/cn/lili/config/CorsConfig.java
New file
@@ -0,0 +1,25 @@
package cn.lili.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
 * 跨域配置
 *
 * @author 29443
 * @date 2022/4/16
 */
@Configuration
public class CorsConfig implements WebMvcConfigurer {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedHeaders("*")
                .allowedMethods("POST", "GET", "PUT", "DELETE")
                .allowedOriginPatterns("*");
    }
}
framework/src/main/java/cn/lili/modules/lmk/domain/entity/Video.java
@@ -5,6 +5,8 @@
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
import lombok.Data;
/**
@@ -77,7 +79,7 @@
    @TableField("audit_pass_time")
    /** 审核通过时间 */
    private LocalDateTime auditPassTime;
    private Date auditPassTime;
}
framework/src/main/java/cn/lili/modules/lmk/domain/entity/VideoAuditRecord.java
New file
@@ -0,0 +1,34 @@
package cn.lili.modules.lmk.domain.entity;
import cn.lili.mybatis.BaseEntity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import lombok.Data;
/**
 * 视频审核记录
 *
 * @author xp
 * @since 2025-05-22
 */
@Data
@TableName("lmk_video_audit_record")
public class VideoAuditRecord extends BaseEntity {
    private static final long serialVersionUID = 1L;
    @TableField("video_id")
    /** 视频id */
    private String videoId;
    @TableField("audit_success")
    /** 审核是否通过 */
    private Boolean auditSuccess;
    @TableField("edit_suggestion")
    /** 修改建议(驳回) */
    private String editSuggestion;
}
framework/src/main/java/cn/lili/modules/lmk/domain/form/FileKey.java
New file
@@ -0,0 +1,14 @@
package cn.lili.modules.lmk.domain.form;
import lombok.Data;
/**
 * @author:xp
 * @date:2025/5/21 14:03
 */
@Data
public class FileKey {
    private String fileKey;
}
framework/src/main/java/cn/lili/modules/lmk/domain/form/VideoAuditingForm.java
New file
@@ -0,0 +1,29 @@
package cn.lili.modules.lmk.domain.form;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
 * @author:xp
 * @date:2025/5/21 15:45
 */
@Data
@ApiModel("视频审核")
public class VideoAuditingForm {
    @NotBlank(message = "视频不能为空")
    @ApiModelProperty("视频id")
    private String id;
    @NotNull(message = "审核结果不能为空")
    @ApiModelProperty("审核结果")
    private Boolean result;
    @ApiModelProperty("审核不通过原因")
    private String reason;
}
framework/src/main/java/cn/lili/modules/lmk/domain/form/VideoDownForm.java
New file
@@ -0,0 +1,26 @@
package cn.lili.modules.lmk.domain.form;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
 * @author:xp
 * @date:2025/5/21 15:45
 */
@Data
@ApiModel("视频下架")
public class VideoDownForm {
    @NotBlank(message = "视频不能为空")
    @ApiModelProperty("视频id")
    private String id;
    @NotBlank(message = "下架原因不能为空")
    @ApiModelProperty("下架原因")
    private String reason;
}
framework/src/main/java/cn/lili/modules/lmk/domain/form/VideoRecommendForm.java
New file
@@ -0,0 +1,26 @@
package cn.lili.modules.lmk.domain.form;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
 * @author:xp
 * @date:2025/5/21 15:45
 */
@Data
@ApiModel("视频首页推荐设置")
public class VideoRecommendForm {
    @NotBlank(message = "视频不能为空")
    @ApiModelProperty("视频id")
    private String id;
    @NotNull(message = "首页推荐不能为空")
    @ApiModelProperty("推荐与否")
    private Boolean recommend;
}
framework/src/main/java/cn/lili/modules/lmk/domain/query/ManagerVideoQuery.java
New file
@@ -0,0 +1,33 @@
package cn.lili.modules.lmk.domain.query;
import cn.lili.base.AbsQuery;
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 = "平台端Video查询参数", description = "视频内容查询参数")
public class ManagerVideoQuery extends AbsQuery {
    @ApiModelProperty("标题")
    private String title;
    @ApiModelProperty("视频标签")
    private List<String> tagList;
    @ApiModelProperty("作者")
    private String authorId;
    @ApiModelProperty("状态")
    private String status;
}
framework/src/main/java/cn/lili/modules/lmk/domain/vo/SimpleVideoTagVO.java
New file
@@ -0,0 +1,40 @@
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 SimpleVideoTagVO {
    @ApiModelProperty("标签id")
    private String id;
    /** 标签名称 */
    @ApiModelProperty("标签名称")
    private String tagName;
    @ApiModelProperty(hidden = true)
    private String videoId;
    public static SimpleVideoTagVO getVoByEntity(@NonNull VideoTag entity, SimpleVideoTagVO vo) {
        if(vo == null) {
            vo = new SimpleVideoTagVO();
        }
        BeanUtils.copyProperties(entity, vo);
        return vo;
    }
}
framework/src/main/java/cn/lili/modules/lmk/domain/vo/VideoAuditRecordVO.java
New file
@@ -0,0 +1,43 @@
package cn.lili.modules.lmk.domain.vo;
import cn.lili.base.AbsVo;
import cn.lili.modules.lmk.domain.entity.VideoAuditRecord;
import java.util.List;
import org.springframework.lang.NonNull;
import org.springframework.beans.BeanUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
 * 视频审核记录展示
 *
 * @author xp
 * @since 2025-05-22
 */
@Data
@ApiModel(value = "视频审核记录响应数据", description = "视频审核记录响应数据")
public class VideoAuditRecordVO extends AbsVo {
    /** 视频id */
    @ApiModelProperty("视频id")
    private String videoId;
    /** 审核是否通过 */
    @ApiModelProperty("审核是否通过")
    private Boolean auditSuccess;
    /** 修改建议(驳回) */
    @ApiModelProperty("修改建议(驳回)")
    private String editSuggestion;
    public static VideoAuditRecordVO getVoByEntity(@NonNull VideoAuditRecord entity, VideoAuditRecordVO vo) {
        if(vo == null) {
            vo = new VideoAuditRecordVO();
        }
        BeanUtils.copyProperties(entity, vo);
        return vo;
    }
}
framework/src/main/java/cn/lili/modules/lmk/domain/vo/VideoVO.java
@@ -2,13 +2,14 @@
import cn.lili.base.AbsVo;
import cn.lili.modules.lmk.domain.entity.Video;
import java.util.List;
import org.springframework.lang.NonNull;
import org.springframework.beans.BeanUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.beans.BeanUtils;
import org.springframework.lang.NonNull;
import java.util.Date;
import java.util.List;
/**
 * 视频内容展示
@@ -23,6 +24,7 @@
    /** 作者id */
    @ApiModelProperty("作者id")
    private String authorId;
    private String authorName;
    /** 图片封面 */
    @ApiModelProperty("图片封面")
@@ -31,6 +33,10 @@
    /** 视频地址 */
    @ApiModelProperty("视频地址")
    private String videoFileKey;
    private String videoUrl;
    @ApiModelProperty("视频标签")
    private List<SimpleVideoTagVO> tagList;
    /** 视频填充模式 */
    @ApiModelProperty("视频填充模式")
framework/src/main/java/cn/lili/modules/lmk/enums/general/VideoStatusEnum.java
@@ -12,7 +12,7 @@
@Getter
public enum VideoStatusEnum {
    AUDITING("99", "审核中"),
    AUDITING("99", "待审核"),
    PUBLISHED("1", "已发布"),
    DISABLE("0", "已下架"),
    REJECT("-1", "审核未通过"),
framework/src/main/java/cn/lili/modules/lmk/mapper/VideoAuditRecordMapper.java
New file
@@ -0,0 +1,24 @@
package cn.lili.modules.lmk.mapper;
import cn.lili.modules.lmk.domain.entity.VideoAuditRecord;
import cn.lili.modules.lmk.domain.vo.VideoAuditRecordVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
 * 视频审核记录 Mapper 接口
 *
 * @author xp
 * @since 2025-05-22
 */
@Mapper
public interface VideoAuditRecordMapper extends BaseMapper<VideoAuditRecord> {
    /**
     * id查找视频审核记录
     * @param id
     * @return
     */
    VideoAuditRecordVO getById(Integer id);
}
framework/src/main/java/cn/lili/modules/lmk/mapper/VideoMapper.java
@@ -1,6 +1,7 @@
package cn.lili.modules.lmk.mapper;
import cn.lili.modules.lmk.domain.entity.Video;
import cn.lili.modules.lmk.domain.query.ManagerVideoQuery;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import cn.lili.modules.lmk.domain.vo.VideoVO;
@@ -24,11 +25,18 @@
     * @param id
     * @return
     */
    VideoVO getById(Integer id);
    VideoVO getById(String id);
    /**
    *  分页
    */
    IPage getPage(IPage page, @Param("query") VideoQuery query);
    /**
     * 管理端分页
     *
     * @param page
     * @param query
     */
    IPage managerPage(IPage page, @Param("query") ManagerVideoQuery query);
}
framework/src/main/java/cn/lili/modules/lmk/mapper/VideoTagRefMapper.java
@@ -1,8 +1,13 @@
package cn.lili.modules.lmk.mapper;
import cn.lili.modules.lmk.domain.entity.VideoTagRef;
import cn.lili.modules.lmk.domain.vo.SimpleVideoTagVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
 * 视频标签中间表 Mapper 接口
@@ -14,4 +19,5 @@
public interface VideoTagRefMapper extends BaseMapper<VideoTagRef> {
    List<SimpleVideoTagVO> getTagsByVideoIds(@Param("videoIds") List<String> videoIds);
}
framework/src/main/java/cn/lili/modules/lmk/service/VideoAuditRecordService.java
New file
@@ -0,0 +1,15 @@
package cn.lili.modules.lmk.service;
import cn.lili.modules.lmk.domain.entity.VideoAuditRecord;
import com.baomidou.mybatisplus.extension.service.IService;
/**
 * 视频审核记录 服务类
 *
 * @author xp
 * @since 2025-05-22
 */
public interface VideoAuditRecordService extends IService<VideoAuditRecord> {
}
framework/src/main/java/cn/lili/modules/lmk/service/VideoService.java
@@ -1,6 +1,10 @@
package cn.lili.modules.lmk.service;
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.query.ManagerVideoQuery;
import com.baomidou.mybatisplus.extension.service.IService;
import cn.lili.base.Result;
import cn.lili.modules.lmk.domain.form.VideoForm;
@@ -55,7 +59,7 @@
     * @param id
     * @return
     */
    Result detail(Integer id);
    Result detail(String id);
    /**
     * 列表
@@ -70,4 +74,44 @@
     * @return
     */
    Result publish(VideoForm form);
    /**
     * 平台端视频分页
     *
     * @param query
     * @return
     */
    Result managerPage(ManagerVideoQuery query);
    /**
     * 首页推荐设置
     *
     * @param form
     * @return
     */
    Result recommendSet(VideoRecommendForm form);
    /**
     * 审核
     *
     * @param form
     * @return
     */
    Result auditing(VideoAuditingForm form);
    /**
     * 上架
     *
     * @param id
     * @return
     */
    Result up(String id);
    /**
     * 下架
     *
     * @param form
     * @return
     */
    Result down(VideoDownForm form);
}
framework/src/main/java/cn/lili/modules/lmk/service/VideoTagRefService.java
@@ -1,7 +1,11 @@
package cn.lili.modules.lmk.service;
import cn.lili.modules.lmk.domain.entity.VideoTagRef;
import cn.lili.modules.lmk.domain.vo.SimpleVideoTagVO;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
import java.util.Map;
/**
 * 视频标签中间表 服务类
@@ -11,5 +15,12 @@
 */
public interface VideoTagRefService extends IService<VideoTagRef> {
    /**
     * 查出这些视频所有的标签
     *
     * @param videoIds
     * @return
     */
    List<SimpleVideoTagVO> getTagsByVideoIds(List<String> videoIds);
}
framework/src/main/java/cn/lili/modules/lmk/service/VideoTagService.java
@@ -61,8 +61,9 @@
    /**
     * 列表
     * @return
     * @param tagName
     */
    Result all();
    Result all(String tagName);
    /**
     * 推荐标签
framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoAuditRecordServiceImpl.java
New file
@@ -0,0 +1,23 @@
package cn.lili.modules.lmk.service.impl;
import cn.lili.modules.lmk.domain.entity.VideoAuditRecord;
import cn.lili.modules.lmk.mapper.VideoAuditRecordMapper;
import cn.lili.modules.lmk.service.VideoAuditRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
/**
 * 视频审核记录 服务实现类
 *
 * @author xp
 * @since 2025-05-22
 */
@Service
@RequiredArgsConstructor
public class VideoAuditRecordServiceImpl extends ServiceImpl<VideoAuditRecordMapper, VideoAuditRecord> implements VideoAuditRecordService {
    private final VideoAuditRecordMapper videoAuditRecordMapper;
}
framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoServiceImpl.java
@@ -1,20 +1,24 @@
package cn.lili.modules.lmk.service.impl;
import cn.lili.common.security.context.UserContext;
import cn.lili.modules.lmk.domain.entity.LmkFile;
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.query.ManagerVideoQuery;
import cn.lili.modules.lmk.domain.vo.SimpleVideoTagVO;
import cn.lili.modules.lmk.enums.general.TagCreateTypeEnum;
import cn.lili.modules.lmk.enums.general.VideoStatusEnum;
import cn.lili.modules.lmk.service.LmkFileService;
import cn.lili.modules.lmk.service.VideoTagRefService;
import cn.lili.modules.lmk.service.VideoTagService;
import cn.lili.modules.lmk.service.*;
import cn.lili.utils.COSUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import cn.lili.modules.lmk.domain.entity.Video;
import cn.lili.modules.lmk.mapper.VideoMapper;
import cn.lili.modules.lmk.service.VideoService;
import cn.lili.base.Result;
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.vo.VideoVO;
@@ -27,8 +31,7 @@
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
/**
@@ -45,6 +48,8 @@
    private final VideoTagService videoTagService;
    private final VideoTagRefService videoTagRefService;
    private final LmkFileService lmkFileService;
    private final VideoAuditRecordService videoAuditRecordService;
    private final COSUtil cosUtil;
    /**
     * 添加
@@ -114,9 +119,12 @@
     * @return
     */
    @Override
    public Result detail(Integer id) {
    public Result detail(String id) {
        VideoVO vo = baseMapper.getById(id);
        Assert.notNull(vo, "记录不存在");
        List<SimpleVideoTagVO> tags = videoTagRefService.getTagsByVideoIds(Arrays.asList(id));
        vo.setTagList(tags);
        vo.setVideoUrl(cosUtil.getPreviewUrl(vo.getVideoFileKey()));
        return Result.ok().data(vo);
    }
@@ -168,4 +176,80 @@
        lmkFileService.addByForm(form.getFileInfo());
        return Result.ok("发布成功,视频审核中~");
    }
    @Override
    public Result managerPage(ManagerVideoQuery query) {
        IPage<VideoVO> page = PageUtil.getPage(query, VideoVO.class);
        // 1. 先查出视频信息
        baseMapper.managerPage(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()));
            });
        }
        return Result.ok().data(page.getRecords()).total(page.getTotal());
    }
    @Override
    public Result recommendSet(VideoRecommendForm form) {
        new LambdaUpdateChainWrapper<>(baseMapper)
                .eq(Video::getId, form.getId())
                .set(Video::getRecommend, form.getRecommend())
                .update();
        return Result.ok("设置成功");
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Result auditing(VideoAuditingForm form) {
        Video video = baseMapper.selectById(form.getId());
        if (Objects.isNull(video)) {
            throw new RuntimeException("视频不存在");
        }
        // 1. 添加审核记录
        VideoAuditRecord auditRecord = new VideoAuditRecord();
        auditRecord.setVideoId(form.getId());
        auditRecord.setAuditSuccess(form.getResult());
        if (!form.getResult()) {
            auditRecord.setEditSuggestion(form.getReason());
        }
        videoAuditRecordService.save(auditRecord);
        // 2. 修改视频状态
        if (form.getResult()) {
            video.setStatus(VideoStatusEnum.PUBLISHED.getValue());
            video.setAuditPassTime(new Date());
        } else {
            video.setStatus(VideoStatusEnum.REJECT.getValue());
        }
        baseMapper.updateById(video);
        return Result.ok();
    }
    @Override
    public Result up(String id) {
        new LambdaUpdateChainWrapper<>(baseMapper)
                .eq(Video::getId, id)
                .set(Video::getStatus, VideoStatusEnum.PUBLISHED.getValue())
                .update();
        return Result.ok("上架成功");
    }
    @Override
    public Result down(VideoDownForm form) {
        new LambdaUpdateChainWrapper<>(baseMapper)
                .eq(Video::getId, form.getId())
                .set(Video::getStatus, VideoStatusEnum.DISABLE.getValue())
                .update();
        // TODO 将下架原因以通知的方式告知用户
        return Result.ok("下架成功");
    }
}
framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoTagRefServiceImpl.java
@@ -1,11 +1,15 @@
package cn.lili.modules.lmk.service.impl;
import cn.lili.modules.lmk.domain.entity.VideoTagRef;
import cn.lili.modules.lmk.domain.vo.SimpleVideoTagVO;
import cn.lili.modules.lmk.mapper.VideoTagRefMapper;
import cn.lili.modules.lmk.service.VideoTagRefService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
 * 视频标签中间表 服务实现类
@@ -20,4 +24,8 @@
    private final VideoTagRefMapper videoTagRefMapper;
    @Override
    public List<SimpleVideoTagVO> getTagsByVideoIds(List<String> videoIds) {
        return baseMapper.getTagsByVideoIds(videoIds);
    }
}
framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoTagServiceImpl.java
@@ -1,6 +1,7 @@
package cn.lili.modules.lmk.service.impl;
import cn.lili.modules.lmk.domain.query.WxVideoTagQuery;
import cn.lili.modules.lmk.domain.vo.SimpleVideoTagVO;
import cn.lili.modules.lmk.enums.general.TagCreateTypeEnum;
import com.baomidou.mybatisplus.core.metadata.IPage;
import cn.lili.modules.lmk.domain.entity.VideoTag;
@@ -12,6 +13,7 @@
import cn.lili.modules.lmk.domain.form.VideoTagForm;
import cn.lili.modules.lmk.domain.vo.VideoTagVO;
import cn.lili.modules.lmk.domain.query.VideoTagQuery;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import lombok.RequiredArgsConstructor;
import cn.lili.utils.PageUtil;
@@ -115,12 +117,21 @@
    /**
     * 列表
     * @return
     * @param tagName
     */
    @Override
    public Result all() {
        List<VideoTag> entities = baseMapper.selectList(null);
        List<VideoTagVO> vos = entities.stream()
                .map(entity -> VideoTagVO.getVoByEntity(entity, null))
    public Result all(String tagName) {
        List<VideoTag> entities = new LambdaQueryChainWrapper<>(baseMapper)
                .select(VideoTag::getId, VideoTag::getTagName)
                .like(StringUtils.isNotBlank(tagName), VideoTag::getTagName, tagName)
                .orderByDesc(VideoTag::getUseNum)
                .list();
        List<SimpleVideoTagVO> vos = entities.stream()
                .map(entity -> {
                    SimpleVideoTagVO vo = new SimpleVideoTagVO();
                    BeanUtils.copyProperties(entity, vo);
                    return vo;
                })
                .collect(Collectors.toList());
        return Result.ok().data(vos);
    }
framework/src/main/java/cn/lili/mybatis/mybatisplus/MyMetaObjectHandler.java
@@ -22,13 +22,19 @@
        AuthUser authUser = UserContext.getCurrentUser();
        if (authUser != null) {
            this.setFieldValByName("createBy", authUser.getUsername(), metaObject);
            this.setFieldValByName("updateBy", authUser.getUsername(), metaObject);
        } else {
            this.setFieldValByName("createBy", "SYSTEM", metaObject);
            this.setFieldValByName("updateBy", "SYSTEM", metaObject);
        }
        //有创建时间字段,切字段值为空
        Date now = new Date();
        if (metaObject.hasGetter("createTime")) {
            this.setFieldValByName("createTime", new Date(), metaObject);
            this.setFieldValByName("createTime",now , metaObject);
        }
        if (metaObject.hasGetter("updateTime")) {
            this.setFieldValByName("updateTime", now, metaObject);
        }
        //有值,则写入
        if (metaObject.hasGetter("deleteFlag")) {
@@ -51,7 +57,9 @@
        if (authUser != null) {
            this.setFieldValByName("updateBy", authUser.getUsername(), metaObject);
        }
        this.setFieldValByName("updateTime", new Date(), metaObject);
        if (metaObject.hasGetter("updateTime")) {
            this.setFieldValByName("updateTime", new Date(), metaObject);
        }
    }
}
framework/src/main/resources/mapper/lmk/VideoAuditRecordMapper.xml
New file
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.lili.modules.lmk.mapper.VideoAuditRecordMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="cn.lili.modules.lmk.domain.vo.VideoAuditRecordVO">
        <id column="id" property="id"/>
        <result column="video_id" property="videoId" />
        <result column="audit_success" property="auditSuccess" />
        <result column="edit_suggestion" property="editSuggestion" />
    </resultMap>
    <select id="getById" resultMap="BaseResultMap">
        SELECT
            LVAR.video_id,
            LVAR.audit_success,
            LVAR.edit_suggestion,
            LVAR.id
        FROM
            lmk_video_audit_record LVAR
        WHERE
            LVAR.id = #{id} AND LVAR.delete_flag = 0
    </select>
    <select id="getPage" resultMap="BaseResultMap">
        SELECT
            LVAR.video_id,
            LVAR.audit_success,
            LVAR.edit_suggestion,
            LVAR.id
        FROM
            lmk_video_audit_record LVAR
        WHERE
            LVAR.delete_flag = 0
    </select>
</mapper>
framework/src/main/resources/mapper/lmk/VideoMapper.xml
@@ -6,6 +6,7 @@
    <resultMap id="BaseResultMap" type="cn.lili.modules.lmk.domain.vo.VideoVO">
        <id column="id" property="id"/>
        <result column="author_id" property="authorId" />
        <result column="authorName" property="authorName" />
        <result column="cover_url" property="coverUrl" />
        <result column="video_file_key" property="videoFileKey" />
        <result column="video_fit" property="videoFit" />
@@ -20,12 +21,8 @@
        <result column="comment_num" property="commentNum" />
        <result column="weight" property="weight" />
        <result column="audit_pass_time" property="auditPassTime" />
        <result column="update_time" property="updateTime" />
    </resultMap>
    <select id="getById" resultMap="BaseResultMap">
@@ -45,9 +42,12 @@
            LV.comment_num,
            LV.weight,
            LV.audit_pass_time,
            LV.id
            LV.update_time,
            LV.id,
            LM.nick_name as authorName
        FROM
            lmk_video LV
                LEFT JOIN li_member LM ON LV.author_id = LM.id
        WHERE
            LV.id = #{id} AND LV.delete_flag = 0
    </select>
@@ -70,11 +70,53 @@
            LV.comment_num,
            LV.weight,
            LV.audit_pass_time,
            LV.id
            LV.update_time,
            LV.id,
            LM.nick_name as authorName
        FROM
            lmk_video LV
                LEFT JOIN li_member LM ON LV.author_id = LM.id
        WHERE
            LV.delete_flag = 0
    </select>
    <select id="managerPage" resultMap="BaseResultMap">
        SELECT
            LV.author_id,
            LV.cover_url,
            LV.video_fit,
            LV.video_file_key,
            LV.title,
            LV.goods_id,
            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.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
            <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>
framework/src/main/resources/mapper/lmk/VideoTagRefMapper.xml
@@ -9,7 +9,17 @@
        <result column="video_tag_id" property="videoTagId" />
    </resultMap>
    <select id="getTagsByVideoIds" resultType="cn.lili.modules.lmk.domain.vo.SimpleVideoTagVO">
        SELECT
            LVTR.video_id,
            LVT.id,
            LVT.tag_name AS tagName
        FROM
            lmk_video_tag_ref LVTR
            JOIN lmk_video_tag LVT ON LVTR.video_tag_id = LVT.id
        WHERE
            LVTR.video_id IN <foreach collection="videoIds" open="(" item="videoId" close=")" separator=",">#{videoId}</foreach>
    </select>
</mapper>
manager-api/src/main/java/cn/lili/controller/lmk/VideoController.java
@@ -2,6 +2,10 @@
import cn.lili.group.Update;
import cn.lili.group.Add;
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.query.ManagerVideoQuery;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import lombok.RequiredArgsConstructor;
@@ -56,15 +60,15 @@
        return videoService.remove(ids);
    }
    @GetMapping("/page")
    @PostMapping("/page")
    @ApiOperation(value = "分页", notes = "分页")
    public Result page(VideoQuery query) {
        return videoService.page(query);
    public Result page(@RequestBody ManagerVideoQuery query) {
        return videoService.managerPage(query);
    }
    @GetMapping("/{id}")
    @ApiOperation(value = "详情", notes = "详情")
    public Result detail(@PathVariable("id") Integer id) {
    public Result detail(@PathVariable("id") String id) {
        return videoService.detail(id);
    }
@@ -73,4 +77,28 @@
    public Result list() {
        return videoService.all();
    }
    @PutMapping("/recommend")
    @ApiOperation(value = "首页推荐设置", notes = "首页推荐设置")
    public Result recommendSet(@RequestBody @Validated VideoRecommendForm form) {
        return videoService.recommendSet(form);
    }
    @PostMapping("/auditing")
    @ApiOperation(value = "审核", notes = "审核")
    public Result auditing(@RequestBody @Validated VideoAuditingForm form) {
        return videoService.auditing(form);
    }
    @PostMapping("/up/{id}")
    @ApiOperation(value = "上架", notes = "上架")
    public Result up(@PathVariable("id") String id) {
        return videoService.up(id);
    }
    @PostMapping("/down")
    @ApiOperation(value = "下架", notes = "下架")
    public Result down(@RequestBody @Validated VideoDownForm form) {
        return videoService.down(form);
    }
}
manager-api/src/main/java/cn/lili/controller/lmk/VideoTagController.java
@@ -70,7 +70,7 @@
    @GetMapping("/list")
    @ApiOperation(value = "列表", notes = "列表")
    public Result list() {
        return videoTagService.all();
    public Result list(String tagName) {
        return videoTagService.all(tagName);
    }
}