mirror of
https://github.com/FatttSnake/Pinnacle-OA.git
synced 2026-04-05 23:11:24 +08:00
Added regex search in StaffManagement
This commit is contained in:
@@ -29,8 +29,8 @@ public class StaffController {
|
||||
|
||||
@GetMapping
|
||||
@PreAuthorize("hasAnyAuthority('staff:manege:get', 'staff:admin:get')")
|
||||
public ResponseResult<IPage<User>> getAllStaff(Long currentPage, Long pageSize, Integer searchType, String searchInput, Integer searchGender, String searchBirthFrom, String searchBirthTo) {
|
||||
return ResponseResult.databaseSelectSuccess(staffService.getAllStaff(currentPage, pageSize, searchType, searchInput, searchGender, searchBirthFrom, searchBirthTo));
|
||||
public ResponseResult<IPage<User>> getAllStaff(Long currentPage, Long pageSize, Integer searchType, String searchInput, Integer searchGender, String searchBirthFrom, String searchBirthTo, Integer searchRegex) {
|
||||
return ResponseResult.databaseSelectSuccess(staffService.getAllStaff(currentPage, pageSize, searchType, searchInput, searchGender, searchBirthFrom, searchBirthTo, searchRegex));
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
|
||||
@@ -17,5 +17,5 @@ import org.apache.ibatis.annotations.Param;
|
||||
*/
|
||||
@Mapper
|
||||
public interface StaffMapper extends BaseMapper<Staff> {
|
||||
IPage<User> getAllStaff(IPage<User> page, @Param("departmentId") Long departmentId, @Param("searchType") Integer searchType, @Param("searchInput") String searchInput, @Param("searchGender") Integer searchGender, @Param("searchBirthFrom") String searchBirthFrom, @Param("searchBirthTo") String searchBirthTo);
|
||||
IPage<User> getAllStaff(IPage<User> page, @Param("departmentId") Long departmentId, @Param("searchType") Integer searchType, @Param("searchInput") String searchInput, @Param("searchGender") Integer searchGender, @Param("searchBirthFrom") String searchBirthFrom, @Param("searchBirthTo") String searchBirthTo, @Param("searchRegex") Integer searchRegex);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import com.cfive.pinnacle.entity.permission.User;
|
||||
* @since 2023-04-30
|
||||
*/
|
||||
public interface IStaffService extends IService<Staff> {
|
||||
IPage<User> getAllStaff(Long currentPage, Long pageSize, Integer searchType, String searchInput, Integer searchGender, String searchBirthFrom, String searchBirthTo);
|
||||
IPage<User> getAllStaff(Long currentPage, Long pageSize, Integer searchType, String searchInput, Integer searchGender, String searchBirthFrom, String searchBirthTo, Integer searchRegex);
|
||||
|
||||
boolean modifyStaff(User user);
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class StaffServiceImpl extends ServiceImpl<StaffMapper, Staff> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<User> getAllStaff(Long currentPage, Long pageSize, Integer searchType, String searchInput, Integer searchGender, String searchBirthFrom, String searchBirthTo) {
|
||||
public IPage<User> getAllStaff(Long currentPage, Long pageSize, Integer searchType, String searchInput, Integer searchGender, String searchBirthFrom, String searchBirthTo, Integer searchRegex) {
|
||||
Long departmentId = WebUtil.hasAuthority("staff:admin:get") ? null : WebUtil.getLoginUser().getUser().getDepartmentId();
|
||||
IPage<User> userIPage;
|
||||
if (currentPage == null || pageSize == null) {
|
||||
@@ -48,7 +48,7 @@ public class StaffServiceImpl extends ServiceImpl<StaffMapper, Staff> implements
|
||||
userIPage = PageDTO.of(currentPage, pageSize);
|
||||
}
|
||||
searchInput = searchInput.trim();
|
||||
return staffMapper.getAllStaff(userIPage, departmentId, searchType, searchInput, searchGender, searchBirthFrom, searchBirthTo);
|
||||
return staffMapper.getAllStaff(userIPage, departmentId, searchType, searchInput, searchGender, searchBirthFrom, searchBirthTo, searchRegex);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -33,32 +33,72 @@
|
||||
<if test="searchInput != null and searchInput != ''">
|
||||
<choose>
|
||||
<when test="searchType == 0">
|
||||
and (
|
||||
instr(t_user.username, #{searchInput}) > 0
|
||||
or instr(concat(ts.first_name, ts.last_name), #{searchInput}) > 0
|
||||
or instr(concat(ts.last_name, ts.first_name), #{searchInput}) > 0
|
||||
or instr(ts.email, #{searchInput}) > 0
|
||||
or instr(ts.tel, #{searchInput}) > 0
|
||||
or instr(ts.address, #{searchInput}) > 0
|
||||
)
|
||||
<if test="searchRegex == 1">
|
||||
and (
|
||||
t_user.username regexp #{searchInput}
|
||||
or concat(ts.first_name, ts.last_name) regexp #{searchInput}
|
||||
or concat(ts.last_name, ts.first_name) regexp #{searchInput}
|
||||
or ts.email regexp #{searchInput}
|
||||
or ts.tel regexp #{searchInput}
|
||||
or ts.address regexp #{searchInput}
|
||||
)
|
||||
</if>
|
||||
<if test="searchRegex != 1">
|
||||
and (
|
||||
instr(t_user.username, #{searchInput}) > 0
|
||||
or instr(concat(ts.first_name, ts.last_name), #{searchInput}) > 0
|
||||
or instr(concat(ts.last_name, ts.first_name), #{searchInput}) > 0
|
||||
or instr(ts.email, #{searchInput}) > 0
|
||||
or instr(ts.tel, #{searchInput}) > 0
|
||||
or instr(ts.address, #{searchInput}) > 0
|
||||
)
|
||||
</if>
|
||||
</when>
|
||||
<when test="searchType == 1">
|
||||
and instr(t_user.username, #{searchInput}) > 0
|
||||
<if test="searchRegex == 1">
|
||||
and t_user.username regexp #{searchInput}
|
||||
</if>
|
||||
<if test="searchRegex != 1">
|
||||
and instr(t_user.username, #{searchInput}) > 0
|
||||
</if>
|
||||
</when>
|
||||
<when test="searchType == 2">
|
||||
and (
|
||||
instr(concat(ts.first_name, ts.last_name), #{searchInput}) > 0
|
||||
or instr(concat(ts.last_name, ts.first_name), #{searchInput}) > 0
|
||||
)
|
||||
<if test="searchRegex == 1">
|
||||
and (
|
||||
concat(ts.first_name, ts.last_name) regexp #{searchInput}
|
||||
or concat(ts.last_name, ts.first_name) regexp #{searchInput}
|
||||
)
|
||||
</if>
|
||||
<if test="searchRegex != 1">
|
||||
and (
|
||||
instr(concat(ts.first_name, ts.last_name), #{searchInput}) > 0
|
||||
or instr(concat(ts.last_name, ts.first_name), #{searchInput}) > 0
|
||||
)
|
||||
</if>
|
||||
</when>
|
||||
<when test="searchType == 3">
|
||||
and instr(ts.email, #{searchInput}) > 0
|
||||
<if test="searchRegex == 1">
|
||||
and ts.email regexp #{searchInput}
|
||||
</if>
|
||||
<if test="searchRegex != 1">
|
||||
and instr(ts.email, #{searchInput}) > 0
|
||||
</if>
|
||||
</when>
|
||||
<when test="searchType == 4">
|
||||
and instr(ts.tel, #{searchInput}) > 0
|
||||
<if test="searchRegex == 1">
|
||||
and ts.tel regexp #{searchInput}
|
||||
</if>
|
||||
<if test="searchRegex != 1">
|
||||
and instr(ts.tel, #{searchInput}) > 0
|
||||
</if>
|
||||
</when>
|
||||
<when test="searchType == 5">
|
||||
and instr(ts.address, #{searchInput}) > 0
|
||||
<if test="searchRegex == 1">
|
||||
and ts.address regexp #{searchInput}
|
||||
</if>
|
||||
<if test="searchRegex != 1">
|
||||
and instr(ts.address, #{searchInput}) > 0
|
||||
</if>
|
||||
</when>
|
||||
</choose>
|
||||
</if>
|
||||
|
||||
Reference in New Issue
Block a user