feat(mkt2): 封装mkt2,素材加工任务回调通知
This commit is contained in:
parent
2e5667bc4b
commit
6f5e1aa47c
30
services/mkt2/client.go
Normal file
30
services/mkt2/client.go
Normal file
@ -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
|
||||
}
|
||||
35
services/mkt2/client_test.go
Normal file
35
services/mkt2/client_test.go
Normal file
@ -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("")
|
||||
}
|
||||
57
services/mkt2/materialtask.go
Normal file
57
services/mkt2/materialtask.go
Normal file
@ -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
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user