修复FastJSON大版本更新后API变动
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
package com.yutou.qqbot;
|
||||
|
||||
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.qqbot.utlis.Log;
|
||||
import com.yutou.qqbot.utlis.RedisTools;
|
||||
import redis.clients.jedis.Jedis;
|
||||
@@ -49,7 +50,7 @@ public class QQNumberManager {
|
||||
}
|
||||
public boolean addPower(Long qq, String power){
|
||||
if(RedisTools.exists(qq,null)){
|
||||
JSONObject json=JSONObject.parseObject(RedisTools.get(qq));
|
||||
JSONObject json=JSON.parseObject(RedisTools.get(qq));
|
||||
JSONArray array=json.getJSONArray("power");
|
||||
array.add(power);
|
||||
json.put("power",array);
|
||||
@@ -60,7 +61,7 @@ public class QQNumberManager {
|
||||
public List<String> getPower(Long qq){
|
||||
List<String> list=new ArrayList<>();
|
||||
if(RedisTools.exists(qq,null)){
|
||||
JSONObject json=JSONObject.parseObject(RedisTools.get(qq));
|
||||
JSONObject json=JSON.parseObject(RedisTools.get(qq));
|
||||
JSONArray array=json.getJSONArray("power");
|
||||
for (Object power : array) {
|
||||
list.add((String) power);
|
||||
@@ -72,7 +73,7 @@ public class QQNumberManager {
|
||||
public List<String> getUseModel(long qq) {
|
||||
List<String> list=new ArrayList<>();
|
||||
if(RedisTools.exists(qq,null)){
|
||||
JSONObject json=JSONObject.parseObject(RedisTools.get(qq));
|
||||
JSONObject json=JSON.parseObject(RedisTools.get(qq));
|
||||
JSONArray array=json.getJSONArray("model");
|
||||
for (Object power : array) {
|
||||
list.add((String) power);
|
||||
@@ -83,7 +84,7 @@ public class QQNumberManager {
|
||||
}
|
||||
public boolean delPower(Long qq, String power){
|
||||
if(RedisTools.exists(qq,null)){
|
||||
JSONObject json=JSONObject.parseObject(RedisTools.get(qq));
|
||||
JSONObject json=JSON.parseObject(RedisTools.get(qq));
|
||||
JSONArray array=json.getJSONArray("power");
|
||||
array.remove(power);
|
||||
json.put("power",array);
|
||||
@@ -93,7 +94,7 @@ public class QQNumberManager {
|
||||
}
|
||||
public boolean addUseModel(Long qq,Class<?> modelClass){
|
||||
if(RedisTools.exists(qq,null)){
|
||||
JSONObject json=JSONObject.parseObject(RedisTools.get(qq));
|
||||
JSONObject json=JSON.parseObject(RedisTools.get(qq));
|
||||
JSONArray array=json.getJSONArray("model");
|
||||
array.add(modelClass.getName());
|
||||
json.put("model",array);
|
||||
@@ -103,7 +104,7 @@ public class QQNumberManager {
|
||||
}
|
||||
public boolean delUseModel(Long qq,Class<?> modelClass){
|
||||
if(RedisTools.exists(qq,null)){
|
||||
JSONObject json=JSONObject.parseObject(RedisTools.get(qq));
|
||||
JSONObject json=JSON.parseObject(RedisTools.get(qq));
|
||||
JSONArray array=json.getJSONArray("model");
|
||||
array.remove(modelClass.getName());
|
||||
json.put("model",array);
|
||||
@@ -113,7 +114,7 @@ public class QQNumberManager {
|
||||
}
|
||||
public boolean isExistsPower(Long qq, String... power){
|
||||
if(RedisTools.exists(qq,null)){
|
||||
JSONObject json=JSONObject.parseObject(RedisTools.get(qq));
|
||||
JSONObject json=JSON.parseObject(RedisTools.get(qq));
|
||||
JSONArray array=json.getJSONArray("power");
|
||||
for (String key : power) {
|
||||
if(!array.contains(key)){
|
||||
@@ -126,14 +127,14 @@ public class QQNumberManager {
|
||||
}
|
||||
public boolean isGroup(Long qq){
|
||||
if(RedisTools.exists(qq,null)){
|
||||
JSONObject json=JSONObject.parseObject(RedisTools.get(qq));
|
||||
return json.getBoolean("group");
|
||||
JSONObject json= JSON.parseObject(RedisTools.get(qq));
|
||||
return json.getBooleanValue("group");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public boolean isUseModel(Long qq,Class<?> modelClass){
|
||||
if(RedisTools.exists(qq,null)){
|
||||
JSONObject json=JSONObject.parseObject(RedisTools.get(qq));
|
||||
JSONObject json=JSON.parseObject(RedisTools.get(qq));
|
||||
JSONArray array=json.getJSONArray("model");
|
||||
return array.contains(modelClass.getName());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user