1
0
mirror of https://github.com/FatttSnake/Pinnacle-OA.git synced 2026-04-05 23:11:24 +08:00

Added regex search in GroupManagement

This commit is contained in:
2023-06-04 03:55:25 +08:00
parent 20fe3a6fa2
commit d8161667f9
7 changed files with 64 additions and 13 deletions

View File

@@ -41,10 +41,10 @@ public class GroupController {
@Operation(summary = "获取所有用户组")
@GetMapping
@PreAuthorize("hasAuthority('system:group:get')")
public ResponseResult<IPage<Group>> getAllGroup(Long currentPage, Long pageSize, String searchName, String searchRole, Integer searchEnable) {
public ResponseResult<IPage<Group>> getAllGroup(Long currentPage, Long pageSize, String searchName, String searchRole, Integer searchEnable, Integer searchRegex) {
List<Long> searchRoleList = WebUtil.convertStringToList(searchRole, Long.class);
IPage<Group> groups = groupService.getAllGroup(currentPage, pageSize, searchName, searchRoleList, searchEnable);
IPage<Group> groups = groupService.getAllGroup(currentPage, pageSize, searchName, searchRoleList, searchEnable, searchRegex);
return ResponseResult.databaseSelectSuccess(groups);
}

View File

@@ -17,7 +17,7 @@ import java.util.List;
*/
@Mapper
public interface GroupMapper extends BaseMapper<Group> {
List<Long> filterGroupByRoleId(@Param("groupList") List<Long> groupList, @Param("roleId") Long roleId, String searchName, Integer searchEnable);
List<Long> filterGroupByRoleId(@Param("groupList") List<Long> groupList, @Param("roleId") Long roleId, @Param("searchName") String searchName, @Param("searchEnable") Integer searchEnable, @Param("searchRegex") Integer searchRegex);
List<Group> getAll(@Param("groupList") List<Group> groupList);
Group getOneById(@Param("id") long id);

View File

@@ -15,7 +15,7 @@ import java.util.List;
* @since 2023-04-30
*/
public interface IGroupService extends IService<Group> {
IPage<Group> getAllGroup(Long currentPage, Long pageSize, String searchName, List<Long> searchRole, Integer searchEnable);
IPage<Group> getAllGroup(Long currentPage, Long pageSize, String searchName, List<Long> searchRole, Integer searchEnable, Integer searchRegex);
Group getGroup(Long id);

View File

@@ -41,13 +41,13 @@ public class GroupServiceImpl extends ServiceImpl<GroupMapper, Group> implements
}
@Override
public IPage<Group> getAllGroup(Long currentPage, Long pageSize, String searchName, List<Long> searchRole, Integer searchEnable) {
public IPage<Group> getAllGroup(Long currentPage, Long pageSize, String searchName, List<Long> searchRole, Integer searchEnable, Integer searchRegex) {
Page<Group> groupIPage = PageDTO.of(currentPage, pageSize);
searchName = searchName.trim();
List<Long> groupList = groupMapper.filterGroupByRoleId(null, null, searchName, searchEnable);
List<Long> groupList = groupMapper.filterGroupByRoleId(null, null, searchName, searchEnable, searchRegex);
if (groupList.size() > 0) {
for (Long roleId : searchRole) {
groupList = groupMapper.filterGroupByRoleId(groupList, roleId, null, null);
groupList = groupMapper.filterGroupByRoleId(groupList, roleId, null, null, null);
if (groupList.size() == 0) {
break;
}

View File

@@ -16,7 +16,12 @@
#{item}
</foreach>
<if test="searchName != null and searchName != ''">
and instr(t_group.name, #{searchName}) > 0
<if test="searchRegex == 1">
and t_group.name regexp #{searchName}
</if>
<if test="searchRegex != 1">
and instr(t_group.name, #{searchName}) > 0
</if>
</if>
<if test="searchEnable != null and searchEnable != -1">
and t_group.enable = #{searchEnable}