feat: list server api

This commit is contained in:
naiba 2024-10-23 17:34:15 +08:00
parent 8d0f6fb7c4
commit bdffd2d840
2 changed files with 21 additions and 0 deletions

View File

@ -72,6 +72,7 @@ func routers(r *gin.Engine) {
auth.PATCH("/server-group/:id", commonHandler(updateServerGroup))
auth.POST("/batch-delete/server-group", commonHandler(batchDeleteServerGroup))
auth.GET("/server", commonHandler(listServer))
auth.PATCH("/server/:id", commonHandler(updateServer))
auth.POST("/batch-delete/server", commonHandler(batchDeleteServer))

View File

@ -12,6 +12,26 @@ import (
"github.com/naiba/nezha/service/singleton"
)
// List server
// @Summary List server
// @Security BearerAuth
// @Schemes
// @Description List server
// @Tags auth required
// @Produce json
// @Success 200 {object} model.CommonResponse[any]
// @Router /server [get]
func listServer(c *gin.Context) error {
var servers []model.Server
if err := singleton.DB.Find(&servers).Error; err != nil {
return newGormError("%v", err)
}
c.JSON(http.StatusOK, model.CommonResponse[any]{
Data: servers,
})
return nil
}
// Edit server
// @Summary Edit server
// @Security BearerAuth