feat: manually mirror opencoze's code from bytedance
Change-Id: I09a73aadda978ad9511264a756b2ce51f5761adf
This commit is contained in:
79
backend/application/plugin/init.go
Normal file
79
backend/application/plugin/init.go
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package plugin
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
pluginConf "github.com/coze-dev/coze-studio/backend/domain/plugin/conf"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/repository"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/service"
|
||||
search "github.com/coze-dev/coze-studio/backend/domain/search/service"
|
||||
user "github.com/coze-dev/coze-studio/backend/domain/user/service"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/storage"
|
||||
)
|
||||
|
||||
type ServiceComponents struct {
|
||||
IDGen idgen.IDGenerator
|
||||
DB *gorm.DB
|
||||
OSS storage.Storage
|
||||
EventBus search.ResourceEventBus
|
||||
UserSVC user.User
|
||||
}
|
||||
|
||||
func InitService(ctx context.Context, components *ServiceComponents) (*PluginApplicationService, error) {
|
||||
err := pluginConf.InitConfig(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
toolRepo := repository.NewToolRepo(&repository.ToolRepoComponents{
|
||||
IDGen: components.IDGen,
|
||||
DB: components.DB,
|
||||
})
|
||||
|
||||
pluginRepo := repository.NewPluginRepo(&repository.PluginRepoComponents{
|
||||
IDGen: components.IDGen,
|
||||
DB: components.DB,
|
||||
})
|
||||
|
||||
oauthRepo := repository.NewOAuthRepo(&repository.OAuthRepoComponents{
|
||||
IDGen: components.IDGen,
|
||||
DB: components.DB,
|
||||
})
|
||||
|
||||
pluginSVC := service.NewService(&service.Components{
|
||||
IDGen: components.IDGen,
|
||||
DB: components.DB,
|
||||
OSS: components.OSS,
|
||||
PluginRepo: pluginRepo,
|
||||
ToolRepo: toolRepo,
|
||||
OAuthRepo: oauthRepo,
|
||||
})
|
||||
|
||||
PluginApplicationSVC.DomainSVC = pluginSVC
|
||||
PluginApplicationSVC.eventbus = components.EventBus
|
||||
PluginApplicationSVC.oss = components.OSS
|
||||
PluginApplicationSVC.userSVC = components.UserSVC
|
||||
PluginApplicationSVC.pluginRepo = pluginRepo
|
||||
PluginApplicationSVC.toolRepo = toolRepo
|
||||
|
||||
return PluginApplicationSVC, nil
|
||||
}
|
||||
34
backend/application/plugin/model.go
Normal file
34
backend/application/plugin/model.go
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package plugin
|
||||
|
||||
import (
|
||||
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
||||
)
|
||||
|
||||
type CopyPluginRequest struct {
|
||||
PluginID int64
|
||||
UserID int64
|
||||
CopyScene model.CopyScene
|
||||
TargetAPPID *int64
|
||||
}
|
||||
|
||||
type CopyPluginResponse struct {
|
||||
Plugin *entity.PluginInfo
|
||||
Tools map[int64]*entity.ToolInfo // old tool id -> new tool id
|
||||
}
|
||||
1759
backend/application/plugin/plugin.go
Normal file
1759
backend/application/plugin/plugin.go
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user