refactor(workflow): Move the database component in the Workflow package into the common crossdomain package (#704)

This commit is contained in:
Ryo
2025-08-12 15:42:58 +08:00
committed by GitHub
parent e7011f2549
commit 9ff065cebd
29 changed files with 834 additions and 1353 deletions

View File

@@ -59,7 +59,10 @@ import (
appplugin "github.com/coze-dev/coze-studio/backend/application/plugin"
"github.com/coze-dev/coze-studio/backend/application/user"
appworkflow "github.com/coze-dev/coze-studio/backend/application/workflow"
crossdatabase "github.com/coze-dev/coze-studio/backend/crossdomain/contract/database"
"github.com/coze-dev/coze-studio/backend/crossdomain/contract/database/databasemock"
crossuser "github.com/coze-dev/coze-studio/backend/crossdomain/contract/user"
"github.com/coze-dev/coze-studio/backend/crossdomain/impl/code"
plugin3 "github.com/coze-dev/coze-studio/backend/crossdomain/workflow/plugin"
entity4 "github.com/coze-dev/coze-studio/backend/domain/memory/database/entity"
entity2 "github.com/coze-dev/coze-studio/backend/domain/openauth/openapiauth/entity"
@@ -67,9 +70,6 @@ import (
entity5 "github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
userentity "github.com/coze-dev/coze-studio/backend/domain/user/entity"
workflow2 "github.com/coze-dev/coze-studio/backend/domain/workflow"
"github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/code"
"github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/database"
"github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/database/databasemock"
"github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/knowledge"
"github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/knowledge/knowledgemock"
"github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/model"
@@ -122,7 +122,7 @@ type wfTestRunner struct {
plugin *mockPlugin.MockPluginService
tos *storageMock.MockStorage
knowledge *knowledgemock.MockKnowledgeOperator
database *databasemock.MockDatabaseOperator
database *databasemock.MockDatabase
pluginSrv *pluginmock.MockService
internalModel *testutil.UTChatModel
ctx context.Context
@@ -291,8 +291,8 @@ func newWfTestRunner(t *testing.T) *wfTestRunner {
m4 := mockey.Mock(ctxutil.MustGetUIDFromCtx).Return(int64(1)).Build()
m5 := mockey.Mock(ctxutil.GetUIDFromCtx).Return(ptr.Of(int64(1))).Build()
mockDatabaseOperator := databasemock.NewMockDatabaseOperator(ctrl)
database.SetDatabaseOperator(mockDatabaseOperator)
mockDatabaseOperator := databasemock.NewMockDatabase(ctrl)
crossdatabase.SetDefaultSVC(mockDatabaseOperator)
mockPluginSrv := pluginmock.NewMockService(ctrl)
plugin.SetPluginService(mockPluginSrv)

View File

@@ -204,3 +204,110 @@ type GetAllDatabaseByAppIDRequest struct {
type GetAllDatabaseByAppIDResponse struct {
Databases []*Database // online databases
}
type SQLParam struct {
Value string
IsNull bool
}
type CustomSQLRequest struct {
DatabaseInfoID int64
SQL string
Params []SQLParam
IsDebugRun bool
UserID string
ConnectorID int64
}
type Object = map[string]any
type Response struct {
RowNumber *int64
Objects []Object
}
type Operator string
type ClauseRelation string
const (
ClauseRelationAND ClauseRelation = "and"
ClauseRelationOR ClauseRelation = "or"
)
const (
OperatorEqual Operator = "="
OperatorNotEqual Operator = "!="
OperatorGreater Operator = ">"
OperatorLesser Operator = "<"
OperatorGreaterOrEqual Operator = ">="
OperatorLesserOrEqual Operator = "<="
OperatorIn Operator = "in"
OperatorNotIn Operator = "not_in"
OperatorIsNull Operator = "is_null"
OperatorIsNotNull Operator = "is_not_null"
OperatorLike Operator = "like"
OperatorNotLike Operator = "not_like"
)
type ClauseGroup struct {
Single *Clause
Multi *MultiClause
}
type Clause struct {
Left string
Operator Operator
}
type MultiClause struct {
Clauses []*Clause
Relation ClauseRelation
}
type ConditionStr struct {
Left string
Operator Operator
Right any
}
type ConditionGroup struct {
Conditions []*ConditionStr
Relation ClauseRelation
}
type DeleteRequest struct {
DatabaseInfoID int64
ConditionGroup *ConditionGroup
IsDebugRun bool
UserID string
ConnectorID int64
}
type QueryRequest struct {
DatabaseInfoID int64
SelectFields []string
Limit int64
ConditionGroup *ConditionGroup
OrderClauses []*OrderClause
IsDebugRun bool
UserID string
ConnectorID int64
}
type OrderClause struct {
FieldID string
IsAsc bool
}
type UpdateRequest struct {
DatabaseInfoID int64
ConditionGroup *ConditionGroup
Fields map[string]any
IsDebugRun bool
UserID string
ConnectorID int64
}
type InsertRequest struct {
DatabaseInfoID int64
Fields map[string]any
IsDebugRun bool
UserID string
ConnectorID int64
}