[Improvement] MyBatis-Plus Enum Refactoring Implementation Plan
๐ Enum Refactoring Plan Discussion
Hi team! I've created a comprehensive refactoring plan for migrating to MyBatis-Plus automatic enum conversion using @EnumValue annotations. This will improve maintainability and consistency across the codebase.
๐ Migration Overview
Goal: Leverage MyBatis-Plus's automatic enum conversion by using @EnumValue annotation for better maintainability and consistency.
๐ Analysis Summary
Phase 1: Enums in streampark-common (12 enums to refactor)
ApplicationType.javaโ Annotatetype(int)ClusterState.javaโ Annotatestate(Integer)FlinkDeployMode.javaโ Annotatemode(Integer)FlinkJobType.javaโ Annotatemode(Integer)FlinkK8sRestExposedType.javaโ Annotatetype(Integer)FlinkRestoreMode.javaโ Annotatemode(int)FlinkSqlValidationFailedType.javaโ AnnotatefailedType(int)ResolveOrder.javaโ Annotateorder(Integer)SparkDeployMode.javaโ Annotatemode(Integer)SparkJobType.javaโ Annotatemode(Integer)SparkSqlValidationFailedType.javaโ AnnotatefailedType(int)StorageType.javaโ Annotatetype(String)
Phase 2: Enums in streampark-console (~25 enums to refactor)
Including: AccessTokenStateEnum, AlertTypeEnum, AppExistsStateEnum, AuthenticationType, BuildStateEnum, etc.
Note: Some enums already have @EnumValue annotation and just need verification.
๐ฏ Implementation Strategy
- Apply
@EnumValueannotations to identified enum fields - Refactor entity classes to use enum types directly instead of primitive values
- Update mapper interfaces and remove manual conversion logic
- Configure Jackson globally for consistent enum serialization to frontend
๐งช Testing & Verification Plan
- Unit tests for enum value mapping
- Integration tests for database persistence
- Full build verification:
mvn clean install - Existing test suite validation
๐ง Frontend Serialization (Bonus)
Recommend global Jackson configuration:
@Bean
public Jackson2ObjectMapperBuilderCustomizer customizer() {
return builder -> builder.featuresToEnable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
}
๐ค Next Steps
I'm ready to begin implementation following community feedback. Please let me know:
- Your thoughts on the approach
- Any concerns or suggestions
- Preferred implementation order
- Review preferences
Looking forward to your feedback! ๐
Reference: MyBatis-Plus Official Docs - Auto Enum Conversion
Good proposal ๐