Interface TaskService

All Known Implementing Classes:
DefaultTaskService

public interface TaskService
Task-centric facade exposing the seven approval operations + todo / lookup. 任务侧门面 —— 暴露 7 个审批操作 + 待办 / 查询接口。

All (taskId, userId, ...) methods MUST perform the v4 §8.0.1 ownership pre-check before any business logic; implementations route through a single requireOwnedPendingTask helper. Reject reasons:

  • task not found → BASE-FLOW-TASK-001 (TASK_NOT_FOUND)
  • task not assigned to caller → BASE-FLOW-TASK-002
  • task already done / canceled → BASE-FLOW-TASK-003

所有 (taskId, userId, ...) 方法必须先做 v4 §8.0.1 的所有权前置校验。

Since:
JDK 25, opencode-base-flow V1.0.5
Author:
Leon Soo
  • Method Details

    • findTodo

      List<Task> findTodo(String userId, int page, int size)
      Paginated todo query (status = PENDING) for a user. size is capped at 200 (v4 D18). 分页查询用户待办(仅 PENDING)。size 硬上限 200。
      Parameters:
      userId - assignee user id — 承接人
      page - zero-based page — 页码(0 起)
      size - page size (≤ 200) — 每页大小(≤ 200)
      Returns:
      tasks on the requested page — 该页任务
      Since:
      JDK 25, opencode-base-flow V1.0.5
    • findTodo

      default List<Task> findTodo(String userId)
      Convenience: equivalent to findTodo(userId, 0, 50). 便利方法:等价于 findTodo(userId, 0, 50)。
      Parameters:
      userId - assignee user id — 承接人
      Returns:
      first page of todos — 首页待办
      Since:
      JDK 25, opencode-base-flow V1.0.5
    • get

      Task get(String taskId)
      Returns the task by id (or throws TASK_NOT_FOUND). 按 id 返回任务(不存在抛 TASK_NOT_FOUND)。
      Parameters:
      taskId - task id — 任务 ID
      Returns:
      task — 任务
      Since:
      JDK 25, opencode-base-flow V1.0.5
    • approve

      void approve(String taskId, String userId, String comment)
      Approve action. 同意。
      Parameters:
      taskId - task id — 任务 ID
      userId - caller user id — 调用者
      comment - comment (nullable) — 文本意见(可空)
      Since:
      JDK 25, opencode-base-flow V1.0.5
    • vote

      void vote(String taskId, String userId, VoteOpinion opinion, String comment)
      Vote action (records vote and marks task DONE). 投票(记录投票并把 task 置为 DONE)。
      Parameters:
      taskId - task id — 任务 ID
      userId - caller user id — 调用者
      opinion - vote opinion — 投票意见
      comment - comment (nullable) — 文本意见(可空)
      Since:
      JDK 25, opencode-base-flow V1.0.5
    • reject

      void reject(String taskId, String userId, String targetStepId, String comment)
      Reject action. 驳回。
      Parameters:
      taskId - task id — 任务 ID
      userId - caller user id — 调用者
      targetStepId - null = previous; "_INITIATOR_" = to-initiator; otherwise a visited step id — null 上一级;"_INITIATOR_" 起草点; 否则指定步骤 id
      comment - comment (nullable) — 文本意见
      Since:
      JDK 25, opencode-base-flow V1.0.5
    • addSign

      void addSign(String taskId, String userId, List<String> additionalUserIds, String comment)
      Add-sign action. Only USER ids accepted (no role / dept). 后加签。仅接受 userId 列表。
      Parameters:
      taskId - task id — 任务 ID
      userId - caller user id — 调用者
      additionalUserIds - extra user ids — 新增加签人
      comment - comment (nullable) — 文本意见
      Since:
      JDK 25, opencode-base-flow V1.0.5
    • withdraw

      void withdraw(String instanceId, String initiatorId, String reason)
      Withdraw the running instance (initiator only). 撤回运行中的实例(仅发起人)。
      Parameters:
      instanceId - instance id — 实例 ID
      initiatorId - initiator user id — 发起人
      reason - reason (nullable) — 理由
      Since:
      JDK 25, opencode-base-flow V1.0.5
    • transfer

      void transfer(String taskId, String fromUserId, String toUserId, String reason)
      Transfer the current task to another user. 转办给他人。
      Parameters:
      taskId - task id — 任务 ID
      fromUserId - caller user id — 调用者
      toUserId - target user id — 目标 userId
      reason - reason (nullable) — 理由
      Since:
      JDK 25, opencode-base-flow V1.0.5
    • circulate

      void circulate(String taskId, String fromUserId, List<String> toUserIds, String comment)
      Circulate (read-only notification) to additional users. 抄送(仅通知)。
      Parameters:
      taskId - task id — 任务 ID
      fromUserId - caller user id — 调用者
      toUserIds - notify these users — 被抄送 userId 列表
      comment - comment (nullable) — 文本意见
      Since:
      JDK 25, opencode-base-flow V1.0.5