mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-02-04 07:43:28 +08:00
feat: 修改代码补全采纳逻辑
This commit is contained in:
@@ -28,6 +28,7 @@ type ProxyUsecase interface {
|
||||
type ProxyRepo interface {
|
||||
Record(ctx context.Context, record *RecordParam) error
|
||||
UpdateByTaskID(ctx context.Context, taskID string, fn func(*db.TaskUpdateOne)) error
|
||||
AcceptCompletion(ctx context.Context, req *AcceptCompletionReq) error
|
||||
SelectModelWithLoadBalancing(modelName string, modelType consts.ModelType) (*db.Model, error)
|
||||
ValidateApiKey(ctx context.Context, key string) (*db.ApiKey, error)
|
||||
}
|
||||
|
||||
@@ -133,3 +133,23 @@ func (r *ProxyRepo) UpdateByTaskID(ctx context.Context, taskID string, fn func(*
|
||||
return up.Exec(ctx)
|
||||
})
|
||||
}
|
||||
|
||||
func (r *ProxyRepo) AcceptCompletion(ctx context.Context, req *domain.AcceptCompletionReq) error {
|
||||
return entx.WithTx(ctx, r.db, func(tx *db.Tx) error {
|
||||
rc, err := tx.Task.Query().Where(task.TaskID(req.ID)).Only(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := tx.Task.UpdateOneID(rc.ID).
|
||||
SetIsAccept(true).
|
||||
SetCompletion(req.Completion).
|
||||
Exec(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return tx.TaskRecord.Update().
|
||||
Where(taskrecord.TaskID(rc.ID)).
|
||||
SetCompletion(req.Completion).Exec(ctx)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"github.com/chaitin/MonkeyCode/backend/pkg/cvt"
|
||||
|
||||
"github.com/chaitin/MonkeyCode/backend/consts"
|
||||
"github.com/chaitin/MonkeyCode/backend/db"
|
||||
"github.com/chaitin/MonkeyCode/backend/domain"
|
||||
)
|
||||
|
||||
@@ -40,8 +39,5 @@ func (p *ProxyUsecase) ValidateApiKey(ctx context.Context, key string) (*domain.
|
||||
}
|
||||
|
||||
func (p *ProxyUsecase) AcceptCompletion(ctx context.Context, req *domain.AcceptCompletionReq) error {
|
||||
return p.repo.UpdateByTaskID(ctx, req.ID, func(ruo *db.TaskUpdateOne) {
|
||||
ruo.SetIsAccept(true)
|
||||
ruo.SetCompletion(req.Completion)
|
||||
})
|
||||
return p.repo.AcceptCompletion(ctx, req)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user