主流程

This commit is contained in:
2026-06-10 17:53:09 +08:00
parent c6f239f424
commit b20435c027
66 changed files with 2779 additions and 1181 deletions
+10 -6
View File
@@ -31,8 +31,9 @@ type Repository interface {
// Session
InsertSession(ctx context.Context, s *Session) (*Session, error)
GetSessionByID(ctx context.Context, id uuid.UUID) (*Session, error)
ListSessionsByUser(ctx context.Context, userID uuid.UUID) ([]*Session, error)
ListAllSessions(ctx context.Context) ([]*Session, error)
// requirementID 非 nil 时仅返回关联该需求的 sessions。
ListSessionsByUser(ctx context.Context, userID uuid.UUID, requirementID *uuid.UUID) ([]*Session, error)
ListAllSessions(ctx context.Context, requirementID *uuid.UUID) ([]*Session, error)
UpdateSessionRunning(ctx context.Context, id uuid.UUID, agentSessionID string, pid int32) error
UpdateSessionFinished(ctx context.Context, id uuid.UUID, status SessionStatus, exitCode *int32, lastErr *string) error
CountActiveSessions(ctx context.Context) (int64, error)
@@ -288,8 +289,11 @@ func (r *pgRepo) GetSessionByID(ctx context.Context, id uuid.UUID) (*Session, er
return rowToSession(row), nil
}
func (r *pgRepo) ListSessionsByUser(ctx context.Context, userID uuid.UUID) ([]*Session, error) {
rows, err := r.q.ListSessionsByUser(ctx, toPgUUID(userID))
func (r *pgRepo) ListSessionsByUser(ctx context.Context, userID uuid.UUID, requirementID *uuid.UUID) ([]*Session, error) {
rows, err := r.q.ListSessionsByUser(ctx, acpsqlc.ListSessionsByUserParams{
UserID: toPgUUID(userID),
Column2: toPgUUIDPtr(requirementID),
})
if err != nil {
return nil, errs.Wrap(err, errs.CodeInternal, "list sessions by user")
}
@@ -300,8 +304,8 @@ func (r *pgRepo) ListSessionsByUser(ctx context.Context, userID uuid.UUID) ([]*S
return out, nil
}
func (r *pgRepo) ListAllSessions(ctx context.Context) ([]*Session, error) {
rows, err := r.q.ListAllSessions(ctx)
func (r *pgRepo) ListAllSessions(ctx context.Context, requirementID *uuid.UUID) ([]*Session, error) {
rows, err := r.q.ListAllSessions(ctx, toPgUUIDPtr(requirementID))
if err != nil {
return nil, errs.Wrap(err, errs.CodeInternal, "list all sessions")
}