fix: upload idl split
This commit is contained in:
@ -413,51 +413,3 @@ func GetTypeList(ctx context.Context, c *app.RequestContext) {
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// CommonUpload .
|
||||
// @router /api/playground/upload [POST]
|
||||
func CommonUpload(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req developer_api.CommonUploadRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
fullUrl := string(c.Request.URI().FullURI())
|
||||
resp, err := upload.SVC.UploadFileCommon(ctx, &req, fullUrl)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// ApplyUploadAction .
|
||||
// @router /api/playground/apply_upload_action [GET]
|
||||
func ApplyUploadAction(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req developer_api.ApplyUploadActionRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
resp := new(developer_api.ApplyUploadActionResponse)
|
||||
host := c.Request.Host()
|
||||
if ptr.From(req.Action) == "ApplyImageUpload" {
|
||||
resp, err = upload.SVC.ApplyImageUpload(ctx, &req, string(host))
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
} else if ptr.From(req.Action) == "CommitImageUpload" {
|
||||
resp, err = upload.SVC.CommitImageUpload(ctx, &req, string(host))
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
64
backend/api/handler/coze/upload_service.go
Normal file
64
backend/api/handler/coze/upload_service.go
Normal file
@ -0,0 +1,64 @@
|
||||
// Code generated by hertz generator.
|
||||
|
||||
package coze
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/cloudwego/hertz/pkg/app"
|
||||
"github.com/cloudwego/hertz/pkg/protocol/consts"
|
||||
|
||||
upload "github.com/coze-dev/coze-studio/backend/api/model/file/upload"
|
||||
uploadSVC "github.com/coze-dev/coze-studio/backend/application/upload"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
)
|
||||
|
||||
// CommonUpload .
|
||||
// @router /api/common/upload/*tos_uri [POST]
|
||||
func CommonUpload(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req upload.CommonUploadRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
fullUrl := string(c.Request.URI().FullURI())
|
||||
|
||||
resp, err := uploadSVC.SVC.UploadFileCommon(ctx, &req, fullUrl)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// ApplyUploadAction .
|
||||
// @router /api/common/upload/apply_upload_action [GET]
|
||||
func ApplyUploadAction(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
var req upload.ApplyUploadActionRequest
|
||||
err = c.BindAndValidate(&req)
|
||||
if err != nil {
|
||||
c.String(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
resp := new(upload.ApplyUploadActionResponse)
|
||||
host := c.Request.Host()
|
||||
if ptr.From(req.Action) == "ApplyImageUpload" {
|
||||
resp, err = uploadSVC.SVC.ApplyImageUpload(ctx, &req, string(host))
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
} else if ptr.From(req.Action) == "CommitImageUpload" {
|
||||
resp, err = uploadSVC.SVC.CommitImageUpload(ctx, &req, string(host))
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
@ -3,10 +3,12 @@
|
||||
package coze
|
||||
|
||||
import (
|
||||
"github.com/apache/thrift/lib/go/thrift"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/conversation/agentrun"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/conversation/conversation"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/conversation/message"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/database"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/file/upload"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/flow/dataengine/dataset"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/flow/marketplace/product_public_api"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/intelligence"
|
||||
@ -19,7 +21,6 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/passport"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/permission/openapiauth"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/resource"
|
||||
"github.com/apache/thrift/lib/go/thrift"
|
||||
)
|
||||
|
||||
type IntelligenceService interface {
|
||||
@ -438,6 +439,32 @@ func NewBotOpenApiServiceClient(c thrift.TClient) *BotOpenApiServiceClient {
|
||||
}
|
||||
}
|
||||
|
||||
type UploadService interface {
|
||||
upload.UploadService
|
||||
}
|
||||
|
||||
type UploadServiceClient struct {
|
||||
*upload.UploadServiceClient
|
||||
}
|
||||
|
||||
func NewUploadServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *UploadServiceClient {
|
||||
return &UploadServiceClient{
|
||||
UploadServiceClient: upload.NewUploadServiceClientFactory(t, f),
|
||||
}
|
||||
}
|
||||
|
||||
func NewUploadServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *UploadServiceClient {
|
||||
return &UploadServiceClient{
|
||||
UploadServiceClient: upload.NewUploadServiceClientProtocol(t, iprot, oprot),
|
||||
}
|
||||
}
|
||||
|
||||
func NewUploadServiceClient(c thrift.TClient) *UploadServiceClient {
|
||||
return &UploadServiceClient{
|
||||
UploadServiceClient: upload.NewUploadServiceClient(c),
|
||||
}
|
||||
}
|
||||
|
||||
type IntelligenceServiceProcessor struct {
|
||||
*intelligence.IntelligenceServiceProcessor
|
||||
}
|
||||
@ -581,3 +608,12 @@ func NewBotOpenApiServiceProcessor(handler BotOpenApiService) *BotOpenApiService
|
||||
self := &BotOpenApiServiceProcessor{bot_open_api.NewBotOpenApiServiceProcessor(handler)}
|
||||
return self
|
||||
}
|
||||
|
||||
type UploadServiceProcessor struct {
|
||||
*upload.UploadServiceProcessor
|
||||
}
|
||||
|
||||
func NewUploadServiceProcessor(handler UploadService) *UploadServiceProcessor {
|
||||
self := &UploadServiceProcessor{upload.NewUploadServiceProcessor(handler)}
|
||||
return self
|
||||
}
|
||||
|
||||
5366
backend/api/model/file/upload/upload.go
Normal file
5366
backend/api/model/file/upload/upload.go
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -24,6 +24,15 @@ func Register(r *server.Hertz) {
|
||||
_bot.POST("/get_type_list", append(_gettypelistMw(), coze.GetTypeList)...)
|
||||
_bot.POST("/upload_file", append(_uploadfileMw(), coze.UploadFile)...)
|
||||
}
|
||||
{
|
||||
_common := _api.Group("/common", _commonMw()...)
|
||||
{
|
||||
_upload := _common.Group("/upload", _uploadMw()...)
|
||||
_upload.GET("/apply_upload_action", append(_applyuploadactionMw(), coze.ApplyUploadAction)...)
|
||||
_upload.POST("/apply_upload_action", append(_applyuploadaction0Mw(), coze.ApplyUploadAction)...)
|
||||
_upload.POST("/*tos_uri", append(_commonuploadMw(), coze.CommonUpload)...)
|
||||
}
|
||||
}
|
||||
{
|
||||
_conversation := _api.Group("/conversation", _conversationMw()...)
|
||||
_conversation.POST("/break_message", append(_breakmessageMw(), coze.BreakMessage)...)
|
||||
@ -252,13 +261,10 @@ func Register(r *server.Hertz) {
|
||||
}
|
||||
{
|
||||
_playground := _api.Group("/playground", _playgroundMw()...)
|
||||
_playground.GET("/apply_upload_action", append(_applyuploadactionMw(), coze.ApplyUploadAction)...)
|
||||
_playground.POST("/apply_upload_action", append(_applyuploadaction0Mw(), coze.ApplyUploadAction)...)
|
||||
_playground.POST("/get_onboarding", append(_getonboardingMw(), coze.GetOnboarding)...)
|
||||
{
|
||||
_upload := _playground.Group("/upload", _uploadMw()...)
|
||||
_upload.POST("/auth_token", append(_getuploadauthtokenMw(), coze.GetUploadAuthToken)...)
|
||||
_upload.POST("/*tos_uri", append(_commonuploadMw(), coze.CommonUpload)...)
|
||||
_upload0 := _playground.Group("/upload", _upload0Mw()...)
|
||||
_upload0.POST("/auth_token", append(_getuploadauthtokenMw(), coze.GetUploadAuthToken)...)
|
||||
}
|
||||
}
|
||||
{
|
||||
@ -395,8 +401,8 @@ func Register(r *server.Hertz) {
|
||||
_project_conversation.POST("/update", append(_updateprojectconversationdefMw(), coze.UpdateProjectConversationDef)...)
|
||||
}
|
||||
{
|
||||
_upload0 := _workflow_api.Group("/upload", _upload0Mw()...)
|
||||
_upload0.POST("/auth_token", append(_getworkflowuploadauthtokenMw(), coze.GetWorkflowUploadAuthToken)...)
|
||||
_upload1 := _workflow_api.Group("/upload", _upload1Mw()...)
|
||||
_upload1.POST("/auth_token", append(_getworkflowuploadauthtokenMw(), coze.GetWorkflowUploadAuthToken)...)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1495,3 +1495,13 @@ func _applyuploadaction0Mw() []app.HandlerFunc {
|
||||
// your code...
|
||||
return nil
|
||||
}
|
||||
|
||||
func _commonMw() []app.HandlerFunc {
|
||||
// your code...
|
||||
return nil
|
||||
}
|
||||
|
||||
func _upload1Mw() []app.HandlerFunc {
|
||||
// your code...
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user