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;
    }

}
