package cn.estsh.i3plus.core.apiservice.util;

import cn.estsh.i3plus.pojo.base.tool.HqlPack;
import cn.estsh.i3plus.pojo.model.platform.UserDetailModel;
import org.apache.commons.lang3.StringUtils;

import java.util.List;

/**
 * @Description :
 * @Reference :
 * @Author : Adair Peng
 * @CreateDate : 2018-12-26 19:22
 * @Modify:
 **/
public class HqlModelPack {



    /**
     * 用户信息 复杂查询拼接
     * @param model
     * @return
     */
    public static String packHqlSysUserByModelOrIds(UserDetailModel model, List<Long> idList){
        StringBuffer result = new StringBuffer();

        // And
        HqlPack.getNumEqualPack(model.getUserStatus(),"userStatus",result);
        HqlPack.getNumEqualPack(model.getUserPhone(),"userPhone",result);

        if(idList != null && idList.size() > 0){
            HqlPack.getInPack(StringUtils.join(idList, ","), "id", result);
        }

        // Like
        HqlPack.getStringLikerPack(model.getInfoName(),"userName",result);
        HqlPack.getStringLikerPack(model.getInfoEmpNo(),"userEmpNo",result);

        return  result.toString();
    }

}
