package com.jwipc.db;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.enums.SqlLike;
import com.baomidou.mybatisplus.core.toolkit.sql.SqlUtils;

import java.util.Collections;
import java.util.List;

/**
 * <p> </p>
 *
 * @author ZhangJie
 * @version 1.0
 * @since JDK 1.8
 */
public class DbUtil {
    public static String toRegexp(String val){
        if(StrUtil.isNotEmpty(val)){
            return val.replace(" ","|");
        }
        return val;
    }
    public static String toLike(String val) {
        if (StrUtil.isNotEmpty(val)) {
            return SqlUtils.concatLike(val, SqlLike.DEFAULT);
        }
        return val;
    }

    public static List<String> toList(String val) {
        if (StrUtil.isNotEmpty(val)) {
            return StrUtil.split(val, StrUtil.COMMA);
        }
        return Collections.emptyList();
    }
    
    public final static String LIMIT1="LIMIT 1";
}
