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.UserRoleData;
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 UserRoleDataSearchFilter extends SearchFilterBase {

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

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

	private String n_deid_eq;

	public void setN_deid_eq(String n_deid_eq) {
        this.n_deid_eq = n_deid_eq;
        if(!StringUtils.isEmpty(this.n_deid_eq)){
            this.selectCond.eq("deid", n_deid_eq);
        }
    }
	private String n_dename_eq;

	public void setN_dename_eq(String n_dename_eq) {
        this.n_dename_eq = n_dename_eq;
        if(!StringUtils.isEmpty(this.n_dename_eq)){
            this.selectCond.eq("dename", n_dename_eq);
        }
    }
	private String n_dename_like;

	public void setN_dename_like(String n_dename_like) {
        this.n_dename_like = n_dename_like;
        if(!StringUtils.isEmpty(this.n_dename_like)){
            this.selectCond.like("dename", n_dename_like);
        }
    }
	private String n_dstorgid_eq;

	public void setN_dstorgid_eq(String n_dstorgid_eq) {
        this.n_dstorgid_eq = n_dstorgid_eq;
        if(!StringUtils.isEmpty(this.n_dstorgid_eq)){
            this.selectCond.eq("dstorgid", n_dstorgid_eq);
        }
    }
	private String n_dstorgname_eq;

	public void setN_dstorgname_eq(String n_dstorgname_eq) {
        this.n_dstorgname_eq = n_dstorgname_eq;
        if(!StringUtils.isEmpty(this.n_dstorgname_eq)){
            this.selectCond.eq("dstorgname", n_dstorgname_eq);
        }
    }
	private String n_dstorgname_like;

	public void setN_dstorgname_like(String n_dstorgname_like) {
        this.n_dstorgname_like = n_dstorgname_like;
        if(!StringUtils.isEmpty(this.n_dstorgname_like)){
            this.selectCond.like("dstorgname", n_dstorgname_like);
        }
    }
	private String n_dstorgsectorid_eq;

	public void setN_dstorgsectorid_eq(String n_dstorgsectorid_eq) {
        this.n_dstorgsectorid_eq = n_dstorgsectorid_eq;
        if(!StringUtils.isEmpty(this.n_dstorgsectorid_eq)){
            this.selectCond.eq("dstorgsectorid", n_dstorgsectorid_eq);
        }
    }
	private String n_dstorgsectorname_eq;

	public void setN_dstorgsectorname_eq(String n_dstorgsectorname_eq) {
        this.n_dstorgsectorname_eq = n_dstorgsectorname_eq;
        if(!StringUtils.isEmpty(this.n_dstorgsectorname_eq)){
            this.selectCond.eq("dstorgsectorname", n_dstorgsectorname_eq);
        }
    }
	private String n_dstorgsectorname_like;

	public void setN_dstorgsectorname_like(String n_dstorgsectorname_like) {
        this.n_dstorgsectorname_like = n_dstorgsectorname_like;
        if(!StringUtils.isEmpty(this.n_dstorgsectorname_like)){
            this.selectCond.like("dstorgsectorname", n_dstorgsectorname_like);
        }
    }
	private String n_userroledataname_like;

	public void setN_userroledataname_like(String n_userroledataname_like) {
        this.n_userroledataname_like = n_userroledataname_like;
        if(!StringUtils.isEmpty(this.n_userroledataname_like)){
            this.selectCond.like("userroledataname", n_userroledataname_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_USERROLEDATA_DATAENTITY_DEID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_deid_eq("NA");
			}
			else{
				this.setN_deid_eq(strParentkey);
			}
		if(this.srfparentdata.containsKey("srfparentmode")&& this.getSrfparentdata().get("srfparentmode").equals("DER1N_USERROLEDATA_ORG_DSTORGID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_dstorgid_eq("NA");
			}
			else{
				this.setN_dstorgid_eq(strParentkey);
			}
		if(this.srfparentdata.containsKey("srfparentmode")&& this.getSrfparentdata().get("srfparentmode").equals("DER1N_USERROLEDATA_ORGSECTOR_DSTORGSECTORID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_dstorgsectorid_eq("NA");
			}
			else{
				this.setN_dstorgsectorid_eq(strParentkey);
			}
	}

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

}