package com.ruoyi.syzy.dto;

import com.fasterxml.jackson.annotation.JsonInclude;

import com.google.common.collect.Maps;
import com.ruoyi.common.utils.StringUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Arrays;
import java.util.Map;

@Data
@ApiModel("院校查询条件")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class UniversitiesCondDTO {

    /** 代码 */
    @ApiModelProperty("代码")
    private String code;

    /** 名称 */
    @ApiModelProperty("名称")
    private String name;

    /** 所在地 */
    @ApiModelProperty("所在地")
    private String location;

    private String cityName;

    /** 主管机构类别 */
    @ApiModelProperty("主管机构类别")
    private String managerType;

    private String natureTypeCN;

    /** 院校类型 */
    @ApiModelProperty("院校类型")
    private String type;

    /** 学历层次 */
    @ApiModelProperty("学历层次")
    private String level;

    @ApiModelProperty("特色")
    private String features;
    private String bxType;
    private String star;
    private String enrollLocation;
    private String majorCategory;
    private String majorCodes;
    private String codes;
    private String examMajor;
    private String tiers;
    private Integer tier;

    /** 状态(0:无效,1:有效) */
    @ApiModelProperty("状态(0:无效,1:有效)")
    private Integer status;

    @ApiModelProperty(value = "排序", example = "id asc")
    private String orderBy;

    private Boolean filterRank;

    public Map toCondMap(Integer year, String entranceType, Integer examMajor, String rankLocation,String tiers,String cityName) {
        Map cond = Maps.newHashMap();
        cond.put("code", code);
        cond.put("name", name);
        cond.put("managerType", managerType);
        cond.put("majorCategory", majorCategory);
        cond.put("year", year);
        cond.put("rankLocation", StringUtils.trimToEmpty(rankLocation));
        if (StringUtils.isNotBlank(location)) {
            cond.put("locations", Arrays.asList(location.split(",")));
        }
        if (StringUtils.isNotBlank(cityName)) {
            cond.put("cityNames", Arrays.asList(cityName.split(",")));
        }
        if (StringUtils.isNotBlank(tiers)) {
            cond.put("tiers", Arrays.asList(tiers.split(",")));
        }
        if(StringUtils.isNotBlank(natureTypeCN)) {
            cond.put("natureTypeCNs", Arrays.asList(natureTypeCN.split(",")));
        }

        if(StringUtils.isNotBlank(type)) {
            cond.put("types", Arrays.asList(type.split(",")));
        }
        if(StringUtils.isNotBlank(level)) {
            cond.put("levels", Arrays.asList(level.split(",")));
        }
        if(StringUtils.isNotBlank(features)) {
            cond.put("featureses", Arrays.asList(features.split(",")));
        }
        if(StringUtils.isNotBlank(bxType)) {
            cond.put("bxTypes", Arrays.asList(bxType.split(",")));
        }
        if(StringUtils.isNotBlank(star)) {
            cond.put("stars", Arrays.asList(star.split(",")));
        }
        if(StringUtils.isNotBlank(enrollLocation)) {
            cond.put("enrollLocations", Arrays.asList(enrollLocation.split(",")));
        }
        if(StringUtils.isNotBlank(majorCodes)) {
            cond.put("majorCodes", Arrays.asList(majorCodes.split(",")));
        }
        if(StringUtils.isNotBlank(codes)) {
            cond.put("codes", Arrays.asList(codes.split(",")));
        }
        cond.put("status", status);
        cond.put("entranceType", entranceType);
        cond.put("examMajor", examMajor);
        cond.put("orderBy", orderBy);
        if (null != filterRank && filterRank) {
            cond.put("filterRank", filterRank);
        }
        return cond;
    }

}
