Defer locked-period supplements to a pending ledger, route duty-holder notifications, persist stage-scoped comments, and prefer Approver for reopen.
59 lines
2.0 KiB
Go
59 lines
2.0 KiB
Go
package server
|
|
|
|
import (
|
|
"chat-agent-system/internal/supplementimpact"
|
|
"context"
|
|
)
|
|
|
|
type supplementImpactAdapter struct {
|
|
svc *supplementimpact.Service
|
|
}
|
|
|
|
func newSupplementImpactAdapter(svc *supplementimpact.Service) SupplementImpactService {
|
|
if svc == nil {
|
|
return nil
|
|
}
|
|
return supplementImpactAdapter{svc: svc}
|
|
}
|
|
|
|
func (a supplementImpactAdapter) GetBatch(ctx context.Context, batchID string) (*SupplementImpactBatchView, error) {
|
|
b, err := a.svc.GetBatch(ctx, batchID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return mapSupplementBatch(b), nil
|
|
}
|
|
|
|
func (a supplementImpactAdapter) Decide(ctx context.Context, batchID string, actorUserID int64, in SupplementImpactDecisionRequest) (*SupplementImpactBatchView, error) {
|
|
b, err := a.svc.Decide(ctx, supplementimpact.DecisionCommand{
|
|
BatchID: batchID, ActorUserID: actorUserID, Kind: in.Kind,
|
|
SelectedDocIDs: in.SelectedDocIDs, DecisionNonce: in.DecisionNonce,
|
|
DecisionDigest: in.DecisionDigest, ExpectedRevision: in.ExpectedRevision,
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return mapSupplementBatch(b), nil
|
|
}
|
|
|
|
func mapSupplementBatch(b *supplementimpact.Batch) *SupplementImpactBatchView {
|
|
if b == nil {
|
|
return nil
|
|
}
|
|
out := &SupplementImpactBatchView{
|
|
BatchID: b.BatchID, ProjectID: b.ProjectID, SessionID: b.SessionID,
|
|
InitiatorUserID: b.InitiatorUserID, SourceKind: b.SourceKind, SourceSummary: b.SourceSummary,
|
|
CoverageStatus: b.CoverageStatus, Status: b.Status, DecisionNonce: b.DecisionNonce,
|
|
DecisionDigest: b.DecisionDigest, Revision: b.Revision, ExpiresAt: b.ExpiresAt,
|
|
}
|
|
for _, it := range b.Items {
|
|
out.Items = append(out.Items, SupplementImpactItemView{
|
|
DocID: it.DocID, Title: it.Title, ItemKey: it.ItemKey, ImpactType: it.ImpactType,
|
|
Depth: it.Depth, Reason: it.Reason, AuthorClaimedSnapshot: it.AuthorClaimedSnapshot,
|
|
BusySnapshot: it.BusySnapshot, LockedSnapshot: it.LockedSnapshot, ChangeSummary: it.ChangeSummary,
|
|
Selected: it.Selected, Outcome: it.Outcome, ProposalID: it.ProposalID,
|
|
})
|
|
}
|
|
return out
|
|
}
|