Forráskód Böngészése

清理部分TODO.

nieqiurong 1 éve
szülő
commit
b92dc11d9e

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

@@ -147,7 +147,6 @@ public class MybatisConfiguration extends Configuration {
      * @param <T>
      */
     public <T> void removeMapper(Class<T> type) {
-        // TODO
         Set<String> mapperRegistryCache = GlobalConfigUtils.getGlobalConfig(this).getMapperRegistryCache();
         final String mapperType = type.toString();
         if (mapperRegistryCache.contains(mapperType)) {
@@ -208,7 +207,6 @@ public class MybatisConfiguration extends Configuration {
     @Override
     public void setDefaultScriptingLanguage(Class<? extends LanguageDriver> driver) {
         if (driver == null) {
-            //todo 替换动态SQL生成的默认语言为自己的。
             driver = MybatisXMLLanguageDriver.class;
         }
         getLanguageRegistry().setDefaultDriverClass(driver);

+ 0 - 8
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/MybatisMapperAnnotationBuilder.java

@@ -108,15 +108,12 @@ public class MybatisMapperAnnotationBuilder extends MapperAnnotationBuilder {
                     parseResultMap(method);
                 }
                 try {
-                    // TODO 加入 注解过滤缓存
                     InterceptorIgnoreHelper.initSqlParserInfoCache(ignoreStrategy, mapperName, method);
                     parseStatement(method);
                 } catch (IncompleteElementException e) {
-                    // TODO 使用 MybatisMethodResolver 而不是 MethodResolver
                     configuration.addIncompleteMethod(new MybatisMethodResolver(this, method));
                 }
             }
-            // TODO 注入 CURD 动态 SQL , 放在在最后, because 可能会有人会用注解重写sql
             try {
                 // https://github.com/baomidou/mybatis-plus/issues/3038
                 if (GlobalConfigUtils.isSupperMapperChildren(configuration, type)) {
@@ -249,7 +246,6 @@ public class MybatisMapperAnnotationBuilder extends MapperAnnotationBuilder {
         applyConstructorArgs(args, returnType, resultMappings);
         applyResults(results, returnType, resultMappings);
         Discriminator disc = applyDiscriminator(resultMapId, returnType, discriminator);
-        // TODO add AutoMappingBehaviour
         assistant.addResultMap(resultMapId, returnType, null, disc, resultMappings, null);
         createDiscriminatorResultMaps(resultMapId, returnType, discriminator);
     }
@@ -262,7 +258,6 @@ public class MybatisMapperAnnotationBuilder extends MapperAnnotationBuilder {
                 // issue #136
                 applyConstructorArgs(c.constructArgs(), resultType, resultMappings);
                 applyResults(c.results(), resultType, resultMappings);
-                // TODO add AutoMappingBehaviour
                 assistant.addResultMap(caseResultMapId, c.type(), resultMapId, null, resultMappings, null);
             }
         }
@@ -365,7 +360,6 @@ public class MybatisMapperAnnotationBuilder extends MapperAnnotationBuilder {
                 resultSetType,
                 flushCache,
                 useCache,
-                // TODO gcode issue #577
                 false,
                 keyGenerator,
                 keyProperty,
@@ -454,7 +448,6 @@ public class MybatisMapperAnnotationBuilder extends MapperAnnotationBuilder {
                     returnType = (Class<?>) returnTypeParameter;
                 }
             }
-            // TODO 下面是支援 IPage 及其子类作为返回值的
             else if (IPage.class.isAssignableFrom(rawType)) {
                 Type[] actualTypeArguments = parameterizedType.getActualTypeArguments();
                 Type returnTypeParameter = actualTypeArguments[0];
@@ -464,7 +457,6 @@ public class MybatisMapperAnnotationBuilder extends MapperAnnotationBuilder {
                     returnType = (Class<?>) ((ParameterizedType) returnTypeParameter).getRawType();
                 }
             }
-            // TODO 上面是支援 IPage 及其子类作为返回值的
         }
 
         return returnType;

+ 0 - 5
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/MybatisMapperRegistry.java

@@ -46,7 +46,6 @@ public class MybatisMapperRegistry extends MapperRegistry {
     @SuppressWarnings("unchecked")
     @Override
     public <T> T getMapper(Class<T> type, SqlSession sqlSession) {
-        // TODO 这里换成 MybatisMapperProxyFactory 而不是 MapperProxyFactory
         // fix https://github.com/baomidou/mybatis-plus/issues/4247
         MybatisMapperProxyFactory<T> mapperProxyFactory = (MybatisMapperProxyFactory<T>) knownMappers.get(type);
         if (mapperProxyFactory == null) {
@@ -78,19 +77,15 @@ public class MybatisMapperRegistry extends MapperRegistry {
     public <T> void addMapper(Class<T> type) {
         if (type.isInterface()) {
             if (hasMapper(type)) {
-                // TODO 如果之前注入 直接返回
                 return;
-                // TODO 这里就不抛异常了
 //                throw new BindingException("Type " + type + " is already known to the MapperRegistry.");
             }
             boolean loadCompleted = false;
             try {
-                // TODO 这里也换成 MybatisMapperProxyFactory 而不是 MapperProxyFactory
                 knownMappers.put(type, new MybatisMapperProxyFactory<>(type));
                 // It's important that the type is added before the parser is run
                 // otherwise the binding may automatically be attempted by the
                 // mapper parser. If the type is already known, it won't try.
-                // TODO 这里也换成 MybatisMapperAnnotationBuilder 而不是 MapperAnnotationBuilder
                 MybatisMapperAnnotationBuilder parser = new MybatisMapperAnnotationBuilder(config, type);
                 parser.parse();
                 loadCompleted = true;

+ 0 - 3
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/MybatisSqlSessionFactoryBuilder.java

@@ -43,7 +43,6 @@ public class MybatisSqlSessionFactoryBuilder extends SqlSessionFactoryBuilder {
     @Override
     public SqlSessionFactory build(Reader reader, String environment, Properties properties) {
         try {
-            //TODO 这里换成 MybatisXMLConfigBuilder 而不是 XMLConfigBuilder
             MybatisXMLConfigBuilder parser = new MybatisXMLConfigBuilder(reader, environment, properties);
             return build(parser.parse());
         } catch (Exception e) {
@@ -62,7 +61,6 @@ public class MybatisSqlSessionFactoryBuilder extends SqlSessionFactoryBuilder {
     @Override
     public SqlSessionFactory build(InputStream inputStream, String environment, Properties properties) {
         try {
-            //TODO 这里换成 MybatisXMLConfigBuilder 而不是 XMLConfigBuilder
             MybatisXMLConfigBuilder parser = new MybatisXMLConfigBuilder(inputStream, environment, properties);
             return build(parser.parse());
         } catch (Exception e) {
@@ -77,7 +75,6 @@ public class MybatisSqlSessionFactoryBuilder extends SqlSessionFactoryBuilder {
         }
     }
 
-    // TODO 使用自己的逻辑,注入必须组件
     @Override
     public SqlSessionFactory build(Configuration configuration) {
         GlobalConfig globalConfig = GlobalConfigUtils.getGlobalConfig(configuration);

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

@@ -83,7 +83,6 @@ public class MybatisXMLConfigBuilder extends BaseBuilder {
     }
 
     private MybatisXMLConfigBuilder(XPathParser parser, String environment, Properties props) {
-        // TODO 使用 MybatisConfiguration 而不是 Configuration
         super(new MybatisConfiguration());
         ErrorContext.instance().resource("SQL Mapper Configuration");
         this.configuration.setVariables(props);
@@ -272,7 +271,6 @@ public class MybatisXMLConfigBuilder extends BaseBuilder {
         configuration.setArgNameBasedConstructorAutoMapping(booleanValueOf(props.getProperty("argNameBasedConstructorAutoMapping"), false));
         configuration.setDefaultSqlProviderType(resolveClass(props.getProperty("defaultSqlProviderType")));
         configuration.setNullableOnForEach(booleanValueOf(props.getProperty("nullableOnForEach"), false));
-        // TODO 下面俩: 1.统一 mapUnderscoreToCamelCase 属性默认值为 true 2.新增`useGeneratedShortKey`属性
         configuration.setMapUnderscoreToCamelCase(booleanValueOf(props.getProperty("mapUnderscoreToCamelCase"), true));
         ((MybatisConfiguration) configuration).setUseGeneratedShortKey(booleanValueOf(props.getProperty("useGeneratedShortKey"), true));
     }

+ 0 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/metadata/TableFieldInfo.java

@@ -562,7 +562,6 @@ public class TableFieldInfo implements Constants {
             TypeHandler<?> typeHandler = registry.getMappingTypeHandler(this.typeHandler);
             if (typeHandler == null) {
                 typeHandler = registry.getInstance(propertyType, this.typeHandler);
-                // todo 这会有影响 registry.register(typeHandler);
             }
             builder.typeHandler(typeHandler);
         }

+ 0 - 2
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/override/MybatisMapperMethod.java

@@ -80,10 +80,8 @@ public class MybatisMapperMethod {
                 } else if (method.returnsCursor()) {
                     result = executeForCursor(sqlSession, args);
                 } else {
-                    // TODO 这里下面改了
                     if (IPage.class.isAssignableFrom(method.getReturnType())) {
                         result = executeForIPage(sqlSession, args);
-                        // TODO 这里上面改了
                     } else {
                         Object param = method.convertArgsToSqlCommandParam(args);
                         result = sqlSession.selectOne(command.getName(), param);

+ 0 - 10
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/spring/MybatisSqlSessionFactoryBean.java

@@ -90,7 +90,6 @@ public class MybatisSqlSessionFactoryBean implements FactoryBean<SqlSessionFacto
 
     private Resource configLocation;
 
-    // TODO 使用 MybatisConfiguration
     private MybatisConfiguration configuration;
 
     private Resource[] mapperLocations;
@@ -144,7 +143,6 @@ public class MybatisSqlSessionFactoryBean implements FactoryBean<SqlSessionFacto
     @Deprecated
     private String typeEnumsPackage;
 
-    // TODO 自定义全局配置
     @Setter
     private GlobalConfig globalConfig;
 
@@ -325,7 +323,6 @@ public class MybatisSqlSessionFactoryBean implements FactoryBean<SqlSessionFacto
 
     /**
      * Set a customized MyBatis configuration.
-     * TODO 这里的入参使用 MybatisConfiguration 而不是 Configuration
      *
      * @param configuration MyBatis configuration
      * @since 1.3.0
@@ -456,7 +453,6 @@ public class MybatisSqlSessionFactoryBean implements FactoryBean<SqlSessionFacto
 
         final Configuration targetConfiguration;
 
-        // TODO 使用 MybatisXmlConfigBuilder 而不是 XMLConfigBuilder
         MybatisXMLConfigBuilder xmlConfigBuilder = null;
         if (this.configuration != null) {
             targetConfiguration = this.configuration;
@@ -466,21 +462,17 @@ public class MybatisSqlSessionFactoryBean implements FactoryBean<SqlSessionFacto
                 targetConfiguration.getVariables().putAll(this.configurationProperties);
             }
         } else if (this.configLocation != null) {
-            // TODO 使用 MybatisXMLConfigBuilder
             xmlConfigBuilder = new MybatisXMLConfigBuilder(this.configLocation.getInputStream(), null, this.configurationProperties);
             targetConfiguration = xmlConfigBuilder.getConfiguration();
         } else {
             LOGGER.debug(() -> "Property 'configuration' or 'configLocation' not specified, using default MyBatis Configuration");
-            // TODO 使用 MybatisConfiguration
             targetConfiguration = new MybatisConfiguration();
             Optional.ofNullable(this.configurationProperties).ifPresent(targetConfiguration::setVariables);
         }
 
-        // TODO 无配置启动所必须的
         this.globalConfig = Optional.ofNullable(this.globalConfig).orElseGet(GlobalConfigUtils::defaults);
         this.globalConfig.setDbConfig(Optional.ofNullable(this.globalConfig.getDbConfig()).orElseGet(GlobalConfig.DbConfig::new));
 
-        // TODO 初始化 id-work 以及 打印骚东西
         GlobalConfigUtils.setGlobalConfig(targetConfiguration, this.globalConfig);
 
         Optional.ofNullable(this.objectFactory).ifPresent(targetConfiguration::setObjectFactory);
@@ -582,10 +574,8 @@ public class MybatisSqlSessionFactoryBean implements FactoryBean<SqlSessionFacto
 
         final SqlSessionFactory sqlSessionFactory = new MybatisSqlSessionFactoryBuilder().build(targetConfiguration);
 
-        // TODO SqlRunner
         SqlHelper.FACTORY = sqlSessionFactory;
 
-        // TODO 打印 Banner
         if (globalConfig.isBanner()) {
             System.out.println(" _ _   |_  _ _|_. ___ _ |    _ ");
             System.out.println("| | |\\/|_)(_| | |_\\  |_)||_|_\\ ");

+ 0 - 14
spring-boot-starter/mybatis-plus-spring-boot-autoconfigure/src/main/java/com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.java

@@ -172,7 +172,6 @@ public class MybatisPlusAutoConfiguration implements InitializingBean {
     @Bean
     @ConditionalOnMissingBean
     public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception {
-        // TODO 使用 MybatisSqlSessionFactoryBean 而不是 SqlSessionFactoryBean
         MybatisSqlSessionFactoryBean factory = new MybatisSqlSessionFactoryBean();
         factory.setDataSource(dataSource);
         factory.setVfs(SpringBootVFS.class);
@@ -204,10 +203,8 @@ public class MybatisPlusAutoConfiguration implements InitializingBean {
         if (!ObjectUtils.isEmpty(this.properties.resolveMapperLocations())) {
             factory.setMapperLocations(this.properties.resolveMapperLocations());
         }
-        // TODO 修改源码支持定义 TransactionFactory
         this.getBeanThen(TransactionFactory.class, factory::setTransactionFactory);
 
-        // TODO 对源码做了一定的修改(因为源码适配了老旧的mybatis版本,但我们不需要适配)
         Class<? extends LanguageDriver> defaultLanguageDriver = this.properties.getDefaultScriptingLanguageDriver();
         if (!ObjectUtils.isEmpty(this.languageDrivers)) {
             factory.setScriptingLanguageDrivers(this.languageDrivers);
@@ -216,21 +213,13 @@ public class MybatisPlusAutoConfiguration implements InitializingBean {
 
         applySqlSessionFactoryBeanCustomizers(factory);
 
-        // TODO 此处必为非 NULL
         GlobalConfig globalConfig = this.properties.getGlobalConfig();
-        // TODO 注入填充器
         this.getBeanThen(MetaObjectHandler.class, globalConfig::setMetaObjectHandler);
-        // TODO 注入注解控制器
         this.getBeanThen(AnnotationHandler.class, globalConfig::setAnnotationHandler);
-        // TODO 注入参与器
         this.getBeanThen(PostInitTableInfoHandler.class, globalConfig::setPostInitTableInfoHandler);
-        // TODO 注入主键生成器
         this.getBeansThen(IKeyGenerator.class, i -> globalConfig.getDbConfig().setKeyGenerators(i));
-        // TODO 注入sql注入器
         this.getBeanThen(ISqlInjector.class, globalConfig::setSqlInjector);
-        // TODO 注入ID生成器
         this.getBeanThen(IdentifierGenerator.class, globalConfig::setIdentifierGenerator);
-        // TODO 设置 GlobalConfig 到 MybatisSqlSessionFactoryBean
         factory.setGlobalConfig(globalConfig);
         return factory.getObject();
     }
@@ -264,9 +253,7 @@ public class MybatisPlusAutoConfiguration implements InitializingBean {
         }
     }
 
-    // TODO 入参使用 MybatisSqlSessionFactoryBean
     private void applyConfiguration(MybatisSqlSessionFactoryBean factory) {
-        // TODO 使用 MybatisConfiguration
         MybatisPlusProperties.CoreConfiguration coreConfiguration = this.properties.getConfiguration();
         MybatisConfiguration configuration = null;
         if (coreConfiguration != null || !StringUtils.hasText(this.properties.getConfigLocation())) {
@@ -337,7 +324,6 @@ public class MybatisPlusAutoConfiguration implements InitializingBean {
                 .collect(Collectors.toSet());
             if (propertyNames.contains("lazyInitialization")) {
                 // Need to mybatis-spring 2.0.2+
-                // TODO 兼容了mybatis.lazy-initialization配置
                 builder.addPropertyValue("lazyInitialization", "${mybatis-plus.lazy-initialization:${mybatis.lazy-initialization:false}}");
             }
             if (propertyNames.contains("defaultScope")) {

+ 1 - 1
spring-boot-starter/mybatis-plus-spring-boot-autoconfigure/src/main/java/com/baomidou/mybatisplus/autoconfigure/MybatisPlusProperties.java

@@ -124,7 +124,7 @@ public class MybatisPlusProperties {
     private String typeEnumsPackage;
 
     /**
-     * TODO 全局配置
+     * 全局配置
      */
     @NestedConfigurationProperty
     private GlobalConfig globalConfig = GlobalConfigUtils.defaults();