hiling_go/api/region.go

38 lines
939 B
Go

package api
import (
"net/http"
"github.com/gin-gonic/gin"
)
func (server *Server) getListRegions(ctx *gin.Context) {
regions, err := server.Store.GetListRegions(ctx)
if err != nil {
ctx.JSON(http.StatusInternalServerError, ErrorResponse(err, "Something went wrong while try to get regions"))
return
}
ctx.JSON(http.StatusOK, regions)
}
func (server *Server) getListProvinces(ctx *gin.Context) {
provinces, err := server.Store.GetListProvinces(ctx)
if err != nil {
ctx.JSON(http.StatusInternalServerError, ErrorResponse(err, "Something went wrong while try to get regions"))
return
}
ctx.JSON(http.StatusOK, provinces)
}
func (server *Server) getListRegencies(ctx *gin.Context) {
regencies, err := server.Store.GetListRegencies(ctx)
if err != nil {
ctx.JSON(http.StatusInternalServerError, ErrorResponse(err, "Something went wrong while try to get regions"))
return
}
ctx.JSON(http.StatusOK, regencies)
}