Преглед изворни кода

add:bg页面加入一些查询功能v1

tujidelv пре 3 година
родитељ
комит
72f2f7fb78

+ 3 - 0
src/main/java/top/lvzhiqiang/config/UnifiedReturnConfig.java

@@ -43,6 +43,9 @@ public class UnifiedReturnConfig {
         public Object beforeBodyWrite(Object body, MethodParameter methodParameter,
                                       MediaType mediaType, Class<? extends HttpMessageConverter<?>> aClass,
                                       ServerHttpRequest serverHttpRequest, ServerHttpResponse serverHttpResponse) {
+            if (serverHttpRequest.getURI().toASCIIString().indexOf("/bg") >= 0) {
+                return body;
+            }
 
             if (body instanceof R) {
                 return body;

+ 78 - 0
src/main/java/top/lvzhiqiang/controller/BgController.java

@@ -108,4 +108,82 @@ public class BgController {
         bgService.jsoupIcodePool(status, isDel);
         return R.ok();
     }
+
+    /**
+     * findDicCode
+     *
+     * @author lvzhiqiang
+     * 2022/5/3 17:37
+     */
+    @RequestMapping("/findDicCode")
+    @ResponseBody
+    public String findDicCode(String codeDesc, String order) throws IllegalAccessException {
+        return bgService.findDicCode(codeDesc, order);
+    }
+
+    /**
+     * findIcodePool
+     *
+     * @author lvzhiqiang
+     * 2022/5/3 17:37
+     */
+    @RequestMapping("/findIcodePool")
+    @ResponseBody
+    public String findIcodePool(String identificationCode, Integer status, String order) throws IllegalAccessException {
+        if (StringUtils.isNotEmpty(identificationCode)) {
+            identificationCode = identificationCode.toUpperCase();
+        }
+
+        return bgService.findIcodePool(identificationCode, status, order);
+    }
+
+    /**
+     * findVideoSitePool
+     *
+     * @author lvzhiqiang
+     * 2022/5/3 17:37
+     */
+    @RequestMapping("/findVideoSitePool")
+    @ResponseBody
+    public String findVideoSitePool(String url, String order) throws IllegalAccessException {
+        return bgService.findVideoSitePool(url, order);
+    }
+
+    /**
+     * findVideoInfoPool
+     *
+     * @author lvzhiqiang
+     * 2022/5/3 17:37
+     */
+    @RequestMapping("/findVideoInfoPool")
+    @ResponseBody
+    public String findVideoInfoPool(String identificationCode, Integer type, String order, String crudT) throws IllegalAccessException {
+        if (StringUtils.isNotEmpty(identificationCode)) {
+            identificationCode = identificationCode.toUpperCase();
+        }
+        if (StringUtils.isEmpty(crudT)) {
+            crudT = "1";
+        }
+
+        return bgService.findVideoInfoPool(identificationCode, type, order, crudT);
+    }
+
+    /**
+     * findVideoInfo
+     *
+     * @author lvzhiqiang
+     * 2022/5/3 17:37
+     */
+    @RequestMapping("/findVideoInfo")
+    @ResponseBody
+    public String findVideoInfo(String identificationCode, Integer type, String order, String crudT) throws IllegalAccessException {
+        if (StringUtils.isNotEmpty(identificationCode)) {
+            identificationCode = identificationCode.toUpperCase();
+        }
+        if (StringUtils.isEmpty(crudT)) {
+            crudT = "1";
+        }
+
+        return bgService.findVideoInfo(identificationCode, type, order, crudT);
+    }
 }

+ 2 - 2
src/main/java/top/lvzhiqiang/entity/DicCode.java

@@ -48,12 +48,12 @@ public class DicCode implements Serializable {
     /**
      * 创建时间
      */
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private LocalDateTime createTime;
 
     /**
      * 最后修改时间
      */
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private LocalDateTime modifyTime;
 }

+ 14 - 0
src/main/java/top/lvzhiqiang/mapper/DicCodeMapper.java

@@ -40,4 +40,18 @@ public interface DicCodeMapper {
      */
     @Select("SELECT * FROM dic_code WHERE delete_flag = 1")
     List<DicCode> findAll();
+
+    /**
+     * 根据codeDesc模糊查询
+     */
+    @Select({"<script>" +
+            "select *  from dic_code WHERE delete_flag = 1" +
+            "<if test=\"codeDesc != null and codeDesc != ''\">" +
+            "   and code_desc like concat('%',#{codeDesc},'%')" +
+            "</if>" +
+            "<if test=\"order != null and order != ''\">" +
+            "   order by modify_time ${order}" +
+            "</if>" +
+            "</script>"})
+    List<DicCode> findByCodeDesc(String codeDesc, String order);
 }

+ 19 - 0
src/main/java/top/lvzhiqiang/mapper/IcodePoolMapper.java

@@ -65,4 +65,23 @@ public interface IcodePoolMapper {
      */
     @Update("update icode_pool set status = #{status},failure_cause = #{failureCause},retry_count = #{retryCount},modify_time = now() where identification_code = #{identificationCode}")
     int updateStatus(IcodePool icodePool);
+
+    /**
+     * 根据识别码和状态查询
+     * @return
+     */
+    @Select({"<script>" +
+            "select *  from icode_pool WHERE delete_flag = 1" +
+            "<if test=\"identificationCode != null and identificationCode != ''\">" +
+            "   and identification_code like concat('%',#{identificationCode},'%')" +
+            "</if>" +
+            "<if test=\"status != null and status != ''\">" +
+            "   and status = #{status}" +
+            "</if>" +
+            "<if test=\"order != null and order != ''\">" +
+            "   order by modify_time ${order}" +
+            "</if>" +
+            "</script>"})
+    List<IcodePool> findByCodeAndStatus(String identificationCode, Integer status, String order);
+
 }

+ 23 - 4
src/main/java/top/lvzhiqiang/mapper/VideoInfoMapper.java

@@ -1,9 +1,6 @@
 package top.lvzhiqiang.mapper;
 
-import org.apache.ibatis.annotations.Delete;
-import org.apache.ibatis.annotations.Insert;
-import org.apache.ibatis.annotations.Options;
-import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.*;
 import top.lvzhiqiang.entity.VideoInfo;
 
 import java.util.List;
@@ -65,4 +62,26 @@ public interface VideoInfoMapper {
      * 根据条件查询
      */
     List<VideoInfo> getVideoInfoList(Map<String, Object> params);
+
+    /**
+     * 根据识别码和类型查询
+     *
+     * @return
+     */
+    @Select({"<script>" +
+            "select *  from video_info WHERE delete_flag = 1" +
+            "<if test=\"identificationCode != null and identificationCode != ''\">" +
+            "   and identification_code like concat('%',#{identificationCode},'%')" +
+            "</if>" +
+            "<if test=\"type != null and type != ''\">" +
+            "   and type = #{type}" +
+            "</if>" +
+            "<if test=\"order != null and order != ''\">" +
+            "   order by issue_date ${order}" +
+            "</if>" +
+            "</script>"})
+    List<VideoInfo> findByCodeAndType(String identificationCode, Integer type, String order);
+
+    @Update("update video_info set delete_flag = 2,modify_time = now() where identification_code = #{identificationCode}")
+    void delByCode(String identificationCode);
 }

+ 26 - 4
src/main/java/top/lvzhiqiang/mapper/VideoInfoPoolMapper.java

@@ -1,9 +1,6 @@
 package top.lvzhiqiang.mapper;
 
-import org.apache.ibatis.annotations.Delete;
-import org.apache.ibatis.annotations.Insert;
-import org.apache.ibatis.annotations.Options;
-import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.*;
 import top.lvzhiqiang.entity.VideoCast;
 import top.lvzhiqiang.entity.VideoGenres;
 import top.lvzhiqiang.entity.VideoInfo;
@@ -76,4 +73,29 @@ public interface VideoInfoPoolMapper {
      */
     @Select("SELECT * FROM video_info_pool WHERE delete_flag = 1")
     List<VideoInfoPool> findAll();
+
+    /**
+     * 根据识别码和类型查询
+     *
+     * @return
+     */
+    @Select({"<script>" +
+            "select *  from video_info_pool WHERE delete_flag = 1" +
+            "<if test=\"identificationCode != null and identificationCode != ''\">" +
+            "   and identification_code like concat('%',#{identificationCode},'%')" +
+            "</if>" +
+            "<if test=\"type != null and type != ''\">" +
+            "   and type = #{type}" +
+            "</if>" +
+            "<if test=\"order != null and order != ''\">" +
+            "   order by issue_date ${order}" +
+            "</if>" +
+            "</script>"})
+    List<VideoInfoPool> findByCodeAndType(String identificationCode, Integer type, String order);
+
+    @Update("update video_info_pool set type = #{type},modify_time = now() where identification_code = #{identificationCode}")
+    void updateTypeByCode(String identificationCode, Integer type);
+
+    @Update("update video_info_pool set delete_flag = 2,modify_time = now() where identification_code = #{identificationCode}")
+    void delByCode(String identificationCode);
 }

+ 16 - 0
src/main/java/top/lvzhiqiang/mapper/VideoSitePoolMapper.java

@@ -64,4 +64,20 @@ public interface VideoSitePoolMapper {
      */
     @Update("update video_site_pool set delete_flag = #{deleteFlag},modify_time = now() where url = #{url}")
     int updateDeleteFlag(@Param("url") String url, @Param("deleteFlag") Integer deleteFlag);
+
+    /**
+     * 根据url模糊查询
+     *
+     * @return
+     */
+    @Select({"<script>" +
+            "select *  from video_site_pool WHERE delete_flag = 1" +
+            "<if test=\"url != null and url != ''\">" +
+            "   and url like concat('%',#{url},'%')" +
+            "</if>" +
+            "<if test=\"order != null and order != ''\">" +
+            "   order by create_time ${order}" +
+            "</if>" +
+            "</script>"})
+    List<VideoSitePool> findByUrl(String url, String order);
 }

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

@@ -36,4 +36,44 @@ public interface BgService {
      * @param identificationCode
      */
     void single4IdentificationCode(String identificationCode);
+
+    /**
+     * findDicCode
+     *
+     * @author lvzhiqiang
+     * 2022/5/3 17:37
+     */
+    String findDicCode(String codeDesc, String order) throws IllegalAccessException;
+
+    /**
+     * findIcodePool
+     *
+     * @author lvzhiqiang
+     * 2022/5/3 17:37
+     */
+    String findIcodePool(String identificationCode, Integer status, String order) throws IllegalAccessException;
+
+    /**
+     * findVideoSitePool
+     *
+     * @author lvzhiqiang
+     * 2022/5/3 17:37
+     */
+    String findVideoSitePool(String url, String order) throws IllegalAccessException;
+
+    /**
+     * findVideoInfoPool
+     *
+     * @author lvzhiqiang
+     * 2022/5/3 17:37
+     */
+    String findVideoInfoPool(String identificationCode, Integer type, String order, String crudT) throws IllegalAccessException;
+
+    /**
+     * findVideoInfo
+     *
+     * @author lvzhiqiang
+     * 2022/5/3 17:37
+     */
+    String findVideoInfo(String identificationCode, Integer type, String order, String crudT) throws IllegalAccessException;
 }

+ 170 - 1
src/main/java/top/lvzhiqiang/service/impl/BgServiceImpl.java

@@ -22,6 +22,7 @@ import top.lvzhiqiang.util.StringUtils;
 
 import javax.annotation.Resource;
 import java.io.*;
+import java.lang.reflect.Field;
 import java.nio.charset.StandardCharsets;
 import java.time.Instant;
 import java.time.LocalDate;
@@ -56,6 +57,174 @@ public class BgServiceImpl implements BgService {
     private VideoInfoPoolMapper videoInfoPoolMapper;
     @Resource
     private VideoSitePoolMapper videoSitePoolMapper;
+    @Resource
+    private DicCodeMapper dicCodeMapper;
+
+    /**
+     * findDicCode
+     *
+     * @author lvzhiqiang
+     * 2022/5/3 17:37
+     */
+    @Override
+    public String findDicCode(String codeDesc, String order) throws IllegalAccessException {
+        List<DicCode> dicCodeList = dicCodeMapper.findByCodeDesc(codeDesc, order);
+
+        StringBuffer sb = new StringBuffer("total:".concat(String.valueOf(dicCodeList.size())).concat("<br/>"));
+        for (DicCode dicCode : dicCodeList) {
+            sb.append("<table border=\"1\" cellspacing=\"0\"><tr><th>key</th><th>value</th></tr>");
+
+            Field[] fields = dicCode.getClass().getDeclaredFields();
+            for (Field field : fields) {
+                field.setAccessible(true);
+                sb.append("<tr>");
+                sb.append("<td>").append(field.getName()).append("</td>");
+                sb.append("<td>").append(field.get(dicCode)).append("</td>");
+                sb.append("</tr>");
+            }
+            sb.append("</table>");
+        }
+
+        return sb.toString();
+    }
+
+    /**
+     * findIcodePool
+     *
+     * @author lvzhiqiang
+     * 2022/5/3 17:37
+     */
+    @Override
+    public String findIcodePool(String identificationCode, Integer status, String order) throws IllegalAccessException {
+        List<IcodePool> icodePoolList = icodePoolMapper.findByCodeAndStatus(identificationCode, status, order);
+
+        StringBuffer sb = new StringBuffer("total:".concat(String.valueOf(icodePoolList.size())).concat("<br/>"));
+        for (IcodePool icodePool : icodePoolList) {
+            sb.append("<table border=\"1\" cellspacing=\"0\"><tr><th>key</th><th>value</th></tr>");
+
+            Field[] fields = icodePool.getClass().getDeclaredFields();
+            for (Field field : fields) {
+                field.setAccessible(true);
+                sb.append("<tr>");
+                sb.append("<td>").append(field.getName()).append("</td>");
+                sb.append("<td>").append(field.get(icodePool)).append("</td>");
+                sb.append("</tr>");
+            }
+            sb.append("</table>");
+        }
+
+        return sb.toString();
+    }
+
+    /**
+     * findVideoSitePool
+     *
+     * @author lvzhiqiang
+     * 2022/5/3 17:37
+     */
+    @Override
+    public String findVideoSitePool(String url, String order) throws IllegalAccessException {
+        List<VideoSitePool> videoSitePoolList = videoSitePoolMapper.findByUrl(url, order);
+
+        StringBuffer sb = new StringBuffer("total:".concat(String.valueOf(videoSitePoolList.size())).concat("<br/>"));
+        for (VideoSitePool videoSitePool : videoSitePoolList) {
+            sb.append("<table border=\"1\" cellspacing=\"0\"><tr><th>key</th><th>value</th></tr>");
+
+            Field[] fields = videoSitePool.getClass().getDeclaredFields();
+            for (Field field : fields) {
+                field.setAccessible(true);
+                sb.append("<tr>");
+                sb.append("<td>").append(field.getName()).append("</td>");
+                sb.append("<td>").append(field.get(videoSitePool)).append("</td>");
+                sb.append("</tr>");
+            }
+            sb.append("</table>");
+        }
+
+        return sb.toString();
+    }
+
+    /**
+     * findVideoInfoPool
+     *
+     * @author lvzhiqiang
+     * 2022/5/3 17:37
+     */
+    @Override
+    public String findVideoInfoPool(String identificationCode, Integer type, String order, String crudT) throws IllegalAccessException {
+        if ("2".equals(crudT)) {
+            //更新
+            if (StringUtils.isEmpty(identificationCode) || null == type) {
+                return "identificationCode和type不能为空";
+            }
+            videoInfoPoolMapper.updateTypeByCode(identificationCode, type);
+            return "success";
+        }
+        if ("3".equals(crudT)) {
+            //删除
+            if (StringUtils.isEmpty(identificationCode)) {
+                return "dentificationCode不能为空";
+            }
+            videoInfoPoolMapper.delByCode(identificationCode);
+            return "success";
+        }
+
+        List<VideoInfoPool> videoInfoPoolList = videoInfoPoolMapper.findByCodeAndType(identificationCode, type, order);
+
+        StringBuffer sb = new StringBuffer("total:".concat(String.valueOf(videoInfoPoolList.size())).concat("<br/>"));
+        for (VideoInfoPool videoInfoPool : videoInfoPoolList) {
+            sb.append("<table border=\"1\" cellspacing=\"0\"><tr><th>key</th><th>value</th></tr>");
+
+            Field[] fields = videoInfoPool.getClass().getDeclaredFields();
+            for (Field field : fields) {
+                field.setAccessible(true);
+                sb.append("<tr>");
+                sb.append("<td>").append(field.getName()).append("</td>");
+                sb.append("<td>").append(field.get(videoInfoPool)).append("</td>");
+                sb.append("</tr>");
+            }
+            sb.append("</table>");
+        }
+
+        return sb.toString();
+    }
+
+    /**
+     * findVideoInfo
+     *
+     * @author lvzhiqiang
+     * 2022/5/3 17:37
+     */
+    @Override
+    public String findVideoInfo(String identificationCode, Integer type, String order, String crudT) throws IllegalAccessException {
+        if ("3".equals(crudT)) {
+            //删除
+            if (StringUtils.isEmpty(identificationCode)) {
+                return "dentificationCode不能为空";
+            }
+            videoInfoMapper.delByCode(identificationCode);
+            return "success";
+        }
+
+        List<VideoInfo> videoInfoList = videoInfoMapper.findByCodeAndType(identificationCode, type, order);
+
+        StringBuffer sb = new StringBuffer("total:".concat(String.valueOf(videoInfoList.size())).concat("<br/>"));
+        for (VideoInfo videoInfo : videoInfoList) {
+            sb.append("<table border=\"1\" cellspacing=\"0\"><tr><th>key</th><th>value</th></tr>");
+
+            Field[] fields = videoInfo.getClass().getDeclaredFields();
+            for (Field field : fields) {
+                field.setAccessible(true);
+                sb.append("<tr>");
+                sb.append("<td>").append(field.getName()).append("</td>");
+                sb.append("<td>").append(field.get(videoInfo)).append("</td>");
+                sb.append("</tr>");
+            }
+            sb.append("</table>");
+        }
+
+        return sb.toString();
+    }
 
     /**
      * 初始化骑兵数据
@@ -335,7 +504,7 @@ public class BgServiceImpl implements BgService {
         if (imgUrlBytes.length > 251) {
             byte[] imgUrlDestBytes = new byte[251];
             System.arraycopy(imgUrlBytes, 0, imgUrlDestBytes, 0, 251);
-            fileName = new String(imgUrlDestBytes, StandardCharsets.UTF_8).replace("�","");
+            fileName = new String(imgUrlDestBytes, StandardCharsets.UTF_8).replace("�", "");
         }
         fileName = fileName.concat(".jpg");
 

+ 76 - 2
src/main/resources/static/bg.html

@@ -10,7 +10,7 @@
     }
 
     .dynamic_hide {
-        display: block;
+        display: none;
     }
 </style>
 <script type="text/javascript">
@@ -25,9 +25,83 @@
     }
 </script>
 <body>
+<span>Hello <font id="myc" style="cursor: pointer;" onclick="show()">W</font>orld!</span>
 <div id="my" class="dynamic_hide">
+    <hr/>
     <div style="margin-right:20px;">
-        <span class="font">initQibingData</span></del>
+        <span class="font">findDicCode</span>
+        <form method="post" action="bg/findDicCode">
+            <span>codeDesc</span>
+            <input type="text" name="codeDesc" placeholder="可为空"/>
+            <span>order</span>
+            <input type="text" name="order" placeholder="ass|desc,可为空"/>
+            <input type="submit" value="提交">
+        </form>
+    </div>
+    <br/>
+    <div style="margin-right:20px;">
+        <span class="font">findIcodePool</span>
+        <form method="post" action="bg/findIcodePool">
+            <span>identificationCode</span>
+            <input type="text" name="identificationCode" placeholder="识别码,可为空"/>
+            <span>status</span>
+            <input type="text" name="status" placeholder="状态(1:待爬取,2:爬取成功,3:爬取失败,4:主表已存在),可为空" style="width: 450px;"/>
+            <span>order</span>
+            <input type="text" name="order" placeholder="ass|desc,可为空"/>
+            <input type="submit" value="提交">
+        </form>
+    </div>
+    <br/>
+    <div style="margin-right:20px;">
+        <span class="font">findVideoSitePool</span>
+        <form method="post" action="bg/findVideoSitePool">
+            <span>url</span>
+            <input type="text" name="url" placeholder="可为空"/>
+            <span>order</span>
+            <input type="text" name="order" placeholder="ass|desc,可为空"/>
+            <input type="submit" value="提交">
+        </form>
+    </div>
+    <br/>
+    <div style="margin-right:20px;">
+        <span class="font">findVideoInfoPool</span>
+        <form method="post" action="bg/findVideoInfoPool">
+            <span>identificationCode</span>
+            <input type="text" name="identificationCode" placeholder="识别码,可为空"/>
+            <span>type</span>
+            <input type="text" name="type" placeholder="类型{1:待审查,2:审查中,3:审查已通过,4:审查未通过},可为空" style="width: 430px;"/>
+            <span>order</span>
+            <input type="text" name="order" placeholder="ass|desc,可为空"/>
+            <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">findVideoInfo</span>
+        <form method="post" action="bg/findVideoInfo">
+            <span>identificationCode</span>
+            <input type="text" name="identificationCode" placeholder="识别码,可为空"/>
+            <span>type</span>
+            <input type="text" name="type" placeholder="类型{1:骑兵,2:步兵,3:流出},可为空" style="width: 270px;"/>
+            <span>order</span>
+            <input type="text" name="order" placeholder="ass|desc,可为空"/>
+            <span>crudT</span>
+            <select name="crudT" style="height: 21.43px;">
+                <option value="1">查询</option>
+                <option value="3">删除</option>
+            </select>
+            <input type="submit" value="提交">
+        </form>
+    </div>
+    <hr/>
+    <div style="margin-right:20px;">
+        <span class="font">initQibingData</span>
         <form method="post" action="bg/initQibingData">
             <input type="submit" value="提交">
         </form>