修复一处异常问题

This commit is contained in:
Yutou 2024-01-20 17:39:40 +08:00
parent 22416227d8
commit d4b8e58946

View File

@ -13,6 +13,7 @@ import java.util.Set;
public class QQNumberManager { public class QQNumberManager {
private static QQNumberManager manager; private static QQNumberManager manager;
private QQNumberManager() { private QQNumberManager() {
} }
@ -23,6 +24,7 @@ public class QQNumberManager {
} }
return manager; return manager;
} }
public void addNumber(Long qq, boolean isGroup) { public void addNumber(Long qq, boolean isGroup) {
if (RedisTools.exists(qq, null)) { if (RedisTools.exists(qq, null)) {
return; return;
@ -33,6 +35,7 @@ public class QQNumberManager {
json.put("model", new JSONArray()); json.put("model", new JSONArray());
RedisTools.set(qq, json.toJSONString()); RedisTools.set(qq, json.toJSONString());
} }
public List<Long> getNumber() { public List<Long> getNumber() {
List<Long> list = new ArrayList<>(); List<Long> list = new ArrayList<>();
Jedis jedis = RedisTools.getRedis(); Jedis jedis = RedisTools.getRedis();
@ -48,6 +51,7 @@ public class QQNumberManager {
jedis.close(); jedis.close();
return list; return list;
} }
public boolean addPower(Long qq, String power) { public boolean addPower(Long qq, String power) {
if (RedisTools.exists(qq, null)) { if (RedisTools.exists(qq, null)) {
JSONObject json = JSON.parseObject(RedisTools.get(qq)); JSONObject json = JSON.parseObject(RedisTools.get(qq));
@ -58,6 +62,7 @@ public class QQNumberManager {
} }
return false; return false;
} }
public List<String> getPower(Long qq) { public List<String> getPower(Long qq) {
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
if (RedisTools.exists(qq, null)) { if (RedisTools.exists(qq, null)) {
@ -70,6 +75,7 @@ public class QQNumberManager {
} }
return list; return list;
} }
public List<String> getUseModel(long qq) { public List<String> getUseModel(long qq) {
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
if (RedisTools.exists(qq, null)) { if (RedisTools.exists(qq, null)) {
@ -82,6 +88,7 @@ public class QQNumberManager {
} }
return list; return list;
} }
public boolean delPower(Long qq, String power) { public boolean delPower(Long qq, String power) {
if (RedisTools.exists(qq, null)) { if (RedisTools.exists(qq, null)) {
JSONObject json = JSON.parseObject(RedisTools.get(qq)); JSONObject json = JSON.parseObject(RedisTools.get(qq));
@ -92,6 +99,7 @@ public class QQNumberManager {
} }
return false; return false;
} }
public boolean addUseModel(Long qq, Class<?> modelClass) { public boolean addUseModel(Long qq, Class<?> modelClass) {
if (RedisTools.exists(qq, null)) { if (RedisTools.exists(qq, null)) {
JSONObject json = JSON.parseObject(RedisTools.get(qq)); JSONObject json = JSON.parseObject(RedisTools.get(qq));
@ -102,6 +110,7 @@ public class QQNumberManager {
} }
return false; return false;
} }
public boolean delUseModel(Long qq, Class<?> modelClass) { public boolean delUseModel(Long qq, Class<?> modelClass) {
if (RedisTools.exists(qq, null)) { if (RedisTools.exists(qq, null)) {
JSONObject json = JSON.parseObject(RedisTools.get(qq)); JSONObject json = JSON.parseObject(RedisTools.get(qq));
@ -112,6 +121,7 @@ public class QQNumberManager {
} }
return false; return false;
} }
public boolean isExistsPower(Long qq, String... power) { public boolean isExistsPower(Long qq, String... power) {
//1 //1
if (RedisTools.exists(qq, null)) { if (RedisTools.exists(qq, null)) {
@ -126,6 +136,7 @@ public class QQNumberManager {
} }
return false; return false;
} }
public boolean isGroup(Long qq) { public boolean isGroup(Long qq) {
if (RedisTools.exists(qq, null)) { if (RedisTools.exists(qq, null)) {
JSONObject json = JSON.parseObject(RedisTools.get(qq)); JSONObject json = JSON.parseObject(RedisTools.get(qq));
@ -133,12 +144,18 @@ public class QQNumberManager {
} }
return false; return false;
} }
public boolean isUseModel(Long qq, Class<?> modelClass) { public boolean isUseModel(Long qq, Class<?> modelClass) {
try {
if (RedisTools.exists(qq, null)) { if (RedisTools.exists(qq, null)) {
JSONObject json = JSON.parseObject(RedisTools.get(qq)); JSONObject json = JSON.parseObject(RedisTools.get(qq));
JSONArray array = json.getJSONArray("model"); JSONArray array = json.getJSONArray("model");
return array.contains(modelClass.getName()); return array.contains(modelClass.getName());
} }
} catch (Exception e) {
e.printStackTrace();
Log.i("isUseModel", qq + " " + modelClass.getName());
}
return false; return false;
} }