广告点击添加
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package adsser
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"videoweb/app/service/upstream"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
const clickPath = "/api/app/ads/click"
|
||||
|
||||
// ClickAppID 广告点击上报固定 appId。
|
||||
const ClickAppID int64 = 12
|
||||
|
||||
// ClickReq 对应上游 AdsClickInfo:appId / adsId / location 均必填。
|
||||
type ClickReq struct {
|
||||
AppId int64 `json:"appId"`
|
||||
AdsId int64 `json:"adsId"`
|
||||
Location int64 `json:"location"`
|
||||
}
|
||||
|
||||
// APIEnvelope 上游通用响应。
|
||||
type APIEnvelope struct {
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Tip string `json:"tip"`
|
||||
Data json.RawMessage `json:"data"`
|
||||
}
|
||||
|
||||
// Click 调用上游上报广告点击。
|
||||
func Click(c *gin.Context, req ClickReq) (*APIEnvelope, error) {
|
||||
var env APIEnvelope
|
||||
if _, err := upstream.PostJSON(c, clickPath, req, &env); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &env, nil
|
||||
}
|
||||
Reference in New Issue
Block a user