package com.phlx.anchorcollect.util;

import com.phlx.anchorcollect.Configs;
import com.phlx.anchorcollect.entity.DictEntity;
import com.phlx.anchorcollect.entity.FrozenSemenEntity;

import java.util.ArrayList;
import java.util.List;

public class LoginInfoUtils {

    public static List<String> getDistNameList(String type) {

        List<String> distNames = new ArrayList<>();
        for (DictEntity de : Configs.dictList) {
            if (type.equals(de.getDictType())) {
                distNames.add(de.getDictLabel());
            }
        }

        return distNames;
    }

    public static List<DictEntity> getDistList(String type) {

        List<DictEntity> dists = new ArrayList<>();
        for (DictEntity de : Configs.dictList) {
            if (type.equals(de.getDictType())) {
                dists.add(de);
            }
        }

        return dists;
    }

    public static FrozenSemenEntity getFrozenSemenForName(String code) {
        for (FrozenSemenEntity frozenSemenEntity : Configs.frozenSemenList) {
            String[] infos = frozenSemenEntity.getInfo().split("/");
            if (infos != null && infos.length > 0) {
                for (int i = 0; i < infos.length; i++) {
                    if (infos[i].equals(code)) {
                        return frozenSemenEntity;
                    }
                }
            }
        }
        return null;
    }


}
