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.UserRoleDataDetail;
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 UserRoleDataDetailSearchFilter extends SearchFilterBase {

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

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

	private String n_querymodelid_eq;

	public void setN_querymodelid_eq(String n_querymodelid_eq) {
        this.n_querymodelid_eq = n_querymodelid_eq;
        if(!StringUtils.isEmpty(this.n_querymodelid_eq)){
            this.selectCond.eq("querymodelid", n_querymodelid_eq);
        }
    }
	private String n_querymodelname_eq;

	public void setN_querymodelname_eq(String n_querymodelname_eq) {
        this.n_querymodelname_eq = n_querymodelname_eq;
        if(!StringUtils.isEmpty(this.n_querymodelname_eq)){
            this.selectCond.eq("querymodelname", n_querymodelname_eq);
        }
    }
	private String n_querymodelname_like;

	public void setN_querymodelname_like(String n_querymodelname_like) {
        this.n_querymodelname_like = n_querymodelname_like;
        if(!StringUtils.isEmpty(this.n_querymodelname_like)){
            this.selectCond.like("querymodelname", n_querymodelname_like);
        }
    }
	private String n_userroledatadetailname_like;

	public void setN_userroledatadetailname_like(String n_userroledatadetailname_like) {
        this.n_userroledatadetailname_like = n_userroledatadetailname_like;
        if(!StringUtils.isEmpty(this.n_userroledatadetailname_like)){
            this.selectCond.like("userroledatadetailname", n_userroledatadetailname_like);
        }
    }
	private String n_userroledataid_eq;

	public void setN_userroledataid_eq(String n_userroledataid_eq) {
        this.n_userroledataid_eq = n_userroledataid_eq;
        if(!StringUtils.isEmpty(this.n_userroledataid_eq)){
            this.selectCond.eq("userroledataid", n_userroledataid_eq);
        }
    }
	private String n_userroledataname_eq;

	public void setN_userroledataname_eq(String n_userroledataname_eq) {
        this.n_userroledataname_eq = n_userroledataname_eq;
        if(!StringUtils.isEmpty(this.n_userroledataname_eq)){
            this.selectCond.eq("userroledataname", n_userroledataname_eq);
        }
    }
	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_USERROLEDATADETAIL_QUERYMODEL_QUERYMODELID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_querymodelid_eq("NA");
			}
			else{
				this.setN_querymodelid_eq(strParentkey);
			}
		if(this.srfparentdata.containsKey("srfparentmode")&& this.getSrfparentdata().get("srfparentmode").equals("DER1N_USERROLEDATADETAIL_USERROLEDATA_USERROLEDATAID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_userroledataid_eq("NA");
			}
			else{
				this.setN_userroledataid_eq(strParentkey);
			}
	}

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

}