Commit 7921432e9e1583db243c35cefc2e4d146becd709
1 parent
85eeceb5
fix(usr): 修复 review round 1 must-fix REQ-USR-003
Showing
5 changed files
with
8 additions
and
4 deletions
backend/src/main/java/com/example/erp/module/usr/controller/UserController.java
| ... | ... | @@ -31,6 +31,7 @@ public class UserController { |
| 31 | 31 | return Result.ok(userService.createUser(req, principal)); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | + // REQ-USR-003: 查询用户 | |
| 34 | 35 | @GetMapping("/users") |
| 35 | 36 | public Result<PageVO<UserListItemVO>> getUsers( |
| 36 | 37 | @RequestParam(defaultValue = "username") String queryField, | ... | ... |
backend/src/main/java/com/example/erp/module/usr/service/impl/UserServiceImpl.java
| ... | ... | @@ -121,6 +121,7 @@ public class UserServiceImpl implements UserService { |
| 121 | 121 | }).collect(Collectors.toList()); |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | + // REQ-USR-003: 查询用户 | |
| 124 | 125 | @Override |
| 125 | 126 | @Transactional(readOnly = true) |
| 126 | 127 | public PageVO<UserListItemVO> getUserList(UserListQueryDTO query, String brandId) { | ... | ... |
backend/src/main/resources/mapper/UsrUserMapper.xml
| ... | ... | @@ -3,6 +3,7 @@ |
| 3 | 3 | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| 4 | 4 | <mapper namespace="com.example.erp.module.usr.mapper.UsrUserMapper"> |
| 5 | 5 | |
| 6 | + <!-- REQ-USR-003: 查询用户 --> | |
| 6 | 7 | <select id="selectUserList" resultType="com.example.erp.module.usr.vo.UserListItemVO"> |
| 7 | 8 | SELECT u.sId, u.sUsername, u.sUserCode, u.sUserType, u.sLanguage, |
| 8 | 9 | u.bIsDisabled, u.tLastLoginDate, u.sCreatorUsername, u.tCreateDate, |
| ... | ... | @@ -24,7 +25,7 @@ |
| 24 | 25 | <when test="queryField == 'staffName'"> |
| 25 | 26 | <choose> |
| 26 | 27 | <when test="matchType == 'contains'">AND s.sStaffName LIKE CONCAT('%', #{queryValue}, '%')</when> |
| 27 | - <when test="matchType == 'notContains'">AND s.sStaffName NOT LIKE CONCAT('%', #{queryValue}, '%')</when> | |
| 28 | + <when test="matchType == 'notContains'">AND (s.sStaffName IS NULL OR s.sStaffName NOT LIKE CONCAT('%', #{queryValue}, '%'))</when> | |
| 28 | 29 | <otherwise>AND s.sStaffName = #{queryValue}</otherwise> |
| 29 | 30 | </choose> |
| 30 | 31 | </when> |
| ... | ... | @@ -38,7 +39,7 @@ |
| 38 | 39 | <when test="queryField == 'department'"> |
| 39 | 40 | <choose> |
| 40 | 41 | <when test="matchType == 'contains'">AND s.sDepartment LIKE CONCAT('%', #{queryValue}, '%')</when> |
| 41 | - <when test="matchType == 'notContains'">AND s.sDepartment NOT LIKE CONCAT('%', #{queryValue}, '%')</when> | |
| 42 | + <when test="matchType == 'notContains'">AND (s.sDepartment IS NULL OR s.sDepartment NOT LIKE CONCAT('%', #{queryValue}, '%'))</when> | |
| 42 | 43 | <otherwise>AND s.sDepartment = #{queryValue}</otherwise> |
| 43 | 44 | </choose> |
| 44 | 45 | </when> | ... | ... |
docs/05-API接口契约.md
| ... | ... | @@ -73,8 +73,8 @@ BasePath: `/api` |
| 73 | 73 | - **Path**: `/api/usr/users` |
| 74 | 74 | - **Auth**: Bearer Token |
| 75 | 75 | - **Permission**: `usr:query` |
| 76 | -- **请求**: Query 参数:`field=用户名|员工名|用户号|部门|用户类型|作废|登录日期|制单人`、`matchMode=包含|不包含|等于`、`value=string`、`pageNum=int`、`pageSize=int` | |
| 77 | -- **响应**: `{ list: [{ "userId", "username", "staffName", "userCode", "department", "userType", "language", "isDisabled", "lastLoginDate", "creatorUsername", "createDate" }], total, pageNum, pageSize }` — 密码字段不返回 | |
| 76 | +- **请求**: Query 参数:`queryField=username|staffName|userCode|department|userType|disabled|lastLoginDate|creator`(默认 username)、`matchType=contains|notContains|equals`(默认 contains)、`queryValue=string`、`page=int`(默认 1)、`pageSize=int`(默认 20,最大 100) | |
| 77 | +- **响应**: `{ list: [{ "sId", "sUsername", "sUserCode", "sUserType", "sLanguage", "bIsDisabled", "tLastLoginDate", "sCreatorUsername", "tCreateDate", "sStaffName", "sDepartment" }], total, page, pageSize }` — sPasswordHash / iLoginFailCount / tLockUntil 不返回 | |
| 78 | 78 | |
| 79 | 79 | #### 错误码 |
| 80 | 80 | - `40001` — 参数校验失败 | ... | ... |
frontend/src/pages/usr/UserListPage.tsx
| ... | ... | @@ -36,6 +36,7 @@ const columns: ColumnsType<UserListItemVO> = [ |
| 36 | 36 | { title: '制单日期', dataIndex: 'tCreateDate' }, |
| 37 | 37 | ] |
| 38 | 38 | |
| 39 | +// REQ-USR-003: 查询用户 | |
| 39 | 40 | export default function UserListPage() { |
| 40 | 41 | const [drawerOpen, setDrawerOpen] = useState(false) |
| 41 | 42 | const [data, setData] = useState<PageVO<UserListItemVO> | null>(null) | ... | ... |