package com.klp.hrm.controller; import com.klp.common.annotation.Log; import com.klp.common.core.controller.BaseController; import com.klp.common.core.domain.PageQuery; import com.klp.common.core.domain.R; import com.klp.common.core.page.TableDataInfo; import com.klp.common.enums.BusinessType; import com.klp.hrm.domain.bo.HrmFlowTaskBo; import com.klp.hrm.domain.bo.HrmFlowTaskApproveBo; import com.klp.hrm.domain.bo.HrmSealStampBo; import com.klp.hrm.domain.vo.HrmFlowTaskVo; import com.klp.hrm.service.IHrmFlowTaskService; import lombok.RequiredArgsConstructor; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import java.util.Arrays; import java.util.List; @Validated @RequiredArgsConstructor @RestController @RequestMapping("/hrm/flow/task") public class HrmFlowTaskController extends BaseController { private final IHrmFlowTaskService service; @GetMapping("/list") public TableDataInfo list(HrmFlowTaskBo bo, PageQuery pageQuery) { return service.queryPageList(bo, pageQuery); } @GetMapping("/todo") public R> todo(@RequestParam(required = false) Long assigneeUserId) { HrmFlowTaskBo bo = new HrmFlowTaskBo(); bo.setAssigneeUserId(assigneeUserId); bo.setStatus("pending"); return R.ok(service.queryList(bo)); } /** * 详情页使用:按 bizType + bizId 查询当前用户的待办任务(pending) */ @GetMapping("/todoByBiz") public R todoByBiz(@RequestParam @NotNull String bizType, @RequestParam @NotNull Long bizId, @RequestParam(required = false) Long assigneeUserId) { return R.ok(service.queryTodoByBiz(bizType, bizId, assigneeUserId)); } @GetMapping("/{taskId}") public R getInfo(@PathVariable @NotNull Long taskId) { return R.ok(service.queryById(taskId)); } @Log(title = "流程任务", businessType = BusinessType.INSERT) @PostMapping public R add(@Validated @RequestBody HrmFlowTaskBo bo) { return toAjax(service.insertByBo(bo)); } @Log(title = "流程任务", businessType = BusinessType.UPDATE) @PutMapping public R edit(@Validated @RequestBody HrmFlowTaskBo bo) { return toAjax(service.updateByBo(bo)); } @Log(title = "流程任务", businessType = BusinessType.DELETE) @DeleteMapping("/{taskIds}") public R remove(@PathVariable @NotEmpty Long[] taskIds) { return toAjax(service.deleteWithValidByIds(Arrays.asList(taskIds), true)); } @Log(title = "流程任务审批通过", businessType = BusinessType.UPDATE) @PostMapping("/{taskId}/approve") public R approve(@PathVariable @NotNull Long taskId, @RequestParam(required = false) Long actionUserId, @RequestBody(required = false) HrmFlowTaskApproveBo approveBo) { String remark = approveBo != null ? approveBo.getRemark() : null; HrmSealStampBo stampBo = approveBo != null ? approveBo.getStampBo() : null; return toAjax(service.approve(taskId, actionUserId, remark, stampBo)); } @Log(title = "流程任务审批驳回", businessType = BusinessType.UPDATE) @PostMapping("/{taskId}/reject") public R reject(@PathVariable @NotNull Long taskId, @RequestParam(required = false) Long actionUserId, @RequestParam(required = false) String remark) { return toAjax(service.reject(taskId, actionUserId, remark)); } @Log(title = "流程任务撤回", businessType = BusinessType.UPDATE) @PostMapping("/{taskId}/withdraw") public R withdraw(@PathVariable @NotNull Long taskId, @RequestParam(required = false) Long actionUserId, @RequestParam(required = false) String remark) { return toAjax(service.withdraw(taskId, actionUserId, remark)); } @Log(title = "流程任务转发", businessType = BusinessType.UPDATE) @PostMapping("/{taskId}/transfer") public R transfer(@PathVariable @NotNull Long taskId, @RequestParam @NotNull Long newAssigneeUserId, @RequestParam(required = false) Long actionUserId, @RequestParam(required = false) String remark) { return toAjax(service.transfer(taskId, newAssigneeUserId, actionUserId, remark)); } }