Files
cid/model/entity/cid_request.go

252 lines
17 KiB
Go
Raw Normal View History

2025-12-06 10:38:48 +08:00
package entity
import (
"gitee.com/red-future---jilin-g/common/do"
)
const CidRequestCollection = "cid_request"
2025-12-19 09:42:39 +08:00
// CidRequest CID请求实体合并后的统一版本
2025-12-06 10:38:48 +08:00
type CidRequest struct {
2025-12-19 09:42:39 +08:00
do.MongoBaseDO `bson:",inline" json:",inline"` // 嵌入基础字段Id, Creator, CreatedAt, Updater, UpdatedAt, IsDeleted
// 请求基础信息
2025-12-06 10:38:48 +08:00
RequestID string `bson:"requestId" json:"requestId"` // 请求唯一ID
SessionID string `bson:"sessionId" json:"sessionId"` // 会话ID
2025-12-19 09:42:39 +08:00
UserID string `bson:"userId" json:"userId"` // 用户ID
// 网络信息
2025-12-06 10:38:48 +08:00
IPAddress string `bson:"ipAddress" json:"ipAddress"` // IP地址
UserAgent string `bson:"userAgent" json:"userAgent"` // 用户代理
Referer string `bson:"referer" json:"referer"` // 来源页面
2025-12-19 09:42:39 +08:00
// 广告位信息(使用内联结构)
2025-12-06 10:38:48 +08:00
PositionCode string `bson:"positionCode" json:"positionCode"` // 广告位编码
PositionSize string `bson:"positionSize" json:"positionSize"` // 广告位尺寸
PositionFormat string `bson:"positionFormat" json:"positionFormat"` // 广告位格式
PositionType string `bson:"positionType" json:"positionType"` // 广告位类型
// 页面信息
PageURL string `bson:"pageUrl" json:"pageUrl"` // 页面URL
PageTitle string `bson:"pageTitle" json:"pageTitle"` // 页面标题
PageCategory string `bson:"pageCategory" json:"pageCategory"` // 页面分类
PageKeywords []string `bson:"pageKeywords" json:"pageKeywords"` // 页面关键词
PageTags map[string]string `bson:"pageTags" json:"pageTags"` // 页面标签
2025-12-19 09:42:39 +08:00
// 用户上下文信息(使用统一版本)
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"` // 请求参数
2025-12-06 10:38:48 +08:00
2025-12-19 09:42:39 +08:00
// 定向规则(使用统一的定向结构)
TargetingRules *UnifiedTargeting `bson:"targetingRules" json:"targetingRules"` // 定向规则
2025-12-06 10:38:48 +08:00
// 策略配置
StrategyConfig *StrategyConfig `bson:"strategyConfig" json:"strategyConfig"` // 策略配置
// 响应信息
Response *CidResponse `bson:"response" json:"response"` // 响应结果
ProcessingTime int64 `bson:"processingTime" json:"processingTime"` // 处理时间(毫秒)
ResponseTime int64 `bson:"responseTime" json:"responseTime"` // 响应时间(毫秒)
// 状态信息
Status string `bson:"status" json:"status"` // 请求状态pending、processing、completed、failed、timeout
ErrorMessage string `bson:"errorMessage" json:"errorMessage"` // 错误信息
ErrorCode string `bson:"errorCode" json:"errorCode"` // 错误代码
// 广告源信息
RequestedAdSources []string `bson:"requestedAdSources" json:"requestedAdSources"` // 请求的广告源列表
RespondedAdSources []string `bson:"respondedAdSources" json:"respondedAdSources"` // 响应的广告源列表
AdSourceResponses map[string]*AdSourceResponse `bson:"adSourceResponses" json:"adSourceResponses"` // 各广告源响应
// 统计信息
TotalAdsReturned int `bson:"totalAdsReturned" json:"totalAdsReturned"` // 返回的广告总数
ValidAdsReturned int `bson:"validAdsReturned" json:"validAdsReturned"` // 有效广告数
FilteredAds int `bson:"filteredAds" json:"filteredAds"` // 过滤的广告数
DuplicateAds int `bson:"duplicateAds" json:"duplicateAds"` // 重复广告数
// 系统信息
ServerInstance string `bson:"serverInstance" json:"serverInstance"` // 服务实例ID
Region string `bson:"region" json:"region"` // 服务区域
Version string `bson:"version" json:"version"` // 系统版本
}
2025-12-19 09:42:39 +08:00
// 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响应合并版本
2025-12-06 10:38:48 +08:00
type CidResponse struct {
Ads []Ad `bson:"ads" json:"ads"` // 广告列表
TrackingInfo *TrackingInfo `bson:"trackingInfo" json:"trackingInfo"` // 跟踪信息
Metadata *ResponseMetadata `bson:"metadata" json:"metadata"` // 响应元数据
}
2025-12-19 09:42:39 +08:00
// Ad 广告结构(合并版本)
2025-12-06 10:38:48 +08:00
type Ad struct {
ID string `bson:"id" json:"id"` // 广告ID
AdSource string `bson:"adSource" json:"adSource"` // 广告源
Advertiser string `bson:"advertiser" json:"advertiser"` // 广告主
Title string `bson:"title" json:"title"` // 广告标题
Description string `bson:"description" json:"description"` // 广告描述
CreativeURL string `bson:"creativeUrl" json:"creativeUrl"` // 创意URL
LandingURL string `bson:"landingUrl" json:"landingUrl"` // 落地页URL
DisplayURL string `bson:"displayUrl" json:"displayUrl"` // 显示URL
AdType string `bson:"adType" json:"adType"` // 广告类型
Format string `bson:"format" json:"format"` // 广告格式
Width int `bson:"width" json:"width"` // 宽度
Height int `bson:"height" json:"height"` // 高度
MimeType string `bson:"mimeType" json:"mimeType"` // MIME类型
BidAmount int64 `bson:"bidAmount" json:"bidAmount"` // 出价(分)
Revenue int64 `bson:"revenue" json:"revenue"` // 预估收入(分)
CTR float64 `bson:"ctr" json:"ctr"` // 点击率
CVR float64 `bson:"cvr" json:"cvr"` // 转化率
Targeting map[string]interface{} `bson:"targeting" json:"targeting"` // 定向条件
Restrictions map[string]interface{} `bson:"restrictions" json:"restrictions"` // 限制条件
TrackingPixels []string `bson:"trackingPixels" json:"trackingPixels"` // 跟踪像素
CustomData map[string]interface{} `bson:"customData" json:"customData"` // 自定义数据
ExpiresAt int64 `bson:"expiresAt" json:"expiresAt"` // 过期时间
Priority int `bson:"priority" json:"priority"` // 优先级
Score float64 `bson:"score" json:"score"` // 评分
}
2025-12-19 09:42:39 +08:00
// TrackingInfo 跟踪信息(合并版本)
2025-12-06 10:38:48 +08:00
type TrackingInfo struct {
ImpressionURLs []string `bson:"impressionUrls" json:"impressionUrls"` // 展示跟踪URL
ClickURLs []string `bson:"clickUrls" json:"clickUrls"` // 点击跟踪URL
ConversionURLs []string `bson:"conversionUrls" json:"conversionUrls"` // 转化跟踪URL
ViewThroughURLs []string `bson:"viewThroughUrls" json:"viewThroughUrls"` // 查看跟踪URL
EventURLs map[string][]string `bson:"eventUrls" json:"eventUrls"` // 事件跟踪URL
BeaconURLs []string `bson:"beaconUrls" json:"beaconUrls"` // 信标URL
}
2025-12-19 09:42:39 +08:00
// ResponseMetadata 响应元数据(合并版本)
2025-12-06 10:38:48 +08:00
type ResponseMetadata struct {
TotalAvailableAds int `bson:"totalAvailableAds" json:"totalAvailableAds"` // 总可用广告数
SelectedAds int `bson:"selectedAds" json:"selectedAds"` // 选择的广告数
FilteredAds int `bson:"filteredAds" json:"filteredAds"` // 过滤的广告数
DuplicateAds int `bson:"duplicateAds" json:"duplicateAds"` // 重复的广告数
AverageBidAmount int64 `bson:"averageBidAmount" json:"averageBidAmount"` // 平均出价
HighestBidAmount int64 `bson:"highestBidAmount" json:"highestBidAmount"` // 最高出价
LowestBidAmount int64 `bson:"lowestBidAmount" json:"lowestBidAmount"` // 最低出价
AverageCTR float64 `bson:"averageCTR" json:"averageCTR"` // 平均点击率
AverageCVR float64 `bson:"averageCVR" json:"averageCVR"` // 平均转化率
ResponseTime int64 `bson:"responseTime" json:"responseTime"` // 响应时间(毫秒)
CacheHit bool `bson:"cacheHit" json:"cacheHit"` // 是否命中缓存
StrategyUsed string `bson:"strategyUsed" json:"strategyUsed"` // 使用的策略
AdSourcesUsed []string `bson:"adSourcesUsed" json:"adSourcesUsed"` // 使用的广告源
}
2025-12-19 09:42:39 +08:00
// AdSourceResponse 广告源响应(合并版本)
2025-12-06 10:38:48 +08:00
type AdSourceResponse struct {
AdSource string `bson:"adSource" json:"adSource"` // 广告源名称
Status string `bson:"status" json:"status"` // 响应状态success、timeout、error
ResponseTime int64 `bson:"responseTime" json:"responseTime"` // 响应时间(毫秒)
AdsReturned int `bson:"adsReturned" json:"adsReturned"` // 返回的广告数
AdsAccepted int `bson:"adsAccepted" json:"adsAccepted"` // 接受的广告数
AdsFiltered int `bson:"adsFiltered" json:"adsFiltered"` // 过滤的广告数
ErrorMessage string `bson:"errorMessage" json:"errorMessage"` // 错误信息
ErrorCode string `bson:"errorCode" json:"errorCode"` // 错误代码
RetryCount int `bson:"retryCount" json:"retryCount"` // 重试次数
CacheHit bool `bson:"cacheHit" json:"cacheHit"` // 是否命中缓存
TotalRevenue int64 `bson:"totalRevenue" json:"totalRevenue"` // 总收入(分)
AverageBidAmount int64 `bson:"averageBidAmount" json:"averageBidAmount"` // 平均出价(分)
}