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.TSSDItem;
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 TSSDItemSearchFilter extends SearchFilterBase {

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

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

	private String n_hourtype_eq;

	public void setN_hourtype_eq(String n_hourtype_eq) {
        this.n_hourtype_eq = n_hourtype_eq;
        if(!StringUtils.isEmpty(this.n_hourtype_eq)){
            this.selectCond.eq("hourtype", n_hourtype_eq);
        }
    }
	private String n_minutetype_eq;

	public void setN_minutetype_eq(String n_minutetype_eq) {
        this.n_minutetype_eq = n_minutetype_eq;
        if(!StringUtils.isEmpty(this.n_minutetype_eq)){
            this.selectCond.eq("minutetype", n_minutetype_eq);
        }
    }
	private String n_monthdaytype_eq;

	public void setN_monthdaytype_eq(String n_monthdaytype_eq) {
        this.n_monthdaytype_eq = n_monthdaytype_eq;
        if(!StringUtils.isEmpty(this.n_monthdaytype_eq)){
            this.selectCond.eq("monthdaytype", n_monthdaytype_eq);
        }
    }
	private String n_monthtype_eq;

	public void setN_monthtype_eq(String n_monthtype_eq) {
        this.n_monthtype_eq = n_monthtype_eq;
        if(!StringUtils.isEmpty(this.n_monthtype_eq)){
            this.selectCond.eq("monthtype", n_monthtype_eq);
        }
    }
	private String n_monthweektype_eq;

	public void setN_monthweektype_eq(String n_monthweektype_eq) {
        this.n_monthweektype_eq = n_monthweektype_eq;
        if(!StringUtils.isEmpty(this.n_monthweektype_eq)){
            this.selectCond.eq("monthweektype", n_monthweektype_eq);
        }
    }
	private String n_secondtype_eq;

	public void setN_secondtype_eq(String n_secondtype_eq) {
        this.n_secondtype_eq = n_secondtype_eq;
        if(!StringUtils.isEmpty(this.n_secondtype_eq)){
            this.selectCond.eq("secondtype", n_secondtype_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");
	}

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

}