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.UserRoleDEFields;
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 UserRoleDEFieldsSearchFilter extends SearchFilterBase {

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

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

	private String n_userroledefieldid_eq;

	public void setN_userroledefieldid_eq(String n_userroledefieldid_eq) {
        this.n_userroledefieldid_eq = n_userroledefieldid_eq;
        if(!StringUtils.isEmpty(this.n_userroledefieldid_eq)){
            this.selectCond.eq("userroledefieldid", n_userroledefieldid_eq);
        }
    }
	private String n_userroledefieldname_eq;

	public void setN_userroledefieldname_eq(String n_userroledefieldname_eq) {
        this.n_userroledefieldname_eq = n_userroledefieldname_eq;
        if(!StringUtils.isEmpty(this.n_userroledefieldname_eq)){
            this.selectCond.eq("userroledefieldname", n_userroledefieldname_eq);
        }
    }
	private String n_userroledefieldname_like;

	public void setN_userroledefieldname_like(String n_userroledefieldname_like) {
        this.n_userroledefieldname_like = n_userroledefieldname_like;
        if(!StringUtils.isEmpty(this.n_userroledefieldname_like)){
            this.selectCond.like("userroledefieldname", n_userroledefieldname_like);
        }
    }
	private String n_userroledefieldsname_like;

	public void setN_userroledefieldsname_like(String n_userroledefieldsname_like) {
        this.n_userroledefieldsname_like = n_userroledefieldsname_like;
        if(!StringUtils.isEmpty(this.n_userroledefieldsname_like)){
            this.selectCond.like("userroledefieldsname", n_userroledefieldsname_like);
        }
    }
	private String n_userroleid_eq;

	public void setN_userroleid_eq(String n_userroleid_eq) {
        this.n_userroleid_eq = n_userroleid_eq;
        if(!StringUtils.isEmpty(this.n_userroleid_eq)){
            this.selectCond.eq("userroleid", n_userroleid_eq);
        }
    }
	private String n_userrolename_eq;

	public void setN_userrolename_eq(String n_userrolename_eq) {
        this.n_userrolename_eq = n_userrolename_eq;
        if(!StringUtils.isEmpty(this.n_userrolename_eq)){
            this.selectCond.eq("userrolename", n_userrolename_eq);
        }
    }
	private String n_userrolename_like;

	public void setN_userrolename_like(String n_userrolename_like) {
        this.n_userrolename_like = n_userrolename_like;
        if(!StringUtils.isEmpty(this.n_userrolename_like)){
            this.selectCond.like("userrolename", n_userrolename_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_USERROLEDEFIELDS_USERROLEDEFIELD_USERROLEDEFIELDID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_userroledefieldid_eq("NA");
			}
			else{
				this.setN_userroledefieldid_eq(strParentkey);
			}
		if(this.srfparentdata.containsKey("srfparentmode")&& this.getSrfparentdata().get("srfparentmode").equals("DER1N_USERROLEDEFIELDS_USERROLE_USERROLEID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_userroleid_eq("NA");
			}
			else{
				this.setN_userroleid_eq(strParentkey);
			}
	}

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

}