mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 00:58:24 +08:00
feat: 添加取相反数的构建。
This commit is contained in:
parent
8724fc0b42
commit
9d464caf3e
@ -0,0 +1,40 @@
|
||||
package com.mybatisflex.core.query;
|
||||
|
||||
import com.mybatisflex.core.FlexConsts;
|
||||
import com.mybatisflex.core.dialect.IDialect;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 取相反数({@code -column})。
|
||||
*
|
||||
* @author 王帅
|
||||
* @since 2023-11-09
|
||||
*/
|
||||
public class NegativeQueryColumn extends QueryColumn implements HasParamsColumn {
|
||||
|
||||
private final QueryColumn queryColumn;
|
||||
|
||||
public NegativeQueryColumn(QueryColumn queryColumn) {
|
||||
this.queryColumn = queryColumn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getParamValues() {
|
||||
if (queryColumn instanceof HasParamsColumn) {
|
||||
return ((HasParamsColumn) queryColumn).getParamValues();
|
||||
}
|
||||
return FlexConsts.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
String toSelectSql(List<QueryTable> queryTables, IDialect dialect) {
|
||||
return toConditionSql(queryTables, dialect) + WrapperUtil.buildColumnAlias(alias, dialect);
|
||||
}
|
||||
|
||||
@Override
|
||||
String toConditionSql(List<QueryTable> queryTables, IDialect dialect) {
|
||||
return "-" + queryColumn.toConditionSql(queryTables, dialect);
|
||||
}
|
||||
|
||||
}
|
||||
@ -2408,6 +2408,13 @@ public class QueryMethods {
|
||||
return new RawQueryColumn("'" + s + "'");
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建相反数。
|
||||
*/
|
||||
public static QueryColumn negative(QueryColumn queryColumn) {
|
||||
return new NegativeQueryColumn(queryColumn);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建自定义列。
|
||||
*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user