|
|
|
|
@ -2,7 +2,6 @@ package com.qiujie.controller;
|
|
|
|
|
|
|
|
|
|
import com.qiujie.service.AttendanceService;
|
|
|
|
|
import com.qiujie.entity.Attendance;
|
|
|
|
|
|
|
|
|
|
import com.qiujie.dto.ResponseDTO;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
@ -15,91 +14,156 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <p>
|
|
|
|
|
* 前端控制器
|
|
|
|
|
* </p>
|
|
|
|
|
*
|
|
|
|
|
* 考勤管理前端控制器
|
|
|
|
|
* 处理考勤相关的所有HTTP请求,包括考勤记录的增删改查、导入导出等操作
|
|
|
|
|
*
|
|
|
|
|
* @author qiujie
|
|
|
|
|
* @since 2022-03-29
|
|
|
|
|
*/
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("/attendance")
|
|
|
|
|
@RestController // 标识为RESTful控制器,返回数据均为JSON格式
|
|
|
|
|
@RequestMapping("/attendance") // 定义基础请求路径为/attendance
|
|
|
|
|
public class AttendanceController {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
@Autowired // 自动注入考勤服务类
|
|
|
|
|
private AttendanceService attendanceService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新增考勤记录接口
|
|
|
|
|
* @param attendance 考勤实体对象,通过请求体传入
|
|
|
|
|
* @return 操作结果响应
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation("新增")
|
|
|
|
|
@PostMapping
|
|
|
|
|
@PostMapping // 处理POST请求,路径为/attendance
|
|
|
|
|
public ResponseDTO add(@RequestBody Attendance attendance) {
|
|
|
|
|
return this.attendanceService.add(attendance);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 逻辑删除考勤记录接口
|
|
|
|
|
* @param id 考勤记录ID,通过路径参数传入
|
|
|
|
|
* @return 操作结果响应
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation("逻辑删除")
|
|
|
|
|
@DeleteMapping("/{id}")
|
|
|
|
|
@DeleteMapping("/{id}") // 处理DELETE请求,路径为/attendance/{id}
|
|
|
|
|
public ResponseDTO delete(@PathVariable Integer id) {
|
|
|
|
|
return this.attendanceService.delete(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 批量逻辑删除考勤记录接口
|
|
|
|
|
* @param ids 考勤记录ID列表,通过路径参数传入
|
|
|
|
|
* @return 操作结果响应
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation("批量逻辑删除")
|
|
|
|
|
@DeleteMapping("/batch/{ids}")
|
|
|
|
|
@DeleteMapping("/batch/{ids}") // 处理DELETE请求,路径为/attendance/batch/{ids}
|
|
|
|
|
public ResponseDTO deleteBatch(@PathVariable List<Integer> ids) {
|
|
|
|
|
return this.attendanceService.deleteBatch(ids);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 编辑更新考勤记录接口
|
|
|
|
|
* @param attendance 考勤实体对象,通过请求体传入
|
|
|
|
|
* @return 操作结果响应
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation("编辑更新")
|
|
|
|
|
@PutMapping
|
|
|
|
|
@PutMapping // 处理PUT请求,路径为/attendance
|
|
|
|
|
public ResponseDTO edit(@RequestBody Attendance attendance) {
|
|
|
|
|
return this.attendanceService.edit(attendance);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据ID查询考勤记录详情接口
|
|
|
|
|
* @param id 考勤记录ID,通过路径参数传入
|
|
|
|
|
* @return 考勤记录信息响应
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation("查询")
|
|
|
|
|
@GetMapping("/{id}")
|
|
|
|
|
@GetMapping("/{id}") // 处理GET请求,路径为/attendance/{id}
|
|
|
|
|
public ResponseDTO query(@PathVariable Integer id) {
|
|
|
|
|
return this.attendanceService.query(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 条件分页查询考勤记录列表接口
|
|
|
|
|
* @param current 当前页码,默认为1
|
|
|
|
|
* @param size 每页大小,默认为10
|
|
|
|
|
* @param name 员工姓名(模糊查询条件)
|
|
|
|
|
* @param deptId 部门ID(筛选条件)
|
|
|
|
|
* @param month 月份(格式如:2024-01)
|
|
|
|
|
* @return 分页考勤记录列表响应
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation("条件查询")
|
|
|
|
|
@GetMapping
|
|
|
|
|
@PreAuthorize("hasAnyAuthority('performance:attendance:list','performance:attendance:search')")
|
|
|
|
|
public ResponseDTO list(@RequestParam(defaultValue = "1") Integer current, @RequestParam(defaultValue = "10") Integer size, String name, Integer deptId, String month) {
|
|
|
|
|
@GetMapping // 处理GET请求,路径为/attendance
|
|
|
|
|
@PreAuthorize("hasAnyAuthority('performance:attendance:list','performance:attendance:search')") // 需要具备考勤列表查看或搜索权限
|
|
|
|
|
public ResponseDTO list(@RequestParam(defaultValue = "1") Integer current,
|
|
|
|
|
@RequestParam(defaultValue = "10") Integer size,
|
|
|
|
|
String name,
|
|
|
|
|
Integer deptId,
|
|
|
|
|
String month) {
|
|
|
|
|
return this.attendanceService.list(current, size, name, deptId, month);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 考勤数据导出接口
|
|
|
|
|
* @param response HTTP响应对象,用于输出Excel文件
|
|
|
|
|
* @param month 导出数据的月份,通过路径参数传入
|
|
|
|
|
* @param filename 导出文件名,通过路径参数传入
|
|
|
|
|
* @throws IOException 可能抛出IO异常
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation("数据导出接口")
|
|
|
|
|
@GetMapping("/export/{month}/{filename}")
|
|
|
|
|
@PreAuthorize("hasAnyAuthority('performance:attendance:export')")
|
|
|
|
|
public void export(HttpServletResponse response, @PathVariable String month,@PathVariable String filename) throws IOException {
|
|
|
|
|
this.attendanceService.export(response, month,filename);
|
|
|
|
|
@GetMapping("/export/{month}/{filename}") // 处理GET请求,路径为/attendance/export/{month}/{filename}
|
|
|
|
|
@PreAuthorize("hasAnyAuthority('performance:attendance:export')") // 需要具备考勤数据导出权限
|
|
|
|
|
public void export(HttpServletResponse response,
|
|
|
|
|
@PathVariable String month,
|
|
|
|
|
@PathVariable String filename) throws IOException {
|
|
|
|
|
this.attendanceService.export(response, month, filename);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 考勤数据导入接口
|
|
|
|
|
* @param file Excel文件对象,包含考勤数据
|
|
|
|
|
* @return 导入结果响应
|
|
|
|
|
* @throws IOException 可能抛出IO异常
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation("数据导入接口")
|
|
|
|
|
@PostMapping("/import")
|
|
|
|
|
@PreAuthorize("hasAnyAuthority('performance:attendance:import')")
|
|
|
|
|
@PostMapping("/import") // 处理POST请求,路径为/attendance/import
|
|
|
|
|
@PreAuthorize("hasAnyAuthority('performance:attendance:import')") // 需要具备考勤数据导入权限
|
|
|
|
|
public ResponseDTO imp(MultipartFile file) throws IOException {
|
|
|
|
|
return this.attendanceService.imp(file);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据员工ID和日期查询考勤记录接口
|
|
|
|
|
* @param id 员工ID,通过路径参数传入
|
|
|
|
|
* @param date 日期字符串,格式如:2024-01-15
|
|
|
|
|
* @return 考勤记录信息响应
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation("查询")
|
|
|
|
|
@GetMapping("/{id}/{date}")
|
|
|
|
|
@GetMapping("/{id}/{date}") // 处理GET请求,路径为/attendance/{id}/{date}
|
|
|
|
|
public ResponseDTO queryByStaffIdAndDate(@PathVariable Integer id, @PathVariable String date) {
|
|
|
|
|
return this.attendanceService.queryByStaffIdAndDate(id, date);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 保存或更新考勤记录接口
|
|
|
|
|
* 如果考勤记录存在则更新,不存在则新增
|
|
|
|
|
* @param attendance 考勤实体对象,通过请求体传入
|
|
|
|
|
* @return 操作结果响应
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation("保存或更新")
|
|
|
|
|
@PutMapping("/set")
|
|
|
|
|
@PreAuthorize("hasAnyAuthority('performance:attendance:set')")
|
|
|
|
|
@PutMapping("/set") // 处理PUT请求,路径为/attendance/set
|
|
|
|
|
@PreAuthorize("hasAnyAuthority('performance:attendance:set')") // 需要具备设置考勤权限
|
|
|
|
|
public ResponseDTO setAttendance(@RequestBody Attendance attendance) {
|
|
|
|
|
return this.attendanceService.setAttendance(attendance);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询所有考勤记录接口
|
|
|
|
|
* @return 所有考勤记录列表响应
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation("获取所有")
|
|
|
|
|
@GetMapping("/all")
|
|
|
|
|
@GetMapping("/all") // 处理GET请求,路径为/attendance/all
|
|
|
|
|
public ResponseDTO queryAll() {
|
|
|
|
|
return this.attendanceService.queryAll();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|