xgb 1 неделя назад
Родитель
Сommit
8fda5f0caa

+ 40 - 62
fs-admin/src/main/java/com/fs/admin/controller/LiveAdminController.java

@@ -2,7 +2,7 @@ package com.fs.admin.controller;
 
 import java.util.*;
 
-import com.fs.admin.helper.AdminCrossTenantHelper;
+import com.fs.admin.service.IAdminLiveService;
 import com.fs.common.annotation.Excel;
 import com.fs.common.annotation.Log;
 import com.fs.common.core.controller.BaseController;
@@ -16,102 +16,80 @@ import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
 /**
- * 总后台直播内容管理控制器
- * 遍历所有租户库查询 live_video 数据
+ * 总后台直播视频管理控制器
  */
 @RestController
 @RequestMapping("/admin/live")
 public class LiveAdminController extends BaseController {
 
     @Autowired
-    private AdminCrossTenantHelper crossTenantHelper;
+    private IAdminLiveService adminLiveService;
 
     private String str(Object o) { return o == null ? "" : o.toString(); }
 
     @Data
     public static class LiveExportVO {
         @Excel(name = "租户名称") private String companyName;
-        @Excel(name = "直播标题") private String title;
-        @Excel(name = "状态") private String liveStatus;
-        @Excel(name = "开始时间") private String startTime;
-        @Excel(name = "结束时间") private String endTime;
+        @Excel(name = "视频ID") private String videoId;
+        @Excel(name = "直播ID") private String liveId;
+        @Excel(name = "视频地址") private String videoUrl;
+        @Excel(name = "视频类型") private String videoType;
+        @Excel(name = "时长(秒)") private String duration;
+        @Excel(name = "文件大小") private String fileSize;
+        @Excel(name = "转码状态") private String finishStatus;
         @Excel(name = "创建时间") private String createTime;
     }
 
-    @Log(title = "导出直播", businessType = BusinessType.EXPORT)
+    @Log(title = "导出直播视频", businessType = BusinessType.EXPORT)
     @PreAuthorize("@ss.hasPermi('admin:live:list')")
     @GetMapping("/export")
-    public AjaxResult export(@RequestParam(required = false) String liveName,
+    public AjaxResult export(@RequestParam(required = false) String liveTitle,
                              @RequestParam(required = false) Long companyId,
-                             @RequestParam(required = false) String companyName) {
-        List<Map<String, Object>> allList = crossTenantHelper.queryAcrossTenants(
-                companyId, companyName, (tenant, jdbc) -> {
-                    StringBuilder sql = new StringBuilder(
-                            "SELECT v.video_id, v.title, v.cover_url, v.live_status, " +
-                            "v.start_time, v.end_time, v.create_time " +
-                            "FROM live_video v WHERE 1=1");
-                    List<Object> params = new ArrayList<>();
-                    if (liveName != null && !liveName.isEmpty()) {
-                        sql.append(" AND v.title LIKE ?");
-                        params.add("%" + liveName + "%");
-                    }
-                    sql.append(" ORDER BY v.create_time DESC");
-                    return params.isEmpty()
-                            ? jdbc.queryForList(sql.toString())
-                            : jdbc.queryForList(sql.toString(), params.toArray());
-                });
+                             @RequestParam(required = false) String companyName,
+                             @RequestParam(required = false) Integer status) {
+        List<Map<String, Object>> allList = adminLiveService.selectLiveListForExport(companyId, companyName, liveTitle, status);
         List<LiveExportVO> voList = new ArrayList<>();
         for (Map<String, Object> m : allList) {
             LiveExportVO vo = new LiveExportVO();
-            vo.setCompanyName(str(m.get("company_name")));
-            vo.setTitle(str(m.get("title")));
-            vo.setLiveStatus(str(m.get("live_status")));
-            vo.setStartTime(str(m.get("start_time")));
-            vo.setEndTime(str(m.get("end_time")));
-            vo.setCreateTime(str(m.get("create_time")));
+            vo.setCompanyName(str(m.get("companyName")));
+            vo.setVideoId(str(m.get("videoId")));
+            vo.setLiveId(str(m.get("liveId")));
+            vo.setVideoUrl(str(m.get("videoUrl")));
+            vo.setVideoType("1".equals(str(m.get("videoType"))) ? "录播" : "2".equals(str(m.get("videoType"))) ? "回放" : str(m.get("videoType")));
+            vo.setDuration(str(m.get("duration")));
+            vo.setFileSize(str(m.get("fileSize")));
+            vo.setFinishStatus(str(m.get("finishStatus")));
+            vo.setCreateTime(str(m.get("createTime")));
             voList.add(vo);
         }
         ExcelUtil<LiveExportVO> util = new ExcelUtil<>(LiveExportVO.class);
-        return util.exportExcel(voList, "直播数据");
+        return util.exportExcel(voList, "直播视频数据");
     }
 
-    /**
-     * 查询所有租户的直播列表
-     */
     @PreAuthorize("@ss.hasPermi('admin:live:list')")
     @GetMapping("/list")
-    public TableDataInfo list(@RequestParam(required = false) String liveName,
+    public TableDataInfo list(@RequestParam(required = false) String liveTitle,
                               @RequestParam(required = false) Long companyId,
-                              @RequestParam(required = false) String companyName) {
-        List<Map<String, Object>> allList = crossTenantHelper.queryAcrossTenants(
-                companyId, companyName, (tenant, jdbc) -> {
-                    StringBuilder sql = new StringBuilder(
-                            "SELECT v.video_id, v.title, v.cover_url, v.live_status, " +
-                            "v.start_time, v.end_time, v.create_time " +
-                            "FROM live_video v WHERE 1=1");
-                    List<Object> params = new ArrayList<>();
-                    if (liveName != null && !liveName.isEmpty()) {
-                        sql.append(" AND v.title LIKE ?");
-                        params.add("%" + liveName + "%");
-                    }
-                    sql.append(" ORDER BY v.create_time DESC LIMIT 200");
-                    return params.isEmpty()
-                            ? jdbc.queryForList(sql.toString())
-                            : jdbc.queryForList(sql.toString(), params.toArray());
-                });
+                              @RequestParam(required = false) String companyName,
+                              @RequestParam(required = false) Integer status) {
+        List<Map<String, Object>> allList = adminLiveService.selectLiveList(companyId, companyName, liveTitle, status);
         return getDataTable(allList);
     }
 
-    /**
-     * 直播统计信息
-     */
+    @PreAuthorize("@ss.hasPermi('admin:live:query')")
+    @GetMapping("/{videoId}")
+    public AjaxResult getInfo(@PathVariable Long videoId) {
+        Map<String, Object> data = adminLiveService.selectLiveById(videoId);
+        if (data == null) return AjaxResult.error("直播视频不存在");
+        return AjaxResult.success(data);
+    }
+
     @PreAuthorize("@ss.hasPermi('admin:live:query')")
     @GetMapping("/statistics")
     public AjaxResult statistics(@RequestParam(required = false) Long companyId,
-                                 @RequestParam(required = false) String companyName) {
-        List<Map<String, Object>> allList = crossTenantHelper.queryAcrossTenants(
-                companyId, companyName, (tenant, jdbc) ->
-                        jdbc.queryForList("SELECT video_id, live_status FROM live_video"));
+                                 @RequestParam(required = false) String companyName,
+                                 @RequestParam(required = false) Integer status) {
+        List<Map<String, Object>> allList = adminLiveService.selectLiveListForExport(companyId, companyName, null, status);
         Map<String, Object> result = new HashMap<>();
         result.put("totalCount", allList.size());
         return AjaxResult.success(result);

+ 14 - 0
fs-service/src/main/java/com/fs/admin/mapper/AdminLiveMapper.java

@@ -0,0 +1,14 @@
+package com.fs.admin.mapper;
+
+import com.fs.admin.vo.AdminLiveVO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface AdminLiveMapper {
+
+    List<AdminLiveVO> selectLiveList(@Param("liveTitle") String liveTitle,
+                                     @Param("status") Integer status);
+
+    AdminLiveVO selectLiveById(@Param("videoId") Long videoId);
+}

+ 13 - 0
fs-service/src/main/java/com/fs/admin/service/IAdminLiveService.java

@@ -0,0 +1,13 @@
+package com.fs.admin.service;
+
+import java.util.List;
+import java.util.Map;
+
+public interface IAdminLiveService {
+
+    List<Map<String, Object>> selectLiveList(Long companyId, String companyName, String liveTitle, Integer status);
+
+    List<Map<String, Object>> selectLiveListForExport(Long companyId, String companyName, String liveTitle, Integer status);
+
+    Map<String, Object> selectLiveById(Long videoId);
+}

+ 69 - 0
fs-service/src/main/java/com/fs/admin/service/impl/AdminLiveServiceImpl.java

@@ -0,0 +1,69 @@
+package com.fs.admin.service.impl;
+
+import com.fs.admin.mapper.AdminLiveMapper;
+import com.fs.admin.service.IAdminLiveService;
+import com.fs.admin.vo.AdminLiveVO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class AdminLiveServiceImpl implements IAdminLiveService {
+
+    @Autowired
+    private AdminLiveMapper adminLiveMapper;
+
+    @Override
+    public List<Map<String, Object>> selectLiveList(Long companyId, String companyName, String liveTitle, Integer status) {
+        return toMapList(adminLiveMapper.selectLiveList(liveTitle, status));
+    }
+
+    @Override
+    public List<Map<String, Object>> selectLiveListForExport(Long companyId, String companyName, String liveTitle, Integer status) {
+        return toMapList(adminLiveMapper.selectLiveList(liveTitle, status));
+    }
+
+    @Override
+    public Map<String, Object> selectLiveById(Long videoId) {
+        AdminLiveVO vo = adminLiveMapper.selectLiveById(videoId);
+        if (vo == null) return null;
+        Map<String, Object> map = new HashMap<>();
+        map.put("videoId", vo.getVideoId());
+        map.put("liveId", vo.getLiveId());
+        map.put("videoUrl", vo.getVideoUrl());
+        map.put("videoType", vo.getVideoType());
+        map.put("duration", vo.getDuration());
+        map.put("createTime", vo.getCreateTime());
+        map.put("sort", vo.getSort());
+        map.put("fileSize", vo.getFileSize());
+        map.put("finishStatus", vo.getFinishStatus());
+        map.put("remark", vo.getRemark());
+        map.put("companyId", vo.getCompanyId());
+        map.put("companyName", vo.getCompanyName());
+        map.put("tenantCode", vo.getTenantCode());
+        return map;
+    }
+
+    private List<Map<String, Object>> toMapList(List<AdminLiveVO> voList) {
+        return voList.stream().map(vo -> {
+            Map<String, Object> map = new HashMap<>();
+            map.put("videoId", vo.getVideoId());
+            map.put("liveId", vo.getLiveId());
+            map.put("videoUrl", vo.getVideoUrl());
+            map.put("videoType", vo.getVideoType());
+            map.put("duration", vo.getDuration());
+            map.put("createTime", vo.getCreateTime());
+            map.put("sort", vo.getSort());
+            map.put("fileSize", vo.getFileSize());
+            map.put("finishStatus", vo.getFinishStatus());
+            map.put("remark", vo.getRemark());
+            map.put("companyId", vo.getCompanyId());
+            map.put("companyName", vo.getCompanyName());
+            map.put("tenantCode", vo.getTenantCode());
+            return map;
+        }).collect(java.util.stream.Collectors.toList());
+    }
+}

+ 33 - 0
fs-service/src/main/java/com/fs/admin/vo/AdminLiveVO.java

@@ -0,0 +1,33 @@
+package com.fs.admin.vo;
+
+import lombok.Data;
+
+@Data
+public class AdminLiveVO {
+
+    private Long videoId;
+
+    private Long liveId;
+
+    private String videoUrl;
+
+    private Integer videoType;
+
+    private Integer duration;
+
+    private String createTime;
+
+    private Integer sort;
+
+    private Integer fileSize;
+
+    private Integer finishStatus;
+
+    private String remark;
+
+    private Long companyId;
+
+    private String companyName;
+
+    private String tenantCode;
+}

+ 42 - 0
fs-service/src/main/resources/mapper/admin/AdminLiveMapper.xml

@@ -0,0 +1,42 @@
+<?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="com.fs.admin.mapper.AdminLiveMapper">
+
+    <resultMap type="com.fs.admin.vo.AdminLiveVO" id="AdminLiveVOResult">
+        <id     property="videoId"       column="video_id"       />
+        <result property="liveId"        column="live_id"        />
+        <result property="videoUrl"      column="video_url"      />
+        <result property="videoType"     column="video_type"     />
+        <result property="duration"      column="duration"       />
+        <result property="createTime"    column="create_time"    />
+        <result property="sort"          column="sort"           />
+        <result property="fileSize"      column="file_size"      />
+        <result property="finishStatus"  column="finish_status"  />
+        <result property="remark"        column="remark"         />
+    </resultMap>
+
+    <sql id="selectAdminLiveVo">
+        SELECT v.video_id, v.live_id, v.video_url, v.video_type,
+               v.duration, v.create_time, v.sort, v.file_size,
+               v.finish_status, v.remark
+        FROM live_video v
+    </sql>
+
+    <select id="selectLiveList" resultMap="AdminLiveVOResult">
+        <include refid="selectAdminLiveVo"/>
+        <where>
+            <if test="status != null">
+                AND v.finish_status = #{status}
+            </if>
+        </where>
+        ORDER BY v.create_time DESC
+    </select>
+
+    <select id="selectLiveById" resultMap="AdminLiveVOResult">
+        <include refid="selectAdminLiveVo"/>
+        WHERE v.video_id = #{videoId}
+    </select>
+
+</mapper>