广告点击添加
This commit is contained in:
@@ -97,6 +97,20 @@ func buildAdvertisementList(list []Advertisement) []Advertisement {
|
||||
return out
|
||||
}
|
||||
|
||||
// ClickID 广告点击上报用的数字 ID(上游下发为数字字符串);非正整数时返回 0。
|
||||
func (a Advertisement) ClickID() int64 {
|
||||
id, err := strconv.ParseInt(strings.TrimSpace(a.ID), 10, 64)
|
||||
if err != nil || id <= 0 {
|
||||
return 0
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// ClickTrackable 广告 ID 与广告位均有效时才输出点击上报数据(data-ads-id / data-ads-location)。
|
||||
func (a Advertisement) ClickTrackable() bool {
|
||||
return a.ClickID() > 0 && a.Location > 0
|
||||
}
|
||||
|
||||
// firstAdvertisementList 返回第一个有可用广告的列表(按字段优先级)。
|
||||
func firstAdvertisementList(lists ...[]Advertisement) []Advertisement {
|
||||
for _, list := range lists {
|
||||
|
||||
Reference in New Issue
Block a user