Commit 1f4469794e3019ec68e41c259c63225bbc6bef0c
1 parent
bd83f4c2
chore(usr): docs/05 补 GET 详情 + ErrorCode 新增 40302/40401 REQ-USR-003
Showing
3 changed files
with
24 additions
and
0 deletions
backend/src/main/java/com/xly/erp/common/response/ErrorCode.java
| ... | ... | @@ -17,6 +17,9 @@ public final class ErrorCode { |
| 17 | 17 | public static final int ACCOUNT_DELETED = 40103; |
| 18 | 18 | |
| 19 | 19 | public static final int FORBIDDEN = 40301; |
| 20 | + public static final int USER_FORBIDDEN_SELF_DEACTIVATE = 40302; | |
| 21 | + | |
| 22 | + public static final int USER_NOT_FOUND = 40401; | |
| 20 | 23 | |
| 21 | 24 | public static final int ACCOUNT_LOCKED = 42301; |
| 22 | 25 | ... | ... |
backend/src/test/java/com/xly/erp/common/response/ErrorCodeTest.java
| ... | ... | @@ -17,6 +17,14 @@ class ErrorCodeTest { |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | @Test |
| 20 | + void httpMappings_coverNewCodes_v003() { | |
| 21 | + assertEquals(403, ErrorCode.toHttpStatus(ErrorCode.USER_FORBIDDEN_SELF_DEACTIVATE)); | |
| 22 | + assertEquals(404, ErrorCode.toHttpStatus(ErrorCode.USER_NOT_FOUND)); | |
| 23 | + assertEquals(40302, ErrorCode.USER_FORBIDDEN_SELF_DEACTIVATE); | |
| 24 | + assertEquals(40401, ErrorCode.USER_NOT_FOUND); | |
| 25 | + } | |
| 26 | + | |
| 27 | + @Test | |
| 20 | 28 | void httpMappings_existingCodes_unchanged() { |
| 21 | 29 | assertEquals(200, ErrorCode.toHttpStatus(ErrorCode.OK)); |
| 22 | 30 | assertEquals(400, ErrorCode.toHttpStatus(ErrorCode.BAD_REQUEST)); | ... | ... |
docs/05-API接口契约.md
| ... | ... | @@ -82,6 +82,19 @@ BasePath: `/api/v1` |
| 82 | 82 | - `40901` — 用户名已存在 |
| 83 | 83 | - `40902` — 用户号已存在 |
| 84 | 84 | |
| 85 | +### REQ-USR-003 GET 用户详情 | |
| 86 | + | |
| 87 | +- **Method**: GET | |
| 88 | +- **Path**: `/api/v1/users/{userId}` | |
| 89 | +- **Auth**: Bearer Token;仅 `userType=SUPER_ADMIN` 可调用 | |
| 90 | +- **请求**: Path `userId: int` | |
| 91 | +- **响应**: JSON `UserDetailVo { userId, username, userCode, userType, language, canEditDocument, isDeleted, employeeId, employeeName, permissionCategoryIds: int[], updatedBy, updatedDate }` | |
| 92 | + | |
| 93 | +#### 错误码 | |
| 94 | +- `40101` — 未携带或无效 Token | |
| 95 | +- `40301` — 当前用户非超级管理员,无权调用 | |
| 96 | +- `40401` — 用户不存在 | |
| 97 | + | |
| 85 | 98 | ### REQ-USR-003 修改用户 |
| 86 | 99 | |
| 87 | 100 | - **Method**: PUT | ... | ... |