Skip to content

[Studio] feat: add core common foundation module with unified response, base entity, enums and global exception handling#455

Open
zhaohai666 wants to merge 3 commits into
apache:rocketmq-studiofrom
zhaohai666:feature/studio-common-foundation
Open

[Studio] feat: add core common foundation module with unified response, base entity, enums and global exception handling#455
zhaohai666 wants to merge 3 commits into
apache:rocketmq-studiofrom
zhaohai666:feature/studio-common-foundation

Conversation

@zhaohai666

Copy link
Copy Markdown

PR Title

[studio] feat: add core common foundation module with unified response, base entity, enums and global exception handling

Overview

This module serves as the foundational common component of the project, delivering standardized response wrappers (Result / PageResult), base entity BaseEntity, 16 business enumerations, global exception handling logic (BusinessException + GlobalExceptionHandler), CORS cross-origin setup and web interceptor configuration. All page-related PRs depend on this module.

Source Code Files (10 files total)

  • StudioApplication.java — Spring Boot application entry point
  • common/config/CorsConfig.java — CORS cross-origin configuration allowing all origins
  • common/config/WebConfig.java — Web interceptor configuration
  • common/domain/BaseEntity.java — Base entity with id, createdAt and updatedAt fields
  • common/domain/PageResult.java — Pagination response wrapper with static factory methods of() and empty()
  • common/domain/Result.java — Unified HTTP response wrapper with static factory methods ok() and error()
  • common/domain/enums/*.java — 16 business enums:
    ClusterStatus, BrokerRole, ClientType, ConsumerStatus, MessageType, AlertLevel, AlertStatus, AlertMetric, AuditOperation, AuditResult, DataSourceType, InstanceStatus, NameServerStatus, ProxyStatus, TopicStatus, QueueType
  • common/exception/BusinessException.java — Custom business runtime exception carrying error code and message
  • common/exception/GlobalExceptionHandler.java — Global exception handler annotated with @RestControllerAdvice

Test Coverage

8 test files with total 632 lines of test code:

Test File Lines Test Methods Coverage Scope
ResultTest.java 80 6 ok() with data/empty/null payload; error() with various error codes; complex object serialization
PageResultTest.java 72 5 Build page via of(), empty page via empty(), pagination parameter validation, edge cases
BaseEntityTest.java 70 5 Field assignment for id/createdAt/updatedAt, default values, equals() & hashCode()
EnumsTest.java 190 16 @nested Each nested class verifies values() and valueOf() for one business enum
BusinessExceptionTest 57 4 Multi-parameter constructors, RuntimeException inheritance, getCode() & getMessage()
GlobalExceptionHandlerTest 71 3 Capture business exceptions and return standardized error Result; capture unknown exceptions and return 500 error
CorsConfigTest.java 48 3 Validate @Configuration annotation, existence of CorsFilter bean, wildcard origin access policy
WebConfigTest.java 44 3 Validate @Configuration annotation and implementation of WebMvcConfigurer

Repository Naming Convention Requirement

All PR and Issue titles associated with this project must start with the [studio] prefix.
This prefix enables community members to quickly identify, filter and track all studio-related work items.

Standard Title Template

@zhaohai666 zhaohai666 changed the title [Studio] feat: add core common foundation module with unified response, base entity, enums and global exception handling [Studio] feat: add core common foundation module with unified response, base entity, enums and global exception handling test Jul 18, 2026
@zhaohai666
zhaohai666 force-pushed the feature/studio-common-foundation branch from 44d4886 to d7e7e26 Compare July 18, 2026 03:57
@zhaohai666 zhaohai666 changed the title [Studio] feat: add core common foundation module with unified response, base entity, enums and global exception handling test [Studio] feat: add core common foundation module with unified response, base entity, enums and global exception handling Jul 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant