package com.sa.ibiz.demo.demo.service.dto;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sa.ibiz.demo.ibizutil.domain.ParentData;
import com.sa.ibiz.demo.demo.domain.UserDictItem;
import org.springframework.util.StringUtils;
import lombok.Data;
import java.util.Map;
import java.sql.Timestamp;
import com.sa.ibiz.demo.ibizutil.service.SearchFilterBase;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.sa.ibiz.demo.ibizutil.helper.DataGridCustomSearchHelper;
import com.alibaba.fastjson.JSONObject;
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class UserDictItemSearchFilter extends SearchFilterBase {

	private String query;
	private Page page;
	private QueryWrapper<UserDictItem> selectCond;
	private JSONObject customsearchval;
	public UserDictItemSearchFilter(){
		this.page =new Page<UserDictItem>(1,Short.MAX_VALUE);
		this.selectCond=new QueryWrapper<UserDictItem>();	
	}

	/**
	 * 设定自定义查询条件，在原有SQL基础上追加该SQL
	 */
	public void setCustomCond(String sql)
	{
		this.selectCond.apply(sql);
	}

	private String n_userdictcatid_eq;

	public void setN_userdictcatid_eq(String n_userdictcatid_eq) {
        this.n_userdictcatid_eq = n_userdictcatid_eq;
        if(!StringUtils.isEmpty(this.n_userdictcatid_eq)){
            this.selectCond.eq("userdictcatid", n_userdictcatid_eq);
        }
    }
	private String n_userdictcatname_eq;

	public void setN_userdictcatname_eq(String n_userdictcatname_eq) {
        this.n_userdictcatname_eq = n_userdictcatname_eq;
        if(!StringUtils.isEmpty(this.n_userdictcatname_eq)){
            this.selectCond.eq("userdictcatname", n_userdictcatname_eq);
        }
    }
	private String n_userdictcatname_like;

	public void setN_userdictcatname_like(String n_userdictcatname_like) {
        this.n_userdictcatname_like = n_userdictcatname_like;
        if(!StringUtils.isEmpty(this.n_userdictcatname_like)){
            this.selectCond.like("userdictcatname", n_userdictcatname_like);
        }
    }
	private String n_userdictid_eq;

	public void setN_userdictid_eq(String n_userdictid_eq) {
        this.n_userdictid_eq = n_userdictid_eq;
        if(!StringUtils.isEmpty(this.n_userdictid_eq)){
            this.selectCond.eq("userdictid", n_userdictid_eq);
        }
    }
	private String n_userdictitemname_like;

	public void setN_userdictitemname_like(String n_userdictitemname_like) {
        this.n_userdictitemname_like = n_userdictitemname_like;
        if(!StringUtils.isEmpty(this.n_userdictitemname_like)){
            this.selectCond.like("userdictitemname", n_userdictitemname_like);
        }
    }
	private String n_userdictname_eq;

	public void setN_userdictname_eq(String n_userdictname_eq) {
        this.n_userdictname_eq = n_userdictname_eq;
        if(!StringUtils.isEmpty(this.n_userdictname_eq)){
            this.selectCond.eq("userdictname", n_userdictname_eq);
        }
    }
	private String n_userdictname_like;

	public void setN_userdictname_like(String n_userdictname_like) {
        this.n_userdictname_like = n_userdictname_like;
        if(!StringUtils.isEmpty(this.n_userdictname_like)){
            this.selectCond.like("userdictname", n_userdictname_like);
        }
    }

	public void setSrfparentdata(Map<String, String> srfparentdata) {
		this.srfparentdata = srfparentdata;
		String strParentkey=this.getSrfparentdata().get("srfparentkey");
		if(this.srfparentdata.containsKey("srfparentmode")&& this.getSrfparentdata().get("srfparentmode").equals("DER1N_USERDICTITEM_USERDICTCAT_USERDICTCATID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_userdictcatid_eq("NA");
			}
			else{
				this.setN_userdictcatid_eq(strParentkey);
			}
		if(this.srfparentdata.containsKey("srfparentmode")&& this.getSrfparentdata().get("srfparentmode").equals("DER1N_USERDICTITEM_USERDICT_USERDICTID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_userdictid_eq("NA");
			}
			else{
				this.setN_userdictid_eq(strParentkey);
			}
	}

	/**
	 * 启用快速搜索
	 */
	public void setQuery(String query)
	{
		 this.query=query;
		 if(!StringUtils.isEmpty(query)){
			this.selectCond.or().like("userdictitemname",query);
		 }
	}

	/**
	 * 自定义查询
	 * @param customsearchval
	 */
	public void setCustomsearchval(JSONObject customsearchval) {
		this.customsearchval = customsearchval;
		if(!StringUtils.isEmpty(customsearchval)){
			DataGridCustomSearchHelper customSearchHelper= DataGridCustomSearchHelper.getInstance();
			String customSql =customSearchHelper.parseCustomVal(customsearchval);
			this.selectCond.apply(customSql);
		}
	}

}