StringBuilder sql = new StringBuilder(" SELECT t.id from table t where 1=1 " );
//判断查询拼接
if (collect != null && collect.size() > 0 ) {
sql.append(" and t.village_id in ( " );
sql( collect, sql);
sql.append(" ) ");
}
//工具类
public void sql(List<String> collect, StringBuilder sql){
for(int i = 0; i < collect.size(); i++) {
if (i > 0)
sql.append(",").append("\'").append(collect.get(i)).append("\'");
else
sql.append("\'").append(collect.get(i)).append("\'");
}
}