feat: add search and pagination to tariff period services
This commit is contained in:
29
internal/http/periode_tarif.go
Normal file
29
internal/http/periode_tarif.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"primaya-api/cpone-middleware/internal/repository"
|
||||
)
|
||||
|
||||
func (h Handler) ListPeriodeTarif(w http.ResponseWriter, r *http.Request) {
|
||||
items, err := h.periodeTarifRepository(r.Context()).ListPeriodeTarif(r.Context())
|
||||
if err != nil {
|
||||
WriteJSON(w, http.StatusInternalServerError, Response{
|
||||
Success: false,
|
||||
Message: "internal server error",
|
||||
Data: nil,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if items == nil {
|
||||
items = []repository.PeriodeTarif{}
|
||||
}
|
||||
|
||||
WriteJSON(w, http.StatusOK, Response{
|
||||
Success: true,
|
||||
Message: "ok",
|
||||
Data: items,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user