feat: list server api
This commit is contained in:
parent
8d0f6fb7c4
commit
bdffd2d840
@ -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))
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user