You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.2 KiB
61 lines
1.2 KiB
package handler |
|
|
|
import ( |
|
"server/common" |
|
"server/db" |
|
"server/modules/web/app" |
|
|
|
"github.com/gin-gonic/gin" |
|
"github.com/liangdas/mqant/log" |
|
) |
|
|
|
// UploadFBReq 上报fb数据 |
|
type UploadFBReq struct { |
|
ChannelID int `json:"ChannelID"` |
|
FBC string `json:"FBC"` |
|
FBP string `json:"FBP"` |
|
} |
|
|
|
func UploadFB(c *gin.Context) { |
|
a := app.NewApp(c) |
|
defer func() { |
|
a.Response() |
|
}() |
|
req := new(UploadFBReq) |
|
// 兼容旧方式,检查是否有请求体,如果没有则跳过参数校验 |
|
if c.Request.ContentLength > 0 { |
|
if !a.S(req) { |
|
return |
|
} |
|
} |
|
ip := a.GetRemoteIP() |
|
ua := c.Request.Header.Get("User-Agent") |
|
fbc := c.Request.Header.Get("fbc") |
|
fbp := c.Request.Header.Get("fbp") |
|
channelId := a.Channel |
|
if fbc == "" { |
|
fbc = req.FBC |
|
} |
|
if fbp == "" { |
|
fbp = req.FBP |
|
} |
|
if req.ChannelID != 0 { |
|
channelId = req.ChannelID |
|
} |
|
log.Debug("upload FB channel:%d, fbc:%v,fbp:%v,ip:%v,user-agent:%v", channelId, fbc, fbp, ip, ua) |
|
if ip == "" { |
|
return |
|
} |
|
|
|
if fbc == "" && fbp == "" { |
|
return |
|
} |
|
|
|
pa := &common.PlayerADData{IP: ip, ChannelID: channelId, FBC: fbc, FBP: fbp} |
|
db.Mysql().Get(pa) |
|
if pa.ID > 0 { |
|
return |
|
} |
|
pa.UserAgent = ua |
|
db.Mysql().Create(pa) |
|
}
|
|
|