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]
|
2024-10-21 02:30:50 -04:00
|
|
|
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
|
2024-10-21 02:30:50 -04:00
|
|
|
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]{
|
2024-10-21 02:30:50 -04:00
|
|
|
Success: true,
|
2024-10-20 11:23:04 -04:00
|
|
|
Data: sg,
|
|
|
|
})
|
2024-10-21 02:30:50 -04:00
|
|
|
return nil
|
2024-10-20 11:23:04 -04:00
|
|
|
}
|