| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- package com.qqflow.engine.domain.flow.controller;
- import com.qqflow.engine.common.PageResult;
- import com.qqflow.engine.common.Result;
- import com.qqflow.engine.common.exception.BusinessException;
- import com.qqflow.engine.common.util.SecurityUtils;
- import com.qqflow.engine.config.security.LoginUser;
- import com.qqflow.engine.domain.flow.dto.ApprovalRecordDTO;
- import com.qqflow.engine.domain.flow.dto.ApprovalTaskDTO;
- import com.qqflow.engine.domain.flow.dto.ApproveTaskDTO;
- import com.qqflow.engine.domain.flow.dto.BatchTaskDTO;
- import com.qqflow.engine.domain.flow.dto.NextNodeDTO;
- import com.qqflow.engine.domain.flow.dto.TransferTaskDTO;
- import com.qqflow.engine.domain.flow.service.ApprovalTaskService;
- import com.qqflow.engine.domain.system.dto.UserDTO;
- import io.swagger.v3.oas.annotations.Operation;
- import io.swagger.v3.oas.annotations.tags.Tag;
- import jakarta.validation.Valid;
- import lombok.RequiredArgsConstructor;
- import org.springframework.web.bind.annotation.GetMapping;
- import org.springframework.web.bind.annotation.PathVariable;
- import org.springframework.web.bind.annotation.PostMapping;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestParam;
- import org.springframework.web.bind.annotation.RestController;
- import java.util.List;
- @RestController
- @RequestMapping("/flow/task")
- @RequiredArgsConstructor
- @Tag(name = "审批任务管理")
- public class ApprovalTaskController {
- private final ApprovalTaskService approvalTaskService;
- @GetMapping("/todo")
- @Operation(summary = "我的待办列表")
- public Result<PageResult<ApprovalTaskDTO>> todoList(
- @RequestParam(defaultValue = "1") Integer pageNum,
- @RequestParam(defaultValue = "10") Integer pageSize,
- @RequestParam(required = false) String processName,
- @RequestParam(required = false) String formFilters) {
- Long assigneeId = SecurityUtils.getUserId();
- String assigneeType = requireLoginUser().getUserType();
- return Result.ok(this.approvalTaskService.todoList(assigneeId, assigneeType, processName, formFilters, pageNum, pageSize));
- }
- @GetMapping("/handled")
- @Operation(summary = "我的已办列表")
- public Result<PageResult<ApprovalTaskDTO>> handledList(
- @RequestParam(defaultValue = "1") Integer pageNum,
- @RequestParam(defaultValue = "10") Integer pageSize,
- @RequestParam(required = false) String processName) {
- Long assigneeId = SecurityUtils.getUserId();
- String assigneeType = requireLoginUser().getUserType();
- return Result.ok(this.approvalTaskService.handledList(assigneeId, assigneeType, processName, pageNum, pageSize));
- }
- @GetMapping("/{taskId}/next-nodes")
- @Operation(summary = "获取当前任务的下游节点列表(条件节点选分支用)")
- public Result<List<NextNodeDTO>> nextNodes(@PathVariable Long taskId) {
- return Result.ok(this.approvalTaskService.getNextNodes(taskId));
- }
- @PostMapping("/{taskId}/approve")
- @Operation(summary = "审批通过")
- public Result<Void> approve(@PathVariable Long taskId, @RequestBody @Valid ApproveTaskDTO dto) {
- dto.setTaskId(taskId);
- this.approvalTaskService.approve(dto);
- return Result.ok();
- }
- @PostMapping("/{taskId}/reject")
- @Operation(summary = "审批拒绝")
- public Result<Void> reject(@PathVariable Long taskId, @RequestBody @Valid ApproveTaskDTO dto) {
- dto.setTaskId(taskId);
- this.approvalTaskService.reject(dto);
- return Result.ok();
- }
- @PostMapping("/batch-approve")
- @Operation(summary = "批量审批通过")
- public Result<Void> batchApprove(@RequestBody @Valid BatchTaskDTO dto) {
- this.approvalTaskService.batchApprove(dto);
- return Result.ok();
- }
- @PostMapping("/batch-reject")
- @Operation(summary = "批量审批拒绝")
- public Result<Void> batchReject(@RequestBody @Valid BatchTaskDTO dto) {
- this.approvalTaskService.batchReject(dto);
- return Result.ok();
- }
- @PostMapping("/{taskId}/return")
- @Operation(summary = "审批回退")
- public Result<Void> returnTask(@PathVariable Long taskId, @RequestBody @Valid ApproveTaskDTO dto) {
- dto.setTaskId(taskId);
- this.approvalTaskService.returnTask(dto);
- return Result.ok();
- }
- @PostMapping("/{taskId}/transfer")
- @Operation(summary = "任务转办")
- public Result<Void> transfer(@PathVariable Long taskId, @RequestBody @Valid TransferTaskDTO dto) {
- dto.setTaskId(taskId);
- this.approvalTaskService.transfer(dto);
- return Result.ok();
- }
- @PostMapping("/{taskId}/add-sign")
- @Operation(summary = "任务加签")
- public Result<Void> addSign(@PathVariable Long taskId, @RequestParam Long assigneeId) {
- this.approvalTaskService.addSign(taskId, assigneeId);
- return Result.ok();
- }
- @GetMapping("/history/{instanceId}")
- @Operation(summary = "审批历史记录")
- public Result<List<ApprovalRecordDTO>> history(@PathVariable Long instanceId) {
- return Result.ok(this.approvalTaskService.history(instanceId));
- }
- @GetMapping("/todo-count")
- @Operation(summary = "我的待办任务数")
- public Result<Long> todoCount() {
- Long assigneeId = SecurityUtils.getUserId();
- String assigneeType = requireLoginUser().getUserType();
- return Result.ok(this.approvalTaskService.todoCount(assigneeId, assigneeType));
- }
- @GetMapping("/cc")
- @Operation(summary = "我的抄送列表")
- public Result<PageResult<ApprovalTaskDTO>> ccList(
- @RequestParam(defaultValue = "1") Integer pageNum,
- @RequestParam(defaultValue = "10") Integer pageSize,
- @RequestParam(required = false) String processName) {
- Long assigneeId = SecurityUtils.getUserId();
- String assigneeType = requireLoginUser().getUserType();
- return Result.ok(this.approvalTaskService.ccList(assigneeId, assigneeType, processName, pageNum, pageSize));
- }
- @PostMapping("/cc/{taskId}/read")
- @Operation(summary = "标记抄送已读")
- public Result<Void> readCc(@PathVariable Long taskId) {
- this.approvalTaskService.readCc(taskId);
- return Result.ok();
- }
- @GetMapping("/{taskId}/transferable-users")
- @Operation(summary = "获取可转办/加签的用户列表")
- public Result<List<UserDTO>> transferableUsers(@PathVariable Long taskId) {
- return Result.ok(this.approvalTaskService.getTransferableUsers(taskId));
- }
- private LoginUser requireLoginUser() {
- LoginUser loginUser = SecurityUtils.getLoginUser();
- if (loginUser == null) {
- throw new BusinessException("未登录");
- }
- return loginUser;
- }
- }
|