Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feat/1.2.0/plugin' into test
Browse files Browse the repository at this point in the history
  • Loading branch information
LinkinStars committed Oct 17, 2023
2 parents 727a973 + cd08586 commit d6543a1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
22 changes: 22 additions & 0 deletions internal/controller_admin/plugin_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,28 @@ func NewPluginController(PluginCommonService *plugin_common.PluginCommonService)
return &PluginController{PluginCommonService: PluginCommonService}
}

// GetAllPluginStatus get all plugins status
// @Summary get all plugins status
// @Description get all plugins status
// @Tags Plugin
// @Security ApiKeyAuth
// @Accept json
// @Produce json
// @Success 200 {object} handler.RespBody{data=[]schema.GetPluginListResp}
// @Router /answer/api/v1/plugin/status [get]
func (pc *PluginController) GetAllPluginStatus(ctx *gin.Context) {
resp := make([]*schema.GetAllPluginStatusResp, 0)
_ = plugin.CallBase(func(base plugin.Base) error {
info := base.Info()
resp = append(resp, &schema.GetAllPluginStatusResp{
SlugName: info.SlugName,
Enabled: plugin.StatusManager.IsEnabled(info.SlugName),
})
return nil
})
handler.HandleResponse(ctx, nil, resp)
}

// GetPluginList get plugin list
// @Summary get plugin list
// @Description get plugin list
Expand Down
3 changes: 3 additions & 0 deletions internal/router/answer_api_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ func (a *AnswerAPIRouter) RegisterMustUnAuthAnswerAPIRouter(authUserMiddleware *
routerGroup.POST("/user/password/reset", a.userController.RetrievePassWord)
routerGroup.POST("/user/password/replacement", a.userController.UseRePassWord)
routerGroup.PUT("/user/notification/unsubscribe", a.userController.UserUnsubscribeNotification)

// plugins
r.GET("/plugin/status", a.pluginController.GetAllPluginStatus)
}

func (a *AnswerAPIRouter) RegisterUnAuthAnswerAPIRouter(r *gin.RouterGroup) {
Expand Down
5 changes: 5 additions & 0 deletions internal/schema/plugin_admin_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ type GetPluginListResp struct {
Link string `json:"link"`
}

type GetAllPluginStatusResp struct {
SlugName string `json:"slug_name"`
Enabled bool `json:"enabled"`
}

type UpdatePluginStatusReq struct {
PluginSlugName string `validate:"required,gt=1,lte=100" json:"plugin_slug_name"`
Enabled bool `json:"enabled"`
Expand Down

0 comments on commit d6543a1

Please sign in to comment.