diff --git a/backend/app/api/v1/app_install.go b/backend/app/api/v1/app_install.go index 7606c827f..3404233e2 100644 --- a/backend/app/api/v1/app_install.go +++ b/backend/app/api/v1/app_install.go @@ -2,9 +2,10 @@ package v1 import ( "errors" - "github.com/1Panel-dev/1Panel/backend/app/dto/request" "reflect" + "github.com/1Panel-dev/1Panel/backend/app/dto/request" + "github.com/1Panel-dev/1Panel/backend/app/api/v1/helper" "github.com/1Panel-dev/1Panel/backend/app/dto" "github.com/1Panel-dev/1Panel/backend/constant" @@ -68,6 +69,20 @@ func (b *BaseApi) LoadPort(c *gin.Context) { helper.SuccessWithData(c, port) } +func (b *BaseApi) LoadPassword(c *gin.Context) { + key, ok := c.Params.Get("key") + if !ok { + helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, errors.New("error key in path")) + return + } + password, err := appInstallService.LoadPassword(key) + if err != nil { + helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) + return + } + helper.SuccessWithData(c, password) +} + func (b *BaseApi) DeleteCheck(c *gin.Context) { appInstallId, err := helper.GetIntParamByKey(c, "appInstallId") if err != nil { diff --git a/backend/app/service/app_install.go b/backend/app/service/app_install.go index 3b5ade574..22804b248 100644 --- a/backend/app/service/app_install.go +++ b/backend/app/service/app_install.go @@ -4,8 +4,6 @@ import ( "context" "encoding/json" "fmt" - "github.com/1Panel-dev/1Panel/backend/app/dto/request" - "github.com/1Panel-dev/1Panel/backend/app/dto/response" "io/ioutil" "os" "path" @@ -13,6 +11,9 @@ import ( "strconv" "strings" + "github.com/1Panel-dev/1Panel/backend/app/dto/request" + "github.com/1Panel-dev/1Panel/backend/app/dto/response" + "github.com/1Panel-dev/1Panel/backend/app/repo" "github.com/1Panel-dev/1Panel/backend/app/dto" @@ -88,6 +89,14 @@ func (a AppInstallService) LoadPort(key string) (int64, error) { return app.Port, nil } +func (a AppInstallService) LoadPassword(key string) (string, error) { + app, err := appInstallRepo.LoadBaseInfoByKey(key) + if err != nil { + return "", nil + } + return app.Password, nil +} + func (a AppInstallService) Search(req request.AppInstalledSearch) ([]response.AppInstalledDTO, error) { var installs []model.AppInstall var err error diff --git a/backend/router/ro_app.go b/backend/router/ro_app.go index b6fb9dcca..75d291fd8 100644 --- a/backend/router/ro_app.go +++ b/backend/router/ro_app.go @@ -23,6 +23,7 @@ func (a *AppRouter) InitAppRouter(Router *gin.RouterGroup) { appRouter.GET("/installed/:appInstallId/versions", baseApi.GetUpdateVersions) appRouter.GET("/installed/check/:key", baseApi.CheckAppInstalled) appRouter.GET("/installed/loadport/:key", baseApi.LoadPort) + appRouter.GET("/installed/loadpassword/:key", baseApi.LoadPassword) appRouter.GET("/installed/delete/check/:appInstallId", baseApi.DeleteCheck) appRouter.POST("/installed", baseApi.SearchAppInstalled) appRouter.POST("/installed/op", baseApi.OperateInstalled) diff --git a/frontend/src/api/modules/app.ts b/frontend/src/api/modules/app.ts index 6a5a05353..0d1e3f126 100644 --- a/frontend/src/api/modules/app.ts +++ b/frontend/src/api/modules/app.ts @@ -34,6 +34,10 @@ export const GetAppPort = (key: string) => { return http.get(`apps/installed/loadport/${key}`); }; +export const GetAppPassword = (key: string) => { + return http.get(`apps/installed/loadpassword/${key}`); +}; + export const CheckAppInstalled = (key: string) => { return http.get(`apps/installed/check/${key}`); }; diff --git a/frontend/src/views/database/mysql/password/index.vue b/frontend/src/views/database/mysql/password/index.vue index 7d7068892..878b8f127 100644 --- a/frontend/src/views/database/mysql/password/index.vue +++ b/frontend/src/views/database/mysql/password/index.vue @@ -15,8 +15,10 @@