mirror of
https://github.com/FatttSnake/Pinnacle-OA.git
synced 2026-04-05 23:11:24 +08:00
Added regex search in UserManagement
This commit is contained in:
@@ -65,11 +65,11 @@ public class UserController {
|
||||
@GetMapping
|
||||
@PreAuthorize("hasAuthority('system:user:get')")
|
||||
@Operation(summary = "获取所有用户(权限管理相关)")
|
||||
public ResponseResult<IPage<User>> getAllUser(Long currentPage, Long pageSize, String searchName, String searchRole, String searchGroup, Integer searchEnable) {
|
||||
public ResponseResult<IPage<User>> getAllUser(Long currentPage, Long pageSize, String searchName, String searchRole, String searchGroup, Integer searchEnable, Integer searchRegex) {
|
||||
List<Long> searchRoleList = WebUtil.convertStringToList(searchRole, Long.class);
|
||||
List<Long> searchGroupList = WebUtil.convertStringToList(searchGroup, Long.class);
|
||||
|
||||
IPage<User> users = userService.getAllUser(currentPage, pageSize, searchName, searchRoleList, searchGroupList, searchEnable);
|
||||
IPage<User> users = userService.getAllUser(currentPage, pageSize, searchName, searchRoleList, searchGroupList, searchEnable, searchRegex);
|
||||
return ResponseResult.databaseSelectSuccess(users);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import java.util.List;
|
||||
*/
|
||||
@Mapper
|
||||
public interface UserMapper extends BaseMapper<User> {
|
||||
List<Long> filterUserByRoleIdAndGroupId(@Param("userList") List<Long> userList, @Param("roleId") Long roleId, @Param("groupId") Long groupId, String searchName, Integer searchEnable);
|
||||
List<Long> filterUserByRoleIdAndGroupId(@Param("userList") List<Long> userList, @Param("roleId") Long roleId, @Param("groupId") Long groupId, @Param("searchName") String searchName, @Param("searchEnable") Integer searchEnable, @Param("searchRegex") Integer searchRegex);
|
||||
|
||||
List<User> getAllWithRoleAndGroup(@Param("userList") List<User> userList);
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public interface IUserService extends IService<User> {
|
||||
|
||||
List<User> getNoticeUser();
|
||||
|
||||
IPage<User> getAllUser(Long currentPage, Long pageSize, String searchName, List<Long> searchRole, List<Long> searchGroup, Integer searchEnable);
|
||||
IPage<User> getAllUser(Long currentPage, Long pageSize, String searchName, List<Long> searchRole, List<Long> searchGroup, Integer searchEnable, Integer searchRegex);
|
||||
|
||||
User getUser(long id);
|
||||
|
||||
|
||||
@@ -96,13 +96,13 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
||||
|
||||
|
||||
@Override
|
||||
public IPage<User> getAllUser(Long currentPage, Long pageSize, String searchName, List<Long> searchRole, List<Long> searchGroup, Integer searchEnable) {
|
||||
public IPage<User> getAllUser(Long currentPage, Long pageSize, String searchName, List<Long> searchRole, List<Long> searchGroup, Integer searchEnable, Integer searchRegex) {
|
||||
IPage<User> userIPage = PageDTO.of(currentPage, pageSize);
|
||||
searchName = searchName.trim();
|
||||
List<Long> userList = userMapper.filterUserByRoleIdAndGroupId(null, null, null, searchName, searchEnable);
|
||||
List<Long> userList = userMapper.filterUserByRoleIdAndGroupId(null, null, null, searchName, searchEnable, searchRegex);
|
||||
if (userList.size() > 0) {
|
||||
for (Long roleId : searchRole) {
|
||||
userList = userMapper.filterUserByRoleIdAndGroupId(userList, roleId, null, null, null);
|
||||
userList = userMapper.filterUserByRoleIdAndGroupId(userList, roleId, null, null, null, null);
|
||||
if (userList.size() == 0) {
|
||||
break;
|
||||
}
|
||||
@@ -110,7 +110,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
||||
}
|
||||
if (userList.size() > 0) {
|
||||
for (Long groupId : searchGroup) {
|
||||
userList = userMapper.filterUserByRoleIdAndGroupId(userList, null, groupId, null, null);
|
||||
userList = userMapper.filterUserByRoleIdAndGroupId(userList, null, groupId, null, null, null);
|
||||
if (userList.size() == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,12 @@
|
||||
#{item}
|
||||
</foreach>
|
||||
<if test="searchName != null and searchName != ''">
|
||||
and instr(t_user.username, #{searchName}) > 0
|
||||
<if test="searchRegex == 1">
|
||||
and t_user.username regexp #{searchName}
|
||||
</if>
|
||||
<if test="searchRegex != 1">
|
||||
and instr(t_user.username, #{searchName}) > 0
|
||||
</if>
|
||||
</if>
|
||||
<if test="searchEnable != null and searchEnable != -1">
|
||||
and t_user.enable = #{searchEnable}
|
||||
|
||||
Reference in New Issue
Block a user