diff --git a/pom.xml b/pom.xml
index e2fd69e..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,20 +47,20 @@
org.springframework.boot
spring-boot-starter-web
- RELEASE
+ 2.7.1
compile
redis.clients
jedis
- 3.6.3
+ 4.2.3
-
+
mysql
mysql-connector-java
@@ -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..8bd600e 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;
@@ -46,6 +46,7 @@ public class RoleAccessDecisionManager implements AccessDecisionManager {
return;
}
if("dev".equals(ConfigTools.load(ConfigTools.CONFIG, "model"))) {
+ authentication.setAuthenticated(true);
return;
}
if(url.endsWith(".ts")||url.endsWith(".m3u8")){
@@ -79,14 +80,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/ToolsApplication.java b/src/main/java/com/yutou/tools/ToolsApplication.java
index 6804134..175e425 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.7";
public static void main(String[] args) {
System.out.println("当前版本号:" + version);
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..5ab31fe 100644
--- a/src/main/java/com/yutou/tools/bangumi/AnimationController.java
+++ b/src/main/java/com/yutou/tools/bangumi/AnimationController.java
@@ -1,13 +1,15 @@
package com.yutou.tools.bangumi;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.yutou.tools.mybatis.dao.BangumiItemDao;
-import com.yutou.tools.mybatis.dao.BangumiListDao;
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
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.nas.UpdateIp;
+import com.yutou.tools.services.interfaces.BangumiService;
+import com.yutou.tools.utils.BangumiTools;
+import com.yutou.tools.utils.HttpTools;
+import com.yutou.tools.utils.RedisTools;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -15,36 +17,32 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
+import java.nio.charset.StandardCharsets;
import java.util.List;
+import java.util.Objects;
@Controller
public class AnimationController {
@Resource
- BangumiListDao listDao;
- @Resource
- BangumiItemDao itemDao;
+ BangumiService bangumiService;
@ResponseBody
@RequestMapping(value = "/anim/rss/data.do", method = RequestMethod.GET)
- public String getAnimList(String key,String type,String team, int page) {
+ public String getAnimList(String key, String type, String team, int page) {
boolean isNull = key.length() == 0;
- if(!StringUtils.isEmpty(type)&&type.length()>2) {
- type=type.substring(2);
+ if (!StringUtils.isEmpty(type) && type.length() > 2) {
+ type = type.substring(2);
}
- if(!StringUtils.isEmpty(team)&&team.length()>2) {
- team=team.substring(2);
+ if (!StringUtils.isEmpty(team) && team.length() > 2) {
+ team = team.substring(2);
}
String[] keys = key.split(" ");
JSONArray items = null;
if (!isNull) {
- items = new AnimationData().bangumiList(page,type,team, keys);
+ 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");
@@ -57,7 +55,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 ? "添加失败" : "添加成功");
@@ -70,17 +68,15 @@ 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(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);
- JSONObject json=new JSONObject();
+ public String delType(int id) {
+ int i = bangumiService.removeBangumiType(id);
+ JSONObject json = new JSONObject();
json.put("code", 0);
json.put("msg", i == 0 ? "删除失败" : "删除成功");
return json.toJSONString();
@@ -88,80 +84,152 @@ 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 JSONObject addAnimationRss(String bgmId, String title, String author, String categories, String titleKey, String bid) {
+ int i = 0;
+ JSONObject json = new JSONObject();
+ json.put("code", 0);
+ if ("-1".equals(bid)) {
+ BangumiItem item = new BangumiItem();
+ item.setId(-1);
+ item.setTitle(title);
+ item.setTitlekey(titleKey);
+ i = bangumiService.addBangumiItem(item);
+ json.put("msg", i == 0 ? "添加失败" : "添加成功");
+ return json;
+ }
+
+ 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);
- JSONObject json = new JSONObject();
- json.put("code", 0);
+ i = bangumiService.addBangumiItem(item);
json.put("msg", i == 0 ? "添加失败" : "添加成功");
- return json.toJSONString();
+ return json;
}
@ResponseBody
@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", JSONArray.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);
- JSONObject json=new JSONObject();
+ public JSONObject delAnimation(String id) {
+ JSONObject json = new JSONObject();
json.put("code", 0);
+ if (id.startsWith("{")) {
+ boolean tmpRss = RedisTools.list_remove("anim_tmp_rss", id);
+ json.put("msg", tmpRss ? "删除成功" : "删除失败");
+ return json;
+ }
+ int i = bangumiService.removeBangumiItem(Integer.parseInt(id));
+
json.put("msg", i == 0 ? "删除失败" : "删除成功");
- return json.toJSONString();
- }
- @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){
- JSONObject json=new JSONObject();
- BangumiItem item =itemDao.selectByPrimaryKey(id);
- if(!StringUtils.isEmpty(title)){
- item.setTitle(title);
- }
- if(!StringUtils.isEmpty(author)){
- item.setAuthor(author);
- }
- if(!StringUtils.isEmpty(categories)){
- item.setCategories(categories);
- }
- if(!StringUtils.isEmpty(titleKey)){
- item.setTitlekey(titleKey);
- }
- if(!StringUtils.isEmpty(enable)){
- item.setEnable(Integer.parseInt(enable));
- }
- int i=itemDao.updateByPrimaryKey(item);
- if(i>0){
- json.put("msg","操作成功");
- }else{
- json.put("msg","操作失败");
- }
- json.put("code",1);
return json;
}
+
+ @ResponseBody
+ @RequestMapping(value = "/anim/rss/edit.do", method = RequestMethod.POST)
+ public JSONObject editAnimation(int id, String bgmId, String title, String author, String categories, String titleKey, String enable) {
+ JSONObject json = new JSONObject();
+ BangumiItem item = bangumiService.getBangumiItem(id);
+ if (!StringUtils.isEmpty(bgmId)) {
+ try {
+ item.setBgmid(Integer.parseInt(bgmId));
+ } catch (Exception ignored) {
+
+ }
+ }
+ if (!StringUtils.isEmpty(title)) {
+ item.setTitle(title);
+ }
+ if (!StringUtils.isEmpty(author)) {
+ item.setAuthor(author);
+ }
+ if (!StringUtils.isEmpty(categories)) {
+ item.setCategories(categories);
+ }
+ if (!StringUtils.isEmpty(titleKey)) {
+ item.setTitlekey(titleKey);
+ }
+ if (!StringUtils.isEmpty(enable)) {
+ item.setEnable(Integer.parseInt(enable));
+ }
+ int i = bangumiService.updateBangumiItem(item);
+ if (i > 0) {
+ json.put("msg", "操作成功");
+ } else {
+ json.put("msg", "操作失败");
+ }
+ json.put("code", 1);
+ return json;
+ }
+
@ResponseBody
@RequestMapping(value = "/anim/client/get.do", method = RequestMethod.GET)
- public String clientApi(){
- AnimationData animationData=new AnimationData();
- List list=itemDao.selectByExample(new BangumiItemExample());
+ public String clientApi() {
+ AnimationData animationData = new AnimationData();
+ List list = bangumiService.getAllBangumiItemList();
for (BangumiItem item : list) {
- item.setCategories(animationData.nameToValue(item.getCategories(),false)+"");
- item.setAuthor(animationData.nameToValue(item.getAuthor(),true)+"");
+ 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();
}
+
+ @ResponseBody
+ @RequestMapping(value = "/anim/getToDay.do", method = RequestMethod.GET)
+ public JSONObject getToDayAnim() {
+ return BangumiTools.getBangumi(0);
+ }
+
+ @ResponseBody
+ @RequestMapping(value = "/anim/setDownload.do", method = RequestMethod.POST)
+ public JSONObject setDownload(int id, String url) {
+ String serverUrl = "http://" + UpdateIp.nas_ip + ":8000/bt/download.do";
+ JSONObject json = new JSONObject();
+ json.put("id", id);
+ json.put("url", url);
+ String post = HttpTools.post(serverUrl, HttpTools.toUrlParams(json).getBytes(StandardCharsets.UTF_8));
+ json.clear();
+ json.put("code", 0);
+ json.put("msg", post);
+ return json;
+ }
+
+ @ResponseBody
+ @RequestMapping(value = "/anim/rssdata.do", method = RequestMethod.POST)
+ public JSONObject getRssData(int id) {
+ JSONObject json = new JSONObject();
+ BangumiItem item = bangumiService.getBangumiItem(id);
+ if (item != null) {
+ String key = item.getTitle().split("/")[0];
+ AnimationData animationData = new AnimationData();
+ JSONArray array = animationData.bangumiList(1, "0", "0", ","+key.replace(" ","+"));
+ json.put("code",0);
+ json.put("data", array);
+ json.put("msg","ok");
+ }else{
+ json.put("code",-1);
+ json.put("msg","id错误");
+ }
+ return json;
+ }
}
diff --git a/src/main/java/com/yutou/tools/bangumi/AnimationData.java b/src/main/java/com/yutou/tools/bangumi/AnimationData.java
index 957621d..c280044 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;
@@ -10,7 +10,7 @@ public class AnimationData {
private String rss2jsonApi_1="wtfm5pebya13pnl8rtu51wfgfpte0mb9sap1foll";
private String rss2jsonApi_2="z2s7zyzxvrsjz9vh5alvq3lxdypzykly2nnvqpdx";
private String rss2jsonUrl = "https://api.rss2json.com/v1/api.json?rss_url=";
- private String animUrl = "http://share.dmhy.org/topics/rss/page/%s/rss.xml?keyword=%s&sort_id=%s&order=date-desc";
+ private String animUrl = "https://share.dmhy.org/topics/rss/page/%s/rss.xml?keyword=%s&sort_id=%s&order=date-desc";
private String team="[{\"0\":\"全部\"},{\"117\":\"動漫花園\"},{\"669\":\"喵萌奶茶屋\"},{\"648\":\"魔星字幕团\"},{\"185\":\"极影字幕社\"},{\"619\":\"桜都字幕组\"},{\"604\":\"lleeopen\"},{\"241\":\"幻樱字幕组\"},{\"151\":\"悠哈C9字幕社\"},{\"657\":\"LoliHouse\"},{\"283\":\"千夏字幕组\"},{\"755\":\"GMTeam\"},{\"390\":\"天使动漫\"},{\"731\":\"星空字幕组\"},{\"303\":\"动漫国字幕组\"},{\"563\":\"花園壓制組\"},{\"37\":\"雪飄工作室(FLsnow)\"},{\"47\":\"爱恋字幕社\"},{\"710\":\"咪梦动漫组\"},{\"88\":\"动音漫影\"},{\"574\":\"梦蓝字幕组\"},{\"504\":\"LoveEcho!\"},{\"765\":\"爱咕字幕组\"},{\"520\":\"豌豆字幕组\"},{\"650\":\"SweetSub\"},{\"430\":\"幻之字幕组\"},{\"407\":\"DHR動研字幕組\"},{\"321\":\"轻之国度\"},{\"581\":\"VCB-Studio\"},{\"703\":\"届恋字幕组\"},{\"576\":\"银色子弹字幕组\"},{\"454\":\"风车字幕组\"},{\"485\":\"天空树双语字幕组\"},{\"134\":\"漫游字幕组\"},{\"434\":\"风之圣殿\"},{\"630\":\"枫叶字幕组\"},{\"228\":\"KRL字幕组\"},{\"526\":\"东京不够热\"},{\"592\":\"未央阁联盟\"},{\"288\":\"诸神kamigami字幕组\"},{\"767\":\"天月動漫&發佈組\"},{\"768\":\"千歲字幕組\"},{\"423\":\"漫貓字幕組\"},{\"562\":\"129.3字幕組\"},{\"447\":\"夢幻戀櫻\"},{\"680\":\"Little字幕组\"},{\"641\":\"冷番补完字幕组\"},{\"31\":\"卡通空間\"},{\"649\":\"云光字幕组\"},{\"701\":\"狐狸小宮\"},{\"459\":\"紫音動漫&發佈組\"},{\"699\":\"小花花同盟戰線\"},{\"626\":\"驯兽师联盟\"},{\"58\":\"澄空学园\"},{\"769\":\"动漫萌\"},{\"734\":\"TD-RAWS\"},{\"225\":\"鈴風字幕組\"},{\"673\":\"VRAINSTORM\"},{\"741\":\"銀月字幕組\"},{\"675\":\"AikatsuFans\"},{\"759\":\"红鸟窝字幕组\"},{\"764\":\"MCE汉化组\"},{\"391\":\"ZERO字幕组\"},{\"561\":\"钉铛字幕组\"},{\"727\":\"2B4B\"},{\"104\":\"动漫先锋\"},{\"567\":\"雪梦字幕组\"},{\"573\":\"Centaurea-Raws\"},{\"652\":\"SFEO-Raws\"},{\"666\":\"中肯字幕組\"},{\"754\":\"BYYM发布组\"},{\"613\":\"AI-Raws\"},{\"706\":\"K&W-RAWS\"},{\"732\":\"肥猫压制\"},{\"424\":\"TSDM字幕組\"},{\"739\":\"Clarita 压制组\"},{\"432\":\"自由字幕组\"},{\"217\":\"AQUA工作室\"},{\"753\":\"柠檬水字幕组\"},{\"763\":\"光之家族字幕组\"},{\"332\":\"CureSub\"},{\"537\":\"NEO·QSW\"},{\"632\":\"歐克勒亞\"},{\"548\":\"Cornflower Studio\"},{\"638\":\"LittleBakas!\"}]";
private String type="[{\"0\":\"全部\"},{\"2\":\"動畫\"},{\"31\":\"季度全集\"},{\"3\":\"漫畫\"},{\"41\":\"港台原版\"},{\"42\":\"日文原版\"},{\"4\":\"音樂\"},{\"43\":\"動漫音樂\"},{\"44\":\"同人音樂\"},{\"15\":\"流行音樂\"},{\"6\":\"日劇\"},{\"7\":\"RAW\"},{\"9\":\"遊戲\"},{\"17\":\"電腦遊戲\"},{\"18\":\"電視遊戲\"},{\"19\":\"掌機遊戲\"},{\"20\":\"網絡遊戲\"},{\"21\":\"遊戲周邊\"},{\"12\":\"特攝\"},{\"1\":\"其他\"}]";
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..28092a7 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 String updateDay ;
+
/**
* 标题过滤词
*/
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/nas/NasManager.java b/src/main/java/com/yutou/tools/nas/NasManager.java
index 093ace4..da53799 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();
@@ -302,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/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/services/BangumiServiceImpl.java b/src/main/java/com/yutou/tools/services/BangumiServiceImpl.java
new file mode 100644
index 0000000..29f7bea
--- /dev/null
+++ b/src/main/java/com/yutou/tools/services/BangumiServiceImpl.java
@@ -0,0 +1,145 @@
+package com.yutou.tools.services;
+
+import com.alibaba.fastjson2.JSON;
+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.RedisTools;
+import com.yutou.tools.utils.Tools;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+@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 (item.getId().equals(-1)) {
+ RedisTools.list_add("anim_tmp_rss", JSON.toJSON(item).toString());
+ } else 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) {
+ List items;
+ if ("-1".equals(type)) {
+ Set strings = RedisTools.list_get("anim_tmp_rss");
+ items=new ArrayList<>();
+ for (String string : strings) {
+ BangumiItem item=JSON.parseObject(string, BangumiItem.class);
+ items.add(item);
+ }
+ return items;
+ }
+ BangumiItemExample example = new BangumiItemExample();
+ example.createCriteria().andBidEqualTo(type);
+ items = itemDao.selectByExample(example);
+ for (BangumiItem item : items) {
+ if (item.getEnable() == 0 || item.getBgmid() == 0) {
+ continue;
+ }
+ String tmp = RedisTools.get(item.getBgmid() + "", 1);
+ JSONObject bangumi = tmp == null ? BangumiTools.getBangumiInfoSmall(item.getBgmid()) : JSONObject.parseObject(tmp);
+ RedisTools.set(1, 2592000, item.getBgmid() + "", bangumi.toJSONString());
+ if (bangumi.containsKey("code") && bangumi.getInteger("code") == 404) {
+ continue;
+ }
+ int day = Tools.getWeekDay();
+ if (day == 0) {
+ day = 7;
+ }
+ if (bangumi.getInteger("air_weekday") == day) {
+ item.setUpdateDay("今天更新");
+ } else {
+ item.setUpdateDay("周" + getDay(bangumi.getInteger("air_weekday")) + "更新");
+ }
+ }
+ return items;
+ }
+
+ private String getDay(int day) {
+ switch (day) {
+ case 1:
+ return "一";
+ case 2:
+ return "二";
+ case 3:
+ return "三";
+ case 4:
+ return "四";
+ case 5:
+ return "五";
+ case 6:
+ return "六";
+ default:
+ return "日";
+ }
+ }
+
+ @Override
+ public List getAllBangumiItemList() {
+ return itemDao.selectByExample(new BangumiItemExample());
+ }
+
+ @Override
+ public List getAllBangumiList() {
+ List list = listDao.selectByExample(new BangumiListExample());
+ BangumiList bangumi = new BangumiList();
+ bangumi.setTitle("临时RSS");
+ bangumi.setId(-1);
+ list.add(bangumi);
+ return list;
+ }
+}
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/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/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/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/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)
//设置允许的方法
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..866026f 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;
@@ -34,15 +34,19 @@ public class RedisTools {
port = 6379;
}
- public static boolean set(int dbIndex, String key, String value) {
+
+ public static boolean set(int dbIndex, int timeout, String key, String value) {
try {
if (isNotInstallRedis) {
return false;
}
Jedis jedis = getRedis();
jedis.select(dbIndex);
- String ret = jedis.set(key, value);
- System.out.println("Redis set =" + ret);
+ if (timeout == -1) {
+ jedis.set(key, value);
+ } else {
+ jedis.setex(key, timeout, value);
+ }
jedis.close();
} catch (Exception e) {
// TODO: handle exception
@@ -52,6 +56,10 @@ public class RedisTools {
return true;
}
+ public static boolean set(int dbIndex, String key, String value) {
+ return set(dbIndex, -1, key, value);
+ }
+
public static boolean set(String key, String value) {
return set(0, key, value);
}
@@ -77,9 +85,9 @@ public class RedisTools {
}
public static String get(String key, int dbIndex) {
- String value = "-999";
+ String value = null;
if (isNotInstallRedis) {
- return value;
+ return null;
}
try (Jedis jedis = getRedis()) {
jedis.select(dbIndex);
@@ -97,7 +105,7 @@ public class RedisTools {
}
public static boolean remove(String key) {
- return remove(key,0);
+ return remove(key, 0);
}
public static void removeLoginState(String uid) {
@@ -148,32 +156,36 @@ public class RedisTools {
}
public static long list_add(String listName, String... value) {
- Jedis jedis=getRedis();
- long index=jedis.sadd(listName,value);
+ Jedis jedis = getRedis();
+ long index = jedis.sadd(listName, value);
jedis.close();
return index;
}
- public static Set list_get(String listName){
- Jedis jedis=getRedis();
- Set set=jedis.smembers(listName);
+
+ public static Set list_get(String listName) {
+ Jedis jedis = getRedis();
+ Set set = jedis.smembers(listName);
jedis.close();
- if(set==null){
- set=new HashSet<>();
+ if (set == null) {
+ set = new HashSet<>();
}
return set;
}
- public static boolean list_remove(String listName,String... value){
- Jedis jedis=getRedis();
- long index=jedis.srem(listName,value);
+
+ public static boolean list_remove(String listName, String... value) {
+ Jedis jedis = getRedis();
+ long index = jedis.srem(listName, value);
jedis.close();
return index != 0;
}
- public static boolean list_isExist(String listName,String value){
- Jedis jedis=getRedis();
- boolean flag=jedis.sismember(listName,value);
+
+ public static boolean list_isExist(String listName, String value) {
+ Jedis jedis = getRedis();
+ boolean flag = jedis.sismember(listName, value);
jedis.close();
return flag;
}
+
private static class PropertyUtil {
// 加载property文件到io流里面
@@ -256,7 +268,7 @@ public class RedisTools {
system("cmd", message);
break;
case "msg":
- Tools.sendServer("来自服务姬的通知~",message);
+ Tools.sendServer("来自服务姬的通知~", message);
break;
}
}
@@ -293,7 +305,6 @@ public class RedisTools {
}
-
public static void bot(String value) {
switch (value) {
case "getip":
@@ -303,6 +314,7 @@ public class RedisTools {
}
}
}
+
public static void processOut(InputStream inputStream) {
String tmp;
@@ -320,6 +332,7 @@ public class RedisTools {
System.out.println("cmd > " + str);
System.out.println("线程结束");
}
+
public static void main(String[] args) {
RedisTools.pullMsg("msg", "abc");
}
diff --git a/src/main/java/com/yutou/tools/utils/Tools.java b/src/main/java/com/yutou/tools/utils/Tools.java
index 845a232..24a7c76 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;
@@ -434,6 +434,9 @@ public class Tools {
}
public static String getLoginUser() {
+ if("dev".equals(ConfigTools.load(ConfigTools.CONFIG, "model"))) {
+ return "admin";
+ }
Object user = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
if (user instanceof String) {
return (String) user;
@@ -463,4 +466,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/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/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`