mirror of
https://github.com/FatttSnake/Pinnacle-OA.git
synced 2026-04-05 23:11:24 +08:00
Added pagination to StaffManagement
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.cfive.pinnacle.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.cfive.pinnacle.entity.common.ResponseCode;
|
||||
import com.cfive.pinnacle.entity.common.ResponseResult;
|
||||
import com.cfive.pinnacle.entity.permission.User;
|
||||
@@ -10,8 +11,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 员工 前端控制器
|
||||
@@ -33,8 +32,8 @@ public class StaffController {
|
||||
|
||||
@GetMapping
|
||||
@PreAuthorize("hasAnyAuthority('staff:manege:get', 'staff:admin:get')")
|
||||
public ResponseResult<List<User>> getAllStaff() {
|
||||
return ResponseResult.databaseSelectSuccess(staffService.getAllStaff(WebUtil.hasAuthority("staff:admin:get") ? null : WebUtil.getLoginUser().getUser().getDepartmentId()));
|
||||
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()));
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package com.cfive.pinnacle.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.cfive.pinnacle.entity.Staff;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.cfive.pinnacle.entity.permission.User;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 员工 Mapper 接口
|
||||
@@ -18,5 +17,5 @@ import java.util.List;
|
||||
*/
|
||||
@Mapper
|
||||
public interface StaffMapper extends BaseMapper<Staff> {
|
||||
List<User> getAllStaff(@Param("departmentId")Long departmentId);
|
||||
IPage<User> getAllStaff(IPage<User> page, @Param("departmentId")Long departmentId);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package com.cfive.pinnacle.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.cfive.pinnacle.entity.Staff;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.cfive.pinnacle.entity.permission.User;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 员工 服务类
|
||||
@@ -15,7 +14,7 @@ import java.util.List;
|
||||
* @since 2023-04-30
|
||||
*/
|
||||
public interface IStaffService extends IService<Staff> {
|
||||
List<User> getAllStaff(Long departmentId);
|
||||
IPage<User> getAllStaff(Long currentPage, Long pageSize, Long departmentId);
|
||||
|
||||
boolean modifyStaff(User user);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.cfive.pinnacle.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
|
||||
import com.cfive.pinnacle.entity.Staff;
|
||||
import com.cfive.pinnacle.entity.permission.User;
|
||||
import com.cfive.pinnacle.exception.DataValidationFailedException;
|
||||
@@ -11,7 +13,6 @@ import com.cfive.pinnacle.utils.WebUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@@ -38,8 +39,14 @@ public class StaffServiceImpl extends ServiceImpl<StaffMapper, Staff> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<User> getAllStaff(Long departmentId) {
|
||||
return staffMapper.getAllStaff(departmentId);
|
||||
public IPage<User> getAllStaff(Long currentPage, Long pageSize, Long departmentId) {
|
||||
IPage<User> userIPage;
|
||||
if (currentPage == null || pageSize == null) {
|
||||
userIPage = PageDTO.of(0, -1);
|
||||
} else {
|
||||
userIPage = PageDTO.of(currentPage, pageSize);
|
||||
}
|
||||
return staffMapper.getAllStaff(userIPage, departmentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user