Evaluate required document approvals before stage transition, expose readiness/advance APIs, show StageAdvanceBanner in the UI, and keep legacy workflow switch for explicit initial_workflow_key projects. Co-authored-by: Cursor <cursoragent@cursor.com>
37 lines
921 B
Go
37 lines
921 B
Go
package projectinstance
|
|
|
|
import (
|
|
"context"
|
|
|
|
"chat-agent-system/internal/docgov"
|
|
)
|
|
|
|
// DocumentReadinessChecker 查询项目文档批准状态。
|
|
type DocumentReadinessChecker interface {
|
|
TaskApprovalStates(ctx context.Context, projectID int64) (map[string]string, error)
|
|
}
|
|
|
|
// DocGovChecker 基于 docgov 的就绪检查。
|
|
type DocGovChecker struct {
|
|
engine *docgov.GovernanceEngine
|
|
}
|
|
|
|
func NewDocGovChecker(engine *docgov.GovernanceEngine) *DocGovChecker {
|
|
return &DocGovChecker{engine: engine}
|
|
}
|
|
|
|
func (c *DocGovChecker) TaskApprovalStates(ctx context.Context, projectID int64) (map[string]string, error) {
|
|
out := make(map[string]string)
|
|
if c == nil || c.engine == nil || projectID <= 0 {
|
|
return out, nil
|
|
}
|
|
docs, err := c.engine.ListWorkflowDocumentsByProject(ctx, projectID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
for _, d := range docs {
|
|
out[d.TaskKey] = string(d.LifecycleState)
|
|
}
|
|
return out, nil
|
|
}
|