278 lines
6.4 KiB
Java
278 lines
6.4 KiB
Java
package aiyh.utils.sqlUtil.whereUtil.impl;
|
|
|
|
import aiyh.utils.sqlUtil.whereUtil.Where;
|
|
import aiyh.utils.sqlUtil.whereUtil.WhereOperator;
|
|
import weaver.conn.RecordSet;
|
|
|
|
import java.util.List;
|
|
|
|
/**
|
|
* @author EBU7-dev1-ayh
|
|
* @date 2021/8/23 0023 13:23
|
|
*/
|
|
|
|
@Deprecated
|
|
public class WhereOperatorImpl implements WhereOperator {
|
|
private final WhereImpl where;
|
|
private String DB_TYPE;
|
|
|
|
{
|
|
// 获取当前数据库的类型
|
|
this.DB_TYPE = (new RecordSet()).getDBType();
|
|
}
|
|
|
|
public WhereOperatorImpl(WhereImpl where) {
|
|
this.where = where;
|
|
}
|
|
|
|
|
|
@Override
|
|
public Where whereNull() {
|
|
this.where.whereAppend(" is null ");
|
|
return this.where;
|
|
}
|
|
|
|
@Override
|
|
public Where whereNotNull() {
|
|
this.where.whereAnd(" is not null ");
|
|
return this.where;
|
|
}
|
|
|
|
@Override
|
|
public Where whereEqual(Object value) {
|
|
this.where.whereAppend(" = ");
|
|
this.where.whereAppend("'");
|
|
this.where.whereAppend(value);
|
|
this.where.whereAppend("'");
|
|
return this.where;
|
|
}
|
|
|
|
@Override
|
|
public Where whereNotEqual(Object value) {
|
|
this.where.whereAppend(" <> ");
|
|
this.where.whereAppend("'");
|
|
this.where.whereAppend(value);
|
|
this.where.whereAppend("'");
|
|
return this.where;
|
|
}
|
|
|
|
@Override
|
|
public Where greaterThan(Object value) {
|
|
this.where.whereAppend(" > ");
|
|
this.where.whereAppend("'");
|
|
this.where.whereAppend(value);
|
|
this.where.whereAppend("'");
|
|
return this.where;
|
|
}
|
|
|
|
@Override
|
|
public Where lessThan(Object value) {
|
|
this.where.whereAppend(" < ");
|
|
this.where.whereAppend("'");
|
|
this.where.whereAppend(value);
|
|
this.where.whereAppend("'");
|
|
return this.where;
|
|
}
|
|
|
|
@Override
|
|
public Where greaterOrEqual(Object value) {
|
|
this.where.whereAppend(" >= ");
|
|
this.where.whereAppend("'");
|
|
this.where.whereAppend(value);
|
|
this.where.whereAppend("'");
|
|
return this.where;
|
|
}
|
|
|
|
@Override
|
|
public Where lessThanOrEqual(Object value) {
|
|
this.where.whereAppend(" <= ");
|
|
this.where.whereAppend("'");
|
|
this.where.whereAppend(value);
|
|
this.where.whereAppend("'");
|
|
return this.where;
|
|
}
|
|
|
|
@Override
|
|
public Where BetweenAnd(Object start, Object end) {
|
|
this.where.whereAppend(" between ");
|
|
this.where.whereAppend("'");
|
|
this.where.whereAppend(start);
|
|
this.where.whereAppend("'");
|
|
this.where.whereAppend(" and ");
|
|
this.where.whereAppend("'");
|
|
this.where.whereAppend(end);
|
|
this.where.whereAppend("'");
|
|
return this.where;
|
|
}
|
|
|
|
@Override
|
|
public Where whereIn(Object... values) {
|
|
this.where.whereAppend(" in ( ");
|
|
for (int i = 0; i < values.length; i++) {
|
|
this.where.whereAppend("'");
|
|
this.where.whereAppend(values[i]);
|
|
this.where.whereAppend("'");
|
|
if (i < values.length - 1) {
|
|
this.where.whereAppend(",");
|
|
}
|
|
}
|
|
this.where.whereAppend(" ) ");
|
|
return this.where;
|
|
}
|
|
|
|
@Override
|
|
public Where whereInList(List<Object> list) {
|
|
this.where.whereAppend(" in ( ");
|
|
for (int i = 0; i < list.size(); i++) {
|
|
this.where.whereAppend("'");
|
|
this.where.whereAppend(list.get(i));
|
|
this.where.whereAppend("'");
|
|
if (i < list.size() - 1) {
|
|
this.where.whereAppend(",");
|
|
}
|
|
}
|
|
this.where.whereAppend(" ) ");
|
|
return this.where;
|
|
}
|
|
|
|
@Override
|
|
public Where whereNotIn(Object... values) {
|
|
this.where.whereAppend(" not in ( ");
|
|
for (int i = 0; i < values.length; i++) {
|
|
this.where.whereAppend("'");
|
|
this.where.whereAppend(values[i]);
|
|
this.where.whereAppend("'");
|
|
if (i < values.length - 1) {
|
|
this.where.whereAppend(",");
|
|
}
|
|
}
|
|
this.where.whereAppend(" ) ");
|
|
return this.where;
|
|
}
|
|
|
|
@Override
|
|
public Where whereNotInList(List<Object> list) {
|
|
this.where.whereAppend(" not in ( ");
|
|
for (int i = 0; i < list.size(); i++) {
|
|
this.where.whereAppend("'");
|
|
this.where.whereAppend(list.get(i));
|
|
this.where.whereAppend("'");
|
|
if (i < list.size() - 1) {
|
|
this.where.whereAppend(", ");
|
|
}
|
|
}
|
|
this.where.whereAppend(" ) ");
|
|
return this.where;
|
|
}
|
|
|
|
@Override
|
|
public Where inSql(Object sql) {
|
|
this.where.whereAppend(" in ( ");
|
|
this.where.whereAppend(sql);
|
|
this.where.whereAppend(" ) ");
|
|
return this.where;
|
|
}
|
|
|
|
@Override
|
|
public Where notInSql(Object sql) {
|
|
this.where.whereAppend(" not in ( ");
|
|
this.where.whereAppend(sql);
|
|
this.where.whereAppend(" ) ");
|
|
return this.where;
|
|
}
|
|
|
|
@Override
|
|
public Where whereLike(Object value) {
|
|
this.where.whereAppend(" like ");
|
|
this.where.whereAppend("'");
|
|
this.where.whereAppend(value);
|
|
this.where.whereAppend("'");
|
|
return this.where;
|
|
}
|
|
|
|
@Override
|
|
public Where whereNotLike(Object value) {
|
|
this.where.whereAppend(" not like ");
|
|
this.where.whereAppend("'");
|
|
this.where.whereAppend(value);
|
|
this.where.whereAppend("'");
|
|
return this.where;
|
|
}
|
|
|
|
@Override
|
|
public Where whereExists(Object... values) {
|
|
this.where.whereAppend(" exists ( ");
|
|
for (int i = 0; i < values.length; i++) {
|
|
this.where.whereAppend("'");
|
|
this.where.whereAppend(values[i]);
|
|
this.where.whereAppend("'");
|
|
if (i < values.length - 1) {
|
|
this.where.whereAppend(",");
|
|
}
|
|
}
|
|
this.where.whereAppend(" ) ");
|
|
return this.where;
|
|
}
|
|
|
|
@Override
|
|
public Where whereNotExists(Object... values) {
|
|
this.where.whereAppend(" not exists ( ");
|
|
for (int i = 0; i < values.length; i++) {
|
|
this.where.whereAppend("'");
|
|
this.where.whereAppend(values[i]);
|
|
this.where.whereAppend("'");
|
|
if (i < values.length - 1) {
|
|
this.where.whereAppend(",");
|
|
}
|
|
}
|
|
this.where.whereAppend(" ) ");
|
|
return this.where;
|
|
}
|
|
|
|
@Override
|
|
public Where whereExistsList(List<Object> list) {
|
|
this.where.whereAppend(" exists ( ");
|
|
for (int i = 0; i < list.size(); i++) {
|
|
this.where.whereAppend("'");
|
|
this.where.whereAppend(list.get(i));
|
|
this.where.whereAppend("'");
|
|
if (i < list.size() - 1) {
|
|
this.where.whereAppend(", ");
|
|
}
|
|
}
|
|
this.where.whereAppend(" ) ");
|
|
return this.where;
|
|
}
|
|
|
|
@Override
|
|
public Where whereNotExistsList(List<Object> list) {
|
|
this.where.whereAppend(" not exists ( ");
|
|
for (int i = 0; i < list.size(); i++) {
|
|
this.where.whereAppend("'");
|
|
this.where.whereAppend(list.get(i));
|
|
this.where.whereAppend("'");
|
|
if (i < list.size() - 1) {
|
|
this.where.whereAppend(", ");
|
|
}
|
|
}
|
|
this.where.whereAppend(" ) ");
|
|
return this.where;
|
|
}
|
|
|
|
@Override
|
|
public Where whereExistsSql(Object sql) {
|
|
this.where.whereAppend(" exists ( ");
|
|
this.where.whereAppend(sql);
|
|
this.where.whereAppend(" ) ");
|
|
return this.where;
|
|
}
|
|
|
|
@Override
|
|
public Where whereNotExistsSql(Object sql) {
|
|
this.where.whereAppend(" not exists ( ");
|
|
this.where.whereAppend(sql);
|
|
this.where.whereAppend(" ) ");
|
|
return this.where;
|
|
}
|
|
}
|