diff --git a/enum/audienceStatus.go b/enum/audienceStatus.go new file mode 100644 index 0000000..54d3ca5 --- /dev/null +++ b/enum/audienceStatus.go @@ -0,0 +1,22 @@ +package enum + +// AudienceStatusEnum 类型 +type AudienceStatus Enum[int] + +func (e AudienceStatus) Values() []AudienceStatus { + return []AudienceStatus{ + {0, "基本属性"}, + {1, "自定义人群"}, + {1025, "已转化用户"}, + {2, "设备属性"}, + {4, "商圈地域"}, + } +} +func (e *AudienceStatus) UnmarshalJSON(b []byte) error { + v, err := UnmarshalJSON[int](b) + if err != nil { + return err + } + *e = AudienceStatus(v) + return nil +} diff --git a/enum/bsType.go b/enum/bsType.go new file mode 100644 index 0000000..92da6fa --- /dev/null +++ b/enum/bsType.go @@ -0,0 +1,21 @@ +package enum + +// BsType 该字段仅支持用于Filter中筛选数据使用。 +type BsType Enum[int] + +func (e BsType) Values() []BsType { + return []BsType{ + {1, "通报告"}, + {3, "商品报告"}, + {7, "信息流RTA"}, + } +} + +func (e *BsType) UnmarshalJSON(b []byte) error { + v, err := UnmarshalJSON[int](b) + if err != nil { + return err + } + *e = BsType(v) + return nil +} diff --git a/enum/deepConvertType.go b/enum/deepConvertType.go new file mode 100644 index 0000000..7653637 --- /dev/null +++ b/enum/deepConvertType.go @@ -0,0 +1,27 @@ +package enum + +// DeepConvertType 深度转化 +type DeepConvertType Enum[int] + +func (e DeepConvertType) Values() []DeepConvertType { + return []DeepConvertType{ + {10, "商品支付成功"}, + {25, "注册"}, + {26, "付费"}, + {27, "客户自定义"}, + {28, "次日留存"}, + {42, "授信"}, + {45, "商品下单成功"}, + {53, "订单核对成功"}, + {54, "收货成功"}, + } +} + +func (e *DeepConvertType) UnmarshalJSON(b []byte) error { + v, err := UnmarshalJSON[int](b) + if err != nil { + return err + } + *e = DeepConvertType(v) + return nil +} diff --git a/enum/device.go b/enum/device.go new file mode 100644 index 0000000..bd07aa3 --- /dev/null +++ b/enum/device.go @@ -0,0 +1,21 @@ +package enum + +// Device 推广设备 +type Device Enum[int] + +func (e Device) Values() []Device { + return []Device{ + {0, "计算机"}, + {1, "移动设备"}, + } +} + +// UnmarshalJSON implement json Unmarshal interface +func (e *Device) UnmarshalJSON(b []byte) error { + v, err := UnmarshalJSON[int](b) + if err != nil { + return err + } + *e = Device(v) + return nil +} diff --git a/enum/enum.go b/enum/enum.go new file mode 100644 index 0000000..6151b87 --- /dev/null +++ b/enum/enum.go @@ -0,0 +1,78 @@ +package enum + +import ( + "strconv" +) + +type Enum[T int | int64] struct { + key T + value string +} + +func EnumFromKey[T int | int64](key T) Enum[T] { + return Enum[T]{key: key} +} + +func (e Enum[T]) Key() T { + return e.key +} + +func (e Enum[T]) Value() string { + return e.value +} + +func (e Enum[T]) String() string { + return e.value +} + +func (e *Enum[T]) SetKey(key T) { + e.key = key +} + +func (e *Enum[T]) SetValue(value string) { + e.value = value +} + +func (e Enum[T]) Values() []Enum[T] { + return nil +} + +type IEnum[T int | int64] interface { + Values() []Enum[T] + Key() T + Value() string +} + +// UnmarshalJSON implement json Unmarshal interface +func UnmarshalJSON[T int | int64](b []byte) (Enum[T], error) { + if b[0] == '"' && b[len(b)-1] == '"' { + b = b[1 : len(b)-1] + } + str := string(b) + var x Enum[T] + values := x.Values() + var found bool + if i, err := strconv.ParseInt(str, 10, 64); err != nil { + for _, val := range values { + if val.Value() == str { + x = val + found = true + break + } + } + } else { + key := T(i) + for _, val := range values { + if val.Key() == key { + x = val + found = true + break + } + } + } + if !found { + (&x).SetKey(-1) + (&x).SetValue(str) + } + return x, nil +} diff --git a/enum/feedFlowType.go b/enum/feedFlowType.go new file mode 100644 index 0000000..ff65851 --- /dev/null +++ b/enum/feedFlowType.go @@ -0,0 +1,24 @@ +package enum + +// FeedFlowType +type FeedFlowType Enum[int] + +func (e FeedFlowType) Values() []FeedFlowType { + return []FeedFlowType{ + {1, "百度信息流"}, + {2, "贴吧"}, + {3, "好看视频"}, + {4, "百度小说"}, + {5, "百青藤"}, + {6, "默认"}, + } +} + +func (e *FeedFlowType) UnmarshalJSON(b []byte) error { + v, err := UnmarshalJSON[int](b) + if err != nil { + return err + } + *e = FeedFlowType(v) + return nil +} diff --git a/enum/feedMaterialStyle.go b/enum/feedMaterialStyle.go new file mode 100644 index 0000000..cc9e737 --- /dev/null +++ b/enum/feedMaterialStyle.go @@ -0,0 +1,31 @@ +package enum + +// FeedMaterialStyle 该字段仅支持用于Filter中筛选数据使用。 +type FeedMaterialStyle Enum[int] + +func (e FeedMaterialStyle) Values() []FeedMaterialStyle { + return []FeedMaterialStyle{ + {0, "全部"}, + {1, "单图"}, + {10, "互动图"}, + {100, "程序化"}, + {16, "开屏视频"}, + {2, "三图"}, + {20, "全部视频"}, + {3, "大图"}, + {5, "橱窗"}, + {6, "开屏图片"}, + {7, "横幅"}, + {8, "横版视频"}, + {9, "竖版视频"}, + } +} + +func (e *FeedMaterialStyle) UnmarshalJSON(b []byte) error { + v, err := UnmarshalJSON[int](b) + if err != nil { + return err + } + *e = FeedMaterialStyle(v) + return nil +} diff --git a/enum/feedSubject.go b/enum/feedSubject.go new file mode 100644 index 0000000..8ff1c94 --- /dev/null +++ b/enum/feedSubject.go @@ -0,0 +1,26 @@ +package enum + +// FeedSubjectEnum 该字段仅支持用于Filter中筛选数据使用。 +type FeedSubject Enum[int] + +func (e FeedSubject) Values() []FeedSubject { + return []FeedSubject{ + {0, "全部"}, + {1, "网站链接"}, + {2, "应用推广(ios)"}, + {3, "应用推广(android)"}, + {4, "小程序"}, + {5, "商品目录"}, + {6, "门店推广"}, + {7, "电商店铺"}, + } +} + +func (e *FeedSubject) UnmarshalJSON(b []byte) error { + v, err := UnmarshalJSON[int](b) + if err != nil { + return err + } + *e = FeedSubject(v) + return nil +} diff --git a/enum/marketingTarget.go b/enum/marketingTarget.go new file mode 100644 index 0000000..1bd7280 --- /dev/null +++ b/enum/marketingTarget.go @@ -0,0 +1,25 @@ +package enum + +// MarketingTarget 营销目标 +type MarketingTarget Enum[int] + +func (e MarketingTarget) Values() []MarketingTarget { + return []MarketingTarget{ + {0, "站链接"}, + {1, "应用推广"}, + {2, "门店推广"}, + {3, "推广营销活动"}, + {4, "电商店铺推广"}, + {5, "商品目录"}, + } +} + +// UnmarshalJSON implement json Unmarshal interface +func (e *MarketingTarget) UnmarshalJSON(b []byte) error { + v, err := UnmarshalJSON[int](b) + if err != nil { + return err + } + *e = MarketingTarget(v) + return nil +} diff --git a/enum/mixWmatch.go b/enum/mixWmatch.go new file mode 100644 index 0000000..7e5323e --- /dev/null +++ b/enum/mixWmatch.go @@ -0,0 +1,24 @@ +package enum + +// MixWmatchEnum 匹配模式 +type MixWmatch Enum[int] + +func (e MixWmatch) Values() []MixWmatch { + return []MixWmatch{ + {0, "智能匹配"}, + {127, "分匹配出价"}, + {16, "智能匹配核心词"}, + {17, "短语匹配"}, + {48, "精确匹配"}, + } +} + +// UnmarshalJSON implement json Unmarshal interface +func (e *MixWmatch) UnmarshalJSON(b []byte) error { + v, err := UnmarshalJSON[int](b) + if err != nil { + return err + } + *e = MixWmatch(v) + return nil +} diff --git a/enum/ocpcTransType.go b/enum/ocpcTransType.go new file mode 100644 index 0000000..b41dc45 --- /dev/null +++ b/enum/ocpcTransType.go @@ -0,0 +1,59 @@ +package enum + +// OcpcTransType 目标转化 +type OcpcTransType Enum[int] + +func (e OcpcTransType) Values() []OcpcTransType { + return []OcpcTransType{ + {1, "咨询按钮点击"}, + {10, "购买成功"}, + {1000, "销售线索"}, + {11, "注册"}, + {12, "沟通"}, + {13, "下单"}, + {14, "订单提交成功"}, + {17, "三句话咨询"}, + {18, "留线索"}, + {19, "一句话咨询"}, + {2, "电话按钮点击"}, + {20, "深度页面访问"}, + {25, "注册"}, + {26, "付费"}, + {3, "表单提交成功"}, + {30, "电话拨通"}, + {35, "微信复制按钮点击"}, + {4, "APP激活"}, + {41, "申请"}, + {42, "授信"}, + {45, "商品下单成功"}, + {46, "加入购物车"}, + {47, "商品收藏"}, + {48, "商品详情页"}, + {5, "表单按钮点击"}, + {55, "完件"}, + {57, "店铺调起"}, + {6, "下载(预约)按钮点击"}, + {67, "微信按钮调起点击"}, + {68, "粉丝关注成功"}, + {71, "应用调起"}, + {78, "店铺停留"}, + {79, "微信加粉成功"}, + {80, "直播间成单"}, + {82, "直播间观看"}, + {83, "直播间商品按钮点击"}, + {84, "直播间停留"}, + {85, "直播间评论"}, + {86, "直播间打赏"}, + {87, "直播间购物袋点击"}, + {999999, "多目标转化"}, + } +} + +func (e *OcpcTransType) UnmarshalJSON(b []byte) error { + v, err := UnmarshalJSON[int](b) + if err != nil { + return err + } + *e = OcpcTransType(v) + return nil +} diff --git a/enum/picScale.go b/enum/picScale.go new file mode 100644 index 0000000..113d0c3 --- /dev/null +++ b/enum/picScale.go @@ -0,0 +1,22 @@ +package enum + +// PicScale 图片比例 +type PicScale Enum[int] + +func (e PicScale) Values() []PicScale { + return []PicScale{ + {1, "1:1"}, + {2, "1.61:1"}, + {3, "3:1"}, + {4, "1.77:1"}, + } +} + +func (e *PicScale) UnmarshalJSON(b []byte) error { + value, err := UnmarshalJSON[int](b) + if err != nil { + return err + } + *e = PicScale(value) + return nil +} diff --git a/enum/productSegment.go b/enum/productSegment.go new file mode 100644 index 0000000..2e34576 --- /dev/null +++ b/enum/productSegment.go @@ -0,0 +1,49 @@ +package enum + +// ProductSegment 组件类型 +type ProductSegment Enum[int] + +func (e ProductSegment) Values() []ProductSegment { + return []ProductSegment{ + {1040, "交通票务列表"}, + {11006, "全息图文"}, + {11007, "商品橱窗"}, + {11009, "商品精选"}, + {11014, "全息"}, + {11015, "商品列表"}, + {11021, "单品橱窗"}, + {11023, "图文商品列表"}, + {11026, "单品爆款橱窗"}, + {11028, "横划大卡片橱窗"}, + {11029, "文本横划"}, + {11031, "智选列表"}, + {11033, "结构化列表"}, + {11034, "全息服务直达"}, + {11035, "智选列表服务直达"}, + {11037, "站内直达高级版"}, + {11038, "知识直达"}, + {11041, "全息摘要"}, + {11043, "单品多图"}, + {11044, "商品卡片精选"}, + {11045, "商品卡片"}, + {11052, "单品大图"}, + {11055, "活动大图"}, + {11058, "类目橱窗"}, + {11059, "搜索推广头条"}, + {11061, "导航"}, + {11063, "站内直达"}, + {11069, "横图卡片"}, + {11072, "百科服务化"}, + {3037, "全景橱窗"}, + {3198, "热点橱窗"}, + } +} + +func (e *ProductSegment) UnmarshalJSON(b []byte) error { + value, err := UnmarshalJSON[int](b) + if err != nil { + return err + } + *e = ProductSegment(value) + return nil +} diff --git a/enum/queryStatus.go b/enum/queryStatus.go new file mode 100644 index 0000000..bcc0e28 --- /dev/null +++ b/enum/queryStatus.go @@ -0,0 +1,22 @@ +package enum + +// QueryStatus 账户添加状态 +type QueryStatus Enum[int] + +func (e QueryStatus) Values() []QueryStatus { + return []QueryStatus{ + {0, "已添加"}, + {1, "未添加"}, + {2, "不可添加"}, + } +} + +// UnmarshalJSON implement json Unmarshal interface +func (e *QueryStatus) UnmarshalJSON(b []byte) error { + val, err := UnmarshalJSON[int](b) + if err != nil { + return err + } + *e = QueryStatus(val) + return nil +} diff --git a/enum/scoreLevel.go b/enum/scoreLevel.go new file mode 100644 index 0000000..ba5f3ed --- /dev/null +++ b/enum/scoreLevel.go @@ -0,0 +1,23 @@ +package enum + +// ScoreLevel 落地页体验 +type ScoreLevel Enum[int] + +func (e ScoreLevel) Values() []ScoreLevel { + return []ScoreLevel{ + {0, "数据积累中"}, + {1, "低于平均"}, + {2, "平均水平"}, + {3, "高于平均"}, + } +} + +// UnmarshalJSON implement json Unmarshal interface +func (e *ScoreLevel) UnmarshalJSON(b []byte) error { + val, err := UnmarshalJSON[int](b) + if err != nil { + return err + } + *e = ScoreLevel(val) + return nil +} diff --git a/enum/segmentType.go b/enum/segmentType.go new file mode 100644 index 0000000..fb80c04 --- /dev/null +++ b/enum/segmentType.go @@ -0,0 +1,22 @@ +package enum + +// SegmentType 比例 +type SegmentType Enum[int] + +func (e SegmentType) Values() []SegmentType { + return []SegmentType{ + {101, "1:1"}, + {100, "1:1"}, + {320, "3:1"}, + {321, "1.77:1"}, + } +} + +func (e *SegmentType) UnmarshalJSON(b []byte) error { + val, err := UnmarshalJSON[int](b) + if err != nil { + return err + } + *e = SegmentType(val) + return nil +} diff --git a/enum/targetingType.go b/enum/targetingType.go new file mode 100644 index 0000000..e5e6cb8 --- /dev/null +++ b/enum/targetingType.go @@ -0,0 +1,21 @@ +package enum + +// TargetingType 购买方式 +type TargetingType Enum[int] + +func (e TargetingType) Values() []TargetingType { + return []TargetingType{ + {0, "关键词"}, + {6, "网址定向"}, + } +} + +// UnmarshalJSON implement json Unmarshal interface +func (e *TargetingType) UnmarshalJSON(b []byte) error { + val, err := UnmarshalJSON[int](b) + if err != nil { + return err + } + *e = TargetingType(val) + return nil +} diff --git a/enum/wInfoType.go b/enum/wInfoType.go new file mode 100644 index 0000000..2f0048c --- /dev/null +++ b/enum/wInfoType.go @@ -0,0 +1,22 @@ +package enum + +// WinfoIdTypeEnum 定向类型 +type WinfoIdType Enum[int] + +func (e WinfoIdType) Values() []WinfoIdType { + return []WinfoIdType{ + {0, "关键词"}, + {1, "词包"}, + {3, "自动扩量"}, + } +} + +// UnmarshalJSON implement json Unmarshal interface +func (e *WinfoIdType) UnmarshalJSON(b []byte) error { + val, err := UnmarshalJSON[int](b) + if err != nil { + return err + } + *e = WinfoIdType(val) + return nil +} diff --git a/enum/wMatchId.go b/enum/wMatchId.go new file mode 100644 index 0000000..de38d8b --- /dev/null +++ b/enum/wMatchId.go @@ -0,0 +1,27 @@ +package enum + +// WMatchId 触发模式 +type WMatchId Enum[int] + +func (e WMatchId) Values() []WMatchId { + return []WMatchId{ + {101, "自动定向(智能匹配)"}, + {103, "网址投放"}, + {109, "商品定向"}, + {110, "自动定向"}, + {111, "词包"}, + {15, "智能"}, + {16, "智能匹配-人群智选"}, + {31, "短语"}, + {63, "精确"}, + } +} + +func (e *WMatchId) UnmarshalJSON(b []byte) error { + val, err := UnmarshalJSON[int](b) + if err != nil { + return err + } + *e = WMatchId(val) + return nil +} diff --git a/model/report/dimension.go b/model/report/dimension.go index b38b027..e4636cf 100644 --- a/model/report/dimension.go +++ b/model/report/dimension.go @@ -220,7 +220,8 @@ type Dimension struct { // SegmentSign 图片签名 SegmentSign string `json:"segmentSign,omitempty"` // SegmentType 比例 - // 只能取以下值: 101 1:1 + // 只能取以下值 + // 101 1:1 // 100 1:1 // 320 3:1 // 321 1.77:1