广告添加
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user