gomod引用

This commit is contained in:
2025-12-19 09:42:39 +08:00
parent 0814c6c819
commit ed0e384907
33 changed files with 723 additions and 3123 deletions

View File

@@ -6,18 +6,21 @@ import (
const CidRequestCollection = "cid_request"
// CidRequest CID请求实体
// CidRequest CID请求实体(合并后的统一版本)
type CidRequest struct {
do.MongoBaseDO `bson:",inline"` // 嵌入基础字段Id, Creator, CreatedAt, Updater, UpdatedAt, IsDeleted
UserID string `bson:"userId" json:"userId"`
// 请求信息
do.MongoBaseDO `bson:",inline" json:",inline"` // 嵌入基础字段Id, Creator, CreatedAt, Updater, UpdatedAt, IsDeleted
// 请求基础信息
RequestID string `bson:"requestId" json:"requestId"` // 请求唯一ID
SessionID string `bson:"sessionId" json:"sessionId"` // 会话ID
UserID string `bson:"userId" json:"userId"` // 用户ID
// 网络信息
IPAddress string `bson:"ipAddress" json:"ipAddress"` // IP地址
UserAgent string `bson:"userAgent" json:"userAgent"` // 用户代理
Referer string `bson:"referer" json:"referer"` // 来源页面
// 广告位信息
// 广告位信息(使用内联结构)
PositionCode string `bson:"positionCode" json:"positionCode"` // 广告位编码
PositionSize string `bson:"positionSize" json:"positionSize"` // 广告位尺寸
PositionFormat string `bson:"positionFormat" json:"positionFormat"` // 广告位格式
@@ -30,15 +33,17 @@ type CidRequest struct {
PageKeywords []string `bson:"pageKeywords" json:"pageKeywords"` // 页面关键词
PageTags map[string]string `bson:"pageTags" json:"pageTags"` // 页面标签
// 用户信息
UserContext *UserContext `bson:"userContext" json:"userContext"` // 用户上下文
DeviceInfo *DeviceInfo `bson:"deviceInfo" json:"deviceInfo"` // 设备信息
LocationInfo *LocationInfo `bson:"locationInfo" json:"locationInfo"` // 位置信息
TemporalInfo *TemporalInfo `bson:"temporalInfo" json:"temporalInfo"` // 时间信息
// 用户上下文信息(使用统一版本)
UserContext *UnifiedUserContext `bson:"userContext" json:"userContext"` // 用户上下文
DeviceInfo *DeviceInfo `bson:"deviceInfo" json:"deviceInfo"` // 设备信息
LocationInfo *UnifiedLocationInfo `bson:"locationInfo" json:"locationInfo"` // 位置信息
TemporalInfo *UnifiedTemporalInfo `bson:"temporalInfo" json:"temporalInfo"` // 时间信息
// 请求参数
RequestParams *RequestParams `bson:"requestParams" json:"requestParams"` // 请求参数
TargetingRules *TargetingRules `bson:"targetingRules" json:"targetingRules"` // 定向规则
// 请求参数(使用合并版本)
RequestParams *RequestParams `bson:"requestParams" json:"requestParams"` // 请求参数
// 定向规则(使用统一的定向结构)
TargetingRules *UnifiedTargeting `bson:"targetingRules" json:"targetingRules"` // 定向规则
// 策略配置
StrategyConfig *StrategyConfig `bson:"strategyConfig" json:"strategyConfig"` // 策略配置
@@ -70,14 +75,111 @@ type CidRequest struct {
Version string `bson:"version" json:"version"` // 系统版本
}
// CidResponse CID响应
// GetCollectionName 获取集合名称
func (c *CidRequest) GetCollectionName() string {
return CidRequestCollection
}
// UnifiedUserContext 统一的用户上下文
type UnifiedUserContext struct {
UserID string `bson:"userId" json:"userId"` // 用户ID
SessionID string `bson:"sessionId" json:"sessionId"` // 会话ID
CookieID string `bson:"cookieId" json:"cookieId"` // Cookie ID
IP string `bson:"ip" json:"ip"` // IP地址
UserAgent string `bson:"userAgent" json:"userAgent"` // 用户代理
Language string `bson:"language" json:"language"` // 语言
Timezone string `bson:"timezone" json:"timezone"` // 时区
CustomData map[string]interface{} `bson:"customData" json:"customData"` // 自定义数据
}
// UnifiedLocationInfo 统一的位置信息
type UnifiedLocationInfo struct {
Country string `bson:"country" json:"country"` // 国家
Region string `bson:"region" json:"region"` // 地区/省份
City string `bson:"city" json:"city"` // 城市
PostalCode string `bson:"postalCode" json:"postalCode"` // 邮政编码
Latitude float64 `bson:"latitude" json:"latitude"` // 纬度
Longitude float64 `bson:"longitude" json:"longitude"` // 经度
Timezone string `bson:"timezone" json:"timezone"` // 时区
Metro string `bson:"metro" json:"metro"` // 都市区
Area string `bson:"area" json:"area"` // 区域
Network string `bson:"network" json:"network"` // 网络运营商
ConnectionType string `bson:"connectionType" json:"connectionType"` // 连接类型
ISP string `bson:"isp" json:"isp"` // 互联网服务提供商
}
// UnifiedTemporalInfo 统一的时间信息
type UnifiedTemporalInfo struct {
Timestamp int64 `bson:"timestamp" json:"timestamp"` // 时间戳(秒)
Milliseconds int64 `bson:"milliseconds" json:"milliseconds"` // 毫秒数
Timezone string `bson:"timezone" json:"timezone"` // 时区
DayOfWeek int `bson:"dayOfWeek" json:"dayOfWeek"` // 星期几(0-6)
HourOfDay int `bson:"hourOfDay" json:"hourOfDay"` // 小时(0-23)
DayOfMonth int `bson:"dayOfMonth" json:"dayOfMonth"` // 月份中的天数
Month int `bson:"month" json:"month"` // 月份(1-12)
Year int `bson:"year" json:"year"` // 年份
IsWeekend bool `bson:"isWeekend" json:"isWeekend"` // 是否周末
IsBusinessHours bool `bson:"isBusinessHours" json:"isBusinessHours"` // 是否营业时间
Season string `bson:"season" json:"season"` // 季节
Holiday string `bson:"holiday" json:"holiday"` // 节假日
}
// DeviceInfo 设备信息
type DeviceInfo struct {
Type string `bson:"type" json:"type"` // 设备类型desktop、mobile、tablet
Brand string `bson:"brand" json:"brand"` // 设备品牌
Model string `bson:"model" json:"model"` // 设备型号
OS string `bson:"os" json:"os"` // 操作系统
OSVersion string `bson:"osVersion" json:"osVersion"` // 操作系统版本
Browser string `bson:"browser" json:"browser"` // 浏览器
BrowserVersion string `bson:"browserVersion" json:"browserVersion"` // 浏览器版本
ScreenWidth int `bson:"screenWidth" json:"screenWidth"` // 屏幕宽度
ScreenHeight int `bson:"screenHeight" json:"screenHeight"` // 屏幕高度
ViewportWidth int `bson:"viewportWidth" json:"viewportWidth"` // 视口宽度
ViewportHeight int `bson:"viewportHeight" json:"viewportHeight"` // 视口高度
DPI int `bson:"dpi" json:"dpi"` // 设备DPI
IsJavaScript bool `bson:"isJavaScript" json:"isJavaScript"` // 是否支持JavaScript
IsCookie bool `bson:"isCookie" json:"isCookie"` // 是否支持Cookie
IsFlash bool `bson:"isFlash" json:"isFlash"` // 是否支持Flash
IsHTTPS bool `bson:"isHTTPS" json:"isHTTPS"` // 是否HTTPS连接
}
// RequestParams 请求参数(合并版本)
type RequestParams struct {
AdCount int `bson:"adCount" json:"adCount"` // 请求的广告数量
AdTypes []string `bson:"adTypes" json:"adTypes"` // 广告类型
AdSizes []string `bson:"adSizes" json:"adSizes"` // 广告尺寸
ExcludedAdSources []string `bson:"excludedAdSources" json:"excludedAdSources"` // 排除的广告源
RequiredAdSources []string `bson:"requiredAdSources" json:"requiredAdSources"` // 必需的广告源
MinBidAmount int64 `bson:"minBidAmount" json:"minBidAmount"` // 最小出价(分)
MaxBidAmount int64 `bson:"maxBidAmount" json:"maxBidAmount"` // 最大出价(分)
AllowDuplicates bool `bson:"allowDuplicates" json:"allowDuplicates"` // 是否允许重复广告
FloorPrice int64 `bson:"floorPrice" json:"floorPrice"` // 底价(分)
CeilingPrice int64 `bson:"ceilingPrice" json:"ceilingPrice"` // 封顶价(分)
CustomParams map[string]interface{} `bson:"customParams" json:"customParams"` // 自定义参数
}
// StrategyConfig 策略配置(合并版本)
type StrategyConfig struct {
StrategyType string `bson:"strategyType" json:"strategyType"` // 策略类型
Priority int `bson:"priority" json:"priority"` // 优先级
Weight float64 `bson:"weight" json:"weight"` // 权重
MinAds int `bson:"minAds" json:"minAds"` // 最小广告数
MaxAds int `bson:"maxAds" json:"maxAds"` // 最大广告数
AllowDuplicates bool `bson:"allowDuplicates" json:"allowDuplicates"` // 是否允许重复
Timeout int64 `bson:"timeout" json:"timeout"` // 超时时间(毫秒)
RetryCount int `bson:"retryCount" json:"retryCount"` // 重试次数
CustomSettings map[string]interface{} `bson:"customSettings" json:"customSettings"` // 自定义设置
}
// CidResponse CID响应合并版本
type CidResponse struct {
Ads []Ad `bson:"ads" json:"ads"` // 广告列表
TrackingInfo *TrackingInfo `bson:"trackingInfo" json:"trackingInfo"` // 跟踪信息
Metadata *ResponseMetadata `bson:"metadata" json:"metadata"` // 响应元数据
}
// Ad 广告
// Ad 广告结构(合并版本)
type Ad struct {
ID string `bson:"id" json:"id"` // 广告ID
AdSource string `bson:"adSource" json:"adSource"` // 广告源
@@ -105,7 +207,7 @@ type Ad struct {
Score float64 `bson:"score" json:"score"` // 评分
}
// TrackingInfo 跟踪信息
// TrackingInfo 跟踪信息(合并版本)
type TrackingInfo struct {
ImpressionURLs []string `bson:"impressionUrls" json:"impressionUrls"` // 展示跟踪URL
ClickURLs []string `bson:"clickUrls" json:"clickUrls"` // 点击跟踪URL
@@ -115,7 +217,7 @@ type TrackingInfo struct {
BeaconURLs []string `bson:"beaconUrls" json:"beaconUrls"` // 信标URL
}
// ResponseMetadata 响应元数据
// ResponseMetadata 响应元数据(合并版本)
type ResponseMetadata struct {
TotalAvailableAds int `bson:"totalAvailableAds" json:"totalAvailableAds"` // 总可用广告数
SelectedAds int `bson:"selectedAds" json:"selectedAds"` // 选择的广告数
@@ -132,7 +234,7 @@ type ResponseMetadata struct {
AdSourcesUsed []string `bson:"adSourcesUsed" json:"adSourcesUsed"` // 使用的广告源
}
// AdSourceResponse 广告源响应
// AdSourceResponse 广告源响应(合并版本)
type AdSourceResponse struct {
AdSource string `bson:"adSource" json:"adSource"` // 广告源名称
Status string `bson:"status" json:"status"` // 响应状态success、timeout、error
@@ -147,164 +249,3 @@ type AdSourceResponse struct {
TotalRevenue int64 `bson:"totalRevenue" json:"totalRevenue"` // 总收入(分)
AverageBidAmount int64 `bson:"averageBidAmount" json:"averageBidAmount"` // 平均出价(分)
}
// UserContext 用户上下文
type UserContext struct {
UserID string `bson:"userId" json:"userId"` // 用户ID
SessionID string `bson:"sessionId" json:"sessionId"` // 会话ID
CookieID string `bson:"cookieId" json:"cookieId"` // Cookie ID
IP string `bson:"ip" json:"ip"` // IP地址
UserAgent string `bson:"userAgent" json:"userAgent"` // 用户代理
Language string `bson:"language" json:"language"` // 语言
Timezone string `bson:"timezone" json:"timezone"` // 时区
CustomData map[string]interface{} `bson:"customData" json:"customData"` // 自定义数据
}
// DeviceInfo 设备信息
type DeviceInfo struct {
Type string `bson:"type" json:"type"` // 设备类型desktop、mobile、tablet
Brand string `bson:"brand" json:"brand"` // 设备品牌
Model string `bson:"model" json:"model"` // 设备型号
OS string `bson:"os" json:"os"` // 操作系统
OSVersion string `bson:"osVersion" json:"osVersion"` // 操作系统版本
Browser string `bson:"browser" json:"browser"` // 浏览器
BrowserVersion string `bson:"browserVersion" json:"browserVersion"` // 浏览器版本
ScreenWidth int `bson:"screenWidth" json:"screenWidth"` // 屏幕宽度
ScreenHeight int `bson:"screenHeight" json:"screenHeight"` // 屏幕高度
ViewportWidth int `bson:"viewportWidth" json:"viewportWidth"` // 视口宽度
ViewportHeight int `bson:"viewportHeight" json:"viewportHeight"` // 视口高度
DPI int `bson:"dpi" json:"dpi"` // 设备DPI
IsJavaScript bool `bson:"isJavaScript" json:"isJavaScript"` // 是否支持JavaScript
IsCookie bool `bson:"isCookie" json:"isCookie"` // 是否支持Cookie
IsFlash bool `bson:"isFlash" json:"isFlash"` // 是否支持Flash
IsHTTPS bool `bson:"isHTTPS" json:"isHTTPS"` // 是否HTTPS连接
}
// LocationInfo 位置信息
type LocationInfo struct {
Country string `bson:"country" json:"country"` // 国家
Region string `bson:"region" json:"region"` // 地区/省份
City string `bson:"city" json:"city"` // 城市
PostalCode string `bson:"postalCode" json:"postalCode"` // 邮政编码
Latitude float64 `bson:"latitude" json:"latitude"` // 纬度
Longitude float64 `bson:"longitude" json:"longitude"` // 经度
Timezone string `bson:"timezone" json:"timezone"` // 时区
Metro string `bson:"metro" json:"metro"` // 都市区
Area string `bson:"area" json:"area"` // 区域
Network string `bson:"network" json:"network"` // 网络运营商
ConnectionType string `bson:"connectionType" json:"connectionType"` // 连接类型
ISP string `bson:"isp" json:"isp"` // 互联网服务提供商
}
// TemporalInfo 时间信息
type TemporalInfo struct {
Timestamp int64 `bson:"timestamp" json:"timestamp"` // 时间戳(秒)
Milliseconds int64 `bson:"milliseconds" json:"milliseconds"` // 毫秒数
Timezone string `bson:"timezone" json:"timezone"` // 时区
DayOfWeek int `bson:"dayOfWeek" json:"dayOfWeek"` // 星期几(0-6)
HourOfDay int `bson:"hourOfDay" json:"hourOfDay"` // 小时(0-23)
DayOfMonth int `bson:"dayOfMonth" json:"dayOfMonth"` // 月份中的天数
Month int `bson:"month" json:"month"` // 月份(1-12)
Year int `bson:"year" json:"year"` // 年份
IsWeekend bool `bson:"isWeekend" json:"isWeekend"` // 是否周末
IsBusinessHours bool `bson:"isBusinessHours" json:"isBusinessHours"` // 是否营业时间
Season string `bson:"season" json:"season"` // 季节
Holiday string `bson:"holiday" json:"holiday"` // 节假日
}
// RequestParams 请求参数
type RequestParams struct {
AdCount int `bson:"adCount" json:"adCount"` // 请求的广告数量
AdTypes []string `bson:"adTypes" json:"adTypes"` // 广告类型
AdSizes []string `bson:"adSizes" json:"adSizes"` // 广告尺寸
ExcludedAdSources []string `bson:"excludedAdSources" json:"excludedAdSources"` // 排除的广告源
RequiredAdSources []string `bson:"requiredAdSources" json:"requiredAdSources"` // 必需的广告源
MinBidAmount int64 `bson:"minBidAmount" json:"minBidAmount"` // 最小出价(分)
MaxBidAmount int64 `bson:"maxBidAmount" json:"maxBidAmount"` // 最大出价(分)
AllowDuplicates bool `bson:"allowDuplicates" json:"allowDuplicates"` // 是否允许重复广告
FloorPrice int64 `bson:"floorPrice" json:"floorPrice"` // 底价(分)
CeilingPrice int64 `bson:"ceilingPrice" json:"ceilingPrice"` // 封顶价(分)
CustomParams map[string]interface{} `bson:"customParams" json:"customParams"` // 自定义参数
}
// TargetingRules 定向规则
type TargetingRules struct {
GeoTargeting *GeoTargeting `bson:"geoTargeting" json:"geoTargeting"` // 地理定向
DemographicTargeting *DemographicTargeting `bson:"demographicTargeting" json:"demographicTargeting"` // 人口统计定向
BehavioralTargeting *BehavioralTargeting `bson:"behavioralTargeting" json:"behavioralTargeting"` // 行为定向
ContextualTargeting *ContextualTargeting `bson:"contextualTargeting" json:"contextualTargeting"` // 上下文定向
DeviceTargeting *DeviceTargeting `bson:"deviceTargeting" json:"deviceTargeting"` // 设备定向
TimeTargeting *TimeTargeting `bson:"timeTargeting" json:"timeTargeting"` // 时间定向
CustomTargeting map[string]interface{} `bson:"customTargeting" json:"customTargeting"` // 自定义定向
}
// GeoTargeting 地理定向
type GeoTargeting struct {
Countries []string `bson:"countries" json:"countries"` // 国家列表
Regions []string `bson:"regions" json:"regions"` // 地区列表
Cities []string `bson:"cities" json:"cities"` // 城市列表
PostalCodes []string `bson:"postalCodes" json:"postalCodes"` // 邮政编码列表
GeoTargets []string `bson:"geoTargets" json:"geoTargets"` // 地理目标
}
// DemographicTargeting 人口统计定向
type DemographicTargeting struct {
AgeRange *AgeRange `bson:"ageRange" json:"ageRange"` // 年龄范围
Gender []string `bson:"gender" json:"gender"` // 性别
Income []string `bson:"income" json:"income"` // 收入水平
Education []string `bson:"education" json:"education"` // 教育程度
Occupation []string `bson:"occupation" json:"occupation"` // 职业类型
Interests []string `bson:"interests" json:"interests"` // 兴趣标签
Lifestyle []string `bson:"lifestyle" json:"lifestyle"` // 生活方式
}
// BehavioralTargeting 行为定向
type BehavioralTargeting struct {
SearchHistory []string `bson:"searchHistory" json:"searchHistory"` // 搜索历史
BrowseHistory []string `bson:"browseHistory" json:"browseHistory"` // 浏览历史
PurchaseHistory []string `bson:"purchaseHistory" json:"purchaseHistory"` // 购买历史
AdInteractions []string `bson:"adInteractions" json:"adInteractions"` // 广告互动
Behaviors []string `bson:"behaviors" json:"behaviors"` // 行为标签
Segments []string `bson:"segments" json:"segments"` // 用户分群
}
// ContextualTargeting 上下文定向
type ContextualTargeting struct {
Categories []string `bson:"categories" json:"categories"` // 内容分类
Keywords []string `bson:"keywords" json:"keywords"` // 关键词
Tags []string `bson:"tags" json:"tags"` // 标签
Sentiment string `bson:"sentiment" json:"sentiment"` // 情感倾向
ContentType string `bson:"contentType" json:"contentType"` // 内容类型
ContentRating string `bson:"contentRating" json:"contentRating"` // 内容评级
}
// DeviceTargeting 设备定向
type DeviceTargeting struct {
DeviceTypes []string `bson:"deviceTypes" json:"deviceTypes"` // 设备类型
OS []string `bson:"os" json:"os"` // 操作系统
Browsers []string `bson:"browsers" json:"browsers"` // 浏览器
Carriers []string `bson:"carriers" json:"carriers"` // 运营商
ConnectionTypes []string `bson:"connectionTypes" json:"connectionTypes"` // 连接类型
}
// TimeTargeting 时间定向
type TimeTargeting struct {
TimeSlots []TimeSlot `bson:"timeSlots" json:"timeSlots"` // 时间段
DaysOfWeek []int `bson:"daysOfWeek" json:"daysOfWeek"` // 星期几
Dates []string `bson:"dates" json:"dates"` // 日期范围
Timezone string `bson:"timezone" json:"timezone"` // 时区
ExcludeHolidays bool `bson:"excludeHolidays" json:"excludeHolidays"` // 排除节假日
}
// StrategyConfig 策略配置
type StrategyConfig struct {
StrategyType string `bson:"strategyType" json:"strategyType"` // 策略类型
Priority int `bson:"priority" json:"priority"` // 优先级
Weight float64 `bson:"weight" json:"weight"` // 权重
MinAds int `bson:"minAds" json:"minAds"` // 最小广告数
MaxAds int `bson:"maxAds" json:"maxAds"` // 最大广告数
AllowDuplicates bool `bson:"allowDuplicates" json:"allowDuplicates"` // 是否允许重复
Timeout int64 `bson:"timeout" json:"timeout"` // 超时时间(毫秒)
RetryCount int `bson:"retryCount" json:"retryCount"` // 重试次数
CustomSettings map[string]interface{} `bson:"customSettings" json:"customSettings"` // 自定义设置
}