nezha/cmd/dashboard/controller/server_group.go

36 lines
775 B
Go
Raw Normal View History

2024-10-20 11:23:04 -04:00
package controller
import (
"log"
"net/http"
"github.com/gin-gonic/gin"
2024-10-21 04:22:30 -04:00
2024-10-20 11:23:04 -04:00
"github.com/naiba/nezha/model"
"github.com/naiba/nezha/service/singleton"
)
// List server group
// @Summary List server group
// @Schemes
// @Description List server group
// @Security BearerAuth
// @Tags common
// @Produce json
// @Success 200 {object} model.CommonResponse[[]model.ServerGroup]
// @Router /server-group [get]
func listServerGroup(c *gin.Context) error {
2024-10-20 11:23:04 -04:00
authorizedUser, has := c.Get(model.CtxKeyAuthorizedUser)
log.Println("bingo test", authorizedUser, has)
var sg []model.ServerGroup
if err := singleton.DB.Find(&sg).Error; err != nil {
return err
}
2024-10-20 11:23:04 -04:00
c.JSON(http.StatusOK, model.CommonResponse[[]model.ServerGroup]{
Success: true,
2024-10-20 11:23:04 -04:00
Data: sg,
})
return nil
2024-10-20 11:23:04 -04:00
}