完成基本功能转移
This commit is contained in:
54
src/main/java/com/yutou/napcat/QQDatabase.java
Normal file
54
src/main/java/com/yutou/napcat/QQDatabase.java
Normal file
@@ -0,0 +1,54 @@
|
||||
package com.yutou.napcat;
|
||||
|
||||
import com.yutou.napcat.model.FriendBean;
|
||||
import com.yutou.napcat.model.GroupBean;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class QQDatabase {
|
||||
private static Map<Long, Object> data = new HashMap<>();
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private static FriendBean me;
|
||||
|
||||
public static void addUser(Long qq, FriendBean bean) {
|
||||
data.put(qq, bean);
|
||||
}
|
||||
|
||||
public static void addGroup(Long qq, GroupBean bean) {
|
||||
data.put(qq, bean);
|
||||
}
|
||||
|
||||
public static boolean checkFriend(Long qq) {
|
||||
if (data.containsKey(qq)) {
|
||||
return data.get(qq) instanceof FriendBean;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean checkGroup(Long qq) {
|
||||
if (data.containsKey(qq)) {
|
||||
return data.get(qq) instanceof GroupBean;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static List<GroupBean> getGroups() {
|
||||
List<GroupBean> numbers = new ArrayList<>();
|
||||
for (Long qq : data.keySet()) {
|
||||
if (data.get(qq) instanceof GroupBean) {
|
||||
{
|
||||
numbers.add((GroupBean) data.get(qq));
|
||||
}
|
||||
}
|
||||
}
|
||||
return numbers;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user