result_info.go 1.1 KB
Newer Older
E
eoLinker API Management 已提交
1 2 3 4 5 6
package entity

import (
	"encoding/json"
)

Y
Your Name 已提交
7
//ResultInfo 结果信息
E
eoLinker API Management 已提交
8 9 10 11 12 13 14 15
type ResultInfo struct {
	ResultType string      `json:"type"`
	StatusCode string      `json:"statusCode"`
	ResultKey  string      `json:"resultKey"`
	Result     interface{} `json:"result,omitempty"`
	ResultDesc string      `json:"resultDesc,omitempty"`
}

Y
Your Name 已提交
16
//String string
E
eoLinker API Management 已提交
17 18 19 20 21 22 23 24
func String(info interface{}) string {
	resultInfo, err := json.Marshal(info)
	if err != nil {
		return ""
	}
	return string(resultInfo)
}

Y
Your Name 已提交
25
//GetResultInfo 获取结果信息
E
eoLinker API Management 已提交
26 27 28 29 30 31 32
func GetResultInfo(statusCode string, resultType string, resultKey string, resultDesc string, result interface{}, successCount string) map[string]interface{} {
	if resultKey == "" {
		return map[string]interface{}{
			"type":       resultType,
			"statusCode": statusCode,
			"resultDesc": resultDesc,
		}
Y
Your Name 已提交
33 34 35 36 37 38 39
	}
	if result != nil {
		return map[string]interface{}{
			"type":       resultType,
			"statusCode": statusCode,
			resultKey:    result,
			"resultDesc": resultDesc,
E
eoLinker API Management 已提交
40 41
		}
	}
Y
Your Name 已提交
42 43 44 45 46
	return map[string]interface{}{
		"type":       resultType,
		"statusCode": statusCode,
		"resultDesc": resultDesc,
	}
E
eoLinker API Management 已提交
47
}