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:
@@ -41,10 +41,10 @@ public class GroupController {
|
|||||||
@Operation(summary = "获取所有用户组")
|
@Operation(summary = "获取所有用户组")
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@PreAuthorize("hasAuthority('system:group:get')")
|
@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);
|
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);
|
return ResponseResult.databaseSelectSuccess(groups);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface GroupMapper extends BaseMapper<Group> {
|
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);
|
List<Group> getAll(@Param("groupList") List<Group> groupList);
|
||||||
|
|
||||||
Group getOneById(@Param("id") long id);
|
Group getOneById(@Param("id") long id);
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import java.util.List;
|
|||||||
* @since 2023-04-30
|
* @since 2023-04-30
|
||||||
*/
|
*/
|
||||||
public interface IGroupService extends IService<Group> {
|
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);
|
Group getGroup(Long id);
|
||||||
|
|
||||||
|
|||||||
@@ -41,13 +41,13 @@ public class GroupServiceImpl extends ServiceImpl<GroupMapper, Group> implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
Page<Group> groupIPage = PageDTO.of(currentPage, pageSize);
|
||||||
searchName = searchName.trim();
|
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) {
|
if (groupList.size() > 0) {
|
||||||
for (Long roleId : searchRole) {
|
for (Long roleId : searchRole) {
|
||||||
groupList = groupMapper.filterGroupByRoleId(groupList, roleId, null, null);
|
groupList = groupMapper.filterGroupByRoleId(groupList, roleId, null, null, null);
|
||||||
if (groupList.size() == 0) {
|
if (groupList.size() == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,8 +16,13 @@
|
|||||||
#{item}
|
#{item}
|
||||||
</foreach>
|
</foreach>
|
||||||
<if test="searchName != null and searchName != ''">
|
<if test="searchName != null and searchName != ''">
|
||||||
|
<if test="searchRegex == 1">
|
||||||
|
and t_group.name regexp #{searchName}
|
||||||
|
</if>
|
||||||
|
<if test="searchRegex != 1">
|
||||||
and instr(t_group.name, #{searchName}) > 0
|
and instr(t_group.name, #{searchName}) > 0
|
||||||
</if>
|
</if>
|
||||||
|
</if>
|
||||||
<if test="searchEnable != null and searchEnable != -1">
|
<if test="searchEnable != null and searchEnable != -1">
|
||||||
and t_group.enable = #{searchEnable}
|
and t_group.enable = #{searchEnable}
|
||||||
</if>
|
</if>
|
||||||
|
|||||||
@@ -24,14 +24,30 @@
|
|||||||
</el-button>
|
</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="5">
|
<el-col :span="5">
|
||||||
<el-form-item label="名称" class="fill-with">
|
<el-form-item
|
||||||
|
label="名称"
|
||||||
|
class="fill-with"
|
||||||
|
:error="isRegexLegal ? '' : '非法正则表达式'"
|
||||||
|
>
|
||||||
<el-input
|
<el-input
|
||||||
v-model="inputName"
|
v-model="inputName"
|
||||||
maxlength="30"
|
maxlength="30"
|
||||||
show-word-limit
|
show-word-limit
|
||||||
placeholder="请输入内容"
|
placeholder="请输入内容"
|
||||||
@keyup.enter="handleQuery"
|
@keyup.enter="handleQuery"
|
||||||
|
@change="handleInputChange"
|
||||||
|
>
|
||||||
|
<template #suffix>
|
||||||
|
<el-tooltip content="正则表达式">
|
||||||
|
<el-checkbox
|
||||||
|
v-model="checkedRegex"
|
||||||
|
label=".*"
|
||||||
|
:true-label="1"
|
||||||
|
@change="handleInputChange"
|
||||||
/>
|
/>
|
||||||
|
</el-tooltip>
|
||||||
|
</template>
|
||||||
|
</el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="9">
|
<el-col :span="9">
|
||||||
@@ -156,6 +172,7 @@ import {
|
|||||||
DATABASE_UPDATE_OK
|
DATABASE_UPDATE_OK
|
||||||
} from '@/constants/Common.constants.js'
|
} from '@/constants/Common.constants.js'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
|
import _ from 'lodash'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'GroupManagement',
|
name: 'GroupManagement',
|
||||||
@@ -166,10 +183,13 @@ export default {
|
|||||||
dialogLoading: true,
|
dialogLoading: true,
|
||||||
roleOptions: [],
|
roleOptions: [],
|
||||||
searchName: '',
|
searchName: '',
|
||||||
searchRole: [],
|
|
||||||
searchEnable: -1,
|
|
||||||
inputName: '',
|
inputName: '',
|
||||||
|
searchRegex: 0,
|
||||||
|
checkedRegex: 0,
|
||||||
|
isRegexLegal: true,
|
||||||
|
searchRole: [],
|
||||||
selectedRole: [],
|
selectedRole: [],
|
||||||
|
searchEnable: -1,
|
||||||
selectedEnable: -1,
|
selectedEnable: -1,
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
pageSize: 50,
|
pageSize: 50,
|
||||||
@@ -196,6 +216,13 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
loadGroupTable() {
|
loadGroupTable() {
|
||||||
|
if (!this.isRegexLegal) {
|
||||||
|
ElMessage.error({
|
||||||
|
dangerouslyUseHTMLString: true,
|
||||||
|
message: '<strong>非法正则表达式</strong>,请重新输入'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
this.tableLoading = true
|
this.tableLoading = true
|
||||||
request
|
request
|
||||||
.get('/group', {
|
.get('/group', {
|
||||||
@@ -203,7 +230,8 @@ export default {
|
|||||||
pageSize: this.pageSize,
|
pageSize: this.pageSize,
|
||||||
searchName: this.searchName,
|
searchName: this.searchName,
|
||||||
searchRole: this.searchRole + '',
|
searchRole: this.searchRole + '',
|
||||||
searchEnable: this.searchEnable
|
searchEnable: this.searchEnable,
|
||||||
|
searchRegex: this.searchRegex ?? 0
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const response = res.data
|
const response = res.data
|
||||||
@@ -366,16 +394,33 @@ export default {
|
|||||||
},
|
},
|
||||||
handleQuery() {
|
handleQuery() {
|
||||||
this.searchName = this.inputName
|
this.searchName = this.inputName
|
||||||
|
this.searchRegex = _.cloneDeep(this.checkedRegex)
|
||||||
this.searchRole = this.selectedRole
|
this.searchRole = this.selectedRole
|
||||||
this.searchEnable = this.selectedEnable
|
this.searchEnable = this.selectedEnable
|
||||||
this.currentPage = 1
|
this.currentPage = 1
|
||||||
|
this.handleInputChange()
|
||||||
this.loadGroupTable()
|
this.loadGroupTable()
|
||||||
},
|
},
|
||||||
handleClear() {
|
handleClear() {
|
||||||
this.inputName = ''
|
this.inputName = ''
|
||||||
|
this.checkedRegex = 0
|
||||||
this.selectedRole = []
|
this.selectedRole = []
|
||||||
this.selectedEnable = -1
|
this.selectedEnable = -1
|
||||||
this.handleQuery()
|
this.handleQuery()
|
||||||
|
},
|
||||||
|
handleInputChange() {
|
||||||
|
if (this.checkedRegex) {
|
||||||
|
try {
|
||||||
|
RegExp(this.inputName)
|
||||||
|
this.isRegexLegal = !(
|
||||||
|
this.inputName.includes('{}') || this.inputName.includes('[]')
|
||||||
|
)
|
||||||
|
} catch (e) {
|
||||||
|
this.isRegexLegal = false
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.isRegexLegal = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
show-word-limit
|
show-word-limit
|
||||||
placeholder="请输入内容"
|
placeholder="请输入内容"
|
||||||
@keyup.enter="handleQuery"
|
@keyup.enter="handleQuery"
|
||||||
|
@change="handleInputChange"
|
||||||
>
|
>
|
||||||
<template #suffix>
|
<template #suffix>
|
||||||
<el-tooltip content="正则表达式">
|
<el-tooltip content="正则表达式">
|
||||||
|
|||||||
Reference in New Issue
Block a user