Files
Vickey d2c897846c refactor(common): split ResponseEnum into SuccessCode/ErrorCode and align body code with HTTP status
Replace the mixed-purpose ResponseEnum with a ResponseCode interface implemented
by SuccessCode (OK/ADD/DELETE/UPDATE) and ErrorCode (NOT_FOUND/UNAUTHORIZED/
TOKEN_INVALID/IP_INVALID/FORBIDDEN/PASSWORD_*/VALIDATION/OUT_OF_RANGE/FAILURE),
each carrying its HTTP status so the envelope body code and transport status no
longer diverge.

- Introduce abstract BusinessException carrying an ErrorCode; all 23 business
  exceptions extend it and bind a fixed code. ExceptionConfig reads the carried
  code to set both body code and HTTP status (404->R404, 401->R401, 422->R422).
- Add GrpcRFactory (ok/fail/notFound) and remove the hand-written GrpcR builder
  boilerplate across 19 gRPC servers.
- Drop the dead @EnumValue index and ofIndex/ofCode/ofName lookups; OUT_OF_RANGE
  is now carried by OutRangeException.
- Update R factory methods to accept ResponseCode; migrate 90+ controllers,
  11 gRPC facades, OpenAPI specs and README to the split enums.

Also fix several pre-existing red tests surfaced by the full suite:
- OAuthMcpRuntimeServiceImplTest: setUp set @Value fields refactored into
  OAuthProperties; inject the properties object instead.
- DriverReadServiceImplTest: reset leaked ConnectionBackoff static state via a
  new clear() in @BeforeEach.
- modbus-rtu/tcp: make the static modbusFactory non-final so tests can swap it.
- ble: override no-arg health() to report OFFLINE before initialization.
- PlcS7/facade-local tests: expect the thrown exception / use the single-arg
  overload matching production behaviour.
- Remove a duplicate dc3-common-constant dependency in dc3-common-data/pom.xml.
2026-06-18 23:53:41 +08:00
..

DC3 Common Web

Overview

dc3-common-web is the shared WebFlux configuration module of the IoT DC3 platform. It provides global exception handling, WebFlux request processing configuration, global web filters, and reactive response utilities for all REST-based center services.

Module Information

  • Group ID: io.github.pnoker
  • Artifact ID: dc3-common-web
  • Version: 2026.5.22

Key Components

Component Purpose
WebFluxConfig Global WebFlux configuration (codecs, CORS, message converters)
ExceptionConfig @ControllerAdvice global exception handler mapping exceptions to R<T> responses
WebFilterConfig Registers global web filters (e.g., request logging, context enrichment)
ResponseUtil Utilities for writing non-controller ServerHttpResponse bodies in reactive context

Exception Handling

All exceptions thrown by controllers are caught by ExceptionConfig and mapped to a structured R<T> response:

{
  "ok": false,
  "code": "FAILURE",
  "message": "Resource not found"
}

Build Instructions

mvn -s ../../.mvn/settings.xml clean package
  • dc3-common-auth, dc3-common-data, dc3-common-manager — All include this for reactive web support
  • dc3-common-public — Provides R<T> response wrapper

License

Copyright 2016-present the IoT DC3 original author or authors.

Licensed under the GNU Affero General Public License v3.0 (AGPL 3.0)