You've already forked agentic-coding-workflow
feat(project): add workspace_id to issue/requirement with tri-state update
This commit is contained in:
@@ -65,16 +65,21 @@ func (s *requirementService) Create(ctx context.Context, c Caller, slug string,
|
||||
}
|
||||
in1 := &Requirement{
|
||||
ID: uuid.New(), ProjectID: p.ID,
|
||||
Title: in.Title, Description: in.Description,
|
||||
WorkspaceID: in.WorkspaceID,
|
||||
Title: in.Title, Description: in.Description,
|
||||
OwnerID: owner,
|
||||
}
|
||||
out, err := s.createWithRetry(ctx, in1)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.recordAudit(ctx, c, "requirement.create", out.ID.String(), map[string]any{
|
||||
meta := map[string]any{
|
||||
"project_id": p.ID.String(), "number": out.Number, "title": out.Title,
|
||||
})
|
||||
}
|
||||
if in.WorkspaceID != nil {
|
||||
meta["workspace_id"] = in.WorkspaceID.String()
|
||||
}
|
||||
s.recordAudit(ctx, c, "requirement.create", out.ID.String(), meta)
|
||||
return out, nil
|
||||
}
|
||||
|
||||
@@ -137,6 +142,27 @@ func (s *requirementService) Update(ctx context.Context, c Caller, slug string,
|
||||
r.OwnerID = *in.OwnerID
|
||||
changed["owner_id"] = in.OwnerID.String()
|
||||
}
|
||||
// workspace 三态:nil(未提供)/ &uuid.Nil(解绑)/ &id(关联)
|
||||
if in.WorkspaceID != nil {
|
||||
auditFrom := "<none>"
|
||||
if r.WorkspaceID != nil {
|
||||
auditFrom = r.WorkspaceID.String()
|
||||
}
|
||||
if *in.WorkspaceID == uuid.Nil {
|
||||
r.WorkspaceID = nil
|
||||
} else {
|
||||
v := *in.WorkspaceID
|
||||
r.WorkspaceID = &v
|
||||
}
|
||||
auditTo := "<none>"
|
||||
if r.WorkspaceID != nil {
|
||||
auditTo = r.WorkspaceID.String()
|
||||
}
|
||||
if auditFrom != auditTo {
|
||||
changed["from_workspace"] = auditFrom
|
||||
changed["to_workspace"] = auditTo
|
||||
}
|
||||
}
|
||||
if len(changed) == 0 {
|
||||
return r, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user