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.*; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @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 reportAttendanceLeave() throws Exception { return new ResponseEntity<>(attendanceLeaveFlowableService.report(), HttpStatus.OK); } @GetMapping(value = "/approve") @Log("查询待审批的请假(Flowable)") @ApiOperation("查询待审批的请假(Flowable)") @PreAuthorize("@el.check('attendanceLeaveFlowable:list')") public ResponseEntity approveAttendanceLeave() throws Exception { return new ResponseEntity<>(attendanceLeaveFlowableService.approve(),HttpStatus.OK); } @PostMapping @Log("新增请假(Flowable)") @ApiOperation("新增请假(Flowable)") @PreAuthorize("@el.check('attendanceLeaveFlowable:add')") public ResponseEntity createAttendanceLeave(@Validated @RequestBody AttendanceLeaveDto resources) throws Exception { attendanceLeaveFlowableService.create(resources); return new ResponseEntity<>(HttpStatus.CREATED); } @PostMapping(value = "/agree") @Log("同意请假(Flowable)") @ApiOperation("同意请假(Flowable)") public ResponseEntity agreeAttendanceLeave(@RequestBody String processInstanceId) throws Exception { attendanceLeaveFlowableService.agree(processInstanceId); return new ResponseEntity<>(HttpStatus.OK); } @PostMapping(value = "/reject") @Log("拒绝请假(Flowable)") @ApiOperation("拒绝请假(Flowable)") public ResponseEntity rejectAttendanceLeave(@RequestBody String processInstanceId) throws Exception { attendanceLeaveFlowableService.reject(processInstanceId); return new ResponseEntity<>(HttpStatus.OK); } @GetMapping(value = "/processDiagram") @Log("查询请假流程图(Flowable)") @ApiOperation("查询请假流程图(Flowable)") @PreAuthorize("@el.check('attendanceLeaveFlowable:list')") public void processDiagramAttendanceLeave(HttpServletRequest request, HttpServletResponse response, @RequestParam String processInstanceId) throws Exception { attendanceLeaveFlowableService.processDiagram(request, response, processInstanceId); } }