Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize plugin configuration ce #2843

Merged
merged 4 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sqle/api/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ func StartApi(net *gracenet.Net, exitChan chan struct{}, config *config.SqleOpti
v1Router.POST("/data_resource/handle", v1.OperateDataResourceHandle, sqleMiddleware.OpGlobalAllowed())
v1Router.POST(fmt.Sprintf("%s/connection", dmsV1.InternalDBServiceRouterGroup), v1.CheckInstanceIsConnectable, sqleMiddleware.OpGlobalAllowed())
v1Router.GET("/database_driver_options", v1.GetDatabaseDriverOptions)
v1Router.GET("/database_driver_logos", v1.GetDatabaseDriverLogos)
}

// project admin and global manage router
Expand Down
45 changes: 45 additions & 0 deletions sqle/api/controller/v1/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"net/http"
"strings"

baseV1 "github.com/actiontech/dms/pkg/dms-common/api/base/v1"
dmsV1 "github.com/actiontech/dms/pkg/dms-common/api/dms/v1"
Expand Down Expand Up @@ -633,3 +634,47 @@ func convertParamsToInstanceAdditionalParamRes(params params.Params) []*Instance
}
return res
}

type DatabaseDriverLogosReqV1 struct {
FilterDBTypes string `json:"db_types" query:"db_types"`
ColdWaterLW marked this conversation as resolved.
Show resolved Hide resolved
}

type GetDatabaseDriverLogosResV1 struct {
controller.BaseRes
Logos []*DatabaseDriverLogosV1 `json:"data"`
}

type DatabaseDriverLogosV1 struct {
DBType string `json:"db_type"`
Logo []byte `json:"logo"`
}

// GetDatabaseDriverLogos get database driver logos
// @Summary 获取数据库插件的Logo图片
// @Description get database driver logos
// @Id GetDatabaseDriverLogos
// @Tags instance
// @Param db_types query string true "MySQL,Oracle"
// @Security ApiKeyAuth
// @Success 200 {object} v1.GetDatabaseDriverLogosResV1
// @router /v1/database_driver_logos [get]
func GetDatabaseDriverLogos(c echo.Context) error {
req := new(DatabaseDriverLogosReqV1)
if err := controller.BindAndValidateReq(c, req); err != nil {
return controller.JSONBaseErrorReq(c, err)
}
dbTypes := strings.Split(req.FilterDBTypes, ",")
pluginMgr := driver.GetPluginManager()
allLogos := pluginMgr.AllLogo()
logos := make([]*DatabaseDriverLogosV1, len(dbTypes))
for i, dbType := range dbTypes {
logos[i] = &DatabaseDriverLogosV1{
DBType: dbType,
Logo: allLogos[dbType],
}
}
return c.JSON(http.StatusOK, &GetDatabaseDriverLogosResV1{
Logos: logos,
BaseRes: controller.NewBaseReq(nil),
})
}