step 3 : route, handler dan services
This commit is contained in:
50
handlers/dev/kartukontrol.handlers.go
Normal file
50
handlers/dev/kartukontrol.handlers.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package dev_handlers
|
||||
|
||||
import (
|
||||
"cpone/models"
|
||||
"cpone/utils"
|
||||
kartukontrol "cpone/views/dev/kartukontrol"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type KartuKontrolService interface {
|
||||
GetkartuKontrolById(id string) ([]models.KartuKontrolModel, error)
|
||||
}
|
||||
|
||||
func NewKartuKontrolHandler(us KartuKontrolService) *KartuKontrolHandler {
|
||||
return &KartuKontrolHandler{
|
||||
KartuKontrolService: us,
|
||||
}
|
||||
}
|
||||
|
||||
type KartuKontrolHandler struct {
|
||||
KartuKontrolService KartuKontrolService
|
||||
}
|
||||
|
||||
func (lh *KartuKontrolHandler) HandlerShowKartuKontrol(c echo.Context) error {
|
||||
|
||||
id := c.Param("id")
|
||||
// id := "1"
|
||||
logger, _ := zap.NewProduction()
|
||||
defer logger.Sync()
|
||||
|
||||
dataKartuKontrol, err := lh.KartuKontrolService.GetkartuKontrolById(id)
|
||||
|
||||
if err != nil {
|
||||
logger.Info("Error",
|
||||
zap.Any("Error", err),
|
||||
zap.Any("prm", id),
|
||||
)
|
||||
return err
|
||||
}
|
||||
logger.Info("SHOW DATA KARTU KONTROL handler",
|
||||
zap.Any("return", dataKartuKontrol),
|
||||
zap.Any("prm", id),
|
||||
)
|
||||
|
||||
si := kartukontrol.ShowKartuKontrol("Kartu Kontrol", kartukontrol.MainContentKartuKontrolLayout(dataKartuKontrol), kartukontrol.CssKartuKontrol(), kartukontrol.JsKartuKontrol())
|
||||
|
||||
return utils.View(c, si)
|
||||
}
|
||||
@@ -206,4 +206,9 @@ func SetupRoutesDev(app *echo.Echo, appStore db.AppStore) {
|
||||
|
||||
// clientgroup.GET("/usergroup/edit", mastermenuusergroupHandler.ChangeFormEdit)
|
||||
// clientgroup.GET("/usergroup/pagination", mastermenuusergroupHandler.HandleChangePage)
|
||||
|
||||
// kartu kontrol
|
||||
devKartuKontrolServices := dev_services.NewServicesKartuKontrol(appStore)
|
||||
devKartuKontrolhandlers := dev_handlers.NewKartuKontrolHandler(devKartuKontrolServices)
|
||||
dev.GET("/kartukontrol/:id", devKartuKontrolhandlers.HandlerShowKartuKontrol)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user