feat: migrate all remaining modules from rainyun-go-sdk
- domain(24), product(8), rbm(10), rca(21), rgs(38), ros(19), ssl(5), user(10), workorder(11), public remaining 5 - split nested response structs into reusable named types - rgs reuses rcs request/response types - fix source bugs: malformed paths, resp vs &resp, missing bodies - register all 11 services in sdk.New
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
package workorder
|
||||
|
||||
import "github.com/XingfenD/rainyun_api_go_sdk/apis"
|
||||
|
||||
type WorkorderService struct {
|
||||
client *apis.RyClient
|
||||
}
|
||||
|
||||
func NewWorkorderService(c *apis.RyClient) *WorkorderService {
|
||||
return &WorkorderService{client: c}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
package workorder
|
||||
|
||||
import "github.com/XingfenD/rainyun_api_go_sdk/apis/common"
|
||||
|
||||
// 获取工单列表请求
|
||||
type GetWorkOrderListRequest struct {
|
||||
Options common.StandQueryParameters `json:"options"`
|
||||
}
|
||||
|
||||
// 获取工单列表响应
|
||||
type GetWorkOrderListResponse struct {
|
||||
Code int `json:"code"`
|
||||
Data WorkorderListData `json:"data"`
|
||||
}
|
||||
|
||||
// 工单列表数据
|
||||
type WorkorderListData struct {
|
||||
TotalRecords int `json:"TotalRecords"`
|
||||
Records []WorkorderRecord `json:"Records"`
|
||||
}
|
||||
|
||||
// 工单
|
||||
type WorkorderRecord struct {
|
||||
ID int `json:"ID"` // 工单ID
|
||||
UID int `json:"UID"` // 用户ID
|
||||
ExtUserInfo string `json:"ExtUserInfo"`
|
||||
UserName string `json:"UserName"` // 用户名
|
||||
UserEmail string `json:"UserEmail"`
|
||||
UserVip string `json:"UserVip"` // 用户vip等级
|
||||
UserIcon string `json:"UserIcon"` // 用户头像
|
||||
Title string `json:"Title"` // 工单标题
|
||||
Type string `json:"Type"` // 工单类型
|
||||
RelatedProductType string `json:"RelatedProductType"` // 关联产品类型
|
||||
RelatedProductID int `json:"RelatedProductID"` // 关联产品id
|
||||
IsUrgent int `json:"IsUrgent"` // 是否为紧急工单
|
||||
Status string `json:"Status"` // 状态(finished/answered/waiting)
|
||||
Time int `json:"Time"` // 工单创建时间
|
||||
LastTime int `json:"LastTime"`
|
||||
WaitBeginTime int `json:"WaitBeginTime"`
|
||||
AssistID int `json:"AssistID"` // 客服id
|
||||
AuthStatus string `json:"AuthStatus"`
|
||||
AuthTime int `json:"AuthTime"`
|
||||
AuthID int `json:"AuthID"`
|
||||
}
|
||||
|
||||
// 工单回复
|
||||
type WorkorderDiscuss struct {
|
||||
ID int `json:"ID"`
|
||||
IsAssist bool `json:"IsAssist"`
|
||||
UID int `json:"UID"`
|
||||
UserName string `json:"UserName"`
|
||||
UserEmail string `json:"UserEmail"`
|
||||
UserVip string `json:"UserVip"`
|
||||
UserIcon string `json:"UserIcon"`
|
||||
Content string `json:"Content"`
|
||||
Time int `json:"Time"`
|
||||
WaitTime int `json:"WaitTime"`
|
||||
LastEditedTime int `json:"LastEditedTime"`
|
||||
IsScored bool `json:"IsScored"`
|
||||
}
|
||||
|
||||
// 工单详情数据
|
||||
type WorkorderDetailData struct {
|
||||
WorkorderRecord
|
||||
Content string `json:"Content"`
|
||||
Discuss []WorkorderDiscuss `json:"Discuss"`
|
||||
}
|
||||
|
||||
// 获取工单详情响应
|
||||
type GetWorkOrderDetailResponse struct {
|
||||
Code int `json:"code"`
|
||||
Data WorkorderDetailData `json:"data"`
|
||||
}
|
||||
|
||||
// 创建工单
|
||||
type CreateWorkerorderRequest struct {
|
||||
Content string `json:"content"`
|
||||
IsAuthed bool `json:"is_authed"` // 是否需要授权(可选)
|
||||
IsUrgent int `json:"is_urgent"` // 是否为紧急工单
|
||||
RelatedProductID int `json:"related_product_id"` // 关联产品类型(可选)
|
||||
RelatedProductType string `json:"related_product_type"` // 关联产品id(可选)
|
||||
Title string `json:"title"`
|
||||
Type string `json:"type"` // 工单类型
|
||||
}
|
||||
|
||||
// 创建工单数据
|
||||
type CreateWorkorderData struct {
|
||||
WorkorderRecord
|
||||
Content string `json:"Content"`
|
||||
}
|
||||
|
||||
// 创建工单响应
|
||||
type CreateWorkerorderResponse struct {
|
||||
Code int `json:"code"`
|
||||
Data CreateWorkorderData `json:"data"`
|
||||
}
|
||||
|
||||
// 产品授权请求
|
||||
type ProductAuthRequest struct {
|
||||
ProductID int `json:"product_id"` // 产品ID
|
||||
ProductType string `json:"product_type"` // 产品类型(rvh/rcs/rgs/rbm/ros)
|
||||
}
|
||||
|
||||
// 回复工单请求
|
||||
type ReplyWorkerorderRequest struct {
|
||||
Content string `json:"content"` // 回复内容
|
||||
}
|
||||
|
||||
// 工单打分
|
||||
type ScoreWorkerorderRequest struct {
|
||||
Score int `json:"score"` // 分数(1-5)
|
||||
Reason string `json:"reason"` // (可选)
|
||||
IsSolved bool `json:"is_solved"` // 是否解决(可选)
|
||||
DiscussID int `json:"discuss_id"` // 回复ID(可选)
|
||||
Aid int `json:"aid"` // 客服id(可选)
|
||||
}
|
||||
|
||||
// 工单打分详情数据
|
||||
type ScoreWorkorderData struct {
|
||||
UID int `json:"uid"`
|
||||
Aid int `json:"aid"`
|
||||
OrderID int `json:"order_id"`
|
||||
DiscussID int `json:"discuss_id"`
|
||||
Score int `json:"score"`
|
||||
Reason string `json:"reason"`
|
||||
IsSolved bool `json:"is_solved"`
|
||||
DiscussTime int `json:"DiscussTime"`
|
||||
ScoreTime int `json:"score_time"`
|
||||
}
|
||||
|
||||
// 获取工单打分响应
|
||||
type GetScoreWorkorderResponse struct {
|
||||
Code int `json:"code"`
|
||||
Data ScoreWorkorderData `json:"data"`
|
||||
}
|
||||
|
||||
// 工单状态数据
|
||||
type WorkorderStatusData struct {
|
||||
LastTime int `json:"LastTime"`
|
||||
Status string `json:"Status"`
|
||||
}
|
||||
|
||||
// 获取工单状态响应
|
||||
type GetWorkorderStatusResponse struct {
|
||||
Code int `json:"code"`
|
||||
Data WorkorderStatusData `json:"data"`
|
||||
}
|
||||
|
||||
// 设置工单状态请求
|
||||
type SetWorkorderStatusRequest struct {
|
||||
Status string `json:"status"`
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package workorder
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/apis/common"
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/constant"
|
||||
)
|
||||
|
||||
// 工单打分
|
||||
//
|
||||
// id: 工单ID
|
||||
func (s *WorkorderService) ScoreWorkorder(id int, req *ScoreWorkerorderRequest) (*common.BasicOperationResponse, error) {
|
||||
path := fmt.Sprintf("/workorder/%d/score", id)
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_POST, path, nil, req, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 编辑工单打分
|
||||
//
|
||||
// id: 工单ID
|
||||
func (s *WorkorderService) EditScoreWorkorder(id int, req *ScoreWorkerorderRequest) (*common.BasicOperationResponse, error) {
|
||||
path := fmt.Sprintf("/workorder/%d/score", id)
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_PATCH, path, nil, req, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 获取工单打分
|
||||
//
|
||||
// id: 工单ID
|
||||
//
|
||||
// discussID: 客服回复ID
|
||||
func (s *WorkorderService) GetScoreWorkorder(id int, discussID int) (*GetScoreWorkorderResponse, error) {
|
||||
path := fmt.Sprintf("/workorder/%d/score/%d", id, discussID)
|
||||
|
||||
var resp GetScoreWorkorderResponse
|
||||
err := s.client.Do(constant.HTTPMethod_GET, path, nil, nil, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package workorder
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/apis/common"
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/constant"
|
||||
)
|
||||
|
||||
// 获取工单列表
|
||||
//
|
||||
// req.Options 为分页查询参数, 可用 common.StandQueryParameters 构造
|
||||
func (s *WorkorderService) GetWorkOrderList(req *GetWorkOrderListRequest) (*GetWorkOrderListResponse, error) {
|
||||
path := "/workorder/"
|
||||
|
||||
var resp GetWorkOrderListResponse
|
||||
querys, err := common.MarshalQueryParams(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = s.client.Do(constant.HTTPMethod_GET, path, querys, nil, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 获取工单详情
|
||||
//
|
||||
// id: 工单ID
|
||||
func (s *WorkorderService) GetWorkOrderDetail(id int) (*GetWorkOrderDetailResponse, error) {
|
||||
path := fmt.Sprintf("/workorder/%d", id)
|
||||
|
||||
var resp GetWorkOrderDetailResponse
|
||||
err := s.client.Do(constant.HTTPMethod_GET, path, nil, nil, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 创建工单
|
||||
func (s *WorkorderService) CreateWorkOrder(req *CreateWorkerorderRequest) (*CreateWorkerorderResponse, error) {
|
||||
path := "/workorder/"
|
||||
|
||||
var resp CreateWorkerorderResponse
|
||||
err := s.client.Do(constant.HTTPMethod_POST, path, nil, req, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 产品授权
|
||||
//
|
||||
// id:工单ID
|
||||
//
|
||||
// productID:产品ID
|
||||
//
|
||||
// productType:产品类型(rvh/rcs/rgs/rbm/ros)
|
||||
func (s *WorkorderService) ProductAuth(id int, productID int, productType string) (*common.BasicOperationResponse, error) {
|
||||
path := fmt.Sprintf("/workorder/%d/auth", id)
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_POST, path, nil, ProductAuthRequest{ProductID: productID, ProductType: productType}, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 回复工单
|
||||
//
|
||||
// id: 工单ID
|
||||
//
|
||||
// content: 回复内容
|
||||
func (s *WorkorderService) ReplyWorkorder(id int, content string) (*common.BasicOperationResponse, error) {
|
||||
path := fmt.Sprintf("/workorder/%d/reply_order", id)
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_POST, path, nil, ReplyWorkerorderRequest{Content: content}, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 编辑回复工单
|
||||
//
|
||||
// id: 工单ID
|
||||
//
|
||||
// replyID: 回复ID
|
||||
//
|
||||
// content: 编辑后的内容
|
||||
func (s *WorkorderService) EditWorkorderReply(id int, replyID int, content string) (*common.BasicOperationResponse, error) {
|
||||
path := fmt.Sprintf("/workorder/%d/reply_order/%d", id, replyID)
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_PATCH, path, nil, ReplyWorkerorderRequest{Content: content}, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 获取工单状态
|
||||
//
|
||||
// id: 工单ID
|
||||
func (s *WorkorderService) GetWorkorderStatus(id int) (*GetWorkorderStatusResponse, error) {
|
||||
path := fmt.Sprintf("/workorder/%d/status", id)
|
||||
|
||||
var resp GetWorkorderStatusResponse
|
||||
err := s.client.Do(constant.HTTPMethod_GET, path, nil, nil, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 设置工单状态
|
||||
//
|
||||
// id: 工单ID
|
||||
//
|
||||
// status: 目标状态
|
||||
func (s *WorkorderService) SetWorkorderStatus(id int, status string) (*common.BasicOperationResponse, error) {
|
||||
path := fmt.Sprintf("/workorder/%d/status", id)
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_PATCH, path, nil, SetWorkorderStatusRequest{Status: status}, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
Reference in New Issue
Block a user