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.WFUCPolicy;
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 WFUCPolicySearchFilter extends SearchFilterBase {

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

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

	private String n_majorwfuserid_eq;

	public void setN_majorwfuserid_eq(String n_majorwfuserid_eq) {
        this.n_majorwfuserid_eq = n_majorwfuserid_eq;
        if(!StringUtils.isEmpty(this.n_majorwfuserid_eq)){
            this.selectCond.eq("majorwfuserid", n_majorwfuserid_eq);
        }
    }
	private String n_majorwfusername_eq;

	public void setN_majorwfusername_eq(String n_majorwfusername_eq) {
        this.n_majorwfusername_eq = n_majorwfusername_eq;
        if(!StringUtils.isEmpty(this.n_majorwfusername_eq)){
            this.selectCond.eq("majorwfusername", n_majorwfusername_eq);
        }
    }
	private String n_majorwfusername_like;

	public void setN_majorwfusername_like(String n_majorwfusername_like) {
        this.n_majorwfusername_like = n_majorwfusername_like;
        if(!StringUtils.isEmpty(this.n_majorwfusername_like)){
            this.selectCond.like("majorwfusername", n_majorwfusername_like);
        }
    }
	private String n_minorwfuserid_eq;

	public void setN_minorwfuserid_eq(String n_minorwfuserid_eq) {
        this.n_minorwfuserid_eq = n_minorwfuserid_eq;
        if(!StringUtils.isEmpty(this.n_minorwfuserid_eq)){
            this.selectCond.eq("minorwfuserid", n_minorwfuserid_eq);
        }
    }
	private String n_minorwfusername_eq;

	public void setN_minorwfusername_eq(String n_minorwfusername_eq) {
        this.n_minorwfusername_eq = n_minorwfusername_eq;
        if(!StringUtils.isEmpty(this.n_minorwfusername_eq)){
            this.selectCond.eq("minorwfusername", n_minorwfusername_eq);
        }
    }
	private String n_minorwfusername_like;

	public void setN_minorwfusername_like(String n_minorwfusername_like) {
        this.n_minorwfusername_like = n_minorwfusername_like;
        if(!StringUtils.isEmpty(this.n_minorwfusername_like)){
            this.selectCond.like("minorwfusername", n_minorwfusername_like);
        }
    }
	private Integer n_policystate_eq;

	public void setN_policystate_eq(Integer n_policystate_eq) {
        this.n_policystate_eq = n_policystate_eq;
        if(!StringUtils.isEmpty(this.n_policystate_eq)){
            this.selectCond.eq("policystate", n_policystate_eq);
        }
    }
	private String n_wfucpolicyname_like;

	public void setN_wfucpolicyname_like(String n_wfucpolicyname_like) {
        this.n_wfucpolicyname_like = n_wfucpolicyname_like;
        if(!StringUtils.isEmpty(this.n_wfucpolicyname_like)){
            this.selectCond.like("wfucpolicyname", n_wfucpolicyname_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_WFUCPOLICY_WFUSER_MAJORWFUSERID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_majorwfuserid_eq("NA");
			}
			else{
				this.setN_majorwfuserid_eq(strParentkey);
			}
		if(this.srfparentdata.containsKey("srfparentmode")&& this.getSrfparentdata().get("srfparentmode").equals("DER1N_WFUCPOLICY_WFUSER_MINORWFUSERID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_minorwfuserid_eq("NA");
			}
			else{
				this.setN_minorwfuserid_eq(strParentkey);
			}
	}

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

}