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;
|
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.ResponseCode;
|
||||||
import com.cfive.pinnacle.entity.common.ResponseResult;
|
import com.cfive.pinnacle.entity.common.ResponseResult;
|
||||||
import com.cfive.pinnacle.entity.permission.User;
|
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.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 员工 前端控制器
|
* 员工 前端控制器
|
||||||
@@ -33,8 +32,8 @@ public class StaffController {
|
|||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@PreAuthorize("hasAnyAuthority('staff:manege:get', 'staff:admin:get')")
|
@PreAuthorize("hasAnyAuthority('staff:manege:get', 'staff:admin:get')")
|
||||||
public ResponseResult<List<User>> getAllStaff() {
|
public ResponseResult<IPage<User>> getAllStaff(Long currentPage, Long pageSize) {
|
||||||
return ResponseResult.databaseSelectSuccess(staffService.getAllStaff(WebUtil.hasAuthority("staff:admin:get") ? null : WebUtil.getLoginUser().getUser().getDepartmentId()));
|
return ResponseResult.databaseSelectSuccess(staffService.getAllStaff(currentPage, pageSize, WebUtil.hasAuthority("staff:admin:get") ? null : WebUtil.getLoginUser().getUser().getDepartmentId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping
|
@PutMapping
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
package com.cfive.pinnacle.mapper;
|
package com.cfive.pinnacle.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.cfive.pinnacle.entity.Staff;
|
import com.cfive.pinnacle.entity.Staff;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.cfive.pinnacle.entity.permission.User;
|
import com.cfive.pinnacle.entity.permission.User;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 员工 Mapper 接口
|
* 员工 Mapper 接口
|
||||||
@@ -18,5 +17,5 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface StaffMapper extends BaseMapper<Staff> {
|
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;
|
package com.cfive.pinnacle.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.cfive.pinnacle.entity.Staff;
|
import com.cfive.pinnacle.entity.Staff;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.cfive.pinnacle.entity.permission.User;
|
import com.cfive.pinnacle.entity.permission.User;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 员工 服务类
|
* 员工 服务类
|
||||||
@@ -15,7 +14,7 @@ import java.util.List;
|
|||||||
* @since 2023-04-30
|
* @since 2023-04-30
|
||||||
*/
|
*/
|
||||||
public interface IStaffService extends IService<Staff> {
|
public interface IStaffService extends IService<Staff> {
|
||||||
List<User> getAllStaff(Long departmentId);
|
IPage<User> getAllStaff(Long currentPage, Long pageSize, Long departmentId);
|
||||||
|
|
||||||
boolean modifyStaff(User user);
|
boolean modifyStaff(User user);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.cfive.pinnacle.service.impl;
|
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.Staff;
|
||||||
import com.cfive.pinnacle.entity.permission.User;
|
import com.cfive.pinnacle.entity.permission.User;
|
||||||
import com.cfive.pinnacle.exception.DataValidationFailedException;
|
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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -38,8 +39,14 @@ public class StaffServiceImpl extends ServiceImpl<StaffMapper, Staff> implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<User> getAllStaff(Long departmentId) {
|
public IPage<User> getAllStaff(Long currentPage, Long pageSize, Long departmentId) {
|
||||||
return staffMapper.getAllStaff(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
|
@Override
|
||||||
|
|||||||
@@ -34,6 +34,17 @@
|
|||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
<div class="pagination">
|
||||||
|
<el-pagination
|
||||||
|
v-model:current-page="currentPage"
|
||||||
|
v-model:page-size="pageSize"
|
||||||
|
:page-sizes="[50, 100, 200, 500, 1000]"
|
||||||
|
layout="total, sizes, prev, pager, next, jumper"
|
||||||
|
:total="totalCount"
|
||||||
|
@size-change="handleSizeChange"
|
||||||
|
@current-change="handleCurrentChange"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<el-dialog title="编辑员工信息" :close-on-click-modal="false" draggable v-model="dialogVisible">
|
<el-dialog title="编辑员工信息" :close-on-click-modal="false" draggable v-model="dialogVisible">
|
||||||
<template #default>
|
<template #default>
|
||||||
@@ -101,6 +112,9 @@ export default {
|
|||||||
dialogVisible: false,
|
dialogVisible: false,
|
||||||
tableLoading: true,
|
tableLoading: true,
|
||||||
dialogLoading: true,
|
dialogLoading: true,
|
||||||
|
currentPage: 1,
|
||||||
|
pageSize: 50,
|
||||||
|
totalCount: 0,
|
||||||
staffTable: [],
|
staffTable: [],
|
||||||
editUserId: '',
|
editUserId: '',
|
||||||
rules: {
|
rules: {
|
||||||
@@ -132,10 +146,13 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
loadStaffTable() {
|
loadStaffTable() {
|
||||||
this.tableLoading = true
|
this.tableLoading = true
|
||||||
request.get('/staff').then((res) => {
|
request
|
||||||
|
.get('/staff', { currentPage: this.currentPage, pageSize: this.pageSize })
|
||||||
|
.then((res) => {
|
||||||
const response = res.data
|
const response = res.data
|
||||||
if (response.code === DATABASE_SELECT_OK) {
|
if (response.code === DATABASE_SELECT_OK) {
|
||||||
this.staffTable = response.data
|
this.staffTable = response.data.records
|
||||||
|
this.totalCount = response.data.total
|
||||||
this.tableLoading = false
|
this.tableLoading = false
|
||||||
} else {
|
} else {
|
||||||
ElMessage.error({
|
ElMessage.error({
|
||||||
@@ -211,6 +228,14 @@ export default {
|
|||||||
},
|
},
|
||||||
handleCancel() {
|
handleCancel() {
|
||||||
this.dialogVisible = false
|
this.dialogVisible = false
|
||||||
|
},
|
||||||
|
handleSizeChange(pageSize) {
|
||||||
|
this.pageSize = pageSize
|
||||||
|
this.loadStaffTable()
|
||||||
|
},
|
||||||
|
handleCurrentChange(currentPage) {
|
||||||
|
this.currentPage = currentPage
|
||||||
|
this.loadStaffTable()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@@ -219,4 +244,10 @@ export default {
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped></style>
|
<style scoped>
|
||||||
|
.pagination {
|
||||||
|
display: flex;
|
||||||
|
margin-top: 10px;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user