65 lines
1.7 KiB
Go
65 lines
1.7 KiB
Go
|
package center_api
|
||
|
|
||
|
import (
|
||
|
"crypto/md5"
|
||
|
"encoding/hex"
|
||
|
"fmt"
|
||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||
|
)
|
||
|
|
||
|
type PackagingTaskCallbackReq struct {
|
||
|
*requests.RpcRequest
|
||
|
TaskId string `position:"Body" field:"task_id"`
|
||
|
Status int `position:"Body" field:"status"`
|
||
|
Msg string `position:"Body" field:"msg"`
|
||
|
Url string `position:"Body" field:"url"`
|
||
|
Md5 string `position:"Body" field:"md5"`
|
||
|
Sign string `position:"Body" field:"sign"`
|
||
|
Ts int64 `position:"Body" field:"ts"`
|
||
|
}
|
||
|
|
||
|
type PackagingTaskCallbackResp struct {
|
||
|
*responses.BaseResponse
|
||
|
StatusCode int `json:"status_code"`
|
||
|
StatusMsg string `json:"status_msg"`
|
||
|
}
|
||
|
|
||
|
type Data struct {
|
||
|
TaskId string `json:"task_id"`
|
||
|
Status int `json:"status"`
|
||
|
Msg string `json:"msg"`
|
||
|
Url string `json:"url"`
|
||
|
Md5 string `json:"md5"`
|
||
|
}
|
||
|
|
||
|
func CreatePackagingTaskCallbackReq(data Data) *PackagingTaskCallbackReq {
|
||
|
req := &PackagingTaskCallbackReq{
|
||
|
RpcRequest: &requests.RpcRequest{},
|
||
|
}
|
||
|
|
||
|
req.TaskId = data.TaskId
|
||
|
req.Status = data.Status
|
||
|
req.Msg = data.Msg
|
||
|
req.Url = data.Url
|
||
|
req.Md5 = data.Md5
|
||
|
req.Ts = 1730357662
|
||
|
|
||
|
// sign=md5(ts+task_id+sign_key) 32位
|
||
|
// 生成 MD5 哈希
|
||
|
hash := md5.Sum([]byte(fmt.Sprintf("%d%s%s", req.Ts, req.TaskId, "xBPVBJ132asdUeJC3XjD7AnFWD2sbGH6pJC4654y89")))
|
||
|
|
||
|
// 将哈希结果转换为十六进制字符串
|
||
|
hashString := hex.EncodeToString(hash[:])
|
||
|
req.Sign = hashString
|
||
|
req.InitWithApiInfo(HOST, VERSION, "/v1/packaging/task/callback")
|
||
|
req.Method = requests.POST
|
||
|
return req
|
||
|
}
|
||
|
|
||
|
func CreatePackagingTaskCallbackResp() *PackagingTaskCallbackResp {
|
||
|
return &PackagingTaskCallbackResp{
|
||
|
BaseResponse: &responses.BaseResponse{},
|
||
|
}
|
||
|
}
|