Browse Source

add:增加影片分辨率、原档、字幕、转码选项查询及更新v1

tujidelv 3 years ago
parent
commit
706828a199

+ 2 - 2
src/main/java/top/lvzhiqiang/config/MyJobs.java

@@ -165,9 +165,9 @@ public class MyJobs {
     }
 
     /**
-     * 每天6:30 jsoupXiaoeknowCourse
+     * 每天17:30 jsoupXiaoeknowCourse
      */
-    @Scheduled(cron = "0 30 6 * * ?", zone = SCHEDULED_ZONE)
+    @Scheduled(cron = "0 30 17 * * ?", zone = SCHEDULED_ZONE)
     @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
     public void jsoupXiaoeknowCourse() {
         log.warn("jsoupXiaoeknowCourse开始==============================");

+ 18 - 2
src/main/java/top/lvzhiqiang/controller/BgController.java

@@ -158,14 +158,14 @@ public class BgController {
     }
 
     /**
-     * insetOrupdateScoreOrComment
+     * insertOrUpdateScoreOrComment
      *
      * @author lvzhiqiang
      * 2022/5/4 9:54
      */
     @RequestMapping("/insertOrUpdateScoreOrComment")
     @ResponseBody
-    public String insertOrUpdateScoreOrComment(String identificationCode, String score, String comment) throws IllegalAccessException {
+    public String insertOrUpdateScoreOrComment(String identificationCode, String score, String comment) {
         if (StringUtils.isEmpty(identificationCode)) {
             throw new ParameterException("identificationCode为空!");
         }
@@ -178,6 +178,22 @@ public class BgController {
     }
 
     /**
+     * findVideoInfoOther
+     *
+     * @author lvzhiqiang
+     * 2022/9/17 19:17
+     */
+    @RequestMapping("/findVideoInfoOther")
+    @ResponseBody
+    public String findVideoInfoOther(String identificationCode, String resolutionRatio, Integer original, Integer subtitle, Integer recoding, String crudT) {
+        if (!"1".equals(crudT) && StringUtils.isEmpty(identificationCode)) {
+            throw new ParameterException("identificationCode为空!");
+        }
+
+        return bgService.findVideoInfoOther(identificationCode.toUpperCase(), resolutionRatio, original, subtitle, recoding, crudT);
+    }
+
+    /**
      * findDicCode
      *
      * @author lvzhiqiang

+ 86 - 0
src/main/java/top/lvzhiqiang/entity/VideoInfoOther.java

@@ -0,0 +1,86 @@
+package top.lvzhiqiang.entity;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import top.lvzhiqiang.util.DateUtils;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * 电影信息其他表
+ *
+ * @author lvzhiqiang
+ * 2022/9/17 20:18
+ */
+@Data
+public class VideoInfoOther implements Serializable {
+
+    /**
+     * 主键
+     */
+    private Long id;
+
+    /**
+     * 识别码
+     */
+    private String identificationCode;
+
+    /**
+     * 评分
+     */
+    private String score;
+
+    /**
+     * 评语
+     */
+    private String comment;
+
+    /**
+     * 评语_first
+     */
+    private String commentFirst;
+
+    /**
+     * 图片flag(1:无,2:有)
+     */
+    private Integer picFlag;
+
+    /**
+     * 分辨率{720P,1080P,4k}
+     */
+    private String resolutionRatio;
+
+    /**
+     * 原档{1是,2否}
+     */
+    private Integer original;
+
+    /**
+     * 字幕{1是,2否}
+     */
+    private Integer subtitle;
+
+    /**
+     * 重新编码{1是,2否}
+     */
+    private Integer recoding;
+
+    /**
+     * 删除标志{1:正常,2:已删除}
+     */
+    private Integer deleteFlag;
+
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern = DateUtils.PATTERN_TO_SECONDS)
+    private LocalDateTime createTime;
+
+    /**
+     * 最后修改时间
+     */
+    @JsonFormat(pattern = DateUtils.PATTERN_TO_SECONDS)
+    private LocalDateTime modifyTime;
+
+}

+ 52 - 0
src/main/java/top/lvzhiqiang/mapper/VideoInfoOtherMapper.java

@@ -4,8 +4,10 @@ import org.apache.ibatis.annotations.Delete;
 import org.apache.ibatis.annotations.Insert;
 import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Update;
+import top.lvzhiqiang.entity.VideoInfoOther;
 
 import java.math.BigDecimal;
+import java.util.List;
 
 /**
  * 电影信息其他Mapper
@@ -30,6 +32,7 @@ public interface VideoInfoOtherMapper {
             "<if test=\"comment != null and comment != ''\">" +
             "   comment = #{comment}," +
             "</if>" +
+            "modify_time=now()" +
             "</set>" +
             "where identification_code = #{identificationCode}" +
             "</script>"})
@@ -52,4 +55,53 @@ public interface VideoInfoOtherMapper {
             "VALUES (#{identificationCode}, #{picFlag}, now(), now()) " +
             "ON DUPLICATE KEY UPDATE pic_flag=values(pic_flag),modify_time=now()")
     int insertOrUpdate(String identificationCode, Integer picFlag);
+
+    @Insert("INSERT INTO video_info_other(identification_code, resolution_ratio, original, subtitle, recoding, create_time, modify_time) " +
+            "VALUES (#{identificationCode},#{resolutionRatio},#{original}, #{subtitle}, #{recoding}, now(), now())")
+    void insertVideoInfoOther(String identificationCode, String resolutionRatio, Integer original, Integer subtitle, Integer recoding);
+
+    @Update({"<script>" +
+            "update video_info_other " +
+            "<set>" +
+            "<if test=\"resolutionRatio != null and resolutionRatio != ''\">" +
+            "  resolution_ratio = #{resolutionRatio}," +
+            "</if>" +
+            "<if test=\"original != null\">" +
+            "   original = #{original}," +
+            "</if>" +
+            "<if test=\"subtitle != null\">" +
+            "   subtitle = #{subtitle}," +
+            "</if>" +
+            "<if test=\"recoding != null\">" +
+            "   recoding = #{recoding}," +
+            "</if>" +
+            "modify_time=now()" +
+            "</set>" +
+            "where identification_code = #{identificationCode}" +
+            "</script>"})
+    void updateVideoInfoOther(String identificationCode, String resolutionRatio, Integer original, Integer subtitle, Integer recoding);
+
+    @Update("update video_info_other set delete_flag = 2,modify_time = now() where identification_code = #{identificationCode}")
+    void delByCode(String identificationCode);
+
+    @Select({"<script>" +
+            "select * from video_info_other WHERE delete_flag = 1" +
+            "<if test=\"identificationCode != null and identificationCode != ''\">" +
+            "   and identification_code like concat('%',#{identificationCode},'%')" +
+            "</if>" +
+            "<if test=\"resolutionRatio != null and resolutionRatio != ''\">" +
+            "   and resolution_ratio = #{resolutionRatio}" +
+            "</if>" +
+            "<if test=\"original != null\">" +
+            "   and original = #{original}" +
+            "</if>" +
+            "<if test=\"subtitle != null\">" +
+            "   and subtitle = #{subtitle}" +
+            "</if>" +
+            "<if test=\"recoding != null\">" +
+            "   and recoding = #{recoding}" +
+            "</if>" +
+            "   order by modify_time desc" +
+            "</script>"})
+    List<VideoInfoOther> findVideoInfoOther4MultipleParams(String identificationCode, String resolutionRatio, Integer original, Integer subtitle, Integer recoding);
 }

+ 8 - 0
src/main/java/top/lvzhiqiang/service/BgService.java

@@ -110,4 +110,12 @@ public interface BgService {
      * 2022/5/29 12:59
      */
     void delVideoInfo(String identificationCode, String parentTypeName, String allFlag);
+
+    /**
+     * findVideoInfoOther
+     *
+     * @author lvzhiqiang
+     * 2022/9/17 19:17
+     */
+    String findVideoInfoOther(String identificationCode, String resolutionRatio, Integer original, Integer subtitle, Integer recoding, String crudT);
 }

+ 55 - 0
src/main/java/top/lvzhiqiang/service/impl/BgServiceImpl.java

@@ -461,6 +461,61 @@ public class BgServiceImpl implements BgService {
         }
     }
 
+
+    /**
+     * findVideoInfoOther
+     *
+     * @author lvzhiqiang
+     * 2022/9/17 19:17
+     */
+    @Override
+    public String findVideoInfoOther(String identificationCode, String resolutionRatio, Integer original, Integer subtitle, Integer recoding, String crudT) {
+        if ("2".equals(crudT)) {
+            // 更新/新增
+            int num = videoInfoOtherMapper.findByCode(identificationCode);
+            if (num == 0) {
+                videoInfoOtherMapper.insertVideoInfoOther(identificationCode, resolutionRatio, original, subtitle, recoding);
+                return "insert success";
+            }
+
+            videoInfoOtherMapper.updateVideoInfoOther(identificationCode, resolutionRatio, original, subtitle, recoding);
+            return "update success";
+        }
+        if ("3".equals(crudT)) {
+            //删除
+            videoInfoOtherMapper.delByCode(identificationCode);
+            return "success";
+        }
+
+        // 查询
+        List<VideoInfoOther> videoInfoOtherList = videoInfoOtherMapper.findVideoInfoOther4MultipleParams(identificationCode, resolutionRatio, original, subtitle, recoding);
+
+        StringBuffer sb = new StringBuffer("total:".concat(String.valueOf(videoInfoOtherList.size())).concat("<br/>"));
+        sb.append("<table border=\"1\" cellspacing=\"0\"><tr><th>序号</th><th>识别码</th><th>评分</th><th>评语</th><th>评语first</th><th>分辨率</th><th>原档</th><th>字幕</th><th>重新编码</th><th>创建时间</th><th>最后修改时间</th></tr>");
+        int i = 0;
+        for (VideoInfoOther videoInfoOther : videoInfoOtherList) {
+            i++;
+            sb.append("<tr>");
+
+            sb.append("<td>").append(i).append("</td>");
+            sb.append("<td>").append(videoInfoOther.getIdentificationCode()).append("</td>");
+            sb.append("<td>").append(videoInfoOther.getScore()).append("</td>");
+            sb.append("<td>").append(videoInfoOther.getComment()).append("</td>");
+            sb.append("<td>").append(videoInfoOther.getCommentFirst()).append("</td>");
+            sb.append("<td>").append(videoInfoOther.getResolutionRatio()).append("</td>");
+            sb.append("<td>").append(videoInfoOther.getOriginal() == null ? "?" : (videoInfoOther.getOriginal() == 1 ? "是" : "否")).append("</td>");
+            sb.append("<td>").append(videoInfoOther.getSubtitle() == null ? "?" : (videoInfoOther.getSubtitle() == 1 ? "是" : "否")).append("</td>");
+            sb.append("<td>").append(videoInfoOther.getRecoding() == null ? "?" : (videoInfoOther.getRecoding() == 1 ? "是" : "否")).append("</td>");
+            sb.append("<td>").append(videoInfoOther.getCreateTime()).append("</td>");
+            sb.append("<td>").append(videoInfoOther.getModifyTime()).append("</td>");
+
+            sb.append("</tr>");
+        }
+        sb.append("</table>");
+
+        return sb.toString();
+    }
+
     /**
      * 初始化骑兵数据
      */

+ 4 - 2
src/main/java/top/lvzhiqiang/service/impl/CrawlerServiceImpl.java

@@ -281,7 +281,7 @@ public class CrawlerServiceImpl implements CrawlerService {
         Connection.Response response;
         StringBuffer sb = new StringBuffer();
         JSONObject result = null;
-        for (int i = 0; i < 2; i++) {
+        for (int i = 0; i < 3; i++) {
             try {
                 stopWatch.start("search");
                 response = Jsoup.connect(ikoaConstantMap.get("search_url"))
@@ -305,7 +305,9 @@ public class CrawlerServiceImpl implements CrawlerService {
                 generateIkoaToken(ikoaConstantMap, proxy);
             } catch (Exception e) {
                 log.error("IKOA搜索异常,ikoaConstantMap={},result={}", ikoaConstantMap, result.toString(), e);
-                throw new Exception("IKOA搜索异常!");
+                if (i == 2) {
+                    throw new Exception("IKOA搜索异常!");
+                }
             }
         }
 

+ 39 - 0
src/main/resources/static/bg.html

@@ -181,6 +181,45 @@
             <input type="submit" value="提交">
         </form>
     </div>
+    <div style="margin-right:20px;">
+        <span class="font">findVideoInfoOther</span>
+        <form method="post" action="bg/findVideoInfoOther">
+            <span>identificationCode</span>
+            <input type="text" name="identificationCode" placeholder="识别码,查询可为空"/>
+            <span>resolutionRatio</span>
+            <select name="resolutionRatio" style="height: 21.43px;">
+                <option value="">--</option>
+                <option value="720P">720P</option>
+                <option value="1080P">1080P</option>
+                <option value="4K">4K</option>
+            </select>
+            <span>original</span>
+            <select name="original" style="height: 21.43px;">
+                <option value="">--</option>
+                <option value="1">是</option>
+                <option value="2">否</option>
+            </select>
+            <span>subtitle</span>
+            <select name="subtitle" style="height: 21.43px;">
+                <option value="">--</option>
+                <option value="1">是</option>
+                <option value="2">否</option>
+            </select>
+            <span>recoding</span>
+            <select name="recoding" style="height: 21.43px;">
+                <option value="">--</option>
+                <option value="1">是</option>
+                <option value="2">否</option>
+            </select>
+            <span>crudT</span>
+            <select name="crudT" style="height: 21.43px;">
+                <option value="1">查询</option>
+                <option value="2">新增/更新</option>
+                <option value="3">删除</option>
+            </select>
+            <input type="submit" value="提交">
+        </form>
+    </div>
     <br/>
     <div style="margin-right:20px;">
         <span class="font">delVideoInfo</span>