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.WFUserGroupDetail;
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 WFUserGroupDetailSearchFilter extends SearchFilterBase {

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

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

	private String n_wfusergroupdetailname_like;

	public void setN_wfusergroupdetailname_like(String n_wfusergroupdetailname_like) {
        this.n_wfusergroupdetailname_like = n_wfusergroupdetailname_like;
        if(!StringUtils.isEmpty(this.n_wfusergroupdetailname_like)){
            this.selectCond.like("wfusergroupdetailname", n_wfusergroupdetailname_like);
        }
    }
	private String n_wfusergroupid_eq;

	public void setN_wfusergroupid_eq(String n_wfusergroupid_eq) {
        this.n_wfusergroupid_eq = n_wfusergroupid_eq;
        if(!StringUtils.isEmpty(this.n_wfusergroupid_eq)){
            this.selectCond.eq("wfusergroupid", n_wfusergroupid_eq);
        }
    }
	private String n_wfusergroupname_eq;

	public void setN_wfusergroupname_eq(String n_wfusergroupname_eq) {
        this.n_wfusergroupname_eq = n_wfusergroupname_eq;
        if(!StringUtils.isEmpty(this.n_wfusergroupname_eq)){
            this.selectCond.eq("wfusergroupname", n_wfusergroupname_eq);
        }
    }
	private String n_wfusergroupname_like;

	public void setN_wfusergroupname_like(String n_wfusergroupname_like) {
        this.n_wfusergroupname_like = n_wfusergroupname_like;
        if(!StringUtils.isEmpty(this.n_wfusergroupname_like)){
            this.selectCond.like("wfusergroupname", n_wfusergroupname_like);
        }
    }
	private String n_wfuserid_eq;

	public void setN_wfuserid_eq(String n_wfuserid_eq) {
        this.n_wfuserid_eq = n_wfuserid_eq;
        if(!StringUtils.isEmpty(this.n_wfuserid_eq)){
            this.selectCond.eq("wfuserid", n_wfuserid_eq);
        }
    }
	private String n_wfusername_eq;

	public void setN_wfusername_eq(String n_wfusername_eq) {
        this.n_wfusername_eq = n_wfusername_eq;
        if(!StringUtils.isEmpty(this.n_wfusername_eq)){
            this.selectCond.eq("wfusername", n_wfusername_eq);
        }
    }
	private String n_wfusername_like;

	public void setN_wfusername_like(String n_wfusername_like) {
        this.n_wfusername_like = n_wfusername_like;
        if(!StringUtils.isEmpty(this.n_wfusername_like)){
            this.selectCond.like("wfusername", n_wfusername_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_WFUSERGROUPDETAIL_WFUSERGROUP_WFUSERGROUPID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_wfusergroupid_eq("NA");
			}
			else{
				this.setN_wfusergroupid_eq(strParentkey);
			}
		if(this.srfparentdata.containsKey("srfparentmode")&& this.getSrfparentdata().get("srfparentmode").equals("DER1N_WFUSERGROUPDETAIL_WFUSER_WFUSERID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_wfuserid_eq("NA");
			}
			else{
				this.setN_wfuserid_eq(strParentkey);
			}
	}

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

}