init
This commit is contained in:
51
local/controller/concert.go
Normal file
51
local/controller/concert.go
Normal file
@@ -0,0 +1,51 @@
|
||||
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"`
|
||||
}
|
||||
21
local/controller/controller.go
Normal file
21
local/controller/controller.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"rockhu-bot/local/service"
|
||||
|
||||
"go.uber.org/dig"
|
||||
)
|
||||
|
||||
// InitializeControllers
|
||||
// Initializes Dependency Injection modules and registers controllers
|
||||
//
|
||||
// Args:
|
||||
// *dig.Container: Dig Container
|
||||
func InitializeControllers(c *dig.Container) {
|
||||
service.InitializeServices(c)
|
||||
|
||||
err := c.Invoke(NewConcertController)
|
||||
if err != nil {
|
||||
panic("unable to initialize Concert controller")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user