fix: 响应信封不再泄露派生字段 success,严格等于 {code, message, data}

- ApiResponse.isSuccess() 加 @JsonIgnore(common 引入 jackson-annotations,仅注解不含 databind);三波以来所有响应都多带了一个契约外的 success 字段,前端解析器忽略未知字段,无破坏
- 测试补断言 $.success doesNotExist;门禁:./mvnw clean test → BUILD SUCCESS,74 测试 0 失败

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-04 14:51:34 +08:00
parent 8bdaf53222
commit 8a799719ff
3 changed files with 17 additions and 1 deletions
+6
View File
@@ -25,6 +25,12 @@
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
</dependency>
<!-- Annotations only (no databind): keeps the wire shape of the shared
envelope under the contract module's control. -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
@@ -1,5 +1,7 @@
package com.patbond.patbond.common.response;
import com.fasterxml.jackson.annotation.JsonIgnore;
public class ApiResponse<T> {
private Integer code;
@@ -23,6 +25,11 @@ public class ApiResponse<T> {
return new ApiResponse<>(code, message, null);
}
/**
* Derived convenience only — not part of the frozen wire contract
* {@code {code, message, data}}, hence never serialized.
*/
@JsonIgnore
public boolean isSuccess() {
return Integer.valueOf(0).equals(code);
}