Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
30afd2cbe1 | |||
517d422993 | |||
721b735a0e | |||
e89f227e54 | |||
1902a769f8 |
3
go.mod
Normal file
3
go.mod
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
module golib.gaore.com/GaoreGo/gaore-common-sdk-go
|
||||||
|
|
||||||
|
go 1.19
|
@ -28,3 +28,15 @@ func (c *Client) TaskCreate(req *TaskCreateRequest) (resp *TaskCreateResponse, e
|
|||||||
err = c.DoAction(req, resp)
|
err = c.DoAction(req, resp)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Client) ConfigModify(req *ConfigModifyRequest) (resp *ConfigModifyResponse, err error) {
|
||||||
|
resp = CreateConfigModifyResponse()
|
||||||
|
err = c.DoAction(req, resp)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) ConfigGet(req *ConfigGetRequest) (resp *ConfigGetResponse, err error) {
|
||||||
|
resp = CreateConfigGetResponse()
|
||||||
|
err = c.DoAction(req, resp)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
@ -16,3 +16,24 @@ func TestTask_Create(t *testing.T) {
|
|||||||
resp, err := client.TaskCreate(req)
|
resp, err := client.TaskCreate(req)
|
||||||
t.Logf("%v", resp.Data.TaskId)
|
t.Logf("%v", resp.Data.TaskId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestConfig_Modify(t *testing.T) {
|
||||||
|
client, err := NewClient()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
req := CreateConfigModifyRequest()
|
||||||
|
req.Content = []byte(`<?xml version='1.0' encoding='UTF-8'?><xml><apks><!-- name:母包文件名 --><!-- screen:屏幕方向 0竖屏 1横屏 --><!-- targetSdk:targetSdkVersion支持30以上 0否 1是 --><apk><param name="id" value="1" /><param name="name" value="heji" /><param name="desc" value="合击" /><param name="screen" value="1" /><param name="targetSdk" value="0" /></apk><apk><param name="id" value="2" /><param name="name" value="lanyue" /><param name="desc" value="蓝月" /><param name="screen" value="1" /><param name="targetSdk" value="0" /></apk></apks></xmls>`)
|
||||||
|
resp, err := client.ConfigModify(req)
|
||||||
|
t.Log(resp.Code, resp.Msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestConfig_Get(t *testing.T) {
|
||||||
|
client, err := NewClient()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
req := CreateConfigGetRequest()
|
||||||
|
resp, err := client.ConfigGet(req)
|
||||||
|
t.Log(resp.Code, resp.Data)
|
||||||
|
}
|
||||||
|
34
services/capk/config_get.go
Normal file
34
services/capk/config_get.go
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
package capk
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ConfigGetRequest struct {
|
||||||
|
*requests.JsonRequest
|
||||||
|
}
|
||||||
|
|
||||||
|
type ConfigGetResponse struct {
|
||||||
|
*responses.BaseResponse
|
||||||
|
Code int `json:"code"`
|
||||||
|
Msg string `json:"msg"`
|
||||||
|
Data string `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateConfigGetRequest() *ConfigGetRequest {
|
||||||
|
req := &ConfigGetRequest{
|
||||||
|
JsonRequest: &requests.JsonRequest{},
|
||||||
|
}
|
||||||
|
|
||||||
|
req.InitWithApiInfo(HOST, VERSION, "/pack/config/get")
|
||||||
|
req.Method = requests.GET
|
||||||
|
|
||||||
|
return req
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateConfigGetResponse() *ConfigGetResponse {
|
||||||
|
return &ConfigGetResponse{
|
||||||
|
BaseResponse: &responses.BaseResponse{},
|
||||||
|
}
|
||||||
|
}
|
33
services/capk/config_modify.go
Normal file
33
services/capk/config_modify.go
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
package capk
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ConfigModifyRequest struct {
|
||||||
|
*requests.StreamRequest
|
||||||
|
}
|
||||||
|
|
||||||
|
type ConfigModifyResponse struct {
|
||||||
|
*responses.BaseResponse
|
||||||
|
Code int `json:"code"`
|
||||||
|
Msg string `json:"msg"`
|
||||||
|
Data string `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateConfigModifyRequest() (req *ConfigModifyRequest) {
|
||||||
|
req = &ConfigModifyRequest{
|
||||||
|
StreamRequest: &requests.StreamRequest{},
|
||||||
|
}
|
||||||
|
|
||||||
|
req.InitWithApiInfo(HOST, VERSION, "/pack/config/set")
|
||||||
|
req.Method = requests.POST
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateConfigModifyResponse() (resp *ConfigModifyResponse) {
|
||||||
|
return &ConfigModifyResponse{
|
||||||
|
BaseResponse: &responses.BaseResponse{},
|
||||||
|
}
|
||||||
|
}
|
31
services/center-api/client.go
Normal file
31
services/center-api/client.go
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
package center_api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
VERSION = "2020-11-16"
|
||||||
|
)
|
||||||
|
|
||||||
|
var HOST = requests.Host{
|
||||||
|
Default: "center-api",
|
||||||
|
}
|
||||||
|
|
||||||
|
type Client struct {
|
||||||
|
sdk.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewClient() (client *Client, err error) {
|
||||||
|
client = new(Client)
|
||||||
|
err = client.Init()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// PackagingTaskCallback 打包任务回调
|
||||||
|
func (c *Client) PackagingTaskCallback(req *PackagingTaskCallbackReq) (resp *PackagingTaskCallbackResp, err error) {
|
||||||
|
resp = CreatePackagingTaskCallbackResp()
|
||||||
|
err = c.DoAction(req, resp)
|
||||||
|
return
|
||||||
|
}
|
28
services/center-api/client_test.go
Normal file
28
services/center-api/client_test.go
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
package center_api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestPackagingTaskCallback(t *testing.T) {
|
||||||
|
client, err := NewClient()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
req := CreatePackagingTaskCallbackReq(Data{
|
||||||
|
TaskId: "asdada120",
|
||||||
|
Status: 1,
|
||||||
|
Msg: "test",
|
||||||
|
Url: "http://www.baidu.com",
|
||||||
|
Md5: "adadsadasdasda",
|
||||||
|
})
|
||||||
|
|
||||||
|
resp, err := client.PackagingTaskCallback(req)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(resp.StatusCode, resp.StatusMsg)
|
||||||
|
}
|
64
services/center-api/packaging.go
Normal file
64
services/center-api/packaging.go
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
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{},
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,7 @@ package oss
|
|||||||
import (
|
import (
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetApkVersionRequest struct {
|
type GetApkVersionRequest struct {
|
||||||
@ -28,6 +29,7 @@ func CreateGetApkVersionRequest() (req *GetApkVersionRequest) {
|
|||||||
}
|
}
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/api/apk/version")
|
req.InitWithApiInfo(HOST, VERSION, "/api/apk/version")
|
||||||
req.Method = requests.POST
|
req.Method = requests.POST
|
||||||
|
req.SetReadTimeout(30 * time.Second)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ func TestCreateInitMultipartUpload(t *testing.T) {
|
|||||||
|
|
||||||
func TestClient_GetApkVersion(t *testing.T) {
|
func TestClient_GetApkVersion(t *testing.T) {
|
||||||
req := CreateGetApkVersionRequest()
|
req := CreateGetApkVersionRequest()
|
||||||
req.Filepath = "51c68615b8d21f9b72b02f48c400cb87.zip"
|
req.Filepath = "uploads/files/package/1f57ac9693f0593fc9073f366b1c1936.zip"
|
||||||
client, err := NewClient()
|
client, err := NewClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
@ -10,12 +10,12 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var HOST requests.Host = requests.Host{
|
var HOST requests.Host = requests.Host{
|
||||||
Default: "pay.gaore.com",
|
Default: "pay.api.gaore.com",
|
||||||
Func: func(s string) string {
|
Func: func(s string) string {
|
||||||
var a = map[string]string{
|
var a = map[string]string{
|
||||||
requests.RELEASE: "pay.gaore.com",
|
requests.RELEASE: "pay.api.gaore.com",
|
||||||
requests.PRE: "pay.gaore.com",
|
requests.PRE: "pay.api.gaore.com",
|
||||||
requests.TEST: "pay.gaore.com",
|
requests.TEST: "pay.api.gaore.com",
|
||||||
}
|
}
|
||||||
return a[s]
|
return a[s]
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user