miemie před 6 roky
rodič
revize
268f54e31a

+ 4 - 4
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/parser/SqlParserHelper.java

@@ -38,7 +38,7 @@ public class SqlParserHelper {
     /**
      * SQL 解析缓存
      */
-    private static final Map<String, SqlParserInfo> SQL_PARSER_INFO_CACHE = new ConcurrentHashMap<>();
+    private static final Map<String, Boolean> SQL_PARSER_INFO_CACHE = new ConcurrentHashMap<>();
 
 
     /**
@@ -54,7 +54,7 @@ public class SqlParserHelper {
             SqlParser sqlParser = method.getAnnotation(SqlParser.class);
             if (null != sqlParser) {
                 String sid = mapperClass.getName() + StringPool.DOT + method.getName();
-                SQL_PARSER_INFO_CACHE.put(sid, new SqlParserInfo(sqlParser));
+                SQL_PARSER_INFO_CACHE.put(sid, sqlParser.filter());
             }
         }
     }
@@ -67,8 +67,8 @@ public class SqlParserHelper {
      *
      * @param metaObject 元数据对象
      */
-    public static SqlParserInfo getSqlParserInfo(MetaObject metaObject) {
-        return SQL_PARSER_INFO_CACHE.get(getMappedStatement(metaObject).getId());
+    public static boolean getSqlParserInfo(MetaObject metaObject) {
+        return SQL_PARSER_INFO_CACHE.getOrDefault(getMappedStatement(metaObject).getId(), false);
     }
 
 

+ 0 - 45
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/parser/SqlParserInfo.java

@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2011-2020, hubin (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.core.parser;
-
-
-import com.baomidou.mybatisplus.annotation.SqlParser;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-import lombok.experimental.Accessors;
-
-/**
- * <p>
- * SQL 解析信息
- * </p>
- *
- * @author hubin
- * @since 2018-01-13
- */
-@Data
-@Accessors(chain = true)
-@NoArgsConstructor
-public class SqlParserInfo {
-
-    /**
-     * 过滤解析
-     */
-    private boolean filter;
-
-    public SqlParserInfo(SqlParser sqlParser) {
-        this.filter = sqlParser.filter();
-    }
-}

+ 5 - 3
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/handlers/AbstractSqlParserHandler.java

@@ -15,7 +15,10 @@
  */
 package com.baomidou.mybatisplus.extension.handlers;
 
-import com.baomidou.mybatisplus.core.parser.*;
+import com.baomidou.mybatisplus.core.parser.ISqlParser;
+import com.baomidou.mybatisplus.core.parser.ISqlParserFilter;
+import com.baomidou.mybatisplus.core.parser.SqlInfo;
+import com.baomidou.mybatisplus.core.parser.SqlParserHelper;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.PluginUtils;
 import lombok.Data;
@@ -50,8 +53,7 @@ public abstract class AbstractSqlParserHandler {
             // SQL 解析
             if (CollectionUtils.isNotEmpty(this.sqlParserList)) {
                 // @SqlParser(filter = true) 跳过该方法解析
-                SqlParserInfo sqlParserInfo = SqlParserHelper.getSqlParserInfo(metaObject);
-                if (null != sqlParserInfo && sqlParserInfo.isFilter()) {
+                if (SqlParserHelper.getSqlParserInfo(metaObject)) {
                     return;
                 }
                 // 标记是否修改过 SQL