miemie 7 роки тому
батько
коміт
3fa5f084d6

+ 0 - 1
mybatis-plus-core/build.gradle

@@ -6,7 +6,6 @@ dependencies {
     compile project(":mybatis-plus-annotation")
     compile rootProject.ext.dependencies["mybatis"]
     compile rootProject.ext.dependencies["jsqlparser"]
-    compile group: 'com.trigersoft', name: 'jaque', version: '2.1.2'
 
     testCompile rootProject.ext.dependencies["mybatis-ehcache"]
     testCompile rootProject.ext.dependencies["logback-classic"]

+ 1 - 16
mybatis-plus-core/src/test/java/com/baomidou/mybatisplus/core/test/Main.java

@@ -1,9 +1,5 @@
 package com.baomidou.mybatisplus.core.test;
 
-import com.baomidou.mybatisplus.core.metadata.TableInfo;
-import com.baomidou.mybatisplus.core.toolkit.TableInfoHelper;
-import org.junit.Assert;
-
 import java.time.LocalDate;
 
 public class Main {
@@ -13,22 +9,11 @@ public class Main {
     }
 
     public static void query() {
-        Query query = new Query(User.class)
-            .select(User::getId, User::getName)
-            .eq(User::getId, 1)
-            .eq(User::getName, "张三")
-            .orderBy(User::getName);
-        System.out.println(query);
-    }
-
-    public static void columnPrefix() {
-        TableInfo tableInfo = TableInfoHelper.initTableInfo(null, Test.class);
-        Assert.assertEquals("test_id", tableInfo.getKeyColumn());
-        tableInfo.getFieldList().forEach(i-> System.out.println(i.getColumn()));
     }
 
 
     public static class Test {
+
         private Long id;
         private String name;
         private String age;

+ 0 - 61
mybatis-plus-core/src/test/java/com/baomidou/mybatisplus/core/test/Query.java

@@ -1,61 +0,0 @@
-package com.baomidou.mybatisplus.core.test;
-
-import static com.baomidou.mybatisplus.core.test.QueryHelper.method;
-
-import java.io.Serializable;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-
-import org.apache.ibatis.jdbc.SQL;
-
-public class Query {
-
-    private SQL sql = new SQL();
-
-    private Class<?> clazz;
-
-    private Map<Method, String> introspector;
-
-    public Query(Class<?> clazz) {
-        this.clazz = clazz;
-        introspector = QueryHelper.introspector(clazz);
-        sql.FROM(clazz.getSimpleName().toUpperCase());
-    }
-
-    public Query select() {
-        sql.SELECT("*");
-        return this;
-    }
-
-    public <T> Query select(Property<T, ?>... fun) {
-        String[] args = Arrays.asList(fun).stream().map(x -> introspector.get(method(x))).collect(Collectors.toList()).toArray(new String[]{});
-        sql.SELECT(args);
-        return this;
-    }
-
-    public <T> Query eq(Property<T, ?> fun, Object param) {
-        String name = introspector.get(method(fun));
-        sql.WHERE(name + "=" + param);
-        return this;
-    }
-
-    public <T> Query orderBy(Property<T, ?> fun) {
-        String name = introspector.get(method(fun));
-        sql.ORDER_BY(name);
-        return this;
-    }
-
-    @Override
-    public String toString() {
-        return sql.toString();
-    }
-
-    public interface Property<T, R> extends Function<T, R>, Serializable {
-
-    }
-
-}

+ 0 - 55
mybatis-plus-core/src/test/java/com/baomidou/mybatisplus/core/test/QueryHelper.java

@@ -1,55 +0,0 @@
-package com.baomidou.mybatisplus.core.test;
-
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.core.test.Query.Property;
-import com.trigersoft.jaque.expression.Expression;
-import com.trigersoft.jaque.expression.InvocationExpression;
-import com.trigersoft.jaque.expression.LambdaExpression;
-import com.trigersoft.jaque.expression.MemberExpression;
-
-import java.beans.BeanInfo;
-import java.beans.IntrospectionException;
-import java.beans.Introspector;
-import java.beans.PropertyDescriptor;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-public class QueryHelper {
-
-    public static <T> Method method(Property<T, ?> fun) {
-        LambdaExpression parsed = LambdaExpression.parse(fun);
-        Expression body = parsed.getBody();
-        return (Method) ((MemberExpression) ((InvocationExpression) body).getTarget()).getMember();
-    }
-
-    public static Map<Method, String> introspector(Class clazz) {
-        Map<Method, String> map = new LinkedHashMap<>();
-        BeanInfo beanInfo = null;
-        try {
-            beanInfo = Introspector.getBeanInfo(clazz, Object.class);
-        } catch (IntrospectionException e) {
-            e.printStackTrace();
-        }
-        PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
-        for (Field field : clazz.getDeclaredFields()) {
-            for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
-                if (propertyDescriptor.getName().equals(field.getName())) {
-                    TableField tableField = field.getDeclaredAnnotation(TableField.class);
-                    if (tableField == null) {
-                        map.put(propertyDescriptor.getReadMethod(), field.getName());
-                    } else {
-                        String value = tableField.value();
-                        if (value == null || value.isEmpty()) {
-                            map.put(propertyDescriptor.getReadMethod(), field.getName());
-                        } else {
-                            map.put(propertyDescriptor.getReadMethod(), value);
-                        }
-                    }
-                }
-            }
-        }
-        return map;
-    }
-}

+ 1 - 1
mybatis-plus/build.gradle

@@ -19,5 +19,5 @@ dependencies {
     testCompile rootProject.ext.dependencies["postgresql"]
     testCompile rootProject.ext.dependencies["oracle"]
     testCompile rootProject.ext.dependencies["mysql"]
-    testCompile "org.apache.logging.log4j:log4j-slf4j-impl:2.9.1"
+    testCompile "org.apache.logging.log4j:log4j-slf4j-impl:2.11.0"
 }