67 lines
1.6 KiB
Go
67 lines
1.6 KiB
Go
package dashboard
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
baseResponse "antrian-operasi/internal/shared"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type DashboardHandler struct {
|
|
repo IDashboardRepository
|
|
}
|
|
|
|
func NewDashboardHandler(repo IDashboardRepository) DashboardHandler {
|
|
return DashboardHandler{repo}
|
|
}
|
|
|
|
// GetAntrianPerKategori godoc
|
|
// @Summary Get Antrian Per Kategori
|
|
// @Tags Dashboard
|
|
// @Success 200 {object} []AntrianPerKategori
|
|
// @Failure 500 {object} shared.BaseErrorResponse
|
|
// @Router /dashboard/antrian-per-kategori/ [get]
|
|
func (h DashboardHandler) GetAntrianPerKategori(c *gin.Context) {
|
|
data, err := h.repo.GetAntrianPerKategori(c)
|
|
if err != nil {
|
|
errorResponse := baseResponse.BaseErrorResponse{
|
|
Success: false,
|
|
Code: 500,
|
|
Message: err.Error(),
|
|
}
|
|
c.JSON(http.StatusInternalServerError, errorResponse)
|
|
return
|
|
}
|
|
|
|
response := baseResponse.ToBaseResponse(data, true, 200, "success get jumlah antrian per kategori")
|
|
|
|
c.JSON(http.StatusOK, response)
|
|
}
|
|
|
|
// GetAntrianPerSpesialis godoc
|
|
// @Summary Get Antrian Per Spesialis
|
|
// @Tags Dashboard
|
|
// @Success 200 {object} []AntrianPerSpesialisResponse
|
|
// @Failure 500 {object} shared.BaseErrorResponse
|
|
// @Router /dashboard/antrian-per-spesialis/ [get]
|
|
func (h DashboardHandler) GetAntrianPerSpesialis(c *gin.Context) {
|
|
data, err := h.repo.GetAntrianPerSpesialis(c)
|
|
if err != nil {
|
|
errorResponse := baseResponse.BaseErrorResponse{
|
|
Success: false,
|
|
Code: 500,
|
|
Message: err.Error(),
|
|
}
|
|
c.JSON(http.StatusInternalServerError, errorResponse)
|
|
}
|
|
|
|
response := baseResponse.ToBaseResponse(
|
|
data.ParseToResponse(),
|
|
true,
|
|
200,
|
|
"success get jumlah antrian per spesialis")
|
|
|
|
c.JSON(http.StatusOK, response)
|
|
}
|