Add client banner-by-id API and point frontend at new client endpoints.
Also save admin uploads locally under /public/images with a 10MB limit. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -16,6 +16,7 @@ const (
|
||||
getCategoriesURL = "/categories"
|
||||
getOneSubCategoryURL = "/sub-categories/:id"
|
||||
getBannersURL = "/banners"
|
||||
getOneBannerURL = "/banners/:id"
|
||||
getStaticsURL = "/static"
|
||||
getOneStaticURL = "/static/:id"
|
||||
getCurrencyURL = "/currency"
|
||||
@@ -40,6 +41,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
||||
router.GET(getCategoriesURL, h.GetCategories)
|
||||
router.GET(getOneSubCategoryURL, h.GetSubCategory)
|
||||
router.GET(getBannersURL, h.GetBanners)
|
||||
router.GET(getOneBannerURL, h.GetOneBanner)
|
||||
router.GET(getStaticsURL, h.GetStatics)
|
||||
router.GET(getOneStaticURL, h.GetOneStatic)
|
||||
router.GET(getCurrencyURL, h.GetCurrency)
|
||||
@@ -154,6 +156,32 @@ func (h *handler) GetBanners(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, successResult)
|
||||
}
|
||||
|
||||
// GetOneBanner godoc
|
||||
// @Description banner by id
|
||||
// @Tags banners
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "banner ID"
|
||||
// @Success 200 {object} BannerDTO
|
||||
// @Router /client/users/banners/{id} [get]
|
||||
func (h *handler) GetOneBanner(c *gin.Context) {
|
||||
id, err := strconv.Atoi(c.Param("id"))
|
||||
if err != nil {
|
||||
c.JSON(http.StatusNotFound, appresult.ErrNotAcceptable)
|
||||
return
|
||||
}
|
||||
|
||||
result, err := h.repository.GetBannerById(c.Request.Context(), id)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, appresult.ErrInternalServer)
|
||||
return
|
||||
}
|
||||
|
||||
successResult := appresult.Success
|
||||
successResult.Data = result
|
||||
c.JSON(http.StatusOK, successResult)
|
||||
}
|
||||
|
||||
// GetStatics godoc
|
||||
// @Description all static data
|
||||
// @Tags statics
|
||||
|
||||
Reference in New Issue
Block a user