httplibAbilityServiceGateway.go 1.8 KB
package service_gateway

import (
	"gitlab.fjmaimaimai.com/linmadan/mmm-worth/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 NewHttplibAbilityServiceGateway() *HttplibAbilityServiceGateway {
	return &HttplibAbilityServiceGateway{
		httplibBaseServiceGateway: httplibBaseServiceGateway{
			baseURL:          constant.ABILITY_SERVICE_HOST,
			connectTimeout:   100 * time.Second,
			readWriteTimeout: 30 * time.Second,
		},
	}
}