赵士淞
2023-05-06 7af8a66fefff0c8ecf81b73c6c6baf9ded3f0c9f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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.service.AttendanceLeaveFlowableService;
import me.zhengjie.modules.attendance.service.dto.AttendanceLeaveDto;
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.*;
 
 
@RestController
@RequiredArgsConstructor
@Api(tags = "请假(Flowable)")
@RequestMapping("/api/attendanceLeaveFlowable")
public class AttendanceLeaveFlowableController {
 
    private final AttendanceLeaveFlowableService attendanceLeaveFlowableService;
 
    @GetMapping(value = "/report")
    @Log("查询我发起的请假(Flowable)")
    @ApiOperation("查询我发起的请假(Flowable)")
    @PreAuthorize("@el.check('attendanceLeaveFlowable:list')")
    public ResponseEntity<Object> reportAttendanceLeave() throws Exception {
        return new ResponseEntity<>(attendanceLeaveFlowableService.report(), HttpStatus.OK);
    }
 
    @GetMapping(value = "/approve")
    @Log("查询待审批的请假(Flowable)")
    @ApiOperation("查询待审批的请假(Flowable)")
    @PreAuthorize("@el.check('attendanceLeaveFlowable:list')")
    public ResponseEntity<Object> approveAttendanceLeave() throws Exception {
        return new ResponseEntity<>(attendanceLeaveFlowableService.approve(),HttpStatus.OK);
    }
 
    @PostMapping
    @Log("新增请假(Flowable)")
    @ApiOperation("新增请假(Flowable)")
    @PreAuthorize("@el.check('attendanceLeaveFlowable:add')")
    public ResponseEntity<Object> createAttendanceLeave(@Validated @RequestBody AttendanceLeaveDto resources) throws Exception {
        attendanceLeaveFlowableService.create(resources);
        return new ResponseEntity<>(HttpStatus.CREATED);
    }
 
    @PostMapping(value = "/agree")
    @Log("同意请假(Flowable)")
    @ApiOperation("同意请假(Flowable)")
    public ResponseEntity<Object> agreeAttendanceLeave(@RequestBody String processInstanceId) throws Exception {
        attendanceLeaveFlowableService.agree(processInstanceId);
        return new ResponseEntity<>(HttpStatus.OK);
    }
 
    @PostMapping(value = "/reject")
    @Log("拒绝请假(Flowable)")
    @ApiOperation("拒绝请假(Flowable)")
    public ResponseEntity<Object> rejectAttendanceLeave(@RequestBody String processInstanceId) throws Exception {
        attendanceLeaveFlowableService.reject(processInstanceId);
        return new ResponseEntity<>(HttpStatus.OK);
    }
}