IdTypeEnvironmentPostProcessor.java.

代码优化

Signed-off-by: 墨轩 <8813596+mx990420@user.noreply.gitee.com>
This commit is contained in:
墨轩
2025-09-24 02:43:31 +00:00
committed by Gitee
parent f12162e7ff
commit 17f8047da0

View File

@@ -59,20 +59,16 @@ public class IdTypeEnvironmentPostProcessor implements EnvironmentPostProcessor
}
public IdType getIdType(ConfigurableEnvironment environment) {
// return environment.getProperty(ID_TYPE_KEY, IdType.class);
String value = environment.getProperty(ID_TYPE_KEY);
try {
return StrUtil.isNotBlank(value) ? IdType.valueOf(value) : IdType.NONE;
} catch (IllegalArgumentException ex) {
log.error("无法解析 id-type 配置值{}", value, ex);
log.error("[getIdType][无法解析 id-type 配置值({})]", value, ex)
return IdType.NONE;
}
}
public void setIdType(ConfigurableEnvironment environment, IdType idType) {
// environment.getSystemProperties().put(ID_TYPE_KEY, idType);
// log.info("[setIdType][修改 MyBatis Plus 的 idType 为({})]", idType);
Map<String, Object> map = new HashMap<>();
map.put(ID_TYPE_KEY, idType);
environment.getPropertySources().addFirst(new MapPropertySource("mybatisPlusIdType", map));