package cn.estsh.i3plus.pojo.mdm.sqlpack;

import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.mdm.bean.busi.MdmDataSubscribe;
import cn.estsh.i3plus.pojo.mdm.bean.busi.MdmExternalApp;

/**
 * @Description :
 * @Reference :
 * @Author : yunhao
 * @CreateDate : 2021-04-14 19:33
 * @Modify:
 **/
public class MdmHqlPack {

    /**
     * mdm订阅信息查询条件拼接
     *
     * @param mdmDataSubscribe
     * @return
     */
    public static DdlPackBean packHqlMdmDataSubscribe(MdmDataSubscribe mdmDataSubscribe) {
        DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(mdmDataSubscribe);

        DdlPreparedPack.getStringLikerPack(mdmDataSubscribe.getMdmName(), "mdmName", ddlPackBean);
        DdlPreparedPack.getStringLikerPack(mdmDataSubscribe.getMdmClassName(), "mdmClassName", ddlPackBean);

        return ddlPackBean;
    }

    public static DdlPackBean packHqlCheckMdmDataSubscribeOnly(MdmDataSubscribe mdmDataSubscribe) {
        DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(mdmDataSubscribe);

        DdlPreparedPack.getNumNOEqualPack(mdmDataSubscribe.getId(), "id", ddlPackBean);
        DdlPreparedPack.getStringEqualPack(mdmDataSubscribe.getMdmClassName(), "mdmClassName", ddlPackBean);

        return ddlPackBean;
    }

    /**
     * 外部应用查询条件拼接
     *
     * @param mdmExternalApp
     * @return
     */
    public static DdlPackBean packHqlMdmExternalApp(MdmExternalApp mdmExternalApp) {
        DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(mdmExternalApp);

        DdlPreparedPack.getStringLikerPack(mdmExternalApp.getAppName(), "appName", ddlPackBean);
        DdlPreparedPack.getStringLikerPack(mdmExternalApp.getAppCode(), "appCode", ddlPackBean);

        return ddlPackBean;
    }

    /**
     * 数据对象查询条件拼接
     *
     * @param mdmExternalApp
     * @return
     */
    public static DdlPackBean packHqlCheckMdmExternalAppOnly(MdmExternalApp mdmExternalApp) {
        DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(mdmExternalApp);

        DdlPreparedPack.getNumNOEqualPack(mdmExternalApp.getId(), "id", ddlPackBean);
        DdlPreparedPack.getStringEqualPack(mdmExternalApp.getAppCode(), "appCode", ddlPackBean);

        return ddlPackBean;
    }

}
