'}
, {field: 'pubDate', title: '发布时间',}
, {field: 'thumbnail', title: '封面', templet: '
'}
, {field: 'title', title: 'magnet', templet: '
'}
From 9d391ea369ce4bdd4643e567930b1bb51c23042c Mon Sep 17 00:00:00 2001
From: Yutousama <583819556@qq.com>
Date: Sun, 10 Jul 2022 14:31:07 +0800
Subject: [PATCH 02/16] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BE=9D=E8=B5=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 20 +++++++++----------
.../yutou/tools/AuthConfig/AuthConfig.java | 2 +-
.../AuthConfig/RoleAccessDecisionManager.java | 6 +++---
.../java/com/yutou/tools/BiliBili/Live.java | 7 ++++---
.../tools/Tools/AuthManagerController.java | 8 ++++----
.../yutou/tools/Tools/PasswordManager.java | 9 +++++----
.../tools/bangumi/AnimMetaController.java | 4 ++--
.../tools/bangumi/AnimationController.java | 11 +++++-----
.../yutou/tools/bangumi/AnimationData.java | 4 ++--
.../java/com/yutou/tools/nas/NasManager.java | 7 ++++---
.../java/com/yutou/tools/nas/UpdateIp.java | 2 +-
.../java/com/yutou/tools/other/tools.java | 4 ++--
.../yutou/tools/sqlite/ADSQLiteManager.java | 4 ++--
.../com/yutou/tools/sqlite/SQLiteManager.java | 4 ++--
.../java/com/yutou/tools/utils/APIFilter.java | 6 +++---
.../yutou/tools/utils/BiliBiliLiveTools.java | 4 ++--
.../com/yutou/tools/utils/ConfigTools.java | 2 +-
.../java/com/yutou/tools/utils/HttpTools.java | 2 +-
.../yutou/tools/utils/NasDepotManager.java | 9 +++++----
.../com/yutou/tools/utils/RedisTools.java | 2 +-
.../java/com/yutou/tools/utils/Tools.java | 4 ++--
.../com/yutou/tools/web/userController.java | 4 ++--
.../yutou/tools/ToolsApplicationTests.java | 2 +-
23 files changed, 66 insertions(+), 61 deletions(-)
diff --git a/pom.xml b/pom.xml
index e2fd69e..8c32008 100644
--- a/pom.xml
+++ b/pom.xml
@@ -47,19 +47,19 @@
org.springframework.boot
spring-boot-starter-web
- RELEASE
+ 2.7.0
compile
redis.clients
jedis
- 3.6.3
+ 4.2.3
org.springframework.data
spring-data-redis
- 2.2.5.RELEASE
+ 2.7.0
mysql
@@ -69,20 +69,20 @@
org.mybatis.spring.boot
mybatis-spring-boot-starter
- 2.2.0
+ 2.2.2
org.projectlombok
lombok
- 1.18.22
+ 1.18.24
provided
- com.alibaba
- fastjson
- 1.2.79
+ com.alibaba.fastjson2
+ fastjson2
+ 2.0.8
@@ -93,13 +93,13 @@
com.aliyun.oss
aliyun-sdk-oss
- 3.13.2
+ 3.15.0
org.xerial
sqlite-jdbc
- 3.36.0.2
+ 3.36.0.3
diff --git a/src/main/java/com/yutou/tools/AuthConfig/AuthConfig.java b/src/main/java/com/yutou/tools/AuthConfig/AuthConfig.java
index fc085cf..d46db6e 100644
--- a/src/main/java/com/yutou/tools/AuthConfig/AuthConfig.java
+++ b/src/main/java/com/yutou/tools/AuthConfig/AuthConfig.java
@@ -1,6 +1,6 @@
package com.yutou.tools.AuthConfig;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSONObject;
import com.yutou.tools.mybatis.dao.PermissionDao;
import com.yutou.tools.mybatis.dao.UKeyDao;
import org.springframework.context.annotation.Configuration;
diff --git a/src/main/java/com/yutou/tools/AuthConfig/RoleAccessDecisionManager.java b/src/main/java/com/yutou/tools/AuthConfig/RoleAccessDecisionManager.java
index 81df89c..f0d1e35 100644
--- a/src/main/java/com/yutou/tools/AuthConfig/RoleAccessDecisionManager.java
+++ b/src/main/java/com/yutou/tools/AuthConfig/RoleAccessDecisionManager.java
@@ -1,6 +1,6 @@
package com.yutou.tools.AuthConfig;
-import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson2.JSONArray;
import com.yutou.tools.mybatis.dao.PermissionDao;
import com.yutou.tools.mybatis.dao.UKeyDao;
import com.yutou.tools.mybatis.model.Permission;
@@ -79,14 +79,14 @@ public class RoleAccessDecisionManager implements AccessDecisionManager {
}
UKey key = list.get(0);
JSONArray powers = JSONArray.parseArray(key.getPower());
- if(powers.toJavaList(String.class).contains("-1")){
+ if(powers.toList(String.class).contains("-1")){
return;
}
PermissionExample pExample = new PermissionExample();
pExample.createCriteria().andUrlEqualTo(url);
List permissions = permissionDao.selectByExample(pExample);
if (!permissions.isEmpty()) {
- if (!powers.toJavaList(String.class).contains(permissions.get(0).getId()+"")) {
+ if (!powers.toList(String.class).contains(permissions.get(0).getId()+"")) {
System.out.println("111111");
error();
}else{
diff --git a/src/main/java/com/yutou/tools/BiliBili/Live.java b/src/main/java/com/yutou/tools/BiliBili/Live.java
index 3cd8456..af5c572 100644
--- a/src/main/java/com/yutou/tools/BiliBili/Live.java
+++ b/src/main/java/com/yutou/tools/BiliBili/Live.java
@@ -1,7 +1,8 @@
package com.yutou.tools.BiliBili;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
import com.yutou.tools.mybatis.dao.BilibiliLiveDao;
import com.yutou.tools.mybatis.model.BilibiliLive;
import com.yutou.tools.mybatis.model.BilibiliLiveExample;
@@ -54,7 +55,7 @@ public class Live {
JSONObject json=new JSONObject();
json.put("code",0);
json.put("msg","ok");
- json.put("data",JSONArray.toJSON(list));
+ json.put("data", JSON.toJSON(list));
return json.toJSONString();
}
@ResponseBody
diff --git a/src/main/java/com/yutou/tools/Tools/AuthManagerController.java b/src/main/java/com/yutou/tools/Tools/AuthManagerController.java
index 7d94e94..eda8576 100644
--- a/src/main/java/com/yutou/tools/Tools/AuthManagerController.java
+++ b/src/main/java/com/yutou/tools/Tools/AuthManagerController.java
@@ -1,8 +1,8 @@
package com.yutou.tools.Tools;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
import com.yutou.tools.mybatis.dao.PermissionDao;
import com.yutou.tools.mybatis.dao.UKeyDao;
import com.yutou.tools.mybatis.model.Permission;
@@ -66,7 +66,7 @@ public class AuthManagerController {
admin.put("disabled", "");
admin.put("checked", "");
allPermission.add(admin);
- List list = powers.toJavaList(String.class);
+ List list = powers.toList(String.class);
if (list.contains("-1")) {
userPermission.add("-1");
}
diff --git a/src/main/java/com/yutou/tools/Tools/PasswordManager.java b/src/main/java/com/yutou/tools/Tools/PasswordManager.java
index e7f2526..f2adbe2 100644
--- a/src/main/java/com/yutou/tools/Tools/PasswordManager.java
+++ b/src/main/java/com/yutou/tools/Tools/PasswordManager.java
@@ -1,7 +1,8 @@
package com.yutou.tools.Tools;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
import com.yutou.tools.mybatis.dao.ToolsPasswordDao;
import com.yutou.tools.mybatis.dao.ToolsPasswordTypeDao;
import com.yutou.tools.mybatis.model.ToolsPassword;
@@ -45,7 +46,7 @@ public class PasswordManager {
}
json.put("code",0);
json.put("msg","ok");
- json.put("data", JSONArray.toJSON(passwords));
+ json.put("data", JSON.toJSON(passwords));
return json.toJSONString();
}
@ResponseBody
@@ -100,7 +101,7 @@ public class PasswordManager {
List toolsPasswordTypes=passwordTypeDao.selectByExample(example);
json.put("code",0);
json.put("msg","ok");
- json.put("data", JSONArray.toJSON(toolsPasswordTypes));
+ json.put("data", JSON.toJSON(toolsPasswordTypes));
return json.toJSONString();
}
@ResponseBody
diff --git a/src/main/java/com/yutou/tools/bangumi/AnimMetaController.java b/src/main/java/com/yutou/tools/bangumi/AnimMetaController.java
index 42081fd..b6e7693 100644
--- a/src/main/java/com/yutou/tools/bangumi/AnimMetaController.java
+++ b/src/main/java/com/yutou/tools/bangumi/AnimMetaController.java
@@ -1,7 +1,7 @@
package com.yutou.tools.bangumi;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
import com.yutou.tools.nas.UpdateIp;
import com.yutou.tools.utils.HttpTools;
import org.springframework.stereotype.Controller;
diff --git a/src/main/java/com/yutou/tools/bangumi/AnimationController.java b/src/main/java/com/yutou/tools/bangumi/AnimationController.java
index e578fa2..1403925 100644
--- a/src/main/java/com/yutou/tools/bangumi/AnimationController.java
+++ b/src/main/java/com/yutou/tools/bangumi/AnimationController.java
@@ -1,7 +1,8 @@
package com.yutou.tools.bangumi;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
import com.yutou.tools.mybatis.dao.BangumiItemDao;
import com.yutou.tools.mybatis.dao.BangumiListDao;
import com.yutou.tools.mybatis.model.BangumiItem;
@@ -70,7 +71,7 @@ public class AnimationController {
JSONObject json = new JSONObject();
json.put("code", 0);
json.put("msg", "ok");
- json.put("data", JSONArray.toJSON(listDao.selectByExample(new BangumiListExample())));
+ json.put("data", JSON.toJSON(listDao.selectByExample(new BangumiListExample())));
return json.toJSONString();
}
@ResponseBody
@@ -111,7 +112,7 @@ public class AnimationController {
example.createCriteria().andBidEqualTo(type);
json.put("code", 0);
json.put("msg", "ok");
- json.put("data", JSONArray.toJSON(itemDao.selectByExample(example)));
+ json.put("data", JSON.toJSON(itemDao.selectByExample(example)));
return json.toJSONString();
}
@ResponseBody
@@ -161,7 +162,7 @@ public class AnimationController {
item.setCategories(animationData.nameToValue(item.getCategories(),false)+"");
item.setAuthor(animationData.nameToValue(item.getAuthor(),true)+"");
}
- JSONArray array= (JSONArray) JSONArray.toJSON(list);
+ JSONArray array= (JSONArray) JSON.toJSON(list);
return array.toJSONString();
}
}
diff --git a/src/main/java/com/yutou/tools/bangumi/AnimationData.java b/src/main/java/com/yutou/tools/bangumi/AnimationData.java
index 957621d..d742f29 100644
--- a/src/main/java/com/yutou/tools/bangumi/AnimationData.java
+++ b/src/main/java/com/yutou/tools/bangumi/AnimationData.java
@@ -1,7 +1,7 @@
package com.yutou.tools.bangumi;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
import com.yutou.tools.utils.HttpTools;
import java.net.URLEncoder;
diff --git a/src/main/java/com/yutou/tools/nas/NasManager.java b/src/main/java/com/yutou/tools/nas/NasManager.java
index 093ace4..c81fbe4 100644
--- a/src/main/java/com/yutou/tools/nas/NasManager.java
+++ b/src/main/java/com/yutou/tools/nas/NasManager.java
@@ -1,7 +1,8 @@
package com.yutou.tools.nas;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
import com.yutou.tools.mybatis.dao.NasAdminAddressDao;
import com.yutou.tools.mybatis.model.NasAdminAddress;
import com.yutou.tools.mybatis.model.NasAdminAddressExample;
@@ -66,7 +67,7 @@ public class NasManager {
if (list.size() == 0) {
json.put("data", new JSONArray());
} else {
- json.put("data", JSONArray.toJSON(list));
+ json.put("data", JSON.toJSON(list));
}
} catch (Exception e) {
e.printStackTrace();
diff --git a/src/main/java/com/yutou/tools/nas/UpdateIp.java b/src/main/java/com/yutou/tools/nas/UpdateIp.java
index d64f80f..c4fa740 100644
--- a/src/main/java/com/yutou/tools/nas/UpdateIp.java
+++ b/src/main/java/com/yutou/tools/nas/UpdateIp.java
@@ -1,6 +1,6 @@
package com.yutou.tools.nas;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSONObject;
import com.yutou.tools.utils.ConfigTools;
import com.yutou.tools.utils.RedisTools;
import com.yutou.tools.utils.Tools;
diff --git a/src/main/java/com/yutou/tools/other/tools.java b/src/main/java/com/yutou/tools/other/tools.java
index f495e23..260a4e3 100644
--- a/src/main/java/com/yutou/tools/other/tools.java
+++ b/src/main/java/com/yutou/tools/other/tools.java
@@ -1,7 +1,7 @@
package com.yutou.tools.other;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
import com.yutou.tools.ToolsApplication;
import com.yutou.tools.mybatis.dao.UKeyDao;
import com.yutou.tools.mybatis.model.UKey;
diff --git a/src/main/java/com/yutou/tools/sqlite/ADSQLiteManager.java b/src/main/java/com/yutou/tools/sqlite/ADSQLiteManager.java
index 77687f3..1f8bd4f 100644
--- a/src/main/java/com/yutou/tools/sqlite/ADSQLiteManager.java
+++ b/src/main/java/com/yutou/tools/sqlite/ADSQLiteManager.java
@@ -1,7 +1,7 @@
package com.yutou.tools.sqlite;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
import java.sql.ResultSet;
import java.sql.SQLException;
diff --git a/src/main/java/com/yutou/tools/sqlite/SQLiteManager.java b/src/main/java/com/yutou/tools/sqlite/SQLiteManager.java
index 844dafa..2670971 100644
--- a/src/main/java/com/yutou/tools/sqlite/SQLiteManager.java
+++ b/src/main/java/com/yutou/tools/sqlite/SQLiteManager.java
@@ -1,7 +1,7 @@
package com.yutou.tools.sqlite;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
import com.yutou.tools.utils.ConfigTools;
import java.io.File;
diff --git a/src/main/java/com/yutou/tools/utils/APIFilter.java b/src/main/java/com/yutou/tools/utils/APIFilter.java
index 3d3510a..65b8c8b 100644
--- a/src/main/java/com/yutou/tools/utils/APIFilter.java
+++ b/src/main/java/com/yutou/tools/utils/APIFilter.java
@@ -1,6 +1,6 @@
package com.yutou.tools.utils;
-import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson2.JSONArray;
import com.yutou.tools.mybatis.dao.PermissionDao;
import com.yutou.tools.mybatis.dao.UKeyDao;
import com.yutou.tools.mybatis.model.Permission;
@@ -62,14 +62,14 @@ public class APIFilter implements Filter {
UKey key = list.get(0);
JSONArray powers = JSONArray.parseArray(key.getPower());
- if(powers.toJavaList(String.class).contains("-1")){
+ if(powers.toList(String.class).contains("-1")){
isToken=true;
}else {
PermissionExample pExample = new PermissionExample();
pExample.createCriteria().andUrlEqualTo(url);
List permissions = permissionDao.selectByExample(pExample);
if (permissions != null && permissions.size() > 0) {
- if (powers.toJavaList(String.class).contains(permissions.get(0).getId()+"")) {
+ if (powers.toList(String.class).contains(permissions.get(0).getId()+"")) {
isToken = true;
}
}
diff --git a/src/main/java/com/yutou/tools/utils/BiliBiliLiveTools.java b/src/main/java/com/yutou/tools/utils/BiliBiliLiveTools.java
index 7a8d2d8..0ae5e13 100644
--- a/src/main/java/com/yutou/tools/utils/BiliBiliLiveTools.java
+++ b/src/main/java/com/yutou/tools/utils/BiliBiliLiveTools.java
@@ -1,7 +1,7 @@
package com.yutou.tools.utils;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONObject;
import javax.net.ssl.HttpsURLConnection;
import java.io.BufferedReader;
diff --git a/src/main/java/com/yutou/tools/utils/ConfigTools.java b/src/main/java/com/yutou/tools/utils/ConfigTools.java
index f5b5d41..607cae8 100644
--- a/src/main/java/com/yutou/tools/utils/ConfigTools.java
+++ b/src/main/java/com/yutou/tools/utils/ConfigTools.java
@@ -1,6 +1,6 @@
package com.yutou.tools.utils;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSONObject;
import java.io.*;
diff --git a/src/main/java/com/yutou/tools/utils/HttpTools.java b/src/main/java/com/yutou/tools/utils/HttpTools.java
index ad8e603..969abf3 100644
--- a/src/main/java/com/yutou/tools/utils/HttpTools.java
+++ b/src/main/java/com/yutou/tools/utils/HttpTools.java
@@ -1,6 +1,6 @@
package com.yutou.tools.utils;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSONObject;
import com.yutou.tools.interfaces.DownloadInterface;
import org.springframework.util.StringUtils;
diff --git a/src/main/java/com/yutou/tools/utils/NasDepotManager.java b/src/main/java/com/yutou/tools/utils/NasDepotManager.java
index e2525ca..2a4b3b8 100644
--- a/src/main/java/com/yutou/tools/utils/NasDepotManager.java
+++ b/src/main/java/com/yutou/tools/utils/NasDepotManager.java
@@ -1,7 +1,8 @@
package com.yutou.tools.utils;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@@ -26,7 +27,7 @@ public class NasDepotManager {
json.put("code",1);
json.put("msg","添加成功");
}
- json.put("data", JSONArray.toJSON(RedisTools.list_get(DEPOT_NAME)));
+ json.put("data", JSON.toJSON(RedisTools.list_get(DEPOT_NAME)));
return json;
}
@@ -36,7 +37,7 @@ public class NasDepotManager {
JSONObject json=new JSONObject();
json.put("code",1);
json.put("msg","ok");
- json.put("data", JSONArray.toJSON(RedisTools.list_get(DEPOT_NAME)));
+ json.put("data", JSON.toJSON(RedisTools.list_get(DEPOT_NAME)));
return json;
}
@ResponseBody
diff --git a/src/main/java/com/yutou/tools/utils/RedisTools.java b/src/main/java/com/yutou/tools/utils/RedisTools.java
index 2079331..78b763f 100644
--- a/src/main/java/com/yutou/tools/utils/RedisTools.java
+++ b/src/main/java/com/yutou/tools/utils/RedisTools.java
@@ -8,7 +8,7 @@ import java.util.HashSet;
import java.util.Properties;
import java.util.Set;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSONObject;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
diff --git a/src/main/java/com/yutou/tools/utils/Tools.java b/src/main/java/com/yutou/tools/utils/Tools.java
index bd435c7..202c10e 100644
--- a/src/main/java/com/yutou/tools/utils/Tools.java
+++ b/src/main/java/com/yutou/tools/utils/Tools.java
@@ -1,7 +1,7 @@
package com.yutou.tools.utils;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
import com.yutou.tools.interfaces.DownloadInterface;
import com.yutou.tools.nas.UpdateIp;
import org.apache.commons.codec.digest.DigestUtils;
diff --git a/src/main/java/com/yutou/tools/web/userController.java b/src/main/java/com/yutou/tools/web/userController.java
index 37ee2e1..107cb83 100644
--- a/src/main/java/com/yutou/tools/web/userController.java
+++ b/src/main/java/com/yutou/tools/web/userController.java
@@ -1,7 +1,7 @@
package com.yutou.tools.web;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
import com.yutou.tools.Tools.GoogleAccount;
import com.yutou.tools.utils.ConfigTools;
import com.yutou.tools.utils.RedisTools;
diff --git a/src/test/java/com/yutou/tools/ToolsApplicationTests.java b/src/test/java/com/yutou/tools/ToolsApplicationTests.java
index 4010c95..2d942d0 100644
--- a/src/test/java/com/yutou/tools/ToolsApplicationTests.java
+++ b/src/test/java/com/yutou/tools/ToolsApplicationTests.java
@@ -1,6 +1,6 @@
package com.yutou.tools;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSONObject;
import com.yutou.tools.Tools.AuthManagerController;
import com.yutou.tools.utils.Tools;
import org.junit.jupiter.api.Test;
From fe7f7997a8d3ff32881e018d6c9d5031d4a1b697 Mon Sep 17 00:00:00 2001
From: Yutousama <583819556@qq.com>
Date: Sun, 10 Jul 2022 14:56:05 +0800
Subject: [PATCH 03/16] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BE=9D=E8=B5=96=20?=
=?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=B7=A8=E5=9F=9F=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 10 +++++-----
src/main/java/com/yutou/tools/nas/NasManager.java | 2 +-
src/main/java/com/yutou/tools/utils/CorsConfig.java | 2 +-
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/pom.xml b/pom.xml
index 8c32008..7d64ed3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
org.springframework.boot
spring-boot-starter-parent
- 2.2.4.RELEASE
+ 2.7.1
com.yutou
@@ -47,7 +47,7 @@
org.springframework.boot
spring-boot-starter-web
- 2.7.0
+ 2.7.1
compile
@@ -56,11 +56,11 @@
jedis
4.2.3
-
+
mysql
mysql-connector-java
diff --git a/src/main/java/com/yutou/tools/nas/NasManager.java b/src/main/java/com/yutou/tools/nas/NasManager.java
index c81fbe4..da53799 100644
--- a/src/main/java/com/yutou/tools/nas/NasManager.java
+++ b/src/main/java/com/yutou/tools/nas/NasManager.java
@@ -303,7 +303,7 @@ public class NasManager {
e.printStackTrace();
}
}
- @RequestMapping("/nas/door/{*.ts}")
+ @RequestMapping("/nas/door/*.ts")
public void getDoorCCTVOfTs(HttpServletResponse response, HttpServletRequest request, @PathVariable("*.ts") String name){
try {
if(!name.endsWith(".ts")){
diff --git a/src/main/java/com/yutou/tools/utils/CorsConfig.java b/src/main/java/com/yutou/tools/utils/CorsConfig.java
index 6d93f51..04f0e79 100644
--- a/src/main/java/com/yutou/tools/utils/CorsConfig.java
+++ b/src/main/java/com/yutou/tools/utils/CorsConfig.java
@@ -11,7 +11,7 @@ public class CorsConfig implements WebMvcConfigurer {
//设置允许跨域的路径
registry.addMapping("/**")
//设置允许跨域请求的域名
- .allowedOrigins("*")
+ .allowedOrigins("Access-Control-Allow-Origin")
//是否允许证书 不再默认开启
.allowCredentials(true)
//设置允许的方法
From 6b8932c86f48c0e4336e2fd6eb3429b3f7751f13 Mon Sep 17 00:00:00 2001
From: Yutousama <583819556@qq.com>
Date: Sun, 10 Jul 2022 17:02:48 +0800
Subject: [PATCH 04/16] =?UTF-8?q?update:=E5=8A=A8=E7=94=BBrss=E7=95=8C?=
=?UTF-8?q?=E9=9D=A2=E6=96=B0=E5=A2=9E=E3=80=90=E7=95=AA=E5=89=A7=E8=AE=A1?=
=?UTF-8?q?=E5=88=92=E3=80=91=E5=85=A5=E5=8F=A3=EF=BC=8C=E4=BB=A5=E5=8F=8A?=
=?UTF-8?q?=E6=98=AF=E5=90=A6=E4=BB=8A=E6=97=A5=E6=9B=B4=E6=96=B0=E6=8F=90?=
=?UTF-8?q?=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../com/yutou/tools/ToolsApplication.java | 2 +-
.../tools/bangumi/AnimationController.java | 51 +--
.../tools/mybatis/model/BangumiItem.java | 4 +
.../mybatis/model/BangumiItemExample.java | 60 +++
.../tools/services/BangumiServiceImpl.java | 98 +++++
.../services/interfaces/BangumiService.java | 20 +
.../com/yutou/tools/utils/BangumiTools.java | 359 ++++++++++++++++++
.../java/com/yutou/tools/utils/Tools.java | 7 +
src/main/resources/mapper/BangumiItemDao.xml | 31 +-
web/html/body/nas/animMeta.html | 6 +-
web/html/body/nas/animrss.html | 43 ++-
11 files changed, 638 insertions(+), 43 deletions(-)
create mode 100644 src/main/java/com/yutou/tools/services/BangumiServiceImpl.java
create mode 100644 src/main/java/com/yutou/tools/services/interfaces/BangumiService.java
create mode 100644 src/main/java/com/yutou/tools/utils/BangumiTools.java
diff --git a/src/main/java/com/yutou/tools/ToolsApplication.java b/src/main/java/com/yutou/tools/ToolsApplication.java
index 6804134..6d228c5 100644
--- a/src/main/java/com/yutou/tools/ToolsApplication.java
+++ b/src/main/java/com/yutou/tools/ToolsApplication.java
@@ -6,7 +6,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ToolsApplication {
- public static final String version="1.4.5";
+ public static final String version="1.4.6";
public static void main(String[] args) {
System.out.println("当前版本号:" + version);
diff --git a/src/main/java/com/yutou/tools/bangumi/AnimationController.java b/src/main/java/com/yutou/tools/bangumi/AnimationController.java
index 1403925..ca92a21 100644
--- a/src/main/java/com/yutou/tools/bangumi/AnimationController.java
+++ b/src/main/java/com/yutou/tools/bangumi/AnimationController.java
@@ -9,6 +9,7 @@ import com.yutou.tools.mybatis.model.BangumiItem;
import com.yutou.tools.mybatis.model.BangumiItemExample;
import com.yutou.tools.mybatis.model.BangumiList;
import com.yutou.tools.mybatis.model.BangumiListExample;
+import com.yutou.tools.services.interfaces.BangumiService;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -17,13 +18,12 @@ import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.List;
+import java.util.Objects;
@Controller
public class AnimationController {
- @Resource
- BangumiListDao listDao;
- @Resource
- BangumiItemDao itemDao;
+ @Resource
+ BangumiService bangumiService;
@ResponseBody
@RequestMapping(value = "/anim/rss/data.do", method = RequestMethod.GET)
@@ -41,11 +41,7 @@ public class AnimationController {
items = new AnimationData().bangumiList(page,type,team, keys);
}
JSONObject json = new JSONObject();
- if (items != null) {
- json.put("data", items);
- } else {
- json.put("data", new JSONArray());
- }
+ json.put("data", Objects.requireNonNullElseGet(items, JSONArray::new));
json.put("count", 999);
json.put("code", 0);
json.put("msg", "ok");
@@ -58,7 +54,7 @@ public class AnimationController {
BangumiList bangumiList = new BangumiList();
bangumiList.setTitle(title);
bangumiList.setStatus(1);
- int i = listDao.insert(bangumiList);
+ int i = bangumiService.addBangumiList(bangumiList);
JSONObject json = new JSONObject();
json.put("code", 0);
json.put("msg", i == 0 ? "添加失败" : "添加成功");
@@ -71,16 +67,13 @@ public class AnimationController {
JSONObject json = new JSONObject();
json.put("code", 0);
json.put("msg", "ok");
- json.put("data", JSON.toJSON(listDao.selectByExample(new BangumiListExample())));
+ json.put("data", JSON.toJSON(bangumiService.getAllBangumiList()));
return json.toJSONString();
}
@ResponseBody
@RequestMapping(value = "/anim/type/del.do", method = RequestMethod.POST)
public String delType(int id){
- BangumiItemExample example=new BangumiItemExample();
- example.createCriteria().andBidEqualTo(id+"");
- itemDao.deleteByExample(example);
- int i=listDao.deleteByPrimaryKey(id);
+ int i=bangumiService.removeBangumiType(id);
JSONObject json=new JSONObject();
json.put("code", 0);
json.put("msg", i == 0 ? "删除失败" : "删除成功");
@@ -89,15 +82,22 @@ public class AnimationController {
@ResponseBody
@RequestMapping(value = "/anim/rss/add.do", method = RequestMethod.POST)
- public String addAnimationRss(String title, String author, String categories, String titleKey, String bid) {
+ public String addAnimationRss(String bgmId,String title, String author, String categories, String titleKey, String bid) {
+ int id=0;
+ if(!StringUtils.isEmpty(bgmId)){
+ try {
+ id=Integer.parseInt(bgmId.trim());
+ }catch (Exception ignored){}
+ }
BangumiItem item = new BangumiItem();
+ item.setBgmid(id);
item.setTitle(title);
item.setAuthor(author);
item.setCategories(categories);
item.setTitlekey(titleKey);
item.setBid(bid);
item.setEnable(1);
- int i = itemDao.insert(item);
+ int i = bangumiService.addBangumiItem(item);
JSONObject json = new JSONObject();
json.put("code", 0);
json.put("msg", i == 0 ? "添加失败" : "添加成功");
@@ -108,17 +108,15 @@ public class AnimationController {
@RequestMapping(value = "/anim/rss/list.do", method = RequestMethod.GET)
public String getAnimationRssList(String type) {
JSONObject json = new JSONObject();
- BangumiItemExample example=new BangumiItemExample();
- example.createCriteria().andBidEqualTo(type);
json.put("code", 0);
json.put("msg", "ok");
- json.put("data", JSON.toJSON(itemDao.selectByExample(example)));
+ json.put("data", JSON.toJSON(bangumiService.getBangumiItemList(type)));
return json.toJSONString();
}
@ResponseBody
@RequestMapping(value = "/anim/rss/del.do", method = RequestMethod.POST)
public String delAnimation(int id){
- int i=itemDao.deleteByPrimaryKey(id);
+ int i=bangumiService.removeBangumiItem(id);
JSONObject json=new JSONObject();
json.put("code", 0);
json.put("msg", i == 0 ? "删除失败" : "删除成功");
@@ -126,9 +124,12 @@ public class AnimationController {
}
@ResponseBody
@RequestMapping(value = "/anim/rss/edit.do",method = RequestMethod.POST)
- public JSONObject editAnimation(int id,String title, String author, String categories, String titleKey,String enable){
+ public JSONObject editAnimation(int id,int bgmId,String title, String author, String categories, String titleKey,String enable){
JSONObject json=new JSONObject();
- BangumiItem item =itemDao.selectByPrimaryKey(id);
+ BangumiItem item =bangumiService.getBangumiItem(id);
+ if(bgmId!=0){
+ item.setBgmid(bgmId);
+ }
if(!StringUtils.isEmpty(title)){
item.setTitle(title);
}
@@ -144,7 +145,7 @@ public class AnimationController {
if(!StringUtils.isEmpty(enable)){
item.setEnable(Integer.parseInt(enable));
}
- int i=itemDao.updateByPrimaryKey(item);
+ int i=bangumiService.updateBangumiItem(item);
if(i>0){
json.put("msg","操作成功");
}else{
@@ -157,7 +158,7 @@ public class AnimationController {
@RequestMapping(value = "/anim/client/get.do", method = RequestMethod.GET)
public String clientApi(){
AnimationData animationData=new AnimationData();
- List list=itemDao.selectByExample(new BangumiItemExample());
+ List list=bangumiService.getAllBangumiItemList();
for (BangumiItem item : list) {
item.setCategories(animationData.nameToValue(item.getCategories(),false)+"");
item.setAuthor(animationData.nameToValue(item.getAuthor(),true)+"");
diff --git a/src/main/java/com/yutou/tools/mybatis/model/BangumiItem.java b/src/main/java/com/yutou/tools/mybatis/model/BangumiItem.java
index c3d1137..0675e68 100644
--- a/src/main/java/com/yutou/tools/mybatis/model/BangumiItem.java
+++ b/src/main/java/com/yutou/tools/mybatis/model/BangumiItem.java
@@ -11,6 +11,8 @@ import lombok.Data;
public class BangumiItem implements Serializable {
private Integer id;
+ private Integer bgmid;
+
private String bid;
private String categories;
@@ -19,6 +21,8 @@ public class BangumiItem implements Serializable {
private String title;
+ private boolean isUpdate=false;
+
/**
* 标题过滤词
*/
diff --git a/src/main/java/com/yutou/tools/mybatis/model/BangumiItemExample.java b/src/main/java/com/yutou/tools/mybatis/model/BangumiItemExample.java
index c2b4d3f..ee4be26 100644
--- a/src/main/java/com/yutou/tools/mybatis/model/BangumiItemExample.java
+++ b/src/main/java/com/yutou/tools/mybatis/model/BangumiItemExample.java
@@ -164,6 +164,66 @@ public class BangumiItemExample {
return (Criteria) this;
}
+ public Criteria andBgmidIsNull() {
+ addCriterion("bgmId is null");
+ return (Criteria) this;
+ }
+
+ public Criteria andBgmidIsNotNull() {
+ addCriterion("bgmId is not null");
+ return (Criteria) this;
+ }
+
+ public Criteria andBgmidEqualTo(Integer value) {
+ addCriterion("bgmId =", value, "bgmid");
+ return (Criteria) this;
+ }
+
+ public Criteria andBgmidNotEqualTo(Integer value) {
+ addCriterion("bgmId <>", value, "bgmid");
+ return (Criteria) this;
+ }
+
+ public Criteria andBgmidGreaterThan(Integer value) {
+ addCriterion("bgmId >", value, "bgmid");
+ return (Criteria) this;
+ }
+
+ public Criteria andBgmidGreaterThanOrEqualTo(Integer value) {
+ addCriterion("bgmId >=", value, "bgmid");
+ return (Criteria) this;
+ }
+
+ public Criteria andBgmidLessThan(Integer value) {
+ addCriterion("bgmId <", value, "bgmid");
+ return (Criteria) this;
+ }
+
+ public Criteria andBgmidLessThanOrEqualTo(Integer value) {
+ addCriterion("bgmId <=", value, "bgmid");
+ return (Criteria) this;
+ }
+
+ public Criteria andBgmidIn(List values) {
+ addCriterion("bgmId in", values, "bgmid");
+ return (Criteria) this;
+ }
+
+ public Criteria andBgmidNotIn(List values) {
+ addCriterion("bgmId not in", values, "bgmid");
+ return (Criteria) this;
+ }
+
+ public Criteria andBgmidBetween(Integer value1, Integer value2) {
+ addCriterion("bgmId between", value1, value2, "bgmid");
+ return (Criteria) this;
+ }
+
+ public Criteria andBgmidNotBetween(Integer value1, Integer value2) {
+ addCriterion("bgmId not between", value1, value2, "bgmid");
+ return (Criteria) this;
+ }
+
public Criteria andBidIsNull() {
addCriterion("bid is null");
return (Criteria) this;
diff --git a/src/main/java/com/yutou/tools/services/BangumiServiceImpl.java b/src/main/java/com/yutou/tools/services/BangumiServiceImpl.java
new file mode 100644
index 0000000..f5dbcb2
--- /dev/null
+++ b/src/main/java/com/yutou/tools/services/BangumiServiceImpl.java
@@ -0,0 +1,98 @@
+package com.yutou.tools.services;
+
+import com.alibaba.fastjson2.JSONObject;
+import com.yutou.tools.mybatis.dao.BangumiItemDao;
+import com.yutou.tools.mybatis.dao.BangumiListDao;
+import com.yutou.tools.mybatis.model.BangumiItem;
+import com.yutou.tools.mybatis.model.BangumiItemExample;
+import com.yutou.tools.mybatis.model.BangumiList;
+import com.yutou.tools.mybatis.model.BangumiListExample;
+import com.yutou.tools.services.interfaces.BangumiService;
+import com.yutou.tools.utils.BangumiTools;
+import com.yutou.tools.utils.Tools;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@Service("BangumiService")
+public class BangumiServiceImpl implements BangumiService {
+ @Resource
+ BangumiListDao listDao;
+ @Resource
+ BangumiItemDao itemDao;
+
+ @Override
+ public int addBangumiList(BangumiList... list) {
+ for (BangumiList bangumiList : list) {
+ if (listDao.insert(bangumiList) <= 0) {
+ return 0;
+ }
+ }
+ return 1;
+ }
+
+ @Override
+ public int addBangumiItem(BangumiItem... list) {
+ for (BangumiItem item : list) {
+ if (itemDao.insert(item) <= 0) {
+ return 0;
+ }
+ }
+ return 1;
+ }
+
+ @Override
+ public int updateBangumiItem(BangumiItem item) {
+ return itemDao.updateByPrimaryKey(item);
+ }
+
+ @Override
+ public int removeBangumiItem(int id) {
+ return itemDao.deleteByPrimaryKey(id);
+ }
+
+ @Override
+ public int removeBangumiType(int id) {
+ BangumiItemExample example = new BangumiItemExample();
+ example.createCriteria().andBidEqualTo(id + "");
+ itemDao.deleteByExample(example);
+ return listDao.deleteByPrimaryKey(id);
+ }
+
+ @Override
+ public BangumiItem getBangumiItem(int id) {
+ return itemDao.selectByPrimaryKey(id);
+ }
+
+ @Override
+ public List getBangumiItemList(String type) {
+ BangumiItemExample example = new BangumiItemExample();
+ example.createCriteria().andBidEqualTo(type);
+ List items = itemDao.selectByExample(example);
+ for (BangumiItem item : items) {
+ if(item.getEnable()==0){
+ continue;
+ }
+ JSONObject bangumi=BangumiTools.getBangumiInfoSmall(item.getBgmid());
+ int day=Tools.getWeekDay();
+ if (day == 0) {
+ day = 7;
+ }
+ if(bangumi.getInteger("air_weekday")==day) {
+ item.setUpdate(true);
+ }
+ }
+ return items;
+ }
+
+ @Override
+ public List getAllBangumiItemList() {
+ return itemDao.selectByExample(new BangumiItemExample());
+ }
+
+ @Override
+ public List getAllBangumiList() {
+ return listDao.selectByExample(new BangumiListExample());
+ }
+}
diff --git a/src/main/java/com/yutou/tools/services/interfaces/BangumiService.java b/src/main/java/com/yutou/tools/services/interfaces/BangumiService.java
new file mode 100644
index 0000000..a904d4d
--- /dev/null
+++ b/src/main/java/com/yutou/tools/services/interfaces/BangumiService.java
@@ -0,0 +1,20 @@
+package com.yutou.tools.services.interfaces;
+
+import com.yutou.tools.mybatis.model.BangumiItem;
+import com.yutou.tools.mybatis.model.BangumiList;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+
+public interface BangumiService {
+ int addBangumiList(BangumiList... list);
+ int addBangumiItem(BangumiItem... list);
+ int updateBangumiItem(BangumiItem item);
+ int removeBangumiItem(int id);
+ int removeBangumiType(int id);
+ BangumiItem getBangumiItem(int id);
+ List getBangumiItemList(String type);
+ List getAllBangumiItemList();
+ List getAllBangumiList();
+}
diff --git a/src/main/java/com/yutou/tools/utils/BangumiTools.java b/src/main/java/com/yutou/tools/utils/BangumiTools.java
new file mode 100644
index 0000000..f47baa8
--- /dev/null
+++ b/src/main/java/com/yutou/tools/utils/BangumiTools.java
@@ -0,0 +1,359 @@
+package com.yutou.tools.utils;
+
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
+import com.aliyuncs.utils.StringUtils;
+
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+public class BangumiTools {
+ private static final String url = "https://api.bgm.tv/";
+ private static final String toDayBangumi = url + "calendar";
+ private static final String BangumiInfo = url + "subject/%s?responseGroup=large";
+
+ private static final String BangumiInfoSmall = url + "subject/%s?responseGroup=small";
+ private static final String SearchBangumi = url + "search/subject/%s?responseGroup=large&type=2";
+
+ /**
+ * 获取番剧列表
+ *
+ * @param day 周几,-1为全部,非1~7范围则为当天
+ * @return 当日数据
+ */
+ public static JSONObject getBangumi(int day) {
+ String str = HttpTools.get(toDayBangumi);
+ JSONArray main = JSON.parseArray(str);
+ if (day == -1) {
+ JSONObject json = new JSONObject();
+ json.put("bangumi", main);
+ return json;
+ }
+ if (day < 1 || day > 7) {
+ day=Tools.getWeekDay();
+ if (day == 0) {
+ day = 7;
+ }
+ }
+ if (main != null) {
+ for (Object o : main) {
+ JSONObject json = (JSONObject) o;
+ if (json.getJSONObject("weekday").getInteger("id") == day) {
+ return json;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * 获取番剧详细信息
+ *
+ * @param id 剧集id
+ * @return 详细信息
+ */
+ public static JSONObject getBangumiInfo(int id) {
+ String str = HttpTools.get(String.format(BangumiInfo, id + ""));
+ return JSON.parseObject(str);
+ }
+ /**
+ * 获取番剧简略信息
+ *
+ * @param id 剧集id
+ * @return 详细信息
+ */
+ public static JSONObject getBangumiInfoSmall(int id) {
+ String str = HttpTools.get(String.format(BangumiInfoSmall, id + ""));
+ return JSON.parseObject(str);
+ }
+
+ public static JSONArray getPeople(int id) {
+ /**
+ * Actor 演员
+ * Composer 作曲家
+ * Director 导演
+ * GuestStar 特邀明星
+ * Producer 制片人
+ * Writer 编剧
+ */
+ JSONArray people = new JSONArray();
+ JSONObject bangumi = getBangumiInfo(id);
+ JSONArray crt = bangumi.getJSONArray("crt");
+ if(crt!=null) {
+ for (Object o : crt) {
+ JSONObject item = (JSONObject) o;
+ JSONObject pel = new JSONObject();
+ pel.put("Name", item.getString("name_cn"));
+ pel.put("Role", item.getString("role_name"));
+ pel.put("Type", "Actor");
+ people.add(pel);
+ }
+ }
+ crt = bangumi.getJSONArray("staff");
+ if(crt!=null) {
+ for (Object o : crt) {
+ JSONObject item = (JSONObject) o;
+ JSONObject pel = new JSONObject();
+ pel.put("Name", item.getString("name_cn"));
+ String jobsName="";
+ for (Object _jobs : item.getJSONArray("jobs")) {
+ jobsName+=_jobs+"、";
+ }
+ jobsName=jobsName.substring(0,jobsName.length()-1);
+ pel.put("Role", jobsName);
+ pel.put("Type", "");
+ if (jobsName.contains("导演")) {
+ pel.put("Type", "Director");
+ } else if (jobsName.contains("脚本")) {
+ pel.put("Type", "DirectorDirector");
+ }
+ people.add(pel);
+ }
+ }
+ return people;
+ }
+
+ /**
+ * 搜索番剧
+ *
+ * @param key 关键词
+ * @return 详细信息
+ */
+ public static JSONObject search(String key) {
+ String str = HttpTools.get(String.format(SearchBangumi, URLEncoder.encode(key, StandardCharsets.UTF_8)));
+ return JSON.parseObject(str);
+ }
+
+ /**
+ * 获取下一集播放日期
+ *
+ * @param id 番剧id
+ * @return 日期
+ */
+ public static String getPlayNextTime(int id) {
+ JSONObject info = getBangumiInfo(id);
+ JSONArray eps = info.getJSONArray("eps");
+ String toDayTime = Tools.getToDayTime();
+ for (Object o : eps) {
+ JSONObject ep = (JSONObject) o;
+ String time = ep.getString("airdate");
+ try {
+ if (new SimpleDateFormat("yyyy-MM-dd").parse(time).getTime() >=
+ new SimpleDateFormat("yyyy-MM-dd").parse(toDayTime).getTime()) {
+ return time;
+ }
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ }
+ return null;
+ }
+
+ /**
+ * 格式化字符串输出番剧详细信息
+ *
+ * @param id 番剧id
+ * @return 详细内容
+ */
+ public static List reportBangumiInfo(int id) {
+ List bangumiList = new ArrayList<>();
+ JSONObject json = getBangumiInfo(id);
+ if (json.containsKey("code")) {
+ bangumiList.add("error = " + json.toJSONString());
+ return bangumiList;
+ }
+ JSONArray eps = json.getJSONArray("eps");
+ JSONArray crts = json.getJSONArray("crt");
+ JSONArray staffs = json.getJSONArray("staff");
+ StringBuilder builder = new StringBuilder();
+ builder.append("").append("\n");
+ builder.append("标题:").append(json.getString("name_cn")).append("\n");
+ builder.append("日文标题:").append(json.getString("name")).append("\n");
+ builder.append("首播时间:").append(json.getString("air_date")).append("\n");
+ builder.append("每周").append(json.getInteger("air_weekday")).append("放送").append("\n");
+ builder.append("Bangumi地址:").append(json.getString("url")).append("\n");
+ builder.append("Bangumi评分:").append(json.getJSONObject("rating").getFloat("score")).append("\n");
+ builder.append("预计放送集数:").append(json.getInteger("eps_count")).append("\n");
+ if (eps != null) {
+ builder.append("已放送集:").append("\n");
+ for (Object o : eps) {
+ JSONObject ep = (JSONObject) o;
+ if (ep.getString("status").equals("Air")) {
+ builder.append("· 第").append(ep.getInteger("sort")).append("话:");
+ builder.append(ep.getString("name"));
+ builder.append("[").append(ep.getString("name_cn")).append("]").append("\n");
+ builder.append("播放日期:").append(ep.getString("airdate")).append(";\n");
+ builder.append("播放时长:").append(ep.getString("duration")).append(";\n");
+ builder.append("单集介绍:").append(ep.getString("desc"));
+ builder.append("\n\n");
+ } else {
+ builder.append("下一话:");
+ builder.append(" 第").append(ep.getInteger("sort")).append("话:");
+ builder.append("播放日期:").append(ep.getString("airdate")).append("\n\n");
+ break;
+ }
+ }
+ }
+ if (crts != null) {
+ builder.append("角色介绍:").append("\n");
+ for (Object o : crts) {
+ JSONObject crt = (JSONObject) o;
+ JSONObject info = crt.getJSONObject("info");
+ builder.append(crt.getString("role_name")).append(":");
+ builder.append(crt.getString("name"));
+ builder.append("(").append(crt.getString("name_cn")).append(")").append(" ");
+ builder.append("CV:").append(crt.getJSONArray("actors").getJSONObject(0).getString("name"));
+ builder.append("(").append(info.getString("gender")).append(")");
+ builder.append("\n");
+ }
+ }
+ Map> map = new HashMap<>();
+ for (Object o : staffs) {
+ JSONObject staff = (JSONObject) o;
+ for (Object jobs : staff.getJSONArray("jobs")) {
+ String job = (String) jobs;
+ List list;
+ if (!map.containsKey(job)) {
+ list = new ArrayList<>();
+ } else {
+ list = map.get(job);
+ }
+ list.add(staff);
+ map.put(job, list);
+ }
+ }
+ if (!map.isEmpty()) {
+ builder.append("staff:").append("\n");
+ for (String key : map.keySet()) {
+ builder.append(key).append(":");
+ for (JSONObject staff : map.get(key)) {
+ builder.append(staff.getString("name_cn"));
+ builder.append("(").append(staff.getString("name")).append(")");
+ builder.append("、");
+ }
+ builder.append("\n");
+ }
+ }
+ bangumiList.add(builder.toString());
+ return bangumiList;
+ }
+
+ /**
+ * 格式化输出新番列表
+ *
+ * @return 新番信息
+ */
+ public static String reportBangumiList() {
+ try {
+ JSONObject json = getBangumi(-1);
+ StringBuilder builder = new StringBuilder();
+ assert json != null;
+ JSONArray array = json.getJSONArray("bangumi");
+ for (Object o : array) {
+ JSONObject data = (JSONObject) o;
+ JSONObject weekday = data.getJSONObject("weekday");
+ JSONArray items = data.getJSONArray("items");
+ builder.append(weekday.getString("cn")).append("(").append(weekday.getString("ja")).append(")");
+ builder.append(":").append("\n");
+ reportBangumi(builder, items, false);
+ builder.append("\n");
+ }
+ return builder.toString();
+ } catch (Exception e) {
+ e.printStackTrace();
+ return e.getMessage();
+ }
+ }
+
+ private static void reportBangumi(StringBuilder builder, JSONArray items, boolean reportEp) {
+ int epIndex = 0;
+ String epName = "N/A";
+ for (Object oj : items) {
+ JSONObject item = (JSONObject) oj;
+ builder.append("[").append(item.getInteger("id")).append("]");
+ builder.append(StringUtils.isEmpty(item.getString("name_cn"))
+ ? item.getString("name") : item.getString("name_cn"));
+ if (!reportEp) {
+ builder.append("\n");
+ continue;
+ }
+ JSONObject info = getBangumiInfo(item.getInteger("id"));
+ if (info.get("eps") == null) {
+ continue;
+ }
+ JSONArray eps = info.getJSONArray("eps");
+ for (Object oe : eps) {
+ JSONObject ep = (JSONObject) oe;
+ if (ep.getString("status").equals("Air")) {
+ epIndex = ep.getInteger("sort");
+ epName = ep.getString("name");
+ } else {
+ break;
+ }
+ }
+ builder.append(" 第").append(epIndex).append("话:");
+ builder.append(epName);
+ builder.append("\n");
+ }
+ }
+
+ /**
+ * 格式化字符串输出今日播放番剧列表
+ *
+ * @return 番剧列表
+ */
+ public static String reportToDayBangumi() {
+ String toDayTime = Tools.getToDayTime();
+ if (!toDayTime.equals(RedisTools.get("reportToDayBangumi"))) {
+ RedisTools.set("reportToDayBangumi", toDayTime);
+ StringBuilder builder = new StringBuilder();
+ JSONObject toDay = getBangumi(0);
+ if (toDay == null) {
+ builder.append("今天没有任何番剧放送~");
+ } else {
+ JSONObject weekday = toDay.getJSONObject("weekday");
+ JSONArray items = toDay.getJSONArray("items");
+ builder.append("今日 ").append(weekday.get("cn")).append("(").append(weekday.get("ja")).append(")");
+ builder.append(" 放送列表:").append("\n");
+ reportBangumi(builder, items, true);
+ }
+ RedisTools.set("toDayBangumi", builder.toString());
+ return builder.toString();
+ } else {
+ System.out.println("error ");
+ return RedisTools.get("toDayBangumi");
+ }
+ }
+
+ /**
+ * 格式化字符串输出搜索动画
+ *
+ * @param key 关键词
+ * @return 详细内容
+ */
+ public static List reportSearchBangumi(String key) {
+ List bangumiList = new ArrayList<>();
+ JSONObject main = search(key);
+ if (main.getInteger("results") > 0) {
+ JSONArray list = main.getJSONArray("list");
+ Collections.reverse(list);
+ for (Object _items : list) {
+ JSONObject items= (JSONObject) _items;
+ bangumiList.addAll(reportBangumiInfo(items.getInteger("id")));
+ }
+ return bangumiList;
+ } else {
+ bangumiList.add("搜索不到任何内容:" + key);
+ return bangumiList;
+ }
+ }
+
+ public static void main(String[] args) {
+ JSONObject toDay = getBangumiInfoSmall(371396);
+ System.out.println(toDay);
+ }
+}
diff --git a/src/main/java/com/yutou/tools/utils/Tools.java b/src/main/java/com/yutou/tools/utils/Tools.java
index 202c10e..401134f 100644
--- a/src/main/java/com/yutou/tools/utils/Tools.java
+++ b/src/main/java/com/yutou/tools/utils/Tools.java
@@ -463,4 +463,11 @@ public class Tools {
return "";
}
+ public static int getWeekDay() {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTimeZone(TimeZone.getTimeZone("GMT+8:00"));
+ calendar.setFirstDayOfWeek(Calendar.MONDAY);
+ calendar.setTime(new Date());
+ return calendar.get(Calendar.DAY_OF_WEEK) - 1;
+ }
}
diff --git a/src/main/resources/mapper/BangumiItemDao.xml b/src/main/resources/mapper/BangumiItemDao.xml
index 9fd4cda..1cfbe35 100644
--- a/src/main/resources/mapper/BangumiItemDao.xml
+++ b/src/main/resources/mapper/BangumiItemDao.xml
@@ -3,6 +3,7 @@
+
@@ -69,7 +70,7 @@
- id, bid, categories, author, title, titleKey, `enable`
+ id, bgmId, bid, categories, author, title, titleKey, `enable`
{{# }}}
+
From 25730638a3661da717a9bbcab57cd3a4b648cf5d Mon Sep 17 00:00:00 2001
From: Yutousama <583819556@qq.com>
Date: Sun, 10 Jul 2022 17:10:28 +0800
Subject: [PATCH 05/16] =?UTF-8?q?update:=E4=BF=AE=E5=A4=8DbgmId=E4=B8=BA?=
=?UTF-8?q?=E7=A9=BA=E6=97=B6=E7=9A=84=E5=BC=82=E5=B8=B8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../java/com/yutou/tools/services/BangumiServiceImpl.java | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/main/java/com/yutou/tools/services/BangumiServiceImpl.java b/src/main/java/com/yutou/tools/services/BangumiServiceImpl.java
index f5dbcb2..bbcb37c 100644
--- a/src/main/java/com/yutou/tools/services/BangumiServiceImpl.java
+++ b/src/main/java/com/yutou/tools/services/BangumiServiceImpl.java
@@ -71,10 +71,13 @@ public class BangumiServiceImpl implements BangumiService {
example.createCriteria().andBidEqualTo(type);
List
items = itemDao.selectByExample(example);
for (BangumiItem item : items) {
- if(item.getEnable()==0){
+ if(item.getEnable()==0||item.getBgmid()==0){
continue;
}
JSONObject bangumi=BangumiTools.getBangumiInfoSmall(item.getBgmid());
+ if(bangumi.getInteger("code")==404){
+ continue;
+ }
int day=Tools.getWeekDay();
if (day == 0) {
day = 7;
From f57325c327f89b7d84e4365a6a505cbfe939c454 Mon Sep 17 00:00:00 2001
From: Yutousama <583819556@qq.com>
Date: Sun, 10 Jul 2022 18:24:17 +0800
Subject: [PATCH 06/16] =?UTF-8?q?add:=E6=96=B0=E5=A2=9E=E4=BB=8A=E6=97=A5?=
=?UTF-8?q?=E5=8A=A8=E7=94=BB=E6=8C=89=E9=92=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../tools/bangumi/AnimationController.java | 6 +++
.../tools/services/BangumiServiceImpl.java | 2 +-
web/html/body/nas/animrss.html | 39 ++++++++++++++++++-
3 files changed, 44 insertions(+), 3 deletions(-)
diff --git a/src/main/java/com/yutou/tools/bangumi/AnimationController.java b/src/main/java/com/yutou/tools/bangumi/AnimationController.java
index ca92a21..4f7043f 100644
--- a/src/main/java/com/yutou/tools/bangumi/AnimationController.java
+++ b/src/main/java/com/yutou/tools/bangumi/AnimationController.java
@@ -10,6 +10,7 @@ import com.yutou.tools.mybatis.model.BangumiItemExample;
import com.yutou.tools.mybatis.model.BangumiList;
import com.yutou.tools.mybatis.model.BangumiListExample;
import com.yutou.tools.services.interfaces.BangumiService;
+import com.yutou.tools.utils.BangumiTools;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -166,4 +167,9 @@ public class AnimationController {
JSONArray array= (JSONArray) JSON.toJSON(list);
return array.toJSONString();
}
+ @ResponseBody
+ @RequestMapping(value = "/anim/getToDay.do", method = RequestMethod.GET)
+ public JSONObject getToDayAnim(){
+ return BangumiTools.getBangumi(0);
+ }
}
diff --git a/src/main/java/com/yutou/tools/services/BangumiServiceImpl.java b/src/main/java/com/yutou/tools/services/BangumiServiceImpl.java
index bbcb37c..ceb32ac 100644
--- a/src/main/java/com/yutou/tools/services/BangumiServiceImpl.java
+++ b/src/main/java/com/yutou/tools/services/BangumiServiceImpl.java
@@ -75,7 +75,7 @@ public class BangumiServiceImpl implements BangumiService {
continue;
}
JSONObject bangumi=BangumiTools.getBangumiInfoSmall(item.getBgmid());
- if(bangumi.getInteger("code")==404){
+ if(bangumi.containsKey("code")&&bangumi.getInteger("code")==404){
continue;
}
int day=Tools.getWeekDay();
diff --git a/web/html/body/nas/animrss.html b/web/html/body/nas/animrss.html
index c741e9e..6772959 100644
--- a/web/html/body/nas/animrss.html
+++ b/web/html/body/nas/animrss.html
@@ -203,11 +203,23 @@
}
})
- layui.use(['layer', 'form', 'element', 'table'], function () {
+ layui.use(['layer', 'form', 'element', 'table', 'util'], function () {
let layer = layui.layer
+ , util = layui.util
, form = layui.form
, table = layui.table
, element = layui.element;
+ util.fixbar({
+ bar1: '',
+ bgcolor: '#393D49',
+ css: {right: 100, bottom: 100},
+ click: function(type){
+ console.log(type);
+ if(type === 'bar1'){
+ showToDayAnim()
+ }
+ }
+ });
$.get("/anim/type/list.do", function (data) {
let json = JSON.parse(data);
if (json.code === 0) {
@@ -411,6 +423,30 @@
}
+ function showToDayAnim() {
+ $.get("/anim/getToDay.do", function (json) {
+ let items = json.items;
+ let _tab = []
+ let html = ' 标题 | 首更时间 | 图片 | 地址 |
'
+ items.forEach((item) => {
+ let name = item.name_cn
+ if (name === '') {
+ name = item.name;
+ }
+ html += '' + name + ' | ' + item.air_date + ' | | 前往番剧计划 |
'
+ _tab.push({title: item.name, url: '前往番剧计划'})
+ })
+ html += "
"
+ layer.open({
+ title: '今日新番列表',
+ area: ['700px', '300px'],
+ content: html,
+ shade: 0,
+ offset: 'rb'
+ });
+ })
+ }
+
});
@@ -420,7 +456,6 @@
$('#bgmUrl')[0].href = url;
}
- //let js="" ; $('#team option').each(function() { let value=$(this).val(); let text=$(this).text(); js+='{"'+value+'":"'+text+'"},'})