mirror of
https://github.com/FatttSnake/Pinnacle-OA.git
synced 2026-04-05 23:11:24 +08:00
Added search in StaffManagement
This commit is contained in:
@@ -5,7 +5,6 @@ import com.cfive.pinnacle.entity.common.ResponseCode;
|
||||
import com.cfive.pinnacle.entity.common.ResponseResult;
|
||||
import com.cfive.pinnacle.entity.permission.User;
|
||||
import com.cfive.pinnacle.service.IStaffService;
|
||||
import com.cfive.pinnacle.utils.WebUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -32,8 +31,8 @@ public class StaffController {
|
||||
|
||||
@GetMapping
|
||||
@PreAuthorize("hasAnyAuthority('staff:manege:get', 'staff:admin:get')")
|
||||
public ResponseResult<IPage<User>> getAllStaff(Long currentPage, Long pageSize) {
|
||||
return ResponseResult.databaseSelectSuccess(staffService.getAllStaff(currentPage, pageSize, WebUtil.hasAuthority("staff:admin:get") ? null : WebUtil.getLoginUser().getUser().getDepartmentId()));
|
||||
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));
|
||||
}
|
||||
|
||||
@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);
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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, Long departmentId);
|
||||
IPage<User> getAllStaff(Long currentPage, Long pageSize, Integer searchType, String searchInput, Integer searchGender, String searchBirthFrom, String searchBirthTo);
|
||||
|
||||
boolean modifyStaff(User user);
|
||||
}
|
||||
|
||||
@@ -39,14 +39,16 @@ public class StaffServiceImpl extends ServiceImpl<StaffMapper, Staff> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<User> getAllStaff(Long currentPage, Long pageSize, Long departmentId) {
|
||||
public IPage<User> getAllStaff(Long currentPage, Long pageSize, Integer searchType, String searchInput, Integer searchGender, String searchBirthFrom, String searchBirthTo) {
|
||||
Long departmentId = WebUtil.hasAuthority("staff:admin:get") ? null : WebUtil.getLoginUser().getUser().getDepartmentId();
|
||||
IPage<User> userIPage;
|
||||
if (currentPage == null || pageSize == null) {
|
||||
userIPage = PageDTO.of(0, -1);
|
||||
} else {
|
||||
userIPage = PageDTO.of(currentPage, pageSize);
|
||||
}
|
||||
return staffMapper.getAllStaff(userIPage, departmentId);
|
||||
searchInput = searchInput.trim();
|
||||
return staffMapper.getAllStaff(userIPage, departmentId, searchType, searchInput, searchGender, searchBirthFrom, searchBirthTo);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,33 +4,70 @@
|
||||
|
||||
<select id="getAllStaff" resultMap="staffMap">
|
||||
select t_user.id as user_id,
|
||||
t_user.username as user_username,
|
||||
t_user.department_id as user_department_id,
|
||||
t_user.deleted as user_deleted,
|
||||
t_user.version as user_version,
|
||||
ts.id as staff_id,
|
||||
ts.user_id as staff_user_id,
|
||||
ts.first_name as staff_first_name,
|
||||
ts.last_name as staff_last_name,
|
||||
ts.gender as staff_gender,
|
||||
ts.birth as staff_birth,
|
||||
ts.email as staff_email,
|
||||
ts.tel as staff_tel,
|
||||
ts.address as staff_address,
|
||||
ts.deleted as staff_deleted,
|
||||
ts.version as staff_version,
|
||||
td.id as department_id,
|
||||
td.name as department_name,
|
||||
td.deleted as department_deleted,
|
||||
td.version as department_version
|
||||
t_user.username as user_username,
|
||||
t_user.department_id as user_department_id,
|
||||
t_user.deleted as user_deleted,
|
||||
t_user.version as user_version,
|
||||
ts.id as staff_id,
|
||||
ts.user_id as staff_user_id,
|
||||
ts.first_name as staff_first_name,
|
||||
ts.last_name as staff_last_name,
|
||||
ts.gender as staff_gender,
|
||||
ts.birth as staff_birth,
|
||||
ts.email as staff_email,
|
||||
ts.tel as staff_tel,
|
||||
ts.address as staff_address,
|
||||
ts.deleted as staff_deleted,
|
||||
ts.version as staff_version,
|
||||
td.id as department_id,
|
||||
td.name as department_name,
|
||||
td.deleted as department_deleted,
|
||||
td.version as department_version
|
||||
from t_user
|
||||
left join (select * from t_staff where deleted = 0) as ts on t_user.id = ts.user_id
|
||||
left join (select * from t_department where deleted = 0) as td on td.id = t_user.department_id
|
||||
left join (select * from t_staff where deleted = 0) as ts on t_user.id = ts.user_id
|
||||
left join (select * from t_department where deleted = 0) as td on td.id = t_user.department_id
|
||||
where t_user.deleted = 0
|
||||
<if test="departmentId != null">
|
||||
and t_user.department_id = #{departmentId}
|
||||
</if>
|
||||
|
||||
<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
|
||||
)
|
||||
</when>
|
||||
<when test="searchType == 1">
|
||||
and instr(t_user.username, #{searchInput}) > 0
|
||||
</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
|
||||
)
|
||||
</when>
|
||||
<when test="searchType == 3">
|
||||
and instr(ts.email, #{searchInput}) > 0
|
||||
</when>
|
||||
<when test="searchType == 4">
|
||||
and instr(ts.tel, #{searchInput}) > 0
|
||||
</when>
|
||||
<when test="searchType == 5">
|
||||
and instr(ts.address, #{searchInput}) > 0
|
||||
</when>
|
||||
</choose>
|
||||
</if>
|
||||
<if test="searchGender != null and searchGender != -1">
|
||||
and ts.gender = #{searchGender}
|
||||
</if>
|
||||
<if test="searchBirthFrom != null and searchBirthFrom != '' and searchBirthTo != null and searchBirthTo != ''">
|
||||
and ts.birth between #{searchBirthFrom} and #{searchBirthTo}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<resultMap id="staffMap" type="user">
|
||||
|
||||
Reference in New Issue
Block a user