package com.bcxin.ars.export;

import com.bcxin.ars.enums.SignType;

import java.util.Map;

/**
 * @author linqinglin
 * @date 2020/04/07 0007 9:20
 */
public class OrLikeExportWhereStrategy implements ExportWhereStrategy {

    @Override
    public String spliceWhereStr(SignType signType, Map<String,String> columnMap, Map<Object, Object> searchParams, Object key) {
        String[] columns = columnMap.get(key).split(",");
        StringBuilder columnStr = new StringBuilder("AND (");
        for (int i = 0; i < columns.length; i++) {
            if(i>0){
                columnStr.append(" or ");
            }
            columnStr.append(columns[i])
                    .append(" like '%")
                    .append(searchParams.get(key))
                    .append("%'");
        }
        columnStr.append(")");
        return columnStr.toString();
    }
}
