package com.qunzhixinxi.hnqz.admin.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

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

/**
 * 税源地
 */
@Getter
@AllArgsConstructor
public enum SubjectLocation {

	// 仁励家通道
	REN_LI_JIA("REN_LI_JIA", GigTypeEnum.REN_LI_JIA, "仁励家", 0),

	// 税邦云通道
	ZHONG_YING("ZHONG_YING", GigTypeEnum.TAX_HELPOR, "湖南众盈", 1),
	LUO_SHU_YUN("LUO_SHU_YUN", GigTypeEnum.TAX_HELPOR, "永州罗数云", 2),

	// 钉零工通道
	FEI_YI("FEI_YI", GigTypeEnum.OLADING, "海南飞亿", 3),
	JIN_YUAN("JIN_YUAN", GigTypeEnum.OLADING, "金园数科", 4),
	XIN_TAI_ZI("XIN_TAI_ZI", GigTypeEnum.OLADING, "河南薪泰梓", 5),

	// 易联
	YI_LIAN("YI_LIAN", GigTypeEnum.YEE, "易联数科", 6);

	@EnumValue
	private final String type;

	private final GigTypeEnum gigType;

	private final String description;

	private final Integer sort;

	/**
	 * 根据gigType获取枚举
	 *
	 * @param gigType
	 * @return
	 */
	public static List<SubjectLocation> getByGigType(GigTypeEnum gigType) {
		List<SubjectLocation> list = new ArrayList<>();
		for (SubjectLocation subjectLocation : SubjectLocation.values()) {
			if (subjectLocation.gigType.equals(gigType)) {
				list.add(subjectLocation);
			}
		}
		return list;
	}

	/**
	 * 根据type获取枚举
	 *
	 * @param type
	 * @return
	 */
	public static SubjectLocation resolve(String type) {
		for (SubjectLocation subjectLocation: SubjectLocation.values()){
			if (subjectLocation.type.equals(type)){
				return subjectLocation;
			}
		}
		return null;
	}
}