فهرست منبع

移除无用代码.

聂秋秋 5 سال پیش
والد
کامیت
1cfe08d561

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

@@ -167,9 +167,9 @@ public class MybatisDefaultParameterHandler extends DefaultParameterHandler {
                     if (IdType.ASSIGN_ID.getKey() == tableInfo.getIdType().getKey()) {
                     if (IdType.ASSIGN_ID.getKey() == tableInfo.getIdType().getKey()) {
                         // 应该只有数值型和字符串的区别了.
                         // 应该只有数值型和字符串的区别了.
                         if (Number.class.isAssignableFrom(tableInfo.getKeyType())) {
                         if (Number.class.isAssignableFrom(tableInfo.getKeyType())) {
-                            metaObject.setValue(tableInfo.getKeyProperty(), idGenerator.generate(parameterObject));
+                            metaObject.setValue(tableInfo.getKeyProperty(), idGenerator.generateId(parameterObject));
                         } else {
                         } else {
-                            metaObject.setValue(tableInfo.getKeyProperty(), idGenerator.generate(parameterObject).toString());
+                            metaObject.setValue(tableInfo.getKeyProperty(), idGenerator.generateId(parameterObject).toString());
                         }
                         }
                     } else if (IdType.UUID.getKey() == tableInfo.getIdType().getKey()) {
                     } else if (IdType.UUID.getKey() == tableInfo.getIdType().getKey()) {
                         metaObject.setValue(tableInfo.getKeyProperty(), idGenerator.generateUUID(parameterObject));
                         metaObject.setValue(tableInfo.getKeyProperty(), idGenerator.generateUUID(parameterObject));

+ 2 - 15
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/config/GlobalConfig.java

@@ -21,7 +21,6 @@ import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
 import com.baomidou.mybatisplus.core.incrementer.IKeyGenerator;
 import com.baomidou.mybatisplus.core.incrementer.IKeyGenerator;
 import com.baomidou.mybatisplus.core.incrementer.IdGenerator;
 import com.baomidou.mybatisplus.core.incrementer.IdGenerator;
 import com.baomidou.mybatisplus.core.incrementer.DefaultGenerator;
 import com.baomidou.mybatisplus.core.incrementer.DefaultGenerator;
-import com.baomidou.mybatisplus.core.incrementer.UUIDGenerator;
 import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
 import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
 import com.baomidou.mybatisplus.core.injector.ISqlInjector;
 import com.baomidou.mybatisplus.core.injector.ISqlInjector;
 import com.baomidou.mybatisplus.core.mapper.Mapper;
 import com.baomidou.mybatisplus.core.mapper.Mapper;
@@ -32,10 +31,8 @@ import lombok.experimental.Accessors;
 import org.apache.ibatis.session.SqlSessionFactory;
 import org.apache.ibatis.session.SqlSessionFactory;
 
 
 import java.io.Serializable;
 import java.io.Serializable;
-import java.util.Map;
 import java.util.Optional;
 import java.util.Optional;
 import java.util.Set;
 import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentSkipListSet;
 import java.util.concurrent.ConcurrentSkipListSet;
 
 
 /**
 /**
@@ -49,16 +46,6 @@ import java.util.concurrent.ConcurrentSkipListSet;
 @SuppressWarnings("serial")
 @SuppressWarnings("serial")
 public class GlobalConfig implements Serializable {
 public class GlobalConfig implements Serializable {
 
 
-    /**
-     * 默认提供的主键生成器
-     */
-    private static Map<String, IdGenerator> defaultIdGeneratorMap = new ConcurrentHashMap<>();
-
-    static {
-        defaultIdGeneratorMap.put(String.valueOf(IdType.UUID.getKey()), new UUIDGenerator());
-        defaultIdGeneratorMap.put(String.valueOf(IdType.ASSIGN_ID.getKey()), new DefaultGenerator());
-    }
-
     /**
     /**
      * 是否开启 LOGO
      * 是否开启 LOGO
      */
      */
@@ -66,7 +53,7 @@ public class GlobalConfig implements Serializable {
     /**
     /**
      * 机器 ID 部分
      * 机器 ID 部分
      *
      *
-     * @see #registerIdGenerator(IdType, IdGenerator)
+     * @see #setIdGenerator(IdGenerator)
      * @deprecated 3.3.0
      * @deprecated 3.3.0
      */
      */
     @Deprecated
     @Deprecated
@@ -74,7 +61,7 @@ public class GlobalConfig implements Serializable {
     /**
     /**
      * 数据标识 ID 部分
      * 数据标识 ID 部分
      *
      *
-     * @see #registerIdGenerator(IdType, IdGenerator)
+     * @see #setIdGenerator(IdGenerator)
      * @deprecated 3.3.0
      * @deprecated 3.3.0
      */
      */
     @Deprecated
     @Deprecated

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/incrementer/DefaultGenerator.java

@@ -41,7 +41,7 @@ public class DefaultGenerator implements IdGenerator {
     }
     }
 
 
     @Override
     @Override
-    public Long generate(Object entity) {
+    public Long generateId(Object entity) {
         return sequence.nextId();
         return sequence.nextId();
     }
     }
 }
 }

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/incrementer/IdGenerator.java

@@ -35,7 +35,7 @@ public interface IdGenerator {
      * @param entity 实体
      * @param entity 实体
      * @return id
      * @return id
      */
      */
-    Serializable generate(Object entity);
+    Serializable generateId(Object entity);
 
 
     /**
     /**
      * 生成uuid
      * 生成uuid

+ 0 - 34
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/incrementer/UUIDGenerator.java

@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2011-2020, baomidou (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>
- * https://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.incrementer;
-
-
-import com.baomidou.mybatisplus.core.toolkit.IdWorker;
-
-/**
- * UUID生成
- *
- * @author nieqiuqiu 2019-11-29
- * @since 3.3.0
- */
-public class UUIDGenerator implements IdGenerator {
-
-    @Override
-    public String generate(Object entity) {
-        return IdWorker.get32UUID();
-    }
-
-}

+ 3 - 4
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/toolkit/IdWorker.java

@@ -15,7 +15,6 @@
  */
  */
 package com.baomidou.mybatisplus.core.toolkit;
 package com.baomidou.mybatisplus.core.toolkit;
 
 
-import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.core.config.GlobalConfig;
 import com.baomidou.mybatisplus.core.config.GlobalConfig;
 import com.baomidou.mybatisplus.core.incrementer.DefaultGenerator;
 import com.baomidou.mybatisplus.core.incrementer.DefaultGenerator;
 import com.baomidou.mybatisplus.core.incrementer.IdGenerator;
 import com.baomidou.mybatisplus.core.incrementer.IdGenerator;
@@ -55,7 +54,7 @@ public class IdWorker {
      */
      */
     @Deprecated
     @Deprecated
     public static long getId() {
     public static long getId() {
-        return Long.parseLong(ID_GENERATOR.generate(new Object()).toString());
+        return Long.parseLong(ID_GENERATOR.generateId(new Object()).toString());
     }
     }
 
 
     /**
     /**
@@ -66,7 +65,7 @@ public class IdWorker {
      */
      */
     @Deprecated
     @Deprecated
     public static String getIdStr() {
     public static String getIdStr() {
-        return String.valueOf(ID_GENERATOR.generate(new Object()));
+        return String.valueOf(ID_GENERATOR.generateId(new Object()));
     }
     }
 
 
     /**
     /**
@@ -104,7 +103,7 @@ public class IdWorker {
      * 自定义id 生成方式
      * 自定义id 生成方式
      *
      *
      * @param idGenerator id 生成器
      * @param idGenerator id 生成器
-     * @see GlobalConfig#registerIdGenerator(IdType, IdGenerator)
+     * @see GlobalConfig#setIdGenerator(IdGenerator)
      * @deprecated 3.3.0
      * @deprecated 3.3.0
      */
      */
     @Deprecated
     @Deprecated

+ 1 - 1
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/idgenerator/CustomIdGenerator.java

@@ -9,7 +9,7 @@ import org.apache.ibatis.reflection.SystemMetaObject;
 public class CustomIdGenerator implements IdGenerator {
 public class CustomIdGenerator implements IdGenerator {
 
 
     @Override
     @Override
-    public Number generate(Object entity) {
+    public Number generateId(Object entity) {
         //可以将当前传入的class全类名来作为bizKey,或者提取参数来生成bizKey进行分布式Id调用生成.
         //可以将当前传入的class全类名来作为bizKey,或者提取参数来生成bizKey进行分布式Id调用生成.
         String bizKey = entity.getClass().getName();
         String bizKey = entity.getClass().getName();
         TableInfo tableInfo = TableInfoHelper.getTableInfo(entity.getClass());
         TableInfo tableInfo = TableInfoHelper.getTableInfo(entity.getClass());