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.LoginAccount;
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 LoginAccountSearchFilter extends SearchFilterBase {

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

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

	private String n_appuitheme_eq;

	public void setN_appuitheme_eq(String n_appuitheme_eq) {
        this.n_appuitheme_eq = n_appuitheme_eq;
        if(!StringUtils.isEmpty(this.n_appuitheme_eq)){
            this.selectCond.eq("appuitheme", n_appuitheme_eq);
        }
    }
	private Integer n_isenable_eq;

	public void setN_isenable_eq(Integer n_isenable_eq) {
        this.n_isenable_eq = n_isenable_eq;
        if(!StringUtils.isEmpty(this.n_isenable_eq)){
            this.selectCond.eq("isenable", n_isenable_eq);
        }
    }
	private String n_language_eq;

	public void setN_language_eq(String n_language_eq) {
        this.n_language_eq = n_language_eq;
        if(!StringUtils.isEmpty(this.n_language_eq)){
            this.selectCond.eq("language", n_language_eq);
        }
    }
	private String n_loginaccountname_like;

	public void setN_loginaccountname_like(String n_loginaccountname_like) {
        this.n_loginaccountname_like = n_loginaccountname_like;
        if(!StringUtils.isEmpty(this.n_loginaccountname_like)){
            this.selectCond.like("loginaccountname", n_loginaccountname_like);
        }
    }
	private String n_userid_eq;

	public void setN_userid_eq(String n_userid_eq) {
        this.n_userid_eq = n_userid_eq;
        if(!StringUtils.isEmpty(this.n_userid_eq)){
            this.selectCond.eq("userid", n_userid_eq);
        }
    }
	private String n_username_eq;

	public void setN_username_eq(String n_username_eq) {
        this.n_username_eq = n_username_eq;
        if(!StringUtils.isEmpty(this.n_username_eq)){
            this.selectCond.eq("username", n_username_eq);
        }
    }
	private String n_username_like;

	public void setN_username_like(String n_username_like) {
        this.n_username_like = n_username_like;
        if(!StringUtils.isEmpty(this.n_username_like)){
            this.selectCond.like("username", n_username_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_LOGINACCOUNT_USER_USERID"))
			if(StringUtils.isEmpty(strParentkey)){
				this.setN_userid_eq("NA");
			}
			else{
				this.setN_userid_eq(strParentkey);
			}
	}

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

}