You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@streampark.apache.org by "GOODBOY008 (via GitHub)" <gi...@apache.org> on 2025/08/07 07:24:09 UTC

[I] MyBatis-Plus Enum Refactoring Implementation Plan [streampark]

GOODBOY008 opened a new issue, #4275:
URL: https://github.com/apache/streampark/issues/4275

   ## MyBatis-Plus Enum Refactoring Implementation Plan\n\n### Purpose\nRefactor the current enum usage in StreamPark to leverage MyBatis-Plus's automatic enum conversion feature by using the @EnumValue annotation. This will improve maintainability and consistency throughout the codebase.\n\n### Current State\nCurrently, many entities in StreamPark store enum values as Integer or String types and manually convert them to/from enum instances. This approach requires boilerplate code and is error-prone.\n\n### Proposed Changes\n1. Apply @EnumValue annotation to all relevant enums in both streampark-common and streampark-console modules\n2. Modify entity classes to directly use enum types instead of Integer/String representations\n3. Remove manual conversion logic in services and controllers\n4. Update MyBatis configuration to properly handle enum conversion\n\n### Benefits\n- Reduced boilerplate code\n- Improved type safety\n- Better maintainability\n- Consistent enum handling across th
 e application\n\n### Implementation Steps\n1. Analyze all enums in streampark-common/src/main/java/org/apache/streampark/common/enums/ and streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/enums/\n2. Apply @EnumValue annotation to appropriate fields in each enum\n3. Refactor entity classes to use enum types directly\n4. Update related service and controller classes\n5. Add unit tests to verify enum conversion functionality\n6. Update documentation if necessary\n\n### Impact\nThis change will be backward compatible as MyBatis-Plus handles the conversion automatically. However, it will require careful testing to ensure no functionality is broken.\n\nPlease discuss if this implementation plan is necessary and any suggestions for improvements.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@streampark.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] MyBatis-Plus Enum Refactoring Implementation Plan [streampark]

Posted by "GOODBOY008 (via GitHub)" <gi...@apache.org>.
GOODBOY008 commented on issue #4275:
URL: https://github.com/apache/streampark/issues/4275#issuecomment-3162869261

   ## ๐Ÿš€ 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` โ†’ Annotate `type` (int)
   - `ClusterState.java` โ†’ Annotate `state` (Integer) 
   - `FlinkDeployMode.java` โ†’ Annotate `mode` (Integer)
   - `FlinkJobType.java` โ†’ Annotate `mode` (Integer)
   - `FlinkK8sRestExposedType.java` โ†’ Annotate `type` (Integer)
   - `FlinkRestoreMode.java` โ†’ Annotate `mode` (int)
   - `FlinkSqlValidationFailedType.java` โ†’ Annotate `failedType` (int)
   - `ResolveOrder.java` โ†’ Annotate `order` (Integer)
   - `SparkDeployMode.java` โ†’ Annotate `mode` (Integer)
   - `SparkJobType.java` โ†’ Annotate `mode` (Integer)
   - `SparkSqlValidationFailedType.java` โ†’ Annotate `failedType` (int)
   - `StorageType.java` โ†’ Annotate `type` (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**
   
   1. **Apply `@EnumValue` annotations** to identified enum fields
   2. **Refactor entity classes** to use enum types directly instead of primitive values
   3. **Update mapper interfaces** and remove manual conversion logic
   4. **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:
   ```java
   @Bean
   public Jackson2ObjectMapperBuilderCustomizer customizer() {
       return builder -> builder.featuresToEnable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
   }
   ```
   
   ### ๐Ÿ“ **Discussion Points**
   
   1. **Priority**: Which modules should we tackle first? I suggest starting with `streampark-common` as it's foundational.
   
   2. **Backward Compatibility**: Should we maintain any compatibility layers during migration?
   
   3. **Timeline**: What's the preferred timeline for this refactoring?
   
   4. **Review Process**: How should we structure the PRs? By module or by enum type?
   
   5. **Testing Coverage**: Are there specific integration test scenarios we should prioritize?
   
   ### ๐Ÿค **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](https://baomidou.com/guides/auto-convert-enum/)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@streampark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Improvement] MyBatis-Plus Enum Refactoring Implementation Plan [streampark]

Posted by "wolfboys (via GitHub)" <gi...@apache.org>.
wolfboys closed issue #4275: [Improvement] MyBatis-Plus Enum Refactoring Implementation Plan
URL: https://github.com/apache/streampark/issues/4275


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@streampark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Improvement] MyBatis-Plus Enum Refactoring Implementation Plan [streampark]

Posted by "wolfboys (via GitHub)" <gi...@apache.org>.
wolfboys commented on issue #4275:
URL: https://github.com/apache/streampark/issues/4275#issuecomment-3164278182

   Good proposal  ๐Ÿ™Œ


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@streampark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Improvement] MyBatis-Plus Enum Refactoring Implementation Plan [streampark]

Posted by "wolfboys (via GitHub)" <gi...@apache.org>.
wolfboys commented on issue #4275:
URL: https://github.com/apache/streampark/issues/4275#issuecomment-5523014891

   Thanks for your feedback. We are closing this issue because it is outdated.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@streampark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org