add KeyGenerators.java

This commit is contained in:
开源海哥 2023-05-16 10:13:32 +08:00
parent 37aab2c951
commit bf629721d1
2 changed files with 40 additions and 3 deletions

View File

@ -30,9 +30,9 @@ public class KeyGeneratorFactory {
/** 内置了 uuid 的生成器因此主键配置的时候可以直接配置为 @Id(keyType = KeyType.Generator, value = "uuid") /** 内置了 uuid 的生成器因此主键配置的时候可以直接配置为 @Id(keyType = KeyType.Generator, value = "uuid")
* {@link com.mybatisflex.annotation.Id} * {@link com.mybatisflex.annotation.Id}
*/ */
register("uuid", new UUIDKeyGenerator()); register(KeyGenerators.uuid, new UUIDKeyGenerator());
register("flexId", new FlexIDKeyGenerator()); register(KeyGenerators.flexId, new FlexIDKeyGenerator());
register("snowFlakeId", new SnowFlakeIDKeyGenerator()); register(KeyGenerators.snowFlakeId, new SnowFlakeIDKeyGenerator());
} }

View File

@ -0,0 +1,37 @@
/**
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.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.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";
}