fix(agent): disallow update if prompt is empty (#1802)

This commit is contained in:
Ryo 2025-08-25 20:22:45 +08:00 committed by GitHub
parent 14ce6bc112
commit f19761fa31
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 19 additions and 5 deletions

View File

@ -102,6 +102,18 @@ func (sa *SingleAgentDraftDAO) MGet(ctx context.Context, agentIDs []int64) ([]*e
return dos, nil
}
func (sa *SingleAgentDraftDAO) Save(ctx context.Context, agentInfo *entity.SingleAgent) (err error) {
po := sa.singleAgentDraftDo2Po(agentInfo)
singleAgentDAOModel := sa.dbQuery.SingleAgentDraft
err = singleAgentDAOModel.WithContext(ctx).Where(singleAgentDAOModel.AgentID.Eq(agentInfo.AgentID)).Save(po)
if err != nil {
return errorx.WrapByCode(err, errno.ErrAgentUpdateCode)
}
return nil
}
func (sa *SingleAgentDraftDAO) Update(ctx context.Context, agentInfo *entity.SingleAgent) (err error) {
po := sa.singleAgentDraftDo2Po(agentInfo)
singleAgentDAOModel := sa.dbQuery.SingleAgentDraft

View File

@ -46,6 +46,7 @@ type SingleAgentDraftRepo interface {
MGet(ctx context.Context, agentIDs []int64) ([]*entity.SingleAgent, error)
Delete(ctx context.Context, spaceID, agentID int64) (err error)
Update(ctx context.Context, agentInfo *entity.SingleAgent) (err error)
Save(ctx context.Context, agentInfo *entity.SingleAgent) (err error)
GetDisplayInfo(ctx context.Context, userID, agentID int64) (*entity.AgentDraftDisplayInfo, error)
UpdateDisplayInfo(ctx context.Context, userID int64, e *entity.AgentDraftDisplayInfo) error

View File

@ -153,7 +153,7 @@ func (s *singleAgentImpl) UpdateSingleAgentDraft(ctx context.Context, agentInfo
}
}
return s.AgentDraftRepo.Update(ctx, agentInfo)
return s.AgentDraftRepo.Save(ctx, agentInfo)
}
func (s *singleAgentImpl) CreateSingleAgentDraftWithID(ctx context.Context, creatorID, agentID int64, draft *entity.SingleAgent) (int64, error) {

View File

@ -24,6 +24,11 @@ import (
"testing"
"github.com/cloudwego/eino/schema"
"github.com/stretchr/testify/assert"
"go.uber.org/mock/gomock"
"gorm.io/driver/mysql"
"gorm.io/gorm"
"github.com/coze-dev/coze-studio/backend/domain/knowledge/entity"
"github.com/coze-dev/coze-studio/backend/domain/knowledge/internal/dal/model"
"github.com/coze-dev/coze-studio/backend/domain/knowledge/repository"
@ -35,10 +40,6 @@ import (
mock_db "github.com/coze-dev/coze-studio/backend/internal/mock/infra/contract/rdb"
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
"github.com/coze-dev/coze-studio/backend/pkg/lang/sets"
"github.com/stretchr/testify/assert"
"go.uber.org/mock/gomock"
"gorm.io/driver/mysql"
"gorm.io/gorm"
)
func TestAddSliceIdColumn(t *testing.T) {