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.WFIAAction;
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 WFIAActionSearchFilter extends SearchFilterBase {

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

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

	private String n_wfiaactionname_like;

	public void setN_wfiaactionname_like(String n_wfiaactionname_like) {
        this.n_wfiaactionname_like = n_wfiaactionname_like;
        if(!StringUtils.isEmpty(this.n_wfiaactionname_like)){
            this.selectCond.like("wfiaactionname", n_wfiaactionname_like);
        }
    }
	private String n_wfstepid_eq;

	public void setN_wfstepid_eq(String n_wfstepid_eq) {
        this.n_wfstepid_eq = n_wfstepid_eq;
        if(!StringUtils.isEmpty(this.n_wfstepid_eq)){
            this.selectCond.eq("wfstepid", n_wfstepid_eq);
        }
    }
	private String n_wfstepname_eq;

	public void setN_wfstepname_eq(String n_wfstepname_eq) {
        this.n_wfstepname_eq = n_wfstepname_eq;
        if(!StringUtils.isEmpty(this.n_wfstepname_eq)){
            this.selectCond.eq("wfstepname", n_wfstepname_eq);
        }
    }
	private String n_wfstepname_like;

	public void setN_wfstepname_like(String n_wfstepname_like) {
        this.n_wfstepname_like = n_wfstepname_like;
        if(!StringUtils.isEmpty(this.n_wfstepname_like)){
            this.selectCond.like("wfstepname", n_wfstepname_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_WFIAACTION_WFSTEP_WFSTEPID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_wfstepid_eq("NA");
			}
			else{
				this.setN_wfstepid_eq(strParentkey);
			}
	}

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

}