52 lines
1.1 KiB
Go
52 lines
1.1 KiB
Go
package controller
|
|
|
|
import (
|
|
"encoding/json"
|
|
"rockhu-bot/local/service"
|
|
"rockhu-bot/local/utl/common"
|
|
|
|
"github.com/gofiber/fiber/v2"
|
|
)
|
|
|
|
type ConcertController struct {
|
|
service *service.ConcertService
|
|
}
|
|
|
|
// NewConcertController
|
|
// Initializes ConcertController.
|
|
//
|
|
// Args:
|
|
// *services.ConcertService: Concert service
|
|
// *Fiber.RouterGroup: Fiber Router Group
|
|
// Returns:
|
|
// *ConcertController: Controller for "Concert" interactions
|
|
func NewConcertController(as *service.ConcertService, routeGroups *common.RouteGroups) *ConcertController {
|
|
ac := &ConcertController{
|
|
service: as,
|
|
}
|
|
|
|
routeGroups.Concert.Get("/", ac.getAll)
|
|
|
|
return ac
|
|
}
|
|
|
|
// getAll returns Concert
|
|
//
|
|
// @Summary Return Concert
|
|
// @Description Return Concert
|
|
// @Tags Concert
|
|
// @Success 200 {array} string
|
|
// @Router /v1/Concert [get]
|
|
func (ac *ConcertController) getAll(c *fiber.Ctx) error {
|
|
ConcertModel := ac.service.GetAll(c.UserContext())
|
|
model, err := json.Marshal(ConcertModel)
|
|
if err != nil {
|
|
return c.SendStatus(400)
|
|
}
|
|
return c.Send(model)
|
|
}
|
|
|
|
type Service struct {
|
|
Name string `json:"name" xml:"name" form:"name"`
|
|
}
|