Files
web_huangguo_web/app/service/configser/ads_click.go
T
2026-10-29 16:39:28 +07:00

35 lines
906 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package configser
import (
"fmt"
"videoweb/app/service/upstream"
"github.com/gin-gonic/gin"
)
const (
adsClickPath = "/api/app/ads/click"
// AdsClickAppID 广告点击上报的应用 ID,由广告后台分配,固定为 12。
AdsClickAppID int64 = 12
)
// AdsClickReq 对应上游 POST /api/app/ads/click(appId / adsId / location 均必填)。
type AdsClickReq struct {
AppID int64 `json:"appId"`
AdsID int64 `json:"adsId"`
Location int64 `json:"location"`
}
// AdsClick 上报一次广告点击。
func AdsClick(c *gin.Context, req AdsClickReq) (*APIEnvelope[any], error) {
if req.AdsID <= 0 || req.Location <= 0 {
return nil, fmt.Errorf("ads click invalid adsId=%d location=%d", req.AdsID, req.Location)
}
req.AppID = AdsClickAppID
var env APIEnvelope[any]
if _, err := upstream.PostJSON(c, adsClickPath, req, &env); err != nil {
return nil, err
}
return &env, nil
}