feat: 新增工作流相关接口 by tcsp · Pull Request #124 · coze-dev/coze-java

Walkthrough

Adds workflow listing and retrieval: new Retrofit WorkflowAPI, request/response DTOs and models, integrates WorkflowAPI into WorkflowService and CozeAPI builder, bumps artifact to 0.4.3, and adds unit tests for WorkflowService list/get.

Changes

Cohort / File(s) Summary
Version bump
api/pom.xml
Update artifact version from 0.4.2 to 0.4.3.
Workflow Retrofit API
api/src/main/java/com/coze/openapi/api/WorkflowAPI.java
New Retrofit interface exposing GET /v1/workflows (list) and GET /v1/workflows/{workflow_id} (get).
Workflow requests
api/src/main/java/com/coze/openapi/client/workflows/WorkflowListReq.java, api/src/main/java/com/coze/openapi/client/workflows/WorkflowGetReq.java
New request DTOs extending BaseReq with Jackson mappings and Lombok builders/constructors.
Workflow responses
api/src/main/java/com/coze/openapi/client/workflows/WorkflowListResp.java, api/src/main/java/com/coze/openapi/client/workflows/WorkflowGetResp.java
New response DTOs for list/get with Jackson mappings and Lombok-generated boilerplate.
Workflow models
api/src/main/java/com/coze/openapi/client/workflows/model/WorkflowDetail.java, .../WorkflowCreator.java, .../WorkflowInput.java, .../WorkflowOutput.java, .../WorkflowParameter.java
New model classes for workflow detail, creator, input/output schemas, and parameter metadata.
Service wiring
api/src/main/java/com/coze/openapi/service/service/CozeAPI.java, api/src/main/java/com/coze/openapi/service/service/workflow/WorkflowService.java
CozeAPI.Builder.build now creates WorkflowAPI; WorkflowService constructor updated to accept WorkflowAPI and adds list and get methods delegating to Retrofit calls.
Unit tests
api/src/test/java/com/coze/openapi/service/service/workflow/WorkFlowServiceTest.java
New tests mocking WorkflowAPI calls and asserting WorkflowService.list and WorkflowService.get behaviors.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Client
  participant WorkflowService
  participant WorkflowAPI as Retrofit:WorkflowAPI
  participant Server as HTTP

  Client->>WorkflowService: list(WorkflowListReq)
  WorkflowService->>WorkflowAPI: list(workspace_id, page_num, page_size, workflow_mode, app_id, publish_status, BaseReq)
  WorkflowAPI->>Server: GET /v1/workflows?...
  Server-->>WorkflowAPI: 200 BaseResponse<WorkflowListResp>
  WorkflowAPI-->>WorkflowService: Response<BaseResponse<...>>
  WorkflowService-->>Client: BaseResponse<WorkflowListResp>

  alt get workflow
    Client->>WorkflowService: get(WorkflowGetReq)
    WorkflowService->>WorkflowAPI: get(workflow_id, include_input_output, BaseReq)
    WorkflowAPI->>Server: GET /v1/workflows/{workflow_id}?include_input_output=...
    Server-->>WorkflowAPI: 200 BaseResponse<WorkflowGetResp>
    WorkflowAPI-->>WorkflowService: Response<BaseResponse<...>>
    WorkflowService-->>Client: BaseResponse<WorkflowGetResp>
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

feature

Poem

I hop through code with eager paws,
New endpoints stitched in tidy laws.
List and get now dance in place,
Retrofit hums a steady pace.
Tests applaud — I thump with glee! 🐇✨


📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 07773e9 and 39ef33a.

📒 Files selected for processing (1)
  • api/src/test/java/com/coze/openapi/service/service/workflow/WorkFlowServiceTest.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • api/src/test/java/com/coze/openapi/service/service/workflow/WorkFlowServiceTest.java
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: test (Java 17 on Windows)
  • GitHub Check: test (Java 11 on macOS)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.