add state history
This commit is contained in:
@@ -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
|
||||
|
||||
43
local/controller/stateHistory.go
Normal file
43
local/controller/stateHistory.go
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user