diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/keygen/KeyGeneratorFactory.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/keygen/KeyGeneratorFactory.java index ea79ede3..034ade60 100644 --- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/keygen/KeyGeneratorFactory.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/keygen/KeyGeneratorFactory.java @@ -30,9 +30,9 @@ public class KeyGeneratorFactory { /** 内置了 uuid 的生成器,因此主键配置的时候可以直接配置为 @Id(keyType = KeyType.Generator, value = "uuid") * {@link com.mybatisflex.annotation.Id} */ - register("uuid", new UUIDKeyGenerator()); - register("flexId", new FlexIDKeyGenerator()); - register("snowFlakeId", new SnowFlakeIDKeyGenerator()); + register(KeyGenerators.uuid, new UUIDKeyGenerator()); + register(KeyGenerators.flexId, new FlexIDKeyGenerator()); + register(KeyGenerators.snowFlakeId, new SnowFlakeIDKeyGenerator()); } diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/keygen/KeyGenerators.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/keygen/KeyGenerators.java new file mode 100644 index 00000000..075e6752 --- /dev/null +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/keygen/KeyGenerators.java @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). + *
+ * 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 + *
+ * http://www.apache.org/licenses/LICENSE-2.0 + *
+ * 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.mybatisflex.core.keygen; + +public class KeyGenerators { + + /** + * uuid 主键生成器 + * {@link com.mybatisflex.core.keygen.impl.UUIDKeyGenerator} + */ + public static final String uuid = "uuid"; + + /** + * flexId 主键生成器 + * {@link com.mybatisflex.core.keygen.impl.FlexIDKeyGenerator} + */ + public static final String flexId = "flexId"; + + /** + * 雪花算法主键生成器 + * {@link com.mybatisflex.core.keygen.impl.SnowFlakeIDKeyGenerator} + */ + public static final String snowFlakeId = "snowFlakeId"; +}