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.Services;
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 ServicesSearchFilter extends SearchFilterBase {

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

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

	private String n_container_eq;

	public void setN_container_eq(String n_container_eq) {
        this.n_container_eq = n_container_eq;
        if(!StringUtils.isEmpty(this.n_container_eq)){
            this.selectCond.eq("container", n_container_eq);
        }
    }
	private String n_servicename_like;

	public void setN_servicename_like(String n_servicename_like) {
        this.n_servicename_like = n_servicename_like;
        if(!StringUtils.isEmpty(this.n_servicename_like)){
            this.selectCond.like("servicename", n_servicename_like);
        }
    }
	private String n_servicestate_eq;

	public void setN_servicestate_eq(String n_servicestate_eq) {
        this.n_servicestate_eq = n_servicestate_eq;
        if(!StringUtils.isEmpty(this.n_servicestate_eq)){
            this.selectCond.eq("servicestate", n_servicestate_eq);
        }
    }
	private String n_startmode_eq;

	public void setN_startmode_eq(String n_startmode_eq) {
        this.n_startmode_eq = n_startmode_eq;
        if(!StringUtils.isEmpty(this.n_startmode_eq)){
            this.selectCond.eq("startmode", n_startmode_eq);
        }
    }

	public void setSrfparentdata(Map<String, String> srfparentdata) {
		this.srfparentdata = srfparentdata;
		String strParentkey=this.getSrfparentdata().get("srfparentkey");
	}

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

}