Răsfoiți Sursa

add:videoinfo列表展示优化v2

lvzhiqiang 1 lună în urmă
părinte
comite
d64fe60653

+ 2 - 2
src/main/java/top/lvzhiqiang/controller/VideoInfoController.java

@@ -41,12 +41,12 @@ public class VideoInfoController {
 
     @RequestMapping("/insertOrUpdateQibing")
     @ResponseBody
-    public R insertOrUpdateQibing(String identificationCode, String commentfirst, String commenttwo, String commentxp, String commentscore, String userName) {
+    public R insertOrUpdateQibing(String identificationCode, String commentfirst, String commenttwo, String commentxp, String commentscore,String javdburl, String userName) {
         if (StringUtils.isEmpty(identificationCode)) {
             throw new ParameterException("identificationCode为空!");
         }
 
-        videoInfoService.insertOrUpdateQibing(identificationCode, commentfirst, commenttwo, commentxp, commentscore);
+        videoInfoService.insertOrUpdateQibing(identificationCode, commentfirst, commenttwo, commentxp, commentscore, javdburl);
 
         return R.ok().data("success");
     }

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

@@ -85,4 +85,7 @@ public class VideoInfoOther implements Serializable {
 
     private String commentXp;
 
+    private Integer xpCount;
+
+    private String javdbUrl;
 }

+ 6 - 3
src/main/java/top/lvzhiqiang/mapper/VideoInfoOtherMapper.java

@@ -113,8 +113,11 @@ public interface VideoInfoOtherMapper {
     @Select("SELECT * FROM video_info_other WHERE identification_code = #{identificationCode}")
     VideoInfoOther findVideoInfoOtherByCode(String identificationCode);
 
-    @Insert("INSERT INTO video_info_other(identification_code, comment,comment_first,score, comment_xp, create_time, modify_time) " +
-            "VALUES (#{identificationCode}, #{comment}, #{commentFirst}, #{score}, #{commentXp}, now(), now()) " +
-            "ON DUPLICATE KEY UPDATE comment=values(comment),comment_first=values(comment_first),score=values(score),comment_xp=values(comment_xp),modify_time=now()")
+    @Insert("INSERT INTO video_info_other(identification_code, comment,comment_first,score, comment_xp,comment_xp_count,javdb_url, create_time, modify_time) " +
+            "VALUES (#{identificationCode}, #{comment}, #{commentFirst}, #{score}, #{commentXp}, #{xpCount}, #{javdbUrl}, now(), now()) " +
+            "ON DUPLICATE KEY UPDATE comment=values(comment),comment_first=values(comment_first),score=values(score),comment_xp=values(comment_xp),comment_xp_count=values(comment_xp_count),javdb_url=values(javdb_url),modify_time=now()")
     void updateVideoInfoOther4Xp(VideoInfoOther videoInfoOther);
+
+    @Update("update video_info_other set javdb_url=#{javdbUrl} where identification_code=#{identificationCode}")
+    int updateJavdbUrl(String identificationCode, String javdbUrl);
 }

+ 1 - 1
src/main/java/top/lvzhiqiang/service/VideoInfoService.java

@@ -44,5 +44,5 @@ public interface VideoInfoService {
      */
     VideoInfo getVideoInfoDetail(String type, String code);
 
-    void insertOrUpdateQibing(String identificationCode, String commentfirst, String commenttwo, String commentxp, String commentscore);
+    void insertOrUpdateQibing(String identificationCode, String commentfirst, String commenttwo, String commentxp, String commentscore, String javdburl);
 }

+ 8 - 12
src/main/java/top/lvzhiqiang/service/impl/VideoInfoServiceImpl.java

@@ -83,14 +83,6 @@ public class VideoInfoServiceImpl extends BaseServiceImpl<Object> implements Vid
         if ("骑兵".equals(bigType)) {
             paramsToSort2(params,"vi.identification_code desc");
             videoInfoList = videoInfoMapper.getVideoInfoList(params);
-
-            for (VideoInfo videoInfo : videoInfoList) {
-                if (StringUtils.isNotEmpty(videoInfo.getCommentXp())) {
-                    videoInfo.setXpCount(String.valueOf(videoInfo.getCommentXp().split("\\R").length));
-                } else {
-                    videoInfo.setXpCount("0");
-                }
-            }
         } else if ("步兵".equals(bigType)) {
             Object genres = params.get("genres");
             paramsToSort(params);
@@ -230,18 +222,22 @@ public class VideoInfoServiceImpl extends BaseServiceImpl<Object> implements Vid
     }
 
     @Override
-    public void insertOrUpdateQibing(String identificationCode, String commentfirst, String commenttwo, String commentxp, String commentscore) {
+    public void insertOrUpdateQibing(String identificationCode, String commentfirst, String commenttwo, String commentxp, String commentscore, String javdburl) {
         VideoInfoOther videoInfoOther = videoInfoOtherMapper.findVideoInfoOtherByCode(identificationCode);
 
         if (videoInfoOther == null) {
             videoInfoOther = new VideoInfoOther();
         }
 
-        videoInfoOther.setComment(commenttwo);
-        videoInfoOther.setCommentFirst(commentfirst);
-        videoInfoOther.setCommentXp(commentxp);
+        videoInfoOther.setComment("暂无评论".equals(commenttwo) ? null : commenttwo);
+        videoInfoOther.setCommentFirst("暂无评论".equals(commentfirst) ? null : commentfirst);
+        videoInfoOther.setCommentXp("暂无评论".equals(commentxp) ? null : commentxp);
         videoInfoOther.setScore(commentscore);
 
+        videoInfoOther.setXpCount(StringUtils.isEmpty(videoInfoOther.getCommentXp()) ? 0 : videoInfoOther.getCommentXp().split("\\R").length);
+
+        videoInfoOther.setJavdbUrl(StringUtils.isNotEmpty(javdburl) ? javdburl : null);
+
         videoInfoOtherMapper.updateVideoInfoOther4Xp(videoInfoOther);
     }
 }

+ 1 - 1
src/main/resources/mapper/VideoInfoMapper.xml

@@ -8,7 +8,7 @@
     <select id="getVideoInfoList" resultType="top.lvzhiqiang.entity.VideoInfo">
         select vi.*, IFNULL(vio.score, 0) AS score, IFNULL(vio.comment, '暂无评论') AS comment,
             IFNULL(vio.resolution_ratio, '?') AS resolutionRatio,vio.original,vio.subtitle,vio.recoding,
-            vio.comment_first,vio.comment_xp,vio.javdb_url
+            IFNULL(vio.comment_first, '暂无评论') AS commentFirst, IFNULL(vio.comment_xp, '暂无评论') AS commentXp,vio.javdb_url,vio.comment_xp_count xpCount
         from video_info vi
         left join video_info_other vio on vi.identification_code = vio.identification_code and vio.delete_flag = 1
         where vi.delete_flag = 1

+ 183 - 0
src/main/resources/static/css/my-popup-video.css

@@ -0,0 +1,183 @@
+/* 弹窗的基础样式 */
+.popup-video {
+    display: none;
+    position: fixed;
+    top: 20%;
+    left: 30%;
+    width: 500px; /* 设置宽度适当的弹窗 */
+    background: #fff;
+    border: 1px solid #ccc;
+    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
+    padding: 20px;
+    z-index: 1000;
+    cursor: move;
+    overflow: hidden;
+}
+
+.popup-video h2 {
+    margin: 0 0 10px;
+    text-align: center;
+    cursor: move;
+    font-size: 1.5em;
+    font-weight: bold;
+    padding-bottom: 10px;
+}
+
+.popup-video form {
+    display: flex;
+    flex-direction: column;
+    gap: 15px;
+}
+
+.popup-video form .form-item {
+    display: flex;
+    align-items: center;
+    gap: 10px;
+    width: 100%;
+    margin-bottom: 5px; /* 调整每个表单项之间的垂直间距 */
+}
+
+.popup-video form label {
+    flex: 0 0 30%;  /* 标签占据容器的 30% 宽度 */
+    font-size: 14px;
+    text-align: right;
+    margin-right: 10px; /* 标签和输入框之间的间距 */
+    white-space: nowrap;  /* 防止标签文本换行 */
+    overflow: hidden;
+    text-overflow: ellipsis;  /* 标签文本过长时显示省略号 */
+}
+
+.popup-video form select, .popup-video form input[type="file"] {
+    flex: 1; /* 下拉框占据剩余的空间 */
+    padding: 8px;
+    font-size: 14px;
+    width: 100%;  /* 使下拉框自适应填充容器 */
+}
+
+.popup-video form input {
+    flex: 1; /* 让输入框自适应宽度 */
+    padding: 8px;
+    font-size: 13px;
+    width: 100%;
+}
+
+.popup-video form button {
+    padding: 10px;
+    font-size: 14px;
+    background-color: #007bff;
+    color: #fff;
+    border: none;
+    cursor: pointer;
+}
+
+.popup-video form button:hover {
+    background-color: #0056b3;
+}
+
+.close-btn {
+    background: none;
+    border: none;
+    font-size: 24px; /* 字体大小 */
+    color: #555;
+    cursor: pointer;
+    position: absolute;
+    top: 10px;
+    right: 10px;
+    padding: 0; /* 不需要额外的内边距 */
+    border-radius: 50%; /* 圆形背景 */
+    width: 35px; /* 圆形的宽度 */
+    height: 35px; /* 圆形的高度 */
+    text-align: center; /* 水平居中 */
+    line-height: 35px; /* 垂直居中 */
+    background-color: #f0f0f0; /* 背景颜色 */
+    transition: background-color 0.3s ease; /* 背景色过渡效果 */
+}
+
+.close-btn:hover {
+    background-color: #ddd; /* 悬停时的背景色 */
+}
+
+/* 解决文本偏下的情况 */
+.close-btn span {
+    display: inline-block;
+    vertical-align: middle; /* 垂直居中 */
+}
+
+@keyframes spin {
+    0% { transform: rotate(0deg); }
+    100% { transform: rotate(360deg); }
+}
+
+/* 按钮容器样式 */
+.form-buttons {
+    display: flex;
+    justify-content: space-between;
+    /*margin-top: 20px;*/
+}
+
+.form-buttons button {
+    width: 48%;
+}
+
+/* 动态内容容器样式 */
+#form-container {
+    /*margin-top: 10px;*/
+}
+
+.form-item.dynamic {
+    display: flex;
+    align-items: center;
+    gap: 10px;
+    margin-bottom: 10px;
+}
+
+.form-item.dynamic input {
+    flex: 1;
+}
+
+/* 请求结果展示区域 */
+.result-container {
+    margin-top: 20px;
+    padding: 10px;
+    border: 1px solid #ccc;
+    background-color: #f9f9f9;
+    font-size: 14px;
+    display: none; /* 初始隐藏 */
+    max-height: 200px; /* 限制最大高度 */
+    overflow-y: auto; /* 超出部分垂直滚动 */
+    overflow-x: auto; /*启用横向滚动条,当内容超出容器的宽度时,会出现水平滚动条 */
+}
+
+/* 加载动画样式 */
+.loading-icon {
+    display: none;
+    margin-top: 20px;
+    text-align: center;
+}
+
+.loading-icon::after {
+    content: "";
+    display: block;
+    width: 30px;
+    height: 30px;
+    margin: 0 auto;
+    border: 4px solid #f3f3f3;
+    border-top: 4px solid #007bff;
+    border-radius: 50%;
+    animation: spin 1s linear infinite;
+}
+
+.select2-container {
+    font-size: 14px;
+}
+.select2-container--default .select2-selection--multiple {
+    border: 1px solid #ccc;
+    border-radius: 4px;
+    padding: 5px;
+    overflow: auto;
+}
+.select2-container--default .select2-selection--multiple .select2-selection__rendered {
+    line-height: 20px;
+}
+
+

+ 34 - 15
src/main/resources/static/js/my-video.js

@@ -444,28 +444,46 @@ function initContentEvent() {
 }
 
 function initOther4Popup(){
+    let clickTimer = null;
+
     // 打开弹窗
-    $("span.xp").on("click", function () {
-        let parent = $(this).parent();
-        var commentfirst = parent.find("input[type='hidden']").eq(0).attr("commentfirst");
-        var commenttwo = parent.find("input[type='hidden']").eq(1).attr("commenttwo");
-        var commentxp = parent.find("input[type='hidden']").eq(2).attr("commentxp");
-        var commentscore = parent.find("input[type='hidden']").eq(3).attr("commentscore");
-        var bigtype = parent.find("input[type='hidden']").eq(4).attr("bigtype");
-        var identificationCode = $(this).attr("identificationCode");
-        quietPop(bigtype, identificationCode, commentfirst, commenttwo, commentxp, commentscore);
-
-        $(".popup").fadeIn();
-        centerPopup();  // 调用居中函数
+    $("span.xp").unbind("click");
+    $("span.xp").on("click", function (e) {
+        clearTimeout(clickTimer);
+        clickTimer = setTimeout(() => {
+            let parent = $(this).parent();
+            var commentfirst = parent.find("input[type='hidden']").eq(0).attr("commentfirst");
+            var commenttwo = parent.find("input[type='hidden']").eq(1).attr("commenttwo");
+            var commentxp = parent.find("input[type='hidden']").eq(2).attr("commentxp");
+            var commentscore = parent.find("input[type='hidden']").eq(3).attr("commentscore");
+            var bigtype = parent.find("input[type='hidden']").eq(4).attr("bigtype");
+            var identificationCode = $(this).attr("identificationCode");
+            var javdbUrl = $(this).attr("title");
+            quietPop(bigtype, identificationCode, commentfirst, commenttwo, commentxp, commentscore, javdbUrl);
+
+            $(".popup-video").fadeIn();
+            centerPopup();  // 调用居中函数
+        }, 300); // 300ms 是判断单击和双击的时间间隔
+    });
+
+    $("span.xp").off("dblclick");
+    $("span.xp").dblclick(function (e) {
+        clearTimeout(clickTimer);
+
+        let javdbUrl = $(this).attr("title");
+        if (javdbUrl != null) {
+            window.open(javdbUrl, "_blank");
+        }
     });
 
     // 关闭弹窗
+    $(".close-btn").unbind("click");
     $(".close-btn").on("click", function () {
-        $(".popup").fadeOut();
+        $(".popup-video").fadeOut();
     });
 
     // 阻止表单默认提交行为
-    $(".popup form").on("submit", function (e) {
+    $(".popup-video form").on("submit", function (e) {
         e.preventDefault();
 
         var nameEn = $("#popup-form-hidden-nameEn").val();
@@ -539,7 +557,7 @@ function centerPopup() {
     });
 }
 
-function quietPop(bigtype, identificationCode, commentfirst, commenttwo, commentxp, commentscore) {
+function quietPop(bigtype, identificationCode, commentfirst, commenttwo, commentxp, commentscore, javdburl) {
     if (bigtype === '骑兵') {
         let formContent = "";
         formContent += '<div class="form-item"><label for="identificationCode">code:</label><input readonly type="text" name="identificationCode" style="border:revert;"  value="' + identificationCode + '"></div>';
@@ -547,6 +565,7 @@ function quietPop(bigtype, identificationCode, commentfirst, commenttwo, comment
         formContent += '<div class="form-item"><label for="commenttwo">commenttwo:</label><textarea rows="5" cols="100" style="background: antiquewhite;width: 100%;height: 100%;" name="commenttwo">' + commenttwo + '</textarea></div>';
         formContent += '<div class="form-item"><label for="commentxp">commentxp:</label><textarea rows="6" cols="100" style="background: antiquewhite;width: 100%;height: 100%;" name="commentxp">' + commentxp +'</textarea></div>';
         formContent += '<div class="form-item"><label for="commentscore">commentscore:</label><input type="text" name="commentscore" placeholder="可为空" style="border:revert;" value="' + commentscore + '"></div>';
+        formContent += '<div class="form-item"><label for="javdbUrl">javdburl:</label><input type="text" name="javdburl" placeholder="可为空" style="border:revert;" value="' + javdburl + '"></div>';
         $("#form-container-2").html(formContent);
 
         $("#popup-form-hidden-nameEn").val(bigtype);

+ 5 - 4
src/main/resources/static/video.html

@@ -17,7 +17,7 @@
     <link rel="stylesheet" href="css/mytheme-site.css?v=2.8" type="text/css">
     <link rel="stylesheet" href="css/mytheme-font.css?v=2.8" type="text/css">
     <link rel="stylesheet" href="css/my-video.css" type="text/css">
-    <link rel="stylesheet" href="css/my-popup.css" type="text/css">
+    <link rel="stylesheet" href="css/my-popup-video.css" type="text/css">
     <script src="js/jquery-3.6.0.min.js"></script>
     <script src="js/pagination.js"></script>
     <script type="text/javascript" src="js/my-video.js"></script>
@@ -27,9 +27,9 @@
     <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
     <![endif]-->
     <style type="text/css">
-        body {
+        /*body {
             font-family: "Microsoft YaHei", "微软雅黑", "STHeiti", "WenQuanYi Micro Hei", SimSun, sans-serif;
-        }
+        }*/
 
         [class*=col-], .myui-content__list li, .myui-vodlist__media.col li {
             padding: 10px
@@ -220,6 +220,7 @@
                         <li><a class="btn searchbtn" orderField="vi.modify_time" order="desc">更新时间</a></li>
                         <li><a class="btn searchbtn lovefoot" orderField="vi.update_date" order="desc" style="display: none;">原始更新时间</a></li>
                         <li><a class="btn searchbtn" orderField="vio.score" order="asc">评分</a></li>
+                        <li><a class="btn searchbtn" orderField="vio.comment_xp_count" order="asc">xpCount</a></li>
                     </ul>
                 </div>
             </div>
@@ -263,7 +264,7 @@
 <div id="bigpreview"><img src=""/></div>
 
 
-<div class="popup" id="draggable-popup">
+<div class="popup-video" id="draggable-popup">
     <button class="close-btn">&times;</button>
     <h2></h2>
     <form id="popup-form">

+ 21 - 5
src/test/java/top/lvzhiqiang/TestVideo.java

@@ -1,10 +1,6 @@
 package top.lvzhiqiang;
 
-import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
-import org.jsoup.Connection;
-import org.jsoup.HttpStatusException;
-import org.jsoup.Jsoup;
 import org.jsoup.nodes.Document;
 import org.jsoup.nodes.Element;
 import org.jsoup.select.Elements;
@@ -20,7 +16,6 @@ import top.lvzhiqiang.util.StringUtils;
 
 import javax.annotation.Resource;
 import javax.net.ssl.*;
-import java.net.InetSocketAddress;
 import java.net.Proxy;
 import java.nio.charset.StandardCharsets;
 import java.security.SecureRandom;
@@ -63,6 +58,11 @@ public class TestVideo {
     @Resource
     private VideoMonitorActorsMapper videoMonitorActorsMapper;
 
+    @Resource
+    private IcodePoolMapper icodePoolMapper;
+    @Resource
+    private VideoInfoOtherMapper videoInfoOtherMapper;
+
     @Test
     public void testGetBusinessDeptSummary() {
         List<VideoInfoPool> videoInfoPoolList = videoInfoPoolMapper.findAll();
@@ -212,4 +212,20 @@ public class TestVideo {
             }
         }
     }
+
+    @Test
+    public void testInitJavdbUrl() {
+        List<VideoInfo> all = videoInfoMapper.findAll();
+        System.out.println("all size =" + all.size());
+        int i = 0;
+        for (VideoInfo videoInfo : all) {
+            String identificationCode = videoInfo.getIdentificationCode();
+            IcodePool icodePool = icodePoolMapper.findIcodePoolByCode(identificationCode);
+            if (icodePool != null && StringUtils.isNotEmpty(icodePool.getUrl())) {
+                int i1 = videoInfoOtherMapper.updateJavdbUrl(identificationCode, icodePool.getUrl());
+                i += i1;
+            }
+        }
+        System.out.println("update size=" + i);
+    }
 }