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.UserGroupDetail;
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 UserGroupDetailSearchFilter extends SearchFilterBase {

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

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

	private String n_usergroupdetailname_like;

	public void setN_usergroupdetailname_like(String n_usergroupdetailname_like) {
        this.n_usergroupdetailname_like = n_usergroupdetailname_like;
        if(!StringUtils.isEmpty(this.n_usergroupdetailname_like)){
            this.selectCond.like("usergroupdetailname", n_usergroupdetailname_like);
        }
    }
	private String n_usergroupid_eq;

	public void setN_usergroupid_eq(String n_usergroupid_eq) {
        this.n_usergroupid_eq = n_usergroupid_eq;
        if(!StringUtils.isEmpty(this.n_usergroupid_eq)){
            this.selectCond.eq("usergroupid", n_usergroupid_eq);
        }
    }
	private String n_usergroupname_eq;

	public void setN_usergroupname_eq(String n_usergroupname_eq) {
        this.n_usergroupname_eq = n_usergroupname_eq;
        if(!StringUtils.isEmpty(this.n_usergroupname_eq)){
            this.selectCond.eq("usergroupname", n_usergroupname_eq);
        }
    }
	private String n_usergroupname_like;

	public void setN_usergroupname_like(String n_usergroupname_like) {
        this.n_usergroupname_like = n_usergroupname_like;
        if(!StringUtils.isEmpty(this.n_usergroupname_like)){
            this.selectCond.like("usergroupname", n_usergroupname_like);
        }
    }
	private String n_userobjectid_eq;

	public void setN_userobjectid_eq(String n_userobjectid_eq) {
        this.n_userobjectid_eq = n_userobjectid_eq;
        if(!StringUtils.isEmpty(this.n_userobjectid_eq)){
            this.selectCond.eq("userobjectid", n_userobjectid_eq);
        }
    }
	private String n_userobjectname_eq;

	public void setN_userobjectname_eq(String n_userobjectname_eq) {
        this.n_userobjectname_eq = n_userobjectname_eq;
        if(!StringUtils.isEmpty(this.n_userobjectname_eq)){
            this.selectCond.eq("userobjectname", n_userobjectname_eq);
        }
    }
	private String n_userobjectname_like;

	public void setN_userobjectname_like(String n_userobjectname_like) {
        this.n_userobjectname_like = n_userobjectname_like;
        if(!StringUtils.isEmpty(this.n_userobjectname_like)){
            this.selectCond.like("userobjectname", n_userobjectname_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_USERGROUPDETAIL_USERGROUP_USERGROUPID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_usergroupid_eq("NA");
			}
			else{
				this.setN_usergroupid_eq(strParentkey);
			}
		if(this.srfparentdata.containsKey("srfparentmode")&& this.getSrfparentdata().get("srfparentmode").equals("DER1N_USERGROUPDETAIL_USEROBJECT_USEROBJECTID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_userobjectid_eq("NA");
			}
			else{
				this.setN_userobjectid_eq(strParentkey);
			}
	}

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

}