|
@@ -27,18 +27,6 @@ public class Select<T> {
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- public <S, V> Select<T> select(SFunction<S, V> function, SFunction<T, ?> asFunction) {
|
|
|
- String as = PropertyNamer.methodToProperty(LambdaUtils.extract(asFunction).getImplMethodName());
|
|
|
- sql.selectList.add(sql.getSqlFieldName(function) + StringPool.SPACE + as);
|
|
|
- return this;
|
|
|
- }
|
|
|
-
|
|
|
- public <S, V> Select<T> select(String alias, SFunction<S, V> function, SFunction<T, ?> asFunction) {
|
|
|
- String as = PropertyNamer.methodToProperty(LambdaUtils.extract(asFunction).getImplMethodName());
|
|
|
- sql.selectList.add(sql.getSqlFieldName(alias, function) + StringPool.SPACE + as);
|
|
|
- return this;
|
|
|
- }
|
|
|
-
|
|
|
@SafeVarargs
|
|
|
public final <S, V> Select<T> select(SFunction<S, V>... functions) {
|
|
|
for (SFunction<S, V> function : functions) {
|
|
@@ -55,6 +43,44 @@ public class Select<T> {
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
+ public <S, V> Select<T> selectAs(SFunction<S, V> function, SFunction<T, ?> asFunction) {
|
|
|
+ String as = PropertyNamer.methodToProperty(LambdaUtils.extract(asFunction).getImplMethodName());
|
|
|
+ sql.selectList.add(sql.getSqlFieldName(function) + StringPool.SPACE + as);
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public <S, V> Select<T> selectAs(String alias, SFunction<S, V> function, SFunction<T, ?> asFunction) {
|
|
|
+ String as = PropertyNamer.methodToProperty(LambdaUtils.extract(asFunction).getImplMethodName());
|
|
|
+ sql.selectList.add(sql.getSqlFieldName(alias, function) + StringPool.SPACE + as);
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Select<T> selectAll(Class<?> cls) {
|
|
|
+ return selectAll(sql.getTableAlias(cls), cls);
|
|
|
+ }
|
|
|
+
|
|
|
+ public Select<T> selectAll(String alias, Class<?> cls) {
|
|
|
+ Field[] fields = ReflectUtil.getFields(cls);
|
|
|
+ for (Field field : fields) {
|
|
|
+ String fieldName = ReflectUtil.getFieldName(field);
|
|
|
+ if ("serialVersionUID".equals(fieldName)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ TableField tableField = field.getAnnotation(TableField.class);
|
|
|
+ if (tableField != null) {
|
|
|
+ if (!tableField.exist() || !tableField.select()) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String value = tableField.value();
|
|
|
+ if (StrUtil.isNotBlank(value)) {
|
|
|
+ fieldName = value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sql.selectList.add(alias + StringPool.DOT + StrUtil.toUnderlineCase(fieldName));
|
|
|
+ }
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
public Select<T> distinct() {
|
|
|
sql.distinct = true;
|
|
|
return this;
|
|
@@ -108,34 +134,6 @@ public class Select<T> {
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- public Select<T> selectAll(Class<?> cls) {
|
|
|
- return selectAll(sql.getTableAlias(cls), cls);
|
|
|
- }
|
|
|
-
|
|
|
- public Select<T> selectAll(String alias, Class<?> cls) {
|
|
|
- Field[] fields = ReflectUtil.getFields(cls);
|
|
|
- for (Field field : fields) {
|
|
|
- String fieldName = ReflectUtil.getFieldName(field);
|
|
|
- if ("serialVersionUID".equals(fieldName)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- TableField tableField = field.getAnnotation(TableField.class);
|
|
|
- if (tableField != null) {
|
|
|
- if (!tableField.exist() || !tableField.select()) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- String value = tableField.value();
|
|
|
- if (StrUtil.isNotBlank(value)) {
|
|
|
- fieldName = value;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- sql.selectList.add(alias + StringPool.DOT + StrUtil.toUnderlineCase(fieldName));
|
|
|
- }
|
|
|
- return this;
|
|
|
- }
|
|
|
-
|
|
|
public From<T> from(Class<?> cls) {
|
|
|
String tableAlias = sql.getTableAlias(cls);
|
|
|
return from(tableAlias, cls);
|