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.OrgUser;
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 OrgUserSearchFilter extends SearchFilterBase {

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

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

	private String n_orgid_eq;

	public void setN_orgid_eq(String n_orgid_eq) {
        this.n_orgid_eq = n_orgid_eq;
        if(!StringUtils.isEmpty(this.n_orgid_eq)){
            this.selectCond.eq("orgid", n_orgid_eq);
        }
    }
	private String n_orgname_eq;

	public void setN_orgname_eq(String n_orgname_eq) {
        this.n_orgname_eq = n_orgname_eq;
        if(!StringUtils.isEmpty(this.n_orgname_eq)){
            this.selectCond.eq("orgname", n_orgname_eq);
        }
    }
	private String n_orgname_like;

	public void setN_orgname_like(String n_orgname_like) {
        this.n_orgname_like = n_orgname_like;
        if(!StringUtils.isEmpty(this.n_orgname_like)){
            this.selectCond.like("orgname", n_orgname_like);
        }
    }
	private String n_orgsectorid_eq;

	public void setN_orgsectorid_eq(String n_orgsectorid_eq) {
        this.n_orgsectorid_eq = n_orgsectorid_eq;
        if(!StringUtils.isEmpty(this.n_orgsectorid_eq)){
            this.selectCond.eq("orgsectorid", n_orgsectorid_eq);
        }
    }
	private String n_orgsectorname_eq;

	public void setN_orgsectorname_eq(String n_orgsectorname_eq) {
        this.n_orgsectorname_eq = n_orgsectorname_eq;
        if(!StringUtils.isEmpty(this.n_orgsectorname_eq)){
            this.selectCond.eq("orgsectorname", n_orgsectorname_eq);
        }
    }
	private String n_orgsectorname_like;

	public void setN_orgsectorname_like(String n_orgsectorname_like) {
        this.n_orgsectorname_like = n_orgsectorname_like;
        if(!StringUtils.isEmpty(this.n_orgsectorname_like)){
            this.selectCond.like("orgsectorname", n_orgsectorname_like);
        }
    }
	private String n_orgsecusertypeid_eq;

	public void setN_orgsecusertypeid_eq(String n_orgsecusertypeid_eq) {
        this.n_orgsecusertypeid_eq = n_orgsecusertypeid_eq;
        if(!StringUtils.isEmpty(this.n_orgsecusertypeid_eq)){
            this.selectCond.eq("orgsecusertypeid", n_orgsecusertypeid_eq);
        }
    }
	private String n_orgsecusertypename_eq;

	public void setN_orgsecusertypename_eq(String n_orgsecusertypename_eq) {
        this.n_orgsecusertypename_eq = n_orgsecusertypename_eq;
        if(!StringUtils.isEmpty(this.n_orgsecusertypename_eq)){
            this.selectCond.eq("orgsecusertypename", n_orgsecusertypename_eq);
        }
    }
	private String n_orgsecusertypename_like;

	public void setN_orgsecusertypename_like(String n_orgsecusertypename_like) {
        this.n_orgsecusertypename_like = n_orgsecusertypename_like;
        if(!StringUtils.isEmpty(this.n_orgsecusertypename_like)){
            this.selectCond.like("orgsecusertypename", n_orgsecusertypename_like);
        }
    }
	private String n_orguserlevelid_eq;

	public void setN_orguserlevelid_eq(String n_orguserlevelid_eq) {
        this.n_orguserlevelid_eq = n_orguserlevelid_eq;
        if(!StringUtils.isEmpty(this.n_orguserlevelid_eq)){
            this.selectCond.eq("orguserlevelid", n_orguserlevelid_eq);
        }
    }
	private String n_orguserlevelname_eq;

	public void setN_orguserlevelname_eq(String n_orguserlevelname_eq) {
        this.n_orguserlevelname_eq = n_orguserlevelname_eq;
        if(!StringUtils.isEmpty(this.n_orguserlevelname_eq)){
            this.selectCond.eq("orguserlevelname", n_orguserlevelname_eq);
        }
    }
	private String n_orguserlevelname_like;

	public void setN_orguserlevelname_like(String n_orguserlevelname_like) {
        this.n_orguserlevelname_like = n_orguserlevelname_like;
        if(!StringUtils.isEmpty(this.n_orguserlevelname_like)){
            this.selectCond.like("orguserlevelname", n_orguserlevelname_like);
        }
    }
	private String n_orgusername_like;

	public void setN_orgusername_like(String n_orgusername_like) {
        this.n_orgusername_like = n_orgusername_like;
        if(!StringUtils.isEmpty(this.n_orgusername_like)){
            this.selectCond.like("orgusername", n_orgusername_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_ORGUSER_ORG_ORGID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_orgid_eq("NA");
			}
			else{
				this.setN_orgid_eq(strParentkey);
			}
		if(this.srfparentdata.containsKey("srfparentmode")&& this.getSrfparentdata().get("srfparentmode").equals("DER1N_ORGUSER_ORGSECTOR_ORGSECTORID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_orgsectorid_eq("NA");
			}
			else{
				this.setN_orgsectorid_eq(strParentkey);
			}
		if(this.srfparentdata.containsKey("srfparentmode")&& this.getSrfparentdata().get("srfparentmode").equals("DER1N_ORGUSER_ORGSECUSERTYPE_ORGSECUSERTYPEID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_orgsecusertypeid_eq("NA");
			}
			else{
				this.setN_orgsecusertypeid_eq(strParentkey);
			}
		if(this.srfparentdata.containsKey("srfparentmode")&& this.getSrfparentdata().get("srfparentmode").equals("DER1N_ORGUSER_ORGUSERLEVEL_ORGUSERLEVELID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_orguserlevelid_eq("NA");
			}
			else{
				this.setN_orguserlevelid_eq(strParentkey);
			}
	}

	/**
	 * 启用快速搜索
	 */
	public void setQuery(String query)
	{
		 this.query=query;
		 if(!StringUtils.isEmpty(query)){
			this.selectCond.or().like("orgusername",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);
		}
	}

}