From 3840d6038964e28b6668ecf4899fa2bafa8ec26d Mon Sep 17 00:00:00 2001 From: zhora Date: Fri, 10 Oct 2025 11:10:57 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E6=9D=83=E9=99=90?= =?UTF-8?q?=EF=BC=8C=E5=85=BC=E5=AE=B9=E6=97=A7fb=E4=B8=8A=E6=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/backend/handler/power/power.go | 10 ++++----- modules/web/handler/ad.go | 31 ++++++++++++++++++-------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/modules/backend/handler/power/power.go b/modules/backend/handler/power/power.go index c1ce0f3..0965e93 100644 --- a/modules/backend/handler/power/power.go +++ b/modules/backend/handler/power/power.go @@ -81,11 +81,11 @@ func EditUserPower(c *gin.Context) { a.Msg = "账户不存在" return } - if user.Role == values.UserRoleAdmin { - a.Code = values.CodeParam - a.Msg = "不可修改超级管理员" - return - } + //if user.Role == values.UserRoleAdmin { + // a.Code = values.CodeParam + // a.Msg = "不可修改超级管理员" + // return + //} update := map[string]interface{}{} if req.Power != nil { // if user.Power == *req.Power { diff --git a/modules/web/handler/ad.go b/modules/web/handler/ad.go index 519114d..3a68e33 100644 --- a/modules/web/handler/ad.go +++ b/modules/web/handler/ad.go @@ -11,9 +11,9 @@ import ( // UploadFBReq 上报fb数据 type UploadFBReq struct { - ChannelID int `json:"ChannelID" binding:"required"` - FBC string `json:"FBC" binding:"required"` - FBP string `json:"FBP" binding:"required"` + ChannelID int `json:"ChannelID"` + FBC string `json:"FBC"` + FBP string `json:"FBP"` } func UploadFB(c *gin.Context) { @@ -21,15 +21,28 @@ func UploadFB(c *gin.Context) { defer func() { a.Response() }() - // req := new(UploadFBReq) - // if !a.S(req) { - // return - // } + 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") - log.Debug("upload FB fbc:%v,fbp:%v,ip:%v,user-agent:%v", fbc, fbp, ip, ua) + 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 } @@ -38,7 +51,7 @@ func UploadFB(c *gin.Context) { return } - pa := &common.PlayerADData{IP: ip, ChannelID: a.Channel, FBC: fbc, FBP: fbp} + pa := &common.PlayerADData{IP: ip, ChannelID: channelId, FBC: fbc, FBP: fbp} db.Mysql().Get(pa) if pa.ID > 0 { return