Files
xgy-oa/klp-hrm/src/main/java/com/klp/hrm/controller/HrmFlowTaskController.java
2025-12-30 13:47:53 +08:00

116 lines
4.6 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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<HrmFlowTaskVo> list(HrmFlowTaskBo bo, PageQuery pageQuery) {
return service.queryPageList(bo, pageQuery);
}
@GetMapping("/todo")
public R<List<HrmFlowTaskVo>> 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<HrmFlowTaskVo> 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<HrmFlowTaskVo> getInfo(@PathVariable @NotNull Long taskId) {
return R.ok(service.queryById(taskId));
}
@Log(title = "流程任务", businessType = BusinessType.INSERT)
@PostMapping
public R<Void> add(@Validated @RequestBody HrmFlowTaskBo bo) {
return toAjax(service.insertByBo(bo));
}
@Log(title = "流程任务", businessType = BusinessType.UPDATE)
@PutMapping
public R<Void> edit(@Validated @RequestBody HrmFlowTaskBo bo) {
return toAjax(service.updateByBo(bo));
}
@Log(title = "流程任务", businessType = BusinessType.DELETE)
@DeleteMapping("/{taskIds}")
public R<Void> remove(@PathVariable @NotEmpty Long[] taskIds) {
return toAjax(service.deleteWithValidByIds(Arrays.asList(taskIds), true));
}
@Log(title = "流程任务审批通过", businessType = BusinessType.UPDATE)
@PostMapping("/{taskId}/approve")
public R<Void> 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<Void> 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<Void> 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<Void> 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));
}
}