瀏覽代碼

feat:break_data 字段拆分

fuwencai 1 年之前
父節點
當前提交
cdc24a9a73
共有 3 個文件被更改,包括 39 次插入29 次删除
  1. 26 26
      api/hello/v1/personnel.go
  2. 12 1
      internal/controller/personnel/personnel.go
  3. 1 2
      test.http

+ 26 - 26
api/hello/v1/personnel.go

@@ -4,30 +4,30 @@ import "github.com/gogf/gf/v2/frame/g"
 
 type PersonnelInsertReq struct {
 	g.Meta          `path:"/statistics" tags:"contract" method:"post" summary:"insert records"`
-	ActionId        string `json:"action_id" dc:"事件ID"`
-	ActionType      string `json:"action_type" dc:"事件类型"`
-	BreakerId       string `json:"breaker_id" dc:"断点ID"`
-	BreakerName     string `json:"breaker_name" dc:"断点名称"`
-	OrderId         string `json:"order_id" dc:"订单编号"`
-	OrderTime       string `json:"order_time" dc:"下单时间"`
-	PayTime         string `json:"pay_time" dc:"支付时间"`
-	PayWay          string `json:"pay_way" dc:"支付方式"`
-	Price           int    `json:"price" dc:"金额(元)"`
-	Product         string `json:"product" dc:"产品类型"`
-	ProductName     string `json:"product_name" dc:"产品类型名称"`
-	PageId          string `json:"page_id" dc:"页面ID"`
-	PageName        string `json:"page_name" dc:"页面名称"`
-	BiddingId       string `json:"bidding_id" dc:"详情页id"`
-	Desc            string `json:"desc" dc:"页面功能简述"`
-	Source          string `json:"source" dc:"来源名称"`
-	Url             string `json:"url" dc:"地址"`
-	ChainName       string `json:"chain_name" v:"required"  dc:"公链名称"`
-	Port            string `json:"port" `
-	Refer           string `json:"refer" dc:"跳转前页面"`
-	SearchWord      string `json:"search_word"  dc:"搜索词" `
-	Filter          string `json:"filter"  dc:"搜索条件"`
-	BreakData       string `json:"breakData"  dc:"额外数据"`
-	AppId           string `json:"appId"  dc:"appid"`
-	AppVersion      string `json:"appVersion"  dc:"版本号"`
-	MiniProgramCode string `json:"miniProgramCode"  dc:"来源"`
+	ActionId        string                 `json:"action_id" dc:"事件ID"`
+	ActionType      string                 `json:"action_type" dc:"事件类型"`
+	BreakerId       string                 `json:"breaker_id" dc:"断点ID"`
+	BreakerName     string                 `json:"breaker_name" dc:"断点名称"`
+	OrderId         string                 `json:"order_id" dc:"订单编号"`
+	OrderTime       string                 `json:"order_time" dc:"下单时间"`
+	PayTime         string                 `json:"pay_time" dc:"支付时间"`
+	PayWay          string                 `json:"pay_way" dc:"支付方式"`
+	Price           int                    `json:"price" dc:"金额(元)"`
+	Product         string                 `json:"product" dc:"产品类型"`
+	ProductName     string                 `json:"product_name" dc:"产品类型名称"`
+	PageId          string                 `json:"page_id" dc:"页面ID"`
+	PageName        string                 `json:"page_name" dc:"页面名称"`
+	BiddingId       string                 `json:"bidding_id" dc:"详情页id"`
+	Desc            string                 `json:"desc" dc:"页面功能简述"`
+	Source          string                 `json:"source" dc:"来源名称"`
+	Url             string                 `json:"url" dc:"地址"`
+	ChainName       string                 `json:"chain_name" v:"required"  dc:"公链名称"`
+	Port            string                 `json:"port" `
+	Refer           string                 `json:"refer" dc:"跳转前页面"`
+	SearchWord      string                 `json:"search_word"  dc:"搜索词" `
+	Filter          string                 `json:"filter"  dc:"搜索条件"`
+	BreakData       map[string]interface{} `json:"breakData"  dc:"额外数据"`
+	AppId           string                 `json:"appId"  dc:"appid"`
+	AppVersion      string                 `json:"appVersion"  dc:"版本号"`
+	MiniProgramCode string                 `json:"miniProgramCode"  dc:"来源"`
 }

+ 12 - 1
internal/controller/personnel/personnel.go

@@ -3,6 +3,7 @@ package personnel
 import (
 	"app.yhyue.com/moapp/jybase/common"
 	"context"
+	"encoding/json"
 	"github.com/gogf/gf/v2/frame/g"
 	v1 "personnelBehavior/api/hello/v1"
 	"personnelBehavior/internal/model"
@@ -39,7 +40,17 @@ func (p *personnel) Statistics(ctx context.Context, req *v1.PersonnelInsertReq)
 	in.Source = common.If(req.Source == "undefined", "", req.Source).(string)
 	in.Url = common.If(req.Url == "undefined", "", req.Url).(string)
 	in.AppId = common.If(req.AppId == "undefined", "", req.AppId).(string)
-	in.BreakData = common.If(req.BreakData == "undefined", "", req.BreakData).(string)
+	if req.BreakData != nil && len(req.BreakData) > 0 {
+		// 处理page_name 和product_name
+		if pageName, ok := req.BreakData["page_name"]; ok && pageName != "" && pageName != "undefined" && in.PageName == "" {
+			in.PageName = common.InterfaceToStr(pageName)
+		}
+		if productName, ok := req.BreakData["product_name"]; ok && productName != "" && productName != "undefined" && in.ProductName == "" {
+			in.ProductName = common.InterfaceToStr(productName)
+		}
+		breakData, _ := json.Marshal(req.BreakData)
+		in.BreakData = string(breakData)
+	}
 	in.AppVersion = common.If(req.AppVersion == "undefined", "", req.AppVersion).(string)
 
 	sessionGet, err := model.UserSessionCtx.Get(ctx)

+ 1 - 2
test.http

@@ -1,4 +1,4 @@
-POST  https://jybx2-webtest.jydev.jianyu360.com/personnel/statistics
+POST  http://127.0.0.1:7072/personnel/statistics
 Content-Type: application/json
 Apikey: HhYvHgAGQV9fWxEDLw8HFw==
 pageReferrer: 1111
@@ -11,7 +11,6 @@ pageReferrer: 1111
   "appId": "aaaaaidtest",
   "appVersion": "aaatest",
   "miniProgramCode": "testm"
-
 }
 
 ###