add state history

This commit is contained in:
Fran Jurmanović
2025-05-27 20:18:58 +02:00
parent e52894c663
commit 56ef5e1484
12 changed files with 173 additions and 27 deletions

View File

@@ -40,6 +40,11 @@ func InitializeControllers(c *dig.Container) {
if err != nil {
log.Panic("unable to initialize lookup controller")
}
err = c.Invoke(NewStateHistoryController)
if err != nil {
log.Panic("unable to initialize stateHistory controller")
}
}
// FilteredResponse

View File

@@ -0,0 +1,43 @@
package controller
import (
"acc-server-manager/local/service"
"acc-server-manager/local/utl/common"
"github.com/gofiber/fiber/v2"
)
type StateHistoryController struct {
service *service.StateHistoryService
}
// NewStateHistoryController
// Initializes StateHistoryController.
//
// Args:
// *services.StateHistoryService: StateHistory service
// *Fiber.RouterGroup: Fiber Router Group
// Returns:
// *StateHistoryController: Controller for "StateHistory" interactions
func NewStateHistoryController(as *service.StateHistoryService, routeGroups *common.RouteGroups) *StateHistoryController {
ac := &StateHistoryController{
service: as,
}
routeGroups.StateHistory.Get("/", ac.getAll)
return ac
}
// getAll returns StateHistorys
//
// @Summary Return StateHistorys
// @Description Return StateHistorys
// @Tags StateHistory
// @Success 200 {array} string
// @Router /v1/StateHistory [get]
func (ac *StateHistoryController) getAll(c *fiber.Ctx) error {
StateHistoryID, _ := c.ParamsInt("id")
StateHistoryModel := ac.service.GetAll(c, StateHistoryID)
return c.JSON(StateHistoryModel)
}