From 6f5e1aa47c52ca63a373785c54353fd5c6023811 Mon Sep 17 00:00:00 2001 From: liguanjie Date: Tue, 3 Feb 2026 16:03:52 +0800 Subject: [PATCH] =?UTF-8?q?feat(mkt2):=20=E5=B0=81=E8=A3=85mkt2=EF=BC=8C?= =?UTF-8?q?=E7=B4=A0=E6=9D=90=E5=8A=A0=E5=B7=A5=E4=BB=BB=E5=8A=A1=E5=9B=9E?= =?UTF-8?q?=E8=B0=83=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/mkt2/client.go | 30 ++++++++++++++++++ services/mkt2/client_test.go | 35 +++++++++++++++++++++ services/mkt2/materialtask.go | 57 +++++++++++++++++++++++++++++++++++ 3 files changed, 122 insertions(+) create mode 100644 services/mkt2/client.go create mode 100644 services/mkt2/client_test.go create mode 100644 services/mkt2/materialtask.go diff --git a/services/mkt2/client.go b/services/mkt2/client.go new file mode 100644 index 0000000..9415ea5 --- /dev/null +++ b/services/mkt2/client.go @@ -0,0 +1,30 @@ +package mkt2 + +import ( + "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk" + "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests" +) + +const ( + VERSION = "2026-02-03" +) + +var HOST = requests.Host{ + Default: "mkt2-api", +} + +type Client struct { + sdk.Client +} + +func NewClient() (client *Client, err error) { + client = new(Client) + err = client.Init() + return +} + +func (c *Client) MaterialTaskNotify(request *MaterialTaskNotifyRequest) (response *MaterialTaskNotifyResponse, err error) { + response = CreateMaterialTaskNotifyResponse() + err = c.DoAction(request, response) + return +} diff --git a/services/mkt2/client_test.go b/services/mkt2/client_test.go new file mode 100644 index 0000000..db01be6 --- /dev/null +++ b/services/mkt2/client_test.go @@ -0,0 +1,35 @@ +package mkt2 + +import ( + "fmt" + "testing" +) + +// TestClient_MaterialTaskNotify 测试素材处理任务通知 +func TestClient_MaterialTaskNotify(t *testing.T) { + client, err := NewClient() + if err != nil { + t.Error("NewClient error:", err) + return + } + request := CreateMaterialTaskNotifyRequest(MaterialTaskNotifyParam{ + TaskType: "resource_to_vdb", + TaskId: 223, + FileInfo: FileInfo{ + Md5: "2fcf1306458f2321bccbb0e2ee8a712b", + Duration: 0, + Size: 14745, + Width: 480, + Height: 392, + Bitrate: 0, + Format: "jpg", + }, + }) + response, err := client.MaterialTaskNotify(request) + if err != nil { + t.Error("MaterialTaskNotify error:", err) + return + } + t.Log("response:", response) + fmt.Println("") +} diff --git a/services/mkt2/materialtask.go b/services/mkt2/materialtask.go new file mode 100644 index 0000000..638f2a7 --- /dev/null +++ b/services/mkt2/materialtask.go @@ -0,0 +1,57 @@ +package mkt2 + +import ( + "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests" + "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses" +) + +type MaterialTaskNotifyParam struct { + TaskType string `json:"task_type"` + TaskId int64 `json:"task_id"` + FileInfo FileInfo `json:"file_info"` +} + +// MaterialTaskNotifyRequest 媒资任务通知请求 +type MaterialTaskNotifyRequest struct { + *requests.JsonRequest + TaskType string `position:"Json" field:"task_type"` + TaskId int64 `position:"Json" field:"task_id"` + FileInfo FileInfo `position:"Json" field:"file_info"` +} + +// FileInfo 文件信息 +type FileInfo struct { + Md5 string `json:"md5"` + Duration float64 `json:"duration"` + Size int64 `json:"size"` + Width int64 `json:"width"` + Height int64 `json:"height"` + Bitrate int64 `json:"bitrate"` + Format string `json:"format"` +} + +type MaterialTaskNotifyResponse struct { + *responses.BaseResponse + StatusCode int `json:"status_code"` + StatusMsg string `json:"status_msg"` + TraceId string `json:"trace_id"` +} + +func CreateMaterialTaskNotifyRequest(param MaterialTaskNotifyParam) (req *MaterialTaskNotifyRequest) { + req = &MaterialTaskNotifyRequest{ + JsonRequest: &requests.JsonRequest{}, + TaskType: param.TaskType, + TaskId: param.TaskId, + FileInfo: param.FileInfo, + } + req.InitWithApiInfo(HOST, VERSION, "/api/cooperation/creativesMaterial/materialTaskNotify") + req.Method = requests.POST + return +} + +func CreateMaterialTaskNotifyResponse() (response *MaterialTaskNotifyResponse) { + response = &MaterialTaskNotifyResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +}