ColumnExpress增加除法、取模表达式
This commit is contained in:
@@ -15,17 +15,25 @@ package org.redkale.source;
|
||||
*/
|
||||
public enum ColumnExpress {
|
||||
/**
|
||||
* 直接赋值 col = val
|
||||
* 赋值 col = val
|
||||
*/
|
||||
MOV,
|
||||
/**
|
||||
* 追加值 col = col + val
|
||||
* 加值 col = col + val
|
||||
*/
|
||||
INC,
|
||||
/**
|
||||
* 乘值 col = col * val
|
||||
*/
|
||||
MUL,
|
||||
/**
|
||||
* 除值 col = col / val
|
||||
*/
|
||||
DIV,
|
||||
/**
|
||||
* 取模 col = col % val
|
||||
*/
|
||||
MOD,
|
||||
/**
|
||||
* 与值 col = col & val
|
||||
*/
|
||||
|
||||
@@ -617,6 +617,22 @@ public final class EntityCache<T> {
|
||||
numb = numb.longValue() * ((Number) val).floatValue();
|
||||
}
|
||||
break;
|
||||
case DIV:
|
||||
numb = (Number) attr.get(entity);
|
||||
if (numb == null) {
|
||||
numb = 0;
|
||||
} else {
|
||||
numb = numb.longValue() / ((Number) val).floatValue();
|
||||
}
|
||||
break;
|
||||
case MOD:
|
||||
numb = (Number) attr.get(entity);
|
||||
if (numb == null) {
|
||||
numb = 0;
|
||||
} else {
|
||||
numb = numb.longValue() % ((Number) val).intValue();
|
||||
}
|
||||
break;
|
||||
case AND:
|
||||
numb = (Number) attr.get(entity);
|
||||
if (numb == null) {
|
||||
|
||||
@@ -897,9 +897,9 @@ public final class EntityInfo<T> {
|
||||
/**
|
||||
* 字段值转换成带转义的数据库的值
|
||||
*
|
||||
* @param fieldname 字段名
|
||||
* @param fieldvalue 字段值
|
||||
* @param sqlFormatter 转义器
|
||||
* @param fieldname 字段名
|
||||
* @param fieldvalue 字段值
|
||||
* @param sqlFormatter 转义器
|
||||
*
|
||||
* @return CharSequence
|
||||
*/
|
||||
@@ -911,7 +911,7 @@ public final class EntityInfo<T> {
|
||||
/**
|
||||
* 字段值转换成带转义的数据库的值
|
||||
*
|
||||
* @param value 字段值
|
||||
* @param value 字段值
|
||||
* @param sqlFormatter 转义器
|
||||
*
|
||||
* @return CharSequence
|
||||
@@ -939,9 +939,9 @@ public final class EntityInfo<T> {
|
||||
/**
|
||||
* 字段值转换成带转义的数据库的值
|
||||
*
|
||||
* @param <F> 泛型
|
||||
* @param attr Attribute
|
||||
* @param entity 记录对象
|
||||
* @param <F> 泛型
|
||||
* @param attr Attribute
|
||||
* @param entity 记录对象
|
||||
* @param sqlFormatter 转义器
|
||||
*
|
||||
* @return CharSequence
|
||||
@@ -1006,6 +1006,10 @@ public final class EntityInfo<T> {
|
||||
return new StringBuilder().append(col).append(" + ").append(val);
|
||||
case MUL:
|
||||
return new StringBuilder().append(col).append(" * ").append(val);
|
||||
case DIV:
|
||||
return new StringBuilder().append(col).append(" / ").append(val);
|
||||
case MOD:
|
||||
return new StringBuilder().append(col).append(" % ").append(val);
|
||||
case AND:
|
||||
return new StringBuilder().append(col).append(" & ").append(val);
|
||||
case ORR:
|
||||
|
||||
Reference in New Issue
Block a user