Commit a11b55713f99a5640cb221ca611aae61b16d3195
1 parent
fb750522
feat(usr): ErrorCode 新增 40003 + PageResult 通用类 REQ-USR-004
Showing
3 changed files
with
25 additions
and
0 deletions
backend/src/main/java/com/xly/erp/common/response/ErrorCode.java
| ... | ... | @@ -11,6 +11,7 @@ public final class ErrorCode { |
| 11 | 11 | public static final int OK = 200; |
| 12 | 12 | |
| 13 | 13 | public static final int BAD_REQUEST = 40001; |
| 14 | + public static final int INVALID_ENUM_PARAM = 40003; | |
| 14 | 15 | public static final int COMPANY_NOT_FOUND = 40004; |
| 15 | 16 | |
| 16 | 17 | public static final int BAD_CREDENTIALS = 40101; | ... | ... |
backend/src/main/java/com/xly/erp/common/response/PageResult.java
0 → 100644
| 1 | +package com.xly.erp.common.response; | |
| 2 | + | |
| 3 | +import lombok.Builder; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +import java.util.List; | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * 通用分页响应包装。docs/04 § 3.2。 | |
| 10 | + */ | |
| 11 | +@Data | |
| 12 | +@Builder | |
| 13 | +public class PageResult<T> { | |
| 14 | + private List<T> records; | |
| 15 | + private long total; | |
| 16 | + private int page; | |
| 17 | + private int size; | |
| 18 | +} | ... | ... |
backend/src/test/java/com/xly/erp/common/response/ErrorCodeTest.java
| ... | ... | @@ -17,6 +17,12 @@ class ErrorCodeTest { |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | @Test |
| 20 | + void httpMappings_coverNewCodes_v004() { | |
| 21 | + assertEquals(400, ErrorCode.toHttpStatus(ErrorCode.INVALID_ENUM_PARAM)); | |
| 22 | + assertEquals(40003, ErrorCode.INVALID_ENUM_PARAM); | |
| 23 | + } | |
| 24 | + | |
| 25 | + @Test | |
| 20 | 26 | void httpMappings_coverNewCodes_v003() { |
| 21 | 27 | assertEquals(403, ErrorCode.toHttpStatus(ErrorCode.USER_FORBIDDEN_SELF_DEACTIVATE)); |
| 22 | 28 | assertEquals(404, ErrorCode.toHttpStatus(ErrorCode.USER_NOT_FOUND)); | ... | ... |