mirror of
https://github.com/FatttSnake/Pinnacle-OA.git
synced 2026-04-05 23:11:24 +08:00
Added regex search in RoleManagement
This commit is contained in:
@@ -44,10 +44,10 @@ public class RoleController {
|
||||
@Operation(summary = "获取所有角色")
|
||||
@GetMapping
|
||||
@PreAuthorize("hasAuthority('system:role:get')")
|
||||
public ResponseResult<IPage<Role>> getAllRole(Long currentPage, Long pageSize, String searchName, String searchPower, Integer searchEnable) {
|
||||
public ResponseResult<IPage<Role>> getAllRole(Long currentPage, Long pageSize, String searchName, String searchPower, Integer searchEnable, Integer searchRegex) {
|
||||
List<Long> searchPowerList = WebUtil.convertStringToList(searchPower, Long.class);
|
||||
|
||||
IPage<Role> roles = roleService.getAllRole(currentPage, pageSize, searchName, searchPowerList, searchEnable);
|
||||
IPage<Role> roles = roleService.getAllRole(currentPage, pageSize, searchName, searchPowerList, searchEnable, searchRegex);
|
||||
return ResponseResult.databaseSelectSuccess(roles);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import java.util.List;
|
||||
*/
|
||||
@Mapper
|
||||
public interface RoleMapper extends BaseMapper<Role> {
|
||||
List<Long> filterRoleByPowerId(@Param("roleList") List<Long> roleList, @Param("powerId") Long powerId, String searchName, Integer searchEnable);
|
||||
List<Long> filterRoleByPowerId(@Param("roleList") List<Long> roleList, @Param("powerId") Long powerId, @Param("searchName") String searchName, @Param("searchEnable") Integer searchEnable, @Param("searchRegex") Integer searchRegex);
|
||||
|
||||
List<Role> getAll(@Param("roleList") List<Role> roleList);
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.util.List;
|
||||
* @since 2023-04-30
|
||||
*/
|
||||
public interface IRoleService extends IService<Role> {
|
||||
IPage<Role> getAllRole(Long currentPage, Long pageSize, String searchName, List<Long> searchPower, Integer searchEnable);
|
||||
IPage<Role> getAllRole(Long currentPage, Long pageSize, String searchName, List<Long> searchPower, Integer searchEnable, Integer searchRegex);
|
||||
|
||||
Role getRole(long id);
|
||||
|
||||
|
||||
@@ -44,13 +44,13 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IR
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<Role> getAllRole(Long currentPage, Long pageSize, String searchName, List<Long> searchPower, Integer searchEnable) {
|
||||
public IPage<Role> getAllRole(Long currentPage, Long pageSize, String searchName, List<Long> searchPower, Integer searchEnable, Integer searchRegex) {
|
||||
IPage<Role> roleIPage = PageDTO.of(currentPage, pageSize);
|
||||
searchName = searchName.trim();
|
||||
List<Long> roleList = roleMapper.filterRoleByPowerId(null, null, searchName, searchEnable);
|
||||
List<Long> roleList = roleMapper.filterRoleByPowerId(null, null, searchName, searchEnable, searchRegex);
|
||||
if (roleList.size() > 0) {
|
||||
for (Long powerId : searchPower) {
|
||||
roleList = roleMapper.filterRoleByPowerId(roleList, powerId, null, null);
|
||||
roleList = roleMapper.filterRoleByPowerId(roleList, powerId, null, null, null);
|
||||
if (roleList.size() == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,12 @@
|
||||
#{item}
|
||||
</foreach>
|
||||
<if test="searchName != null and searchName != ''">
|
||||
and instr(t_role.name, #{searchName}) > 0
|
||||
<if test="searchRegex == 1">
|
||||
and t_role.name regexp #{searchName}
|
||||
</if>
|
||||
<if test="searchRegex != 1">
|
||||
and instr(t_role.name, #{searchName}) > 0
|
||||
</if>
|
||||
</if>
|
||||
<if test="searchEnable != null and searchEnable != -1">
|
||||
and t_role.enable = #{searchEnable}
|
||||
|
||||
Reference in New Issue
Block a user