From 4ebd8b4131fd948941cfff1290ad7501d5dcc674 Mon Sep 17 00:00:00 2001 From: Syd Xu Date: Fri, 24 Nov 2023 18:14:48 +0800 Subject: [PATCH] =?UTF-8?q?feat(promotion):=20=E5=B7=A8=E9=87=8F=E5=B9=BF?= =?UTF-8?q?=E5=91=8A=E5=8D=87=E7=BA=A7=E7=89=88=E3=80=8C=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=B9=BF=E5=91=8A=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3=E3=80=8D?= =?UTF-8?q?=E5=9B=BE=E6=96=87=E7=B4=A0=E6=9D=90=E7=B1=BB=E5=9E=8B=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E6=9E=9A=E4=B8=BE=E5=80=BC=E5=B0=86=E4=BA=8E12?= =?UTF-8?q?=E6=9C=8819=E6=97=A5=E5=8F=98=E6=9B=B4.=20carousel=5Ftype=20?= =?UTF-8?q?=E7=94=B1int=E7=B1=BB=E5=9E=8B=E5=8F=98=E4=B8=BAenum.ImageMode;?= =?UTF-8?q?=20=E4=B8=BA=E9=80=82=E7=94=A8=E5=8F=98=E5=8C=96=E4=B8=BAenum.I?= =?UTF-8?q?mageMode=E5=A2=9E=E5=8A=A0=E8=87=AA=E5=AE=9A=E4=B9=89UnmarshalJ?= =?UTF-8?q?SON=E4=BB=A5=E5=90=8C=E6=97=B6=E6=94=AF=E6=8C=81=E8=A7=A3?= =?UTF-8?q?=E6=9E=90int/enum.ImageMode=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- marketing-api/enum/image_mode.go | 26 +++++++++++++++++++ marketing-api/model/v3/promotion/promotion.go | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/marketing-api/enum/image_mode.go b/marketing-api/enum/image_mode.go index dc00f264..da5bd289 100644 --- a/marketing-api/enum/image_mode.go +++ b/marketing-api/enum/image_mode.go @@ -1,5 +1,7 @@ package enum +import "strconv" + // ImageMode 素材类型 // 不符合下列素材类型尺寸比例,投放后台不显示 type ImageMode string @@ -39,3 +41,27 @@ const ( // SEARCH_DISPLAY_WINDOW_IMAGE 搜索橱窗橱窗 SEARCH_DISPLAY_WINDOW_IMAGE ImageMode = "SEARCH_DISPLAY_WINDOW_IMAGE" ) + +// UnmarshalJSON implement json Unmarshal interface +func (im *ImageMode) UnmarshalJSON(b []byte) (err error) { + if b[0] == '"' && b[len(b)-1] == '"' { + b = b[1 : len(b)-1] + } + str := string(b) + if i, err := strconv.ParseUint(str, 10, 64); err != nil { + *im = ImageMode(str) + return nil + } else { + switch i { + case 1: + *im = INFORMATION_FLOW_IMAGE + case 2: + *im = TOUTIAO_SEARCH_AD_IMAGE + case 3: + *im = SEARCH_DISPLAY_WINDOW_IMAGE + default: + *im = ImageMode(str) + } + } + return +} diff --git a/marketing-api/model/v3/promotion/promotion.go b/marketing-api/model/v3/promotion/promotion.go index 8d54fc80..d6f43747 100644 --- a/marketing-api/model/v3/promotion/promotion.go +++ b/marketing-api/model/v3/promotion/promotion.go @@ -383,7 +383,7 @@ type CarouselMaterial struct { // MaterialStatus 素材审核状态 MaterialStatus string `json:"material_status,omitempty"` // CarouselType 图集素材类型 - CarouselType int `json:"carousel_type,omitempty"` + CarouselType enum.ImageMode `json:"carousel_type,omitempty"` // ImageSubject 图片主题 ImageSubject []file.ImageSubject `json:"image_subject,omitempty"` }