goProject/.svn/pristine/f1/f1b56bc707c94e31ef151838b9aa2d41b9738b29.svn-base
2025-01-06 16:21:36 +08:00

58 lines
1.7 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package gameServerMgr
import (
"encoding/json"
"fmt"
"strconv"
. "Framework/managecenterModel"
"goutil/logUtil"
"goutil/webUtil"
)
//修改区服注册人数
func UpdateRegisterCount(serverGroupId, registerCount int32) (err error, success bool) {
success = false
//定义参数
requestParamMap := make(map[string]string, 0)
requestParamMap["ServerGroupId"] = strconv.Itoa(int(serverGroupId))
requestParamMap["Registrations"] = strconv.Itoa(int(registerCount))
//构造请求url
url := fmt.Sprintf("%s/%s", mManageCenterServerAPIUrl, "/API/RegistrationUpdate.ashx")
//请求url,请求头
header := webUtil.GetFormHeader()
transport := webUtil.NewTransport()
transport.DisableKeepAlives = true
transport = webUtil.GetTimeoutTransport(transport, 30)
statusCode, returnBytes, err := webUtil.PostMapData(url, requestParamMap, header, transport)
//statusCode, returnBytes, err := webUtil.PostMapData(url, requestParamMap, header, nil)
if err != nil {
return
}
if statusCode != 200 {
err = fmt.Errorf("StatusCode:%d", statusCode)
return
}
// 解析返回值
returnObj := new(ReturnObject)
if err = json.Unmarshal(returnBytes, &returnObj); err != nil {
logUtil.ErrorLog(fmt.Sprintf("更新区服注册人数出错,反序列化返回值出错,错误信息为:%s, str:%s", err, string(returnBytes)))
return
}
// 判断返回状态是否为成功
if returnObj.Code != 0 {
err = fmt.Errorf("更新区服注册人数出错,返回状态:%d信息为%s", returnObj.Code, returnObj.Message)
logUtil.ErrorLog(fmt.Sprintf("更新区服注册人数出错,返回状态:%d信息为%s", returnObj.Code, returnObj.Message))
return
}
success = true
return
}