|
|
package service_gateway
|
|
|
|
|
|
import (
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant"
|
|
|
"strings"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
type HttplibAbilityServiceGateway struct {
|
|
|
httplibBaseServiceGateway
|
|
|
}
|
|
|
|
|
|
func (serviceGateway *HttplibAbilityServiceGateway) CommitQuestionQuotes(uid int64, taskId int64, serials []int64) (map[string]interface{}, error) {
|
|
|
url := strings.Join([]string{serviceGateway.baseURL, "task/commitQuestionQuotes"}, "/")
|
|
|
request := serviceGateway.createRequest(url, "post")
|
|
|
options := make(map[string]interface{})
|
|
|
options["uid"] = uid
|
|
|
options["taskId"] = taskId
|
|
|
options["serials"] = serials
|
|
|
request.JSONBody(options)
|
|
|
response := make(map[string]interface{})
|
|
|
request.ToJSON(&response)
|
|
|
data, err := serviceGateway.responseHandle(response)
|
|
|
return data, err
|
|
|
}
|
|
|
|
|
|
func (serviceGateway *HttplibAbilityServiceGateway) CommitQuestionSolution(qid int64, uid int64, solveUid int64, content string, scoreSolve float64, imgs []string, partners []map[string]interface{}) (map[string]interface{}, error) {
|
|
|
url := strings.Join([]string{serviceGateway.baseURL, "task/commitQuestionSolution"}, "/")
|
|
|
request := serviceGateway.createRequest(url, "post")
|
|
|
options := make(map[string]interface{})
|
|
|
options["qid"] = qid
|
|
|
options["uid"] = uid
|
|
|
options["solveUid"] = solveUid
|
|
|
options["content"] = content
|
|
|
options["scoreSolve"] = scoreSolve
|
|
|
options["imgs"] = imgs
|
|
|
options["partners"] = partners
|
|
|
request.JSONBody(options)
|
|
|
response := make(map[string]interface{})
|
|
|
request.ToJSON(&response)
|
|
|
data, err := serviceGateway.responseHandle(response)
|
|
|
return data, err
|
|
|
}
|
|
|
|
|
|
func (serviceGateway *HttplibAbilityServiceGateway) CloseTaskCallback(taskId int64, referenceResourceIds []int64) (map[string]interface{}, error) {
|
|
|
url := strings.Join([]string{serviceGateway.baseURL, "task/closeTaskCallback"}, "/")
|
|
|
request := serviceGateway.createRequest(url, "post")
|
|
|
options := make(map[string]interface{})
|
|
|
options["taskId"] = taskId
|
|
|
options["referenceResourceIds"] = referenceResourceIds
|
|
|
request.JSONBody(options)
|
|
|
response := make(map[string]interface{})
|
|
|
request.ToJSON(&response)
|
|
|
data, err := serviceGateway.responseHandle(response)
|
|
|
return data, err
|
|
|
}
|
|
|
|
|
|
func (serviceGateway *HttplibAbilityServiceGateway) ReceiverTaskCallback(uid int64, taskId int64, referenceResourceIds []int64, operatorId int64, operatorTime time.Time) (map[string]interface{}, error) {
|
|
|
url := strings.Join([]string{serviceGateway.baseURL, "task/receiverTaskCallback"}, "/")
|
|
|
request := serviceGateway.createRequest(url, "post")
|
|
|
options := make(map[string]interface{})
|
|
|
options["uid"] = uid
|
|
|
options["taskId"] = taskId
|
|
|
options["referenceResourceIds"] = referenceResourceIds
|
|
|
options["operator_id"] = operatorId
|
|
|
options["operator_time"] = operatorTime
|
|
|
request.JSONBody(options)
|
|
|
response := make(map[string]interface{})
|
|
|
request.ToJSON(&response)
|
|
|
data, err := serviceGateway.responseHandle(response)
|
|
|
return data, err
|
|
|
}
|
|
|
|
|
|
func (serviceGateway *HttplibAbilityServiceGateway) SaveTaskCallback(uid int64, taskId int64, serials []int64) (map[string]interface{}, error) {
|
|
|
url := strings.Join([]string{serviceGateway.baseURL, "task/saveTaskCallback"}, "/")
|
|
|
request := serviceGateway.createRequest(url, "post")
|
|
|
options := make(map[string]interface{})
|
|
|
options["uid"] = uid
|
|
|
options["taskId"] = taskId
|
|
|
options["serials"] = serials
|
|
|
request.JSONBody(options)
|
|
|
response := make(map[string]interface{})
|
|
|
request.ToJSON(&response)
|
|
|
data, err := serviceGateway.responseHandle(response)
|
|
|
return data, err
|
|
|
}
|
|
|
|
|
|
func (serviceGateway *HttplibAbilityServiceGateway) DeleteTaskCallback(uid int64, taskId int64, serials []int64) (map[string]interface{}, error) {
|
|
|
url := strings.Join([]string{serviceGateway.baseURL, "task/deleteTaskCallback"}, "/")
|
|
|
request := serviceGateway.createRequest(url, "post")
|
|
|
options := make(map[string]interface{})
|
|
|
options["uid"] = uid
|
|
|
options["taskId"] = taskId
|
|
|
options["serials"] = serials
|
|
|
request.JSONBody(options)
|
|
|
response := make(map[string]interface{})
|
|
|
request.ToJSON(&response)
|
|
|
data, err := serviceGateway.responseHandle(response)
|
|
|
return data, err
|
|
|
}
|
|
|
|
|
|
func NewHttplibAbilityServiceGateway() *HttplibAbilityServiceGateway {
|
|
|
return &HttplibAbilityServiceGateway{
|
|
|
httplibBaseServiceGateway: httplibBaseServiceGateway{
|
|
|
baseURL: constant.ABILITY_SERVICE_HOST,
|
|
|
connectTimeout: 100 * time.Second,
|
|
|
readWriteTimeout: 30 * time.Second,
|
|
|
},
|
|
|
}
|
|
|
} |