【cs服务】
1、新增工单图片上传
This commit is contained in:
parent
607dbc87c6
commit
2ab968dfb2
@ -1,6 +1,7 @@
|
||||
package cs
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||
)
|
||||
@ -52,3 +53,16 @@ func (client *Client) SendSmsCode(req *SendSmsRequest) (resp *SendSmsResponse, e
|
||||
err = client.DoAction(req, resp)
|
||||
return
|
||||
}
|
||||
|
||||
func (client *Client) Upload(req *UploadRequest) (resp *UploadResponse, err error) {
|
||||
// check file stream
|
||||
if req.FileStream == nil {
|
||||
err = errors.New("stream is empty")
|
||||
return
|
||||
}
|
||||
// 必须设置content
|
||||
req.SetContent(req.FileStream)
|
||||
resp = CreateUploadResponse()
|
||||
err = client.DoAction(req, resp)
|
||||
return
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package cs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@ -98,8 +99,31 @@ func TestSendSms(t *testing.T) {
|
||||
}
|
||||
if info.Code != 0 {
|
||||
t.Error("给玩家发送短信失败")
|
||||
}
|
||||
fmt.Printf(fmt.Sprintf("%v", info))
|
||||
}
|
||||
|
||||
// 工单图片上传
|
||||
func TestUpload(t *testing.T) {
|
||||
client, newErr := NewClient()
|
||||
if newErr != nil {
|
||||
panic(newErr)
|
||||
}
|
||||
// 读取文件流
|
||||
file, err := os.ReadFile("test.png")
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
fmt.Printf(fmt.Sprintf("%v", info))
|
||||
req := CreateUploadRequest()
|
||||
req.FileStream = file
|
||||
res, err := client.Upload(req)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
if res.Code != 0 {
|
||||
t.Error("工单图片上传失败")
|
||||
}
|
||||
fmt.Printf(fmt.Sprintf("%v", res))
|
||||
}
|
||||
|
43
services/cs/order.go
Normal file
43
services/cs/order.go
Normal file
@ -0,0 +1,43 @@
|
||||
package cs
|
||||
|
||||
import (
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||
)
|
||||
|
||||
/**
|
||||
* 客服工单,相关方法
|
||||
*/
|
||||
|
||||
type UploadRequest struct {
|
||||
*requests.StreamRequest
|
||||
FileStream []byte
|
||||
}
|
||||
|
||||
type UploadResponse struct {
|
||||
*responses.BaseResponse
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Data struct {
|
||||
FileName string `json:"file_name"`
|
||||
FileUrl string `json:"file_url"`
|
||||
FilePath string `json:"file_path"`
|
||||
}
|
||||
TraceId string `json:"trace_id"`
|
||||
}
|
||||
|
||||
func CreateUploadRequest() (req *UploadRequest) {
|
||||
req = &UploadRequest{
|
||||
StreamRequest: &requests.StreamRequest{},
|
||||
}
|
||||
|
||||
req.InitWithApiInfo(HOST, VERSION, "/v1/work_order/upload_image")
|
||||
req.Method = requests.POST
|
||||
return
|
||||
}
|
||||
|
||||
func CreateUploadResponse() (resp *UploadResponse) {
|
||||
return &UploadResponse{
|
||||
BaseResponse: &responses.BaseResponse{},
|
||||
}
|
||||
}
|
BIN
services/cs/test.png
Normal file
BIN
services/cs/test.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 25 KiB |
Loading…
Reference in New Issue
Block a user