mirror of
https://github.com/FatttSnake/Pinnacle-OA.git
synced 2026-04-05 23:11:24 +08:00
Added department in StaffManagement
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
package com.cfive.pinnacle.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.cfive.pinnacle.entity.Department;
|
||||
import com.cfive.pinnacle.entity.common.ResponseCode;
|
||||
import com.cfive.pinnacle.entity.common.ResponseResult;
|
||||
import com.cfive.pinnacle.service.IDepartmentService;
|
||||
import com.cfive.pinnacle.utils.WebUtil;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -47,6 +49,20 @@ public class DepartmentController {
|
||||
return ResponseResult.databaseSelectSuccess(departmentService.getAllDepartment(currentPage, pageSize, searchType, searchInput));
|
||||
}
|
||||
|
||||
@GetMapping("list")
|
||||
@PreAuthorize("hasAnyAuthority('staff:manege:modify', 'staff:admin:modify')")
|
||||
public ResponseResult<List<Department>> getDepartmentList() {
|
||||
List<Department> departmentList;
|
||||
if (WebUtil.hasAuthority("staff:admin:modify")) {
|
||||
departmentList = departmentService.list();
|
||||
} else {
|
||||
LambdaQueryWrapper<Department> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(Department::getId, WebUtil.getLoginUser().getUser().getDepartmentId());
|
||||
departmentList = departmentService.list(wrapper);
|
||||
}
|
||||
return ResponseResult.databaseSelectSuccess(departmentList);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@PreAuthorize("hasAuthority('department:admin:add')")
|
||||
public ResponseResult<?> addDepartment(@RequestBody Department department) {
|
||||
|
||||
@@ -53,6 +53,7 @@ public class StaffServiceImpl extends ServiceImpl<StaffMapper, Staff> implements
|
||||
|
||||
@Override
|
||||
public boolean modifyStaff(User user) {
|
||||
Long departmentId = user.getDepartmentId();
|
||||
Staff newStaff = user.getStaff();
|
||||
user = userMapper.getOneById(user.getId());
|
||||
Staff oldStaff = user.getStaff();
|
||||
@@ -68,6 +69,8 @@ public class StaffServiceImpl extends ServiceImpl<StaffMapper, Staff> implements
|
||||
newStaff.setId(oldStaff.getId());
|
||||
staffMapper.updateById(newStaff);
|
||||
}
|
||||
user.setDepartmentId(departmentId);
|
||||
userMapper.updateById(user);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user