67 lines
1.7 KiB
Go
67 lines
1.7 KiB
Go
package spesialis
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
baseResponse "antrian-operasi/internal/shared"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type SpesialisHandler struct {
|
|
repo ISpesialisRepository
|
|
}
|
|
|
|
func NewSpesialisHandler(repo ISpesialisRepository) SpesialisHandler {
|
|
return SpesialisHandler{repo}
|
|
}
|
|
|
|
// ListSpesialis godoc
|
|
// @Summary Get List Spesialis
|
|
// @Tags Spesialis
|
|
// @Param search query string false "Search keyword"
|
|
// @Success 200 {object} []SpesialisModel
|
|
// @Failure 500 {object} shared.BaseErrorResponse
|
|
// @Router /reference/spesialis/ [get]
|
|
func (h SpesialisHandler) ListSpesialis(c *gin.Context) {
|
|
list, err := h.repo.SearchableListSpesialis(c)
|
|
if err != nil {
|
|
errorResponse := baseResponse.BaseErrorResponse{
|
|
Success: false,
|
|
Code: 500,
|
|
Message: err.Error(),
|
|
}
|
|
c.JSON(http.StatusInternalServerError, errorResponse)
|
|
return
|
|
}
|
|
|
|
response := baseResponse.ToBaseResponse(list, true, 200, "success get list spesialis")
|
|
|
|
c.JSON(http.StatusOK, response)
|
|
}
|
|
|
|
// ListSubSpesialis godoc
|
|
// @Summary Get List Sub Spesialis
|
|
// @Tags Spesialis
|
|
// @Param search query string false "Search keyword"
|
|
// @Param id_spesialis query int false "Filter by Id Spesialis"
|
|
// @Success 200 {object} []SubSpesialisModel
|
|
// @Failure 500 {object} shared.BaseErrorResponse
|
|
// @Router /reference/sub-spesialis/ [get]
|
|
func (h SpesialisHandler) ListSubSpesialis(c *gin.Context) {
|
|
list, err := h.repo.SearchableListSubSpesialis(c)
|
|
if err != nil {
|
|
errorResponse := baseResponse.BaseErrorResponse{
|
|
Success: false,
|
|
Code: 500,
|
|
Message: err.Error(),
|
|
}
|
|
c.JSON(http.StatusInternalServerError, errorResponse)
|
|
return
|
|
}
|
|
|
|
response := baseResponse.ToBaseResponse(list, true, 200, "success get list spesialis")
|
|
|
|
c.JSON(http.StatusOK, response)
|
|
}
|