mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-24 10:01:04 +01:00
37 lines
1.1 KiB
Go
37 lines
1.1 KiB
Go
package homepageapi
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
apitypes "github.com/yusing/godoxy/internal/api/types"
|
|
"github.com/yusing/godoxy/internal/homepage"
|
|
)
|
|
|
|
type HomepageOverrideItemClickParams struct {
|
|
Which string `form:"which" binding:"required"`
|
|
} // @name HomepageOverrideItemClickParams
|
|
|
|
// @x-id "item-click"
|
|
// @BasePath /api/v1
|
|
// @Summary Increment item click
|
|
// @Description Increment item click.
|
|
// @Tags homepage
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param request query HomepageOverrideItemClickParams true "Increment item click"
|
|
// @Success 200 {object} apitypes.SuccessResponse
|
|
// @Failure 400 {object} apitypes.ErrorResponse
|
|
// @Failure 500 {object} apitypes.ErrorResponse
|
|
// @Router /homepage/item_click [post]
|
|
func ItemClick(c *gin.Context) {
|
|
var params HomepageOverrideItemClickParams
|
|
if err := c.ShouldBindQuery(¶ms); err != nil {
|
|
c.JSON(http.StatusBadRequest, apitypes.Error("invalid request", err))
|
|
return
|
|
}
|
|
overrides := homepage.GetOverrideConfig()
|
|
overrides.IncrementItemClicks(params.Which)
|
|
c.JSON(http.StatusOK, apitypes.Success("success"))
|
|
}
|