zhaohai666 opened a new pull request, #455:
URL: https://github.com/apache/rocketmq-dashboard/pull/455
## 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
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]