Apply .gitignore rules
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package webUtil
|
||||
|
||||
import (
|
||||
"goutil/zlibUtil"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPostWebData(t *testing.T) {
|
||||
weburl := "https://managecenterapitest-sd3.7qule.com/API/ServerActivate.ashx"
|
||||
postDict := make(map[string]string, 0)
|
||||
postDict["ServerGroupID"] = "20002"
|
||||
resp, err := PostWebData(weburl, postDict, nil)
|
||||
if err != nil {
|
||||
t.Errorf("测试错误,返回的结果为:%s", err)
|
||||
}
|
||||
|
||||
if len(resp) == 0 {
|
||||
t.Errorf("返回的数据为空,期望不为空")
|
||||
}
|
||||
|
||||
// 将收到的数据进行zlib解压缩
|
||||
_, err = zlibUtil.Decompress(resp)
|
||||
if err != nil {
|
||||
t.Errorf("Error:%s", err)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package sqlSync
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"os"
|
||||
|
||||
"goutil/fileUtil"
|
||||
"goutil/intAndBytesUtil"
|
||||
)
|
||||
|
||||
const (
|
||||
// 头部字节长度
|
||||
con_Header_Length = 4
|
||||
)
|
||||
|
||||
var (
|
||||
// 字节的大小端顺序
|
||||
byteOrder = binary.LittleEndian
|
||||
)
|
||||
|
||||
// 按照指定方式读取文本内容
|
||||
// fileObj:大文件对象
|
||||
// data:待写入的数据
|
||||
// 返回值:
|
||||
// error:写入是否存在异常
|
||||
func Write(fileObj *fileUtil.BigFile, data string) error {
|
||||
// 获得数据内容的长度
|
||||
dataLength := len(data)
|
||||
|
||||
// 将长度转化为字节数组
|
||||
header := intAndBytesUtil.Int32ToBytes(int32(dataLength), byteOrder)
|
||||
|
||||
// 将头部与内容组合在一起
|
||||
message := append(header, data...)
|
||||
|
||||
// 写入数据
|
||||
return fileObj.WriteMessage(message)
|
||||
}
|
||||
|
||||
// 从文件读取一条数据
|
||||
// fileObj:文件对象
|
||||
// 返回值:
|
||||
// result:读取到的字符串
|
||||
// err:错误信息
|
||||
func Read(fileObj *os.File) (result string, readLen int64, err error) {
|
||||
// 1. 读取头部内容
|
||||
header := make([]byte, 4)
|
||||
var n int
|
||||
n, err = fileObj.Read(header)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if n < con_Header_Length {
|
||||
err = errors.New("can not read 4 byte for read len")
|
||||
readLen = int64(n)
|
||||
return
|
||||
}
|
||||
|
||||
dataLength := intAndBytesUtil.BytesToInt32(header, byteOrder)
|
||||
|
||||
// 2. 读取指定长度的内容
|
||||
data := make([]byte, dataLength)
|
||||
n, err = fileObj.Read(data)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
readLen = int64(len(header) + int(dataLength))
|
||||
result = string(data)
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package managecenterModel
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// 合作商
|
||||
type Partner struct {
|
||||
// 合作商Id
|
||||
Id int32 `json:"PartnerID"`
|
||||
|
||||
// 合作商名称
|
||||
Name string `json:"PartnerName"`
|
||||
|
||||
// 合作商别名
|
||||
Alias string `json:"PartnerAlias"`
|
||||
|
||||
// 应用Id
|
||||
AppId string `json:"AppID"`
|
||||
|
||||
// 登陆加密Key
|
||||
LoginKey string `json:"LoginKey"`
|
||||
|
||||
// 充值配置
|
||||
ChargeConfig string `json:"ChargeConfig"`
|
||||
|
||||
// 其它配置
|
||||
OtherConfigInfo string `json:"OtherConfigInfo"`
|
||||
|
||||
// 游戏版本下载Url
|
||||
GameVersionUrl string `json:"GameVersionUrl"`
|
||||
|
||||
// 充值服务器Url
|
||||
ChargeServerUrl string `json:"ChargeServerUrl"`
|
||||
|
||||
// 合作商类型
|
||||
PartnerType int32 `json:"PartnerType"`
|
||||
|
||||
// 权重
|
||||
Weight int32 `json:"Weight"`
|
||||
|
||||
// 资源包所属类型
|
||||
ResourceType int32 `json:"ResourceType"`
|
||||
}
|
||||
|
||||
// 解析其它配置信息
|
||||
func (this *Partner) ResolveOtherConfig() (otherConfigMap map[string]string, err error) {
|
||||
otherConfigMap = make(map[string]string, 8)
|
||||
if this.OtherConfigInfo == "" {
|
||||
return
|
||||
}
|
||||
|
||||
err = json.Unmarshal([]byte(this.OtherConfigInfo), &otherConfigMap)
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package typeUtil
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestBoolToInt(t *testing.T) {
|
||||
// Test with true value
|
||||
value := true
|
||||
expected := 1
|
||||
got := BoolToInt(value)
|
||||
if expected != got {
|
||||
t.Errorf("Expected %d, but got %d", expected, got)
|
||||
return
|
||||
}
|
||||
|
||||
// Test with false value
|
||||
value = false
|
||||
expected = 0
|
||||
got = BoolToInt(value)
|
||||
if expected != got {
|
||||
t.Errorf("Expected %d, but got %d", expected, got)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func TestIntToBool(t *testing.T) {
|
||||
// Test with 0 value
|
||||
value := 0
|
||||
expected := false
|
||||
got := IntToBool(value)
|
||||
if expected != got {
|
||||
t.Errorf("Expected %t, but got %t", expected, got)
|
||||
return
|
||||
}
|
||||
|
||||
// Test with negative value
|
||||
value = -1
|
||||
expected = false
|
||||
got = IntToBool(value)
|
||||
if expected != got {
|
||||
t.Errorf("Expected %t, but got %t", expected, got)
|
||||
return
|
||||
}
|
||||
|
||||
// Test with positive value
|
||||
value = 1
|
||||
expected = true
|
||||
got = IntToBool(value)
|
||||
if expected != got {
|
||||
t.Errorf("Expected %t, but got %t", expected, got)
|
||||
return
|
||||
}
|
||||
|
||||
// Test with bigger positive value
|
||||
value = 100
|
||||
expected = true
|
||||
got = IntToBool(value)
|
||||
if expected != got {
|
||||
t.Errorf("Expected %t, but got %t", expected, got)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package managecenterMgr
|
||||
|
||||
// ManageCenter的管理包,提供管理合作商、服务器、服务器组、游戏资源、白名单等功能
|
||||
|
||||
// 使用方法:
|
||||
// 首先调用Start方法,这样会进行初始化,后续就可以使用提供的其它方法
|
||||
// 内部会定时去ManageCenter刷新最新的数据
|
||||
Reference in New Issue
Block a user