44 lines
1015 B
Go
44 lines
1015 B
Go
package diagnosa
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
baseResponse "antrian-operasi/internal/shared"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type DiagnosaHandler struct {
|
|
repo IDiagnosaRepository
|
|
}
|
|
|
|
func NewDiagnosaHandler(repo IDiagnosaRepository) DiagnosaHandler {
|
|
return DiagnosaHandler{repo}
|
|
}
|
|
|
|
// List Diagnosa godoc
|
|
// @Summary Get List Diagnosa
|
|
// @Tags Reference
|
|
// @Param search query string false "Search keyword"
|
|
// @Success 200 {object} []DiagnosaResponse
|
|
// @Failure 500 {object} shared.BaseErrorResponse
|
|
// @Router /reference/diagnosa/ [get]
|
|
func (h DiagnosaHandler) ListDiagnosa(c *gin.Context) {
|
|
search := c.Query("search")
|
|
|
|
list, err := h.repo.SearchableListDiagnosa(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 diagnosa")
|
|
|
|
c.JSON(http.StatusOK, response)
|
|
}
|