浏览代码

修改直播视频添加字段和搜索条件

yuhongqi 2 周之前
父节点
当前提交
f375937554

+ 37 - 0
fs-admin/src/main/java/com/fs/live/controller/LiveVideoController.java

@@ -13,6 +13,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * 直播视频Controller
@@ -113,4 +114,40 @@ public class LiveVideoController extends BaseController
     {
         return toAjax(liveVideoService.deleteLiveVideoByVideoIds(videoIds));
     }
+
+    /**
+     * 批量修改视频分类
+     */
+    @Log(title = "批量修改视频分类", businessType = BusinessType.UPDATE)
+    @PutMapping("/batchUpdateCategory")
+    public AjaxResult batchUpdateCategory(@RequestBody Map<String, Object> params)
+    {
+        Object videoIdsObj = params.get("videoIds");
+        Object categoryObj = params.get("category");
+
+        if (videoIdsObj == null) {
+            return AjaxResult.error("视频编号不能为空");
+        }
+
+        Long[] videoIds;
+        if (videoIdsObj instanceof List) {
+            @SuppressWarnings("unchecked")
+            List<Object> list = (List<Object>) videoIdsObj;
+            videoIds = list.stream().map(id -> {
+                if (id instanceof Number) {
+                    return ((Number) id).longValue();
+                }
+                return Long.parseLong(id.toString());
+            }).toArray(Long[]::new);
+        } else if (videoIdsObj instanceof Long[]) {
+            videoIds = (Long[]) videoIdsObj;
+        } else {
+            return AjaxResult.error("视频编号格式错误");
+        }
+
+        String category = categoryObj != null ? categoryObj.toString() : null;
+
+        int result = liveVideoService.batchUpdateCategory(videoIds, category);
+        return toAjax(result);
+    }
 }

+ 8 - 0
fs-service-system/src/main/java/com/fs/live/domain/LiveVideo.java

@@ -31,6 +31,10 @@ public class LiveVideo extends BaseEntity {
     @Excel(name = "视频地址")
     private String videoUrl;
 
+    /** 视频名称 */
+    @Excel(name = "视频名称")
+    private String videoName;
+
     /** 类型 1录播 2回放 */
     @Excel(name = "类型 1录播 2回放 -1视频库 3预告视频")
     private Integer videoType;
@@ -41,6 +45,10 @@ public class LiveVideo extends BaseEntity {
     @Excel(name = "文件大小")
     private Long fileSize;
 
+    /** 分类 */
+    @Excel(name = "分类")
+    private String category;
+
     /** 排序号 */
     @Excel(name = "排序号")
     private Long sort;

+ 9 - 0
fs-service-system/src/main/java/com/fs/live/mapper/LiveVideoMapper.java

@@ -93,4 +93,13 @@ public interface LiveVideoMapper
 
     @Update("update live_video set finish_status = 1 where video_url = #{fileName}")
     void updateFinishStatus(@Param("fileName") String fileName);
+
+    /**
+     * 批量修改视频分类
+     *
+     * @param videoIds 视频ID数组
+     * @param category 分类
+     * @return 结果
+     */
+    int batchUpdateCategory(@Param("videoIds") Long[] videoIds, @Param("category") String category);
 }

+ 9 - 0
fs-service-system/src/main/java/com/fs/live/service/ILiveVideoService.java

@@ -86,4 +86,13 @@ public interface ILiveVideoService
     LiveVideo selectLiveVideoByLiveIdAndType(Long id, int i);
 
     void updateFinishStatus(String string);
+
+    /**
+     * 批量修改视频分类
+     *
+     * @param videoIds 视频ID数组
+     * @param category 分类
+     * @return 结果
+     */
+    int batchUpdateCategory(Long[] videoIds, String category);
 }

+ 15 - 0
fs-service-system/src/main/java/com/fs/live/service/impl/LiveVideoServiceImpl.java

@@ -180,4 +180,19 @@ public class LiveVideoServiceImpl implements ILiveVideoService
         liveVideoMapper.updateFinishStatus(string);
     }
 
+    /**
+     * 批量修改视频分类
+     *
+     * @param videoIds 视频ID数组
+     * @param category 分类
+     * @return 结果
+     */
+    @Override
+    public int batchUpdateCategory(Long[] videoIds, String category) {
+        if (videoIds == null || videoIds.length == 0) {
+            return 0;
+        }
+        return liveVideoMapper.batchUpdateCategory(videoIds, category);
+    }
+
 }

+ 21 - 2
fs-service-system/src/main/resources/mapper/live/LiveVideoMapper.xml

@@ -8,7 +8,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="videoId"    column="video_id"    />
         <result property="liveId"    column="live_id"    />
         <result property="videoUrl"    column="video_url"    />
+        <result property="videoName"    column="video_name"    />
         <result property="videoType"    column="video_type"    />
+        <result property="category"    column="category"    />
         <result property="sort"    column="sort"    />
         <result property="createTime"    column="create_time"    />
         <result property="createBy"    column="create_by"    />
@@ -22,7 +24,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectLiveVideoVo">
-        select video_id, live_id, video_url, video_type, sort, create_time, create_by, update_by, update_time, remark,duration,file_size,finish_status,company_ids from live_video
+        select video_id, live_id, video_url, video_name, video_type, category, sort, create_time, create_by, update_by, update_time, remark,duration,file_size,finish_status,company_ids from live_video
     </sql>
 
     <select id="selectLiveVideoList" parameterType="LiveVideo" resultMap="LiveVideoResult">
@@ -30,14 +32,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <where>
             <if test="liveId != null "> and live_id = #{liveId}</if>
             <if test="videoUrl != null  and videoUrl != ''"> and video_url = #{videoUrl}</if>
+            <if test="videoName != null and videoName != ''"> and video_name like CONCAT('%',#{videoName},'%')</if>
             <if test="videoType != null "> and video_type = #{videoType}</if>
             <if test="sort != null "> and sort = #{sort}</if>
-            <if test="remark != null "> and remark like CONCAT('%',#{remark},'%')</if>
+            <if test="remark != null and remark != ''"> and remark like CONCAT('%',#{remark},'%')</if>
+            <if test="category != null and category != ''"> and category like CONCAT('%',#{category},'%')</if>
             <if test="finishStatus != null "> and finish_status  = #{finishStatus}</if>
             <if test="companyId != null">
                 and (company_ids IS NULL OR company_ids = '' OR company_ids = '[]' OR JSON_CONTAINS(company_ids, CAST(#{companyId} AS JSON), '$'))
             </if>
         </where>
+        order by case when sort is null then 1 else 0 end asc, sort asc, create_time desc
     </select>
 
     <select id="selectLiveVideoByVideoId" parameterType="Long" resultMap="LiveVideoResult">
@@ -54,7 +59,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="liveId != null">live_id,</if>
             <if test="videoUrl != null">video_url,</if>
+            <if test="videoName != null">video_name,</if>
             <if test="videoType != null">video_type,</if>
+            <if test="category != null">category,</if>
             <if test="sort != null">sort,</if>
             <if test="createTime != null">create_time,</if>
             <if test="createBy != null">create_by,</if>
@@ -69,7 +76,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="liveId != null">#{liveId},</if>
             <if test="videoUrl != null">#{videoUrl},</if>
+            <if test="videoName != null">#{videoName},</if>
             <if test="videoType != null">#{videoType},</if>
+            <if test="category != null">#{category},</if>
             <if test="sort != null">#{sort},</if>
             <if test="createTime != null">#{createTime},</if>
             <if test="createBy != null">#{createBy},</if>
@@ -88,7 +97,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <trim prefix="SET" suffixOverrides=",">
             <if test="liveId != null">live_id = #{liveId},</if>
             <if test="videoUrl != null">video_url = #{videoUrl},</if>
+            <if test="videoName != null">video_name = #{videoName},</if>
             <if test="videoType != null">video_type = #{videoType},</if>
+            <if test="category != null">category = #{category},</if>
             <if test="duration != null">duration = #{duration},</if>
             <if test="sort != null">sort = #{sort},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
@@ -113,4 +124,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{videoId}
         </foreach>
     </delete>
+
+    <update id="batchUpdateCategory">
+        update live_video set category = #{category}, update_time = NOW()
+        where video_id in
+        <foreach item="videoId" collection="videoIds" open="(" separator="," close=")">
+            #{videoId}
+        </foreach>
+    </update>
 </mapper>