Jelajahi Sumber

调整过期方法

Caratacus 7 tahun lalu
induk
melakukan
019d38f614

+ 2 - 2
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/MybatisDefaultParameterHandler.java

@@ -64,8 +64,8 @@ public class MybatisDefaultParameterHandler extends DefaultParameterHandler {
     private final TypeHandlerRegistry typeHandlerRegistry;
     private final TypeHandlerRegistry typeHandlerRegistry;
     private final MappedStatement mappedStatement;
     private final MappedStatement mappedStatement;
     private final Object parameterObject;
     private final Object parameterObject;
-    private BoundSql boundSql;
-    private Configuration configuration;
+    private final BoundSql boundSql;
+    private final Configuration configuration;
 
 
     public MybatisDefaultParameterHandler(MappedStatement mappedStatement, Object parameterObject, BoundSql boundSql) {
     public MybatisDefaultParameterHandler(MappedStatement mappedStatement, Object parameterObject, BoundSql boundSql) {
         super(mappedStatement, processBatch(mappedStatement, parameterObject), boundSql);
         super(mappedStatement, processBatch(mappedStatement, parameterObject), boundSql);

+ 9 - 6
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/MybatisMapperAnnotationBuilder.java

@@ -1,5 +1,5 @@
 /**
 /**
- * Copyright 2009-2016 the original author or authors.
+ * Copyright 2009-2017 the original author or authors.
  * <p>
  * <p>
  * Licensed under the Apache License, Version 2.0 (the "License");
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * you may not use this file except in compliance with the License.
@@ -108,21 +108,24 @@ public class MybatisMapperAnnotationBuilder extends MapperAnnotationBuilder {
     private final Set<Class<? extends Annotation>> sqlAnnotationTypes = new HashSet<>();
     private final Set<Class<? extends Annotation>> sqlAnnotationTypes = new HashSet<>();
     private final Set<Class<? extends Annotation>> sqlProviderAnnotationTypes = new HashSet<>();
     private final Set<Class<? extends Annotation>> sqlProviderAnnotationTypes = new HashSet<>();
 
 
-    private Configuration configuration;
-    private MapperBuilderAssistant assistant;
-    private Class<?> type;
+    private final Configuration configuration;
+    private final MapperBuilderAssistant assistant;
+    private final Class<?> type;
 
 
     public MybatisMapperAnnotationBuilder(Configuration configuration, Class<?> type) {
     public MybatisMapperAnnotationBuilder(Configuration configuration, Class<?> type) {
-        // TODO 执行父类
+        // 执行父类
         super(configuration, type);
         super(configuration, type);
+
         String resource = type.getName().replace('.', '/') + ".java (best guess)";
         String resource = type.getName().replace('.', '/') + ".java (best guess)";
         this.assistant = new MapperBuilderAssistant(configuration, resource);
         this.assistant = new MapperBuilderAssistant(configuration, resource);
         this.configuration = configuration;
         this.configuration = configuration;
         this.type = type;
         this.type = type;
+
         sqlAnnotationTypes.add(Select.class);
         sqlAnnotationTypes.add(Select.class);
         sqlAnnotationTypes.add(Insert.class);
         sqlAnnotationTypes.add(Insert.class);
         sqlAnnotationTypes.add(Update.class);
         sqlAnnotationTypes.add(Update.class);
         sqlAnnotationTypes.add(Delete.class);
         sqlAnnotationTypes.add(Delete.class);
+
         sqlProviderAnnotationTypes.add(SelectProvider.class);
         sqlProviderAnnotationTypes.add(SelectProvider.class);
         sqlProviderAnnotationTypes.add(InsertProvider.class);
         sqlProviderAnnotationTypes.add(InsertProvider.class);
         sqlProviderAnnotationTypes.add(UpdateProvider.class);
         sqlProviderAnnotationTypes.add(UpdateProvider.class);
@@ -483,7 +486,7 @@ public class MybatisMapperAnnotationBuilder extends MapperAnnotationBuilder {
                 return buildSqlSourceFromStrings(strings, parameterType, languageDriver);
                 return buildSqlSourceFromStrings(strings, parameterType, languageDriver);
             } else if (sqlProviderAnnotationType != null) {
             } else if (sqlProviderAnnotationType != null) {
                 Annotation sqlProviderAnnotation = method.getAnnotation(sqlProviderAnnotationType);
                 Annotation sqlProviderAnnotation = method.getAnnotation(sqlProviderAnnotationType);
-                return new ProviderSqlSource(assistant.getConfiguration(), sqlProviderAnnotation);
+                return new ProviderSqlSource(assistant.getConfiguration(), sqlProviderAnnotation, type, method);
             }
             }
             return null;
             return null;
         } catch (Exception e) {
         } catch (Exception e) {

+ 1 - 3
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/MybatisMapperRegistry.java

@@ -78,11 +78,9 @@ public class MybatisMapperRegistry extends MapperRegistry {
             boolean loadCompleted = false;
             boolean loadCompleted = false;
             try {
             try {
                 knownMappers.put(type, new MapperProxyFactory<>(type));
                 knownMappers.put(type, new MapperProxyFactory<>(type));
-                // It's important that the type is added before the parser is
-                // run
+                // It's important that the type is added before the parser is run
                 // otherwise the binding may automatically be attempted by the
                 // otherwise the binding may automatically be attempted by the
                 // mapper parser. If the type is already known, it won't try.
                 // mapper parser. If the type is already known, it won't try.
-
                 // TODO 自定义无 XML 注入
                 // TODO 自定义无 XML 注入
                 MybatisMapperAnnotationBuilder parser = new MybatisMapperAnnotationBuilder(config, type);
                 MybatisMapperAnnotationBuilder parser = new MybatisMapperAnnotationBuilder(config, type);
                 parser.parse();
                 parser.parse();

+ 2 - 3
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/MybatisXMLConfigBuilder.java

@@ -64,9 +64,9 @@ import org.apache.ibatis.type.JdbcType;
 public class MybatisXMLConfigBuilder extends BaseBuilder {
 public class MybatisXMLConfigBuilder extends BaseBuilder {
 
 
     private boolean parsed;
     private boolean parsed;
-    private XPathParser parser;
+    private final XPathParser parser;
     private String environment;
     private String environment;
-    private ReflectorFactory localReflectorFactory = new DefaultReflectorFactory();
+    private final ReflectorFactory localReflectorFactory = new DefaultReflectorFactory();
 
 
     public MybatisXMLConfigBuilder(Reader reader) {
     public MybatisXMLConfigBuilder(Reader reader) {
         this(reader, null, null);
         this(reader, null, null);
@@ -364,7 +364,6 @@ public class MybatisXMLConfigBuilder extends BaseBuilder {
         }
         }
     }
     }
 
 
-    // TODO 这里需要优化
     private void mapperElement(XNode parent) throws Exception {
     private void mapperElement(XNode parent) throws Exception {
         /**
         /**
          * 定义集合 用来分类放置mybatis的Mapper与XML 按顺序依次遍历
          * 定义集合 用来分类放置mybatis的Mapper与XML 按顺序依次遍历

+ 1 - 4
mybatis-plus-core/src/test/java/com/baomidou/mybatisplus/test/sql/TenantSqlTest.java

@@ -40,10 +40,7 @@ public class TenantSqlTest {
 
 
             @Override
             @Override
             public boolean doTableFilter(String tableName) {
             public boolean doTableFilter(String tableName) {
-                if ("user".equals(tableName)) {
-                    return true;
-                }
-                return false;
+                return "user".equals(tableName);
             }
             }
         });
         });
     }
     }

+ 1 - 1
mybatis-plus-support/src/main/java/com/baomidou/mybatisplus/mapper/AutoSqlInjector.java

@@ -809,7 +809,7 @@ public class AutoSqlInjector implements ISqlInjector {
         if (null != table) {
         if (null != table) {
             String resultMap = table.getResultMap();
             String resultMap = table.getResultMap();
             if (null != resultMap) {
             if (null != resultMap) {
-				/* 返回 resultMap 映射结果集 */
+                /* 返回 resultMap 映射结果集 */
                 return this.addMappedStatement(mapperClass, id, sqlSource, SqlCommandType.SELECT, null, resultMap, null,
                 return this.addMappedStatement(mapperClass, id, sqlSource, SqlCommandType.SELECT, null, resultMap, null,
                         new NoKeyGenerator(), null, null);
                         new NoKeyGenerator(), null, null);
             }
             }

+ 1 - 1
mybatis-plus-support/src/main/java/com/baomidou/mybatisplus/plugins/pagination/Pagination.java

@@ -265,7 +265,7 @@ public class Pagination extends RowBounds implements Serializable {
     }
     }
 
 
     public List<String> getDescs() {
     public List<String> getDescs() {
-        return orders(!isAsc(), descs);
+        return orders(!isAsc, descs);
     }
     }
 
 
     public void setDescs(List<String> descs) {
     public void setDescs(List<String> descs) {