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.TSSDGroupDetail;
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 TSSDGroupDetailSearchFilter extends SearchFilterBase {

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

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

	private String n_tssdgroupdetailname_like;

	public void setN_tssdgroupdetailname_like(String n_tssdgroupdetailname_like) {
        this.n_tssdgroupdetailname_like = n_tssdgroupdetailname_like;
        if(!StringUtils.isEmpty(this.n_tssdgroupdetailname_like)){
            this.selectCond.like("tssdgroupdetailname", n_tssdgroupdetailname_like);
        }
    }
	private String n_tssdgroupid_eq;

	public void setN_tssdgroupid_eq(String n_tssdgroupid_eq) {
        this.n_tssdgroupid_eq = n_tssdgroupid_eq;
        if(!StringUtils.isEmpty(this.n_tssdgroupid_eq)){
            this.selectCond.eq("tssdgroupid", n_tssdgroupid_eq);
        }
    }
	private String n_tssdgroupname_eq;

	public void setN_tssdgroupname_eq(String n_tssdgroupname_eq) {
        this.n_tssdgroupname_eq = n_tssdgroupname_eq;
        if(!StringUtils.isEmpty(this.n_tssdgroupname_eq)){
            this.selectCond.eq("tssdgroupname", n_tssdgroupname_eq);
        }
    }
	private String n_tssdgroupname_like;

	public void setN_tssdgroupname_like(String n_tssdgroupname_like) {
        this.n_tssdgroupname_like = n_tssdgroupname_like;
        if(!StringUtils.isEmpty(this.n_tssdgroupname_like)){
            this.selectCond.like("tssdgroupname", n_tssdgroupname_like);
        }
    }
	private String n_tssditemid_eq;

	public void setN_tssditemid_eq(String n_tssditemid_eq) {
        this.n_tssditemid_eq = n_tssditemid_eq;
        if(!StringUtils.isEmpty(this.n_tssditemid_eq)){
            this.selectCond.eq("tssditemid", n_tssditemid_eq);
        }
    }
	private String n_tssditemname_eq;

	public void setN_tssditemname_eq(String n_tssditemname_eq) {
        this.n_tssditemname_eq = n_tssditemname_eq;
        if(!StringUtils.isEmpty(this.n_tssditemname_eq)){
            this.selectCond.eq("tssditemname", n_tssditemname_eq);
        }
    }
	private String n_tssditemname_like;

	public void setN_tssditemname_like(String n_tssditemname_like) {
        this.n_tssditemname_like = n_tssditemname_like;
        if(!StringUtils.isEmpty(this.n_tssditemname_like)){
            this.selectCond.like("tssditemname", n_tssditemname_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_TSSDGROUPDETAIL_TSSDGROUP_TSSDGROUPID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_tssdgroupid_eq("NA");
			}
			else{
				this.setN_tssdgroupid_eq(strParentkey);
			}
		if(this.srfparentdata.containsKey("srfparentmode")&& this.getSrfparentdata().get("srfparentmode").equals("DER1N_TSSDGROUPDETAIL_TSSDITEM_TSSDITEMID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_tssditemid_eq("NA");
			}
			else{
				this.setN_tssditemid_eq(strParentkey);
			}
	}

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

}