hiling_go/api/region.go

38 lines
939 B
Go
Raw Normal View History

2023-10-02 08:49:41 +07:00
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)
}