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.MsgAccountDetail;
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 MsgAccountDetailSearchFilter extends SearchFilterBase {

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

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

	private String n_majormsgaccountid_eq;

	public void setN_majormsgaccountid_eq(String n_majormsgaccountid_eq) {
        this.n_majormsgaccountid_eq = n_majormsgaccountid_eq;
        if(!StringUtils.isEmpty(this.n_majormsgaccountid_eq)){
            this.selectCond.eq("majormsgaccountid", n_majormsgaccountid_eq);
        }
    }
	private String n_majormsgaccountname_eq;

	public void setN_majormsgaccountname_eq(String n_majormsgaccountname_eq) {
        this.n_majormsgaccountname_eq = n_majormsgaccountname_eq;
        if(!StringUtils.isEmpty(this.n_majormsgaccountname_eq)){
            this.selectCond.eq("majormsgaccountname", n_majormsgaccountname_eq);
        }
    }
	private String n_majormsgaccountname_like;

	public void setN_majormsgaccountname_like(String n_majormsgaccountname_like) {
        this.n_majormsgaccountname_like = n_majormsgaccountname_like;
        if(!StringUtils.isEmpty(this.n_majormsgaccountname_like)){
            this.selectCond.like("majormsgaccountname", n_majormsgaccountname_like);
        }
    }
	private String n_minormsgaccountid_eq;

	public void setN_minormsgaccountid_eq(String n_minormsgaccountid_eq) {
        this.n_minormsgaccountid_eq = n_minormsgaccountid_eq;
        if(!StringUtils.isEmpty(this.n_minormsgaccountid_eq)){
            this.selectCond.eq("minormsgaccountid", n_minormsgaccountid_eq);
        }
    }
	private String n_minormsgaccountname_eq;

	public void setN_minormsgaccountname_eq(String n_minormsgaccountname_eq) {
        this.n_minormsgaccountname_eq = n_minormsgaccountname_eq;
        if(!StringUtils.isEmpty(this.n_minormsgaccountname_eq)){
            this.selectCond.eq("minormsgaccountname", n_minormsgaccountname_eq);
        }
    }
	private String n_minormsgaccountname_like;

	public void setN_minormsgaccountname_like(String n_minormsgaccountname_like) {
        this.n_minormsgaccountname_like = n_minormsgaccountname_like;
        if(!StringUtils.isEmpty(this.n_minormsgaccountname_like)){
            this.selectCond.like("minormsgaccountname", n_minormsgaccountname_like);
        }
    }
	private String n_msgaccountdetailname_like;

	public void setN_msgaccountdetailname_like(String n_msgaccountdetailname_like) {
        this.n_msgaccountdetailname_like = n_msgaccountdetailname_like;
        if(!StringUtils.isEmpty(this.n_msgaccountdetailname_like)){
            this.selectCond.like("msgaccountdetailname", n_msgaccountdetailname_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_MSGACCOUNTDETAIL_MSGACCOUNT_MAJORMSGACCOUNTID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_majormsgaccountid_eq("NA");
			}
			else{
				this.setN_majormsgaccountid_eq(strParentkey);
			}
		if(this.srfparentdata.containsKey("srfparentmode")&& this.getSrfparentdata().get("srfparentmode").equals("DER1N_MSGACCOUNTDETAIL_MSGACCOUNT_MINORMSGACCOUNTID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_minormsgaccountid_eq("NA");
			}
			else{
				this.setN_minormsgaccountid_eq(strParentkey);
			}
	}

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

}