Просмотр исходного кода

update:findIcodePool支持更新和删除v1

tujidelv 2 лет назад
Родитель
Сommit
330fc3f68f

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

@@ -224,12 +224,16 @@ public class BgController {
      */
     @RequestMapping("/findIcodePool")
     @ResponseBody
-    public String findIcodePool(String identificationCode, Integer status, String order) throws IllegalAccessException {
+    public String findIcodePool(String identificationCode, Integer status, String order, String crudT) throws IllegalAccessException {
         if (StringUtils.isNotEmpty(identificationCode)) {
             identificationCode = identificationCode.toUpperCase();
         }
 
-        return bgService.findIcodePool(identificationCode, status, order);
+        if (StringUtils.isEmpty(crudT)) {
+            crudT = "1";
+        }
+
+        return bgService.findIcodePool(identificationCode, status, order, crudT);
     }
 
     /**

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

@@ -86,4 +86,10 @@ public interface IcodePoolMapper {
             "</if>" +
             "</script>"})
     List<IcodePool> findByCodeAndStatus(String identificationCode, Integer status, String order);
+
+    @Update("update icode_pool set status = #{status},modify_time = now() where identification_code = #{identificationCode}")
+    void updateStatusByCode(String identificationCode, Integer status);
+
+    @Update("update icode_pool set delete_flag = 2,modify_time = now() where identification_code = #{identificationCode}")
+    void delByCode(String identificationCode);
 }

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

@@ -51,7 +51,7 @@ public interface BgService {
      * @author lvzhiqiang
      * 2022/5/3 17:37
      */
-    String findIcodePool(String identificationCode, Integer status, String order) throws IllegalAccessException;
+    String findIcodePool(String identificationCode, Integer status, String order, String crudT) throws IllegalAccessException;
 
     /**
      * findVideoSitePool

+ 19 - 2
src/main/java/top/lvzhiqiang/service/impl/BgServiceImpl.java

@@ -114,7 +114,24 @@ public class BgServiceImpl implements BgService {
      * 2022/5/3 17:37
      */
     @Override
-    public String findIcodePool(String identificationCode, Integer status, String order) throws IllegalAccessException {
+    public String findIcodePool(String identificationCode, Integer status, String order, String crudT) throws IllegalAccessException {
+        if ("2".equals(crudT)) {
+            //更新
+            if (StringUtils.isEmpty(identificationCode) || null == status) {
+                return "identificationCode和status不能为空";
+            }
+            icodePoolMapper.updateStatusByCode(identificationCode, status);
+            return "success";
+        }
+        if ("3".equals(crudT)) {
+            //删除
+            if (StringUtils.isEmpty(identificationCode)) {
+                return "dentificationCode不能为空";
+            }
+            icodePoolMapper.delByCode(identificationCode);
+            return "success";
+        }
+
         List<IcodePool> icodePoolList = icodePoolMapper.findByCodeAndStatus(identificationCode, status, order);
 
         StringBuffer sb = new StringBuffer("total:".concat(String.valueOf(icodePoolList.size())).concat("<br/>"));
@@ -878,7 +895,7 @@ public class BgServiceImpl implements BgService {
         }
 
         // 名称
-        String h3 = container.select("h3").first().text();
+        String h3 = container.select("h3").first().text().replace("/", "");
         String[] nameArr = h3.split("\\s+");
         if (nameArr.length > 1) {
             videoInfoPool.setName(h3.substring(nameArr[0].length()).trim());

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

@@ -48,6 +48,11 @@
             <input type="text" name="status" placeholder="状态(1:待爬取,2:爬取成功,3:爬取失败,4:主表已存在),可为空" style="width: 450px;"/>
             <span>order</span>
             <input type="text" name="order" placeholder="ass|desc,可为空"/>
+            <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>