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

@@ -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