/*
|
* Copyright 2019-2020 Zheng Jie
|
*
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
* you may not use this file except in compliance with the License.
|
* You may obtain a copy of the License at
|
*
|
* http://www.apache.org/licenses/LICENSE-2.0
|
*
|
* Unless required by applicable law or agreed to in writing, software
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* See the License for the specific language governing permissions and
|
* limitations under the License.
|
*/
|
package me.zhengjie.modules.attendance.rest;
|
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import lombok.RequiredArgsConstructor;
|
import me.zhengjie.annotation.Log;
|
import me.zhengjie.modules.attendance.domain.AttendanceLeave;
|
import me.zhengjie.modules.attendance.domain.AttendanceOvertime;
|
import me.zhengjie.modules.attendance.service.AttendanceOvertimeService;
|
import me.zhengjie.modules.attendance.service.dto.AttendanceOvertimeQueryCriteria;
|
import org.springframework.data.domain.Pageable;
|
import org.springframework.http.HttpStatus;
|
import org.springframework.http.ResponseEntity;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.validation.annotation.Validated;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.servlet.http.HttpServletResponse;
|
import java.io.IOException;
|
|
/**
|
* @website https://eladmin.vip
|
* @author weicd
|
* @date 2023-11-24
|
**/
|
@RestController
|
@RequiredArgsConstructor
|
@Api(tags = "考勤加班管理")
|
@RequestMapping("/api/attendanceOvertime")
|
public class AttendanceOvertimeController {
|
|
private final AttendanceOvertimeService attendanceOvertimeService;
|
|
@Log("导出数据")
|
@ApiOperation("导出数据")
|
@GetMapping(value = "/download")
|
@PreAuthorize("@el.check('attendanceOvertime:list')")
|
public void exportAttendanceOvertime(HttpServletResponse response, AttendanceOvertimeQueryCriteria criteria) throws IOException {
|
attendanceOvertimeService.download(attendanceOvertimeService.queryAll(criteria), response);
|
}
|
|
@GetMapping
|
@Log("查询考勤加班")
|
@ApiOperation("查询考勤加班")
|
@PreAuthorize("@el.check('attendanceOvertime:list')")
|
public ResponseEntity<Object> queryAttendanceOvertime(AttendanceOvertimeQueryCriteria criteria, Pageable pageable){
|
return new ResponseEntity<>(attendanceOvertimeService.queryAll(criteria,pageable),HttpStatus.OK);
|
}
|
|
@PostMapping
|
@Log("新增考勤加班")
|
@ApiOperation("新增考勤加班")
|
@PreAuthorize("@el.check('attendanceOvertime:add')")
|
public ResponseEntity<Object> createAttendanceOvertime(@Validated @RequestBody AttendanceOvertime resources) throws Exception {
|
return new ResponseEntity<>(attendanceOvertimeService.create(resources),HttpStatus.CREATED);
|
}
|
|
@PutMapping
|
@Log("修改考勤加班")
|
@ApiOperation("修改考勤加班")
|
@PreAuthorize("@el.check('attendanceOvertime:edit')")
|
public ResponseEntity<Object> updateAttendanceOvertime(@Validated @RequestBody AttendanceOvertime resources){
|
attendanceOvertimeService.update(resources);
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
}
|
|
@DeleteMapping
|
@Log("删除考勤加班")
|
@ApiOperation("删除考勤加班")
|
@PreAuthorize("@el.check('attendanceOvertime:del')")
|
public ResponseEntity<Object> deleteAttendanceOvertime(@RequestBody Long[] ids) {
|
attendanceOvertimeService.deleteAll(ids);
|
return new ResponseEntity<>(HttpStatus.OK);
|
}
|
|
@PostMapping(value = "/calcTimeLength")
|
@Log("计算加班时长")
|
@ApiOperation("计算加班时长")
|
public ResponseEntity<Object> calcTimeLength(@RequestBody AttendanceOvertime resources) throws Exception {
|
return new ResponseEntity<>(attendanceOvertimeService.calcTimeLength(resources), HttpStatus.OK);
|
}
|
|
@PutMapping(value = "/approve")
|
@Log("审核功能")
|
@ApiOperation("审核功能")
|
@PreAuthorize("@el.check('attendanceOvertime:approve')")
|
public ResponseEntity<Object> checkApprove(@Validated @RequestBody AttendanceOvertime resources){
|
attendanceOvertimeService.updateApprove(resources);
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
}
|
}
|