-
Notifications
You must be signed in to change notification settings - Fork 41
/
update_response.go
60 lines (54 loc) · 1.77 KB
/
update_response.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package project
import (
"strconv"
"github.com/bububa/oceanengine/marketing-api/model"
"github.com/bububa/oceanengine/marketing-api/util"
)
// UpdateResponse 更新计划API Response
type UpdateResponse struct {
model.BaseResponse
// Data json返回值
Data *UpdateResponseData `json:"data,omitempty"`
}
// UpdateResponseData json返回值
type UpdateResponseData struct {
// ProjectID 广告项目ID
ProjectID uint64 `json:"project_id,omitempty"`
// PromotionIDs 广告项目ID集合
ProjectIDs []uint64 `json:"project_ids,omitempty"`
// ErrorList 更新失败的广告计划列表
ErrorList []UpdateError `json:"error_list,omitempty"`
// Errors 更新失败的广告计划列表
Errors []UpdateError `json:"errors,omitempty"`
}
// UpdateError 更新失败的广告项目
type UpdateError struct {
// ProjectID 广告项目ID
ProjectID uint64 `json:"project_id,omitempty"`
// ObjectType 错误对象类型
// 枚举值: BASIC 广告基本设置、MATERIAL 广告素材组合、BUDGET 广告预算
ObjectType string `json:"object_type,omitempty"`
// ErrorCode 错误信息
ErrorCode int `json:"error_code,omitempty"`
// ErrorMessage 错误信息
ErrorMessage string `json:"error_message"`
}
// Error implement error interface
func (r UpdateError) Error() string {
var objectType string
switch r.ObjectType {
case "BASIC":
objectType = "广告基本设置"
case "MATERIAL":
objectType = "广告素材组合"
case "BUDGET":
objectType = "广告预算"
}
ret := util.StringsJoin("code:", strconv.Itoa(r.ErrorCode), ", msg:", r.ErrorMessage)
if objectType != "" {
ret = util.StringsJoin("更新 ", objectType, "失败, ", ret)
} else if r.ProjectID > 0 {
ret = util.StringsJoin("广告项目ID:", strconv.FormatUint(r.ProjectID, 10), ", ", ret)
}
return ret
}