44 lines
991 B
Go
44 lines
991 B
Go
package pasien
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
baseResponse "antrian-operasi/internal/shared"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type PasienHandler struct {
|
|
repo IPasienRepository
|
|
}
|
|
|
|
func NewPasienHandler(repo IPasienRepository) PasienHandler {
|
|
return PasienHandler{repo}
|
|
}
|
|
|
|
// ListPasien godoc
|
|
// @Summary Get List Pasien
|
|
// @Tags Reference
|
|
// @Param search query string false "Search keyword"
|
|
// @Success 200 {object} []PasienResponse
|
|
// @Failure 500 {object} shared.BaseErrorResponse
|
|
// @Router /reference/pasien/ [get]
|
|
func (h PasienHandler) ListPasienOperasi(c *gin.Context) {
|
|
search := c.Query("search")
|
|
|
|
list, err := h.repo.SearchableListPasien(c, search)
|
|
if err != nil {
|
|
errorResponse := baseResponse.BaseErrorResponse{
|
|
Success: false,
|
|
Code: 500,
|
|
Message: err.Error(),
|
|
}
|
|
c.JSON(http.StatusInternalServerError, errorResponse)
|
|
return
|
|
}
|
|
|
|
response := baseResponse.ToBaseResponse(list.ToResponseList(), true, 200, "success get pasien")
|
|
|
|
c.JSON(http.StatusOK, response)
|
|
}
|