24282 1 рік тому
батько
коміт
fa511c0ce7

+ 1 - 1
my-test/src/main/java/org/example/join/domain/AbstractQueryColumn.java

@@ -25,7 +25,7 @@ public abstract class AbstractQueryColumn implements IFormat, IQueryColumn {
     public <T> QueryColumnAlias as(SFunction<T, ?> function) {
         LambdaMeta meta = LambdaUtils.extract(function);
         String alias = StrUtil.toUnderlineCase(PropertyNamer.methodToProperty(meta.getImplMethodName()));
-        return new QueryColumnAlias(alias, this);
+        return new QueryColumnAlias(this, alias);
     }
 
     // ===========================================

+ 4 - 4
my-test/src/main/java/org/example/join/domain/QueryColumnAlias.java

@@ -7,14 +7,14 @@ import lombok.RequiredArgsConstructor;
 public class QueryColumnAlias implements IFormat, IQueryColumn {
 
     /**
-     * 字段别名
+     * 查询列
      */
-    private final String alias;
+    private final IQueryColumn queryColumn;
 
     /**
-     * 查询列
+     * 字段别名
      */
-    private final IQueryColumn queryColumn;
+    private final String alias;
 
     @Override
     public String toSql() {

+ 3 - 0
my-test/src/main/java/org/example/join/domain/QueryColumnCompute.java

@@ -10,6 +10,9 @@ public class QueryColumnCompute implements IFormat {
      */
     private final String computeType;
 
+    /**
+     * 计算值
+     */
     private final Object value;
 
     @Override

+ 3 - 0
my-test/src/main/java/org/example/join/domain/QueryConditionConnect.java

@@ -12,6 +12,9 @@ public class QueryConditionConnect implements IFormat {
      */
     private final String connectType;
 
+    /**
+     * 连接方法
+     */
     private final QueryCondition queryCondition;
 
     @Override

+ 8 - 8
my-test/src/main/java/org/example/join/sql/Select.java

@@ -12,14 +12,6 @@ public class Select<R> {
     private final Sql<R> sql;
 
     /**
-     * 去重
-     */
-    public Select<R> distinct() {
-        sql.distinct = true;
-        return this;
-    }
-
-    /**
      * 忽略查询逻辑删除
      */
     public Select<R> logicIgnore() {
@@ -35,6 +27,14 @@ public class Select<R> {
         return this;
     }
 
+    /**
+     * 去重
+     */
+    public Select<R> distinct() {
+        sql.distinct = true;
+        return this;
+    }
+
     public Select<R> select(IQueryColumn... columns) {
         sql.queryFieldsList.addAll(ListUtil.toList(columns));
         return this;

+ 1 - 1
my-test/src/main/java/org/example/join/sql/Sql.java

@@ -22,8 +22,8 @@ public class Sql<R> {
     protected final List<QueryColumn> groupByList = new ArrayList<>();
     protected final List<QueryConditionOrder> orderByList = new ArrayList<>();
 
-    protected Boolean distinct = false;
     protected Boolean logic = false;
+    protected Boolean distinct = false;
     protected String limit = StringPool.EMPTY;
 
     public static <R> Select<R> create(Class<R> cls) {

+ 24 - 24
my-test/src/test/java/MySpringBootTest.java

@@ -43,30 +43,30 @@ public class MySpringBootTest {
                 )
                 .from(sys_dept)
                 .leftJoin(sys_user).on(user_id.eq(dept_id))
-                //.where(
-                //dept_id.eq(100)
-                //concat("777", "555").eq(create_by),
-                //create_by.eq(concat("777", "555").add(777)).and(concat("777", "555").eq("sss")),
-                //create_by.ne(98),
-                //create_by.gt(98),
-                //create_by.lt(98),
-                //create_by.ge(98),
-                //create_by.le(98),
-                //create_by.between(1, 2),
-                //create_by.notBetween(1, 2),
-                //create_by.like(1),
-                //create_by.notLike(1),
-                //create_by.likeLeft(1),
-                //create_by.notLikeLeft(1),
-                //create_by.likeRight(1),
-                //create_by.notLikeRight(1),
-                //create_by.isNull(),
-                //create_by.isNotNull(),
-                //create_by.in(1, 2, 3, 4),
-                //create_by.notIn(1, 2, 3, 4)
-                //)
-                .orderByAsc(dept_id)
-                .groupBy(dept_id)
+                .where(
+                        //dept_id.eq(100)
+                        //concat("777", "555").eq(create_by),
+                        //create_by.eq(concat("777", "555").add(777)).and(concat("777", "555").eq("sss")),
+                        //create_by.ne(98),
+                        //create_by.gt(98),
+                        //create_by.lt(98),
+                        //create_by.ge(98),
+                        //create_by.le(98),
+                        //create_by.between(1, 2),
+                        //create_by.notBetween(1, 2),
+                        //create_by.like(1),
+                        //create_by.notLike(1),
+                        //create_by.likeLeft(1),
+                        //create_by.notLikeLeft(1),
+                        //create_by.likeRight(1),
+                        //create_by.notLikeRight(1),
+                        //create_by.isNull(),
+                        //create_by.isNotNull(),
+                        //create_by.in(1, 2, 3, 4),
+                        //create_by.notIn(1, 2, 3, 4)
+                )
+                .orderByAsc()
+                .groupBy()
                 .limit(1)
                 .one();