Showing preview only (254K chars total). Download the full file or copy to clipboard to get everything.
Repository: dwg255/fish
Branch: master
Commit: a91a14e1f1f1
Files: 58
Total size: 235.5 KB
Directory structure:
gitextract_5x4ila4d/
├── .gitignore
├── README.md
├── account/
│ ├── common/
│ │ ├── config.go
│ │ └── model.go
│ ├── main/
│ │ ├── config.go
│ │ ├── init.go
│ │ └── main.go
│ └── service/
│ └── handle.go
├── common/
│ ├── api/
│ │ └── thrift/
│ │ ├── account.thrift
│ │ └── gen-go/
│ │ └── rpc/
│ │ ├── GoUnusedProtection__.go
│ │ ├── account-consts.go
│ │ ├── account.go
│ │ └── user_service-remote/
│ │ └── user_service-remote.go
│ ├── conf/
│ │ ├── account.conf
│ │ ├── game.conf
│ │ ├── hall.conf
│ │ └── traces.json
│ └── tools/
│ ├── aes.go
│ ├── call_rpc.go
│ ├── snowFlake.go
│ └── tools.go
├── game/
│ ├── common/
│ │ └── config.go
│ ├── controllers/
│ │ ├── create_public_room.go
│ │ ├── create_room.go
│ │ ├── enter_public_room.go
│ │ ├── enter_room.go
│ │ ├── get_server_info.go
│ │ ├── is_room_running.go
│ │ └── ping.go
│ ├── main/
│ │ ├── config.go
│ │ ├── init.go
│ │ └── main.go
│ ├── router/
│ │ └── router.go
│ └── service/
│ ├── client.go
│ ├── define.go
│ ├── fish_utils.go
│ ├── request.go
│ └── room.go
├── go.mod
├── go.sum
├── hall/
│ ├── common/
│ │ └── config.go
│ ├── controllers/
│ │ ├── enter_public_room.go
│ │ ├── get_message.go
│ │ ├── get_server_info.go
│ │ ├── get_user_status.go
│ │ ├── guest.go
│ │ ├── login.go
│ │ ├── qq_callback.go
│ │ ├── qq_login.go
│ │ └── register_game_server.go
│ ├── main/
│ │ ├── config.go
│ │ ├── init.go
│ │ └── main.go
│ └── router/
│ └── router.go
├── start_account.bat
├── start_fish.bat
├── start_hall.bat
└── z-start_all_server.bat
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
.idea/
*.exe
*.log
================================================
FILE: README.md
================================================
# 捕鱼
运行步骤:
1.下载源码:
git clone https://github.com/dwg255/fish
2.编译:
cd fish\
go build -o account.exe account\main\main.go account\main\init.go account\main\config.go
go build -o hall.exe hall\main\main.go hall\main\init.go hall\main\config.go
go build -o fish.exe game\main\main.go game\main\init.go game\main\config.go
3.解压客户端:
tar -zxvf fish.tar.gz /var/www/html/client/fish
4.配置nginx:
```
server {
listen 80;
server_name fish.com;
charset utf8;
index index.html index.htm;
location /qq {
add_header Access-Control-Allow-Origin *;
proxy_set_header X-Target $request_uri;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:9000;
}
location / {
root /var/www/html/client/fish;
add_header Access-Control-Allow-Origin *;
expires 7d;
}
}
```
配置文件位置 /common/conf 内含redis配置和qq第三方登录配置,请自行修改。
5.在线示例:
http://fish.blzz.shop
---
License
This project is released under the terms of the MIT license. See [LICENSE](LICENSE) for more
information or see https://opensource.org/licenses/MIT.
---








================================================
FILE: account/common/config.go
================================================
package common
import (
"github.com/go-redis/redis"
"github.com/jmoiron/sqlx"
)
var (
AccountConf = &AccountServiceConf{
RedisConf: &RedisConf{},
MysqlConf: &MysqlConf{},
}
)
type AccountServiceConf struct {
AccountAesKey string
ThriftPort int
LogPath string
LogLevel string
RedisConf *RedisConf
MysqlConf *MysqlConf
}
type RedisConf struct {
RedisAddrs []string
RedisKeyPrefix string
//RedisPool *redis.ClusterClient
RedisPool *redis.Client
}
type MysqlConf struct {
MysqlAddr string
MysqlUser string
MysqlPassword string
MysqlDatabase string
Pool *sqlx.DB
}
================================================
FILE: account/common/model.go
================================================
package common
type FishUser struct {
UserId int `json:"userid" dB:"UsERID"`
Account string `json:"account" DB:"account"`
Name string `json:"name" DB:"name"`
Sex int `json:"sex" dB:"sex"`
HeadImg string `json:"headimg" DB:"headimg"`
Lv int `json:"lv" DB:"LV"`
Exp int `json:"exP" Db:"exP"`
Coins int `json:"coins" db:"coins"`
Vip int `json:"vip" db:"vip"`
Money int `json:"money" DB:"money"`
Gems int `json:"gems" db:"gems"`
RoomId string `json:"roomid" DB:"roomid"`
History string `json:"history" dB:"history"`
Power int `json:"power" DB:"power"`
ReNameCount int `json:"renamecount" db:"renamecount"`
ReHeadCount int `json:"reheadcount" db:"reheadcount"`
PropId int `json:"propid" db:"propid"`
}
type InvestUserStake struct {
Id int `json:"id" db:"id"`
GameTimesId string `json:"game_times_id" db:"game_times_id"`
Periods int `json:"record_id" db:"periods"`
RoomId int `json:"room_id" db:"room_id"`
RoomType int `json:"room_type" db:"room_type"`
UserId int `json:"user_id" db:"user_id"`
Nickname string `json:"nickname" db:"nickname"`
UserAllStake int `json:"stake_gold" db:"user_all_stake"`
WinGold int `json:"get_gold" db:"get_gold"`
StakeDetail string `json:"stake_detail" db:"stake_detail"`
GameResult int `json:"game_result" db:"game_result"`
Pool int `json:"game_pool" db:"game_pool"`
StakeTime string `json:"stake_time" db:"last_stake_time"`
}
================================================
FILE: account/main/config.go
================================================
package main
import (
"fish/account/common"
"fmt"
"github.com/astaxie/beego/config"
"github.com/astaxie/beego/logs"
)
func initConf() (err error) {
conf, err := config.NewConfig("ini", "./common/conf/account.conf")
if err != nil {
fmt.Println("new config failed,err:", err)
return
}
common.AccountConf.ThriftPort, err = conf.Int("account_port")
if err != nil {
return
}
common.AccountConf.AccountAesKey = conf.String("account_aes_key")
if common.AccountConf.AccountAesKey == "" || len(common.AccountConf.AccountAesKey) < 16 {
return fmt.Errorf("conf err: invalid account_aes_key :%v", common.AccountConf.AccountAesKey)
}
logs.Debug("account_aes_key :%v",common.AccountConf.AccountAesKey)
common.AccountConf.LogPath = conf.String("log_path")
if common.AccountConf.LogPath == "" {
return fmt.Errorf("conf err: log_path is null")
}
common.AccountConf.LogLevel = conf.String("log_level")
if common.AccountConf.LogLevel == "" {
return fmt.Errorf("conf err: log_level is null")
}
//redis配置
common.AccountConf.RedisConf.RedisAddrs = conf.Strings("redis_addrs")
if len(common.AccountConf.RedisConf.RedisAddrs) == 0 {
return fmt.Errorf("conf err: redis addr is null")
}
common.AccountConf.RedisConf.RedisKeyPrefix = conf.String("redis_key_prefix")
if len(common.AccountConf.RedisConf.RedisKeyPrefix) == 0 {
return fmt.Errorf("conf err: redis_key_prefix is null")
}
//mysql配置
common.AccountConf.MysqlConf.MysqlAddr = conf.String("mysql_addr")
if len(common.AccountConf.MysqlConf.MysqlAddr) == 0 {
return fmt.Errorf("conf err: mysql_addr is null")
}
common.AccountConf.MysqlConf.MysqlUser = conf.String("mysql_user")
if len(common.AccountConf.MysqlConf.MysqlUser) == 0 {
return fmt.Errorf("conf err: mysql_user is null")
}
common.AccountConf.MysqlConf.MysqlPassword = conf.String("mysql_password")
if len(common.AccountConf.MysqlConf.MysqlPassword) == 0 {
return fmt.Errorf("conf err: mysql_password is null")
}
common.AccountConf.MysqlConf.MysqlDatabase = conf.String("mysql_db")
if len(common.AccountConf.MysqlConf.MysqlDatabase) == 0 {
return fmt.Errorf("conf err: mysql_db is null")
}
return
}
================================================
FILE: account/main/init.go
================================================
package main
import (
"encoding/json"
"fish/account/common"
"fmt"
"github.com/astaxie/beego/logs"
"github.com/go-redis/redis"
_ "github.com/go-sql-driver/mysql"
"github.com/jmoiron/sqlx"
)
func conversionLogLevel(logLevel string) int {
switch logLevel {
case "debug":
return logs.LevelDebug
case "warn":
return logs.LevelWarn
case "info":
return logs.LevelInfo
case "trace":
return logs.LevelTrace
}
return logs.LevelDebug
}
func initLogger() (err error) {
config := make(map[string]interface{})
config["filename"] = common.AccountConf.LogPath
config["level"] = conversionLogLevel(common.AccountConf.LogLevel)
configStr, err := json.Marshal(config)
if err != nil {
return
}
err = logs.SetLogger(logs.AdapterFile, string(configStr))
return
}
func initMysql() (err error) {
conf := common.AccountConf.MysqlConf
dsn := fmt.Sprintf("%s:%s@tcp(%s)/%s", conf.MysqlUser, conf.MysqlPassword, conf.MysqlAddr, conf.MysqlDatabase)
logs.Debug(dsn)
database, err := sqlx.Open("mysql", dsn)
if err != nil {
return
}
common.AccountConf.MysqlConf.Pool = database
return
}
func initRedis() (err error) {
//client := redis.NewClusterClient(&redis.ClusterOptions{
// Addrs: common.AccountConf.RedisConf.RedisAddrs,
//})
//_, err = client.Ping().Result()
//if err != nil {
// return
//}
//common.AccountConf.RedisConf.RedisPool = client
client := redis.NewClient(&redis.Options{
Addr: "localhost:6379",
Password: "",
DB: 0,
})
common.AccountConf.RedisConf.RedisPool = client
return
}
func initSec() (err error) {
err = initLogger()
if err != nil {
return
}
err = initRedis()
if err != nil {
return
}
/*err = initMysql()
if err != nil {
return
}*/
return
}
================================================
FILE: account/main/main.go
================================================
package main
import (
"fish/account/common"
"fish/account/service"
"fish/common/api/thrift/gen-go/rpc"
"fmt"
"github.com/apache/thrift/lib/go/thrift"
"github.com/astaxie/beego/logs"
)
func main() {
err := initConf()
if err != nil {
logs.Error("init conf err:%v",err)
return
}
logs.Debug("init conf success")
service.InitAesTool()
err = initSec()
if err != nil {
logs.Error("initSec err:%v",err)
return
}
logs.Debug("init sec success")
port := fmt.Sprintf(":%d",common.AccountConf.ThriftPort)
transport, err := thrift.NewTServerSocket(port)
if err != nil {
panic(err)
}
handler := &service.UserServer{}
processor := rpc.NewUserServiceProcessor(handler)
transportFactory := thrift.NewTBufferedTransportFactory(8192)
protocolFactory := thrift.NewTCompactProtocolFactory()
server := thrift.NewTSimpleServer4(
processor,
transport,
transportFactory,
protocolFactory,
)
logs.Debug("account server %s",port)
if err := server.Serve(); err != nil {
panic(err)
}
}
================================================
FILE: account/service/handle.go
================================================
package service
import (
"context"
"fish/account/common"
"fish/common/api/thrift/gen-go/rpc"
"fish/common/tools"
"fmt"
"github.com/astaxie/beego/logs"
"math/rand"
"strconv"
"strings"
"time"
)
var (
redisConf = common.AccountConf.RedisConf
aesTool *tools.AesEncrypt
)
type UserServer struct {
}
func InitAesTool() {
var err error
if aesTool, err = tools.NewAesTool(common.AccountConf.AccountAesKey); err != nil {
panic("new aes tool err: " + err.Error())
}
}
func (p *UserServer) GetUserInfoByOpenId(ctx context.Context, openId string) (r *rpc.Result_, err error) {
logs.Debug("getUserInfoByOpenId openId: %v", openId)
var existsUserId string
var userId int
if existsUserId, err = redisConf.RedisPool.HGet(redisConf.RedisKeyPrefix+"open_id2user_id", openId).Result(); err == nil {
if userId, err = strconv.Atoi(existsUserId); err == nil {
return p.GetUserInfoById(ctx, int32(userId))
}
} else {
r = &rpc.Result_{
Code: rpc.ErrorCode_UserNotExists,
}
err = fmt.Errorf("user openId=%v not exists", openId)
}
return
}
func (p *UserServer) CreateQQUser(ctx context.Context, userInfo *rpc.UserInfo) (r *rpc.Result_, err error) {
logs.Debug("CreateQQUser nickName: %v", userInfo.NickName)
var nextUserId int64
var existsUserId string
var userId int
if existsUserId, err = redisConf.RedisPool.HGet(redisConf.RedisKeyPrefix+"open_id2user_id", userInfo.QqInfo.OpenId).Result(); err == nil {
if userId, err = strconv.Atoi(existsUserId); err == nil {
return p.GetUserInfoById(ctx, int32(userId))
}
} else {
nextUserId, err = redisConf.RedisPool.Incr(redisConf.RedisKeyPrefix + "userId").Result()
token := ""
registerTime := time.Now()
if token, err = aesTool.Encrypt(strconv.Itoa(int(nextUserId)) + "-" + strconv.Itoa(int(registerTime.Unix()))); err == nil {
rand.Seed(time.Now().UnixNano())
userInfoRedisMap := map[string]interface{}{
"UserId": nextUserId,
"UserName": userInfo.UserName,
"NickName": userInfo.NickName,
"Sex": userInfo.Sex,
"HeadImg": userInfo.HeadImg,
"Lv": userInfo.Lv,
"Exp": userInfo.Exp,
"Vip": userInfo.Vip, //VIP级别随机给吧,
"Gems": userInfo.Gems,
"RoomId": 0,
"Power": userInfo.Power,
"ReNameCount": userInfo.ReNameCount,
"ReHeadCount": userInfo.ReHeadCount,
"RegisterDate": registerTime.Format("2006-01-02 15:04:05"),
"Ice": 10,
"Token": token,
"openId": userInfo.QqInfo.OpenId,
"FigureUrl": userInfo.QqInfo.FigureUrl,
"Province": userInfo.QqInfo.Province,
"City": userInfo.QqInfo.City,
"TotalSpending": userInfo.QqInfo.TotalSpending,
}
if _, err = redisConf.RedisPool.HMSet(redisConf.RedisKeyPrefix+strconv.Itoa(int(nextUserId)), userInfoRedisMap).Result(); err == nil {
if _, err = redisConf.RedisPool.HSet(redisConf.RedisKeyPrefix+"open_id2user_id", userInfo.QqInfo.OpenId, nextUserId).Result(); err == nil {
userInfo.UserId = nextUserId
userInfo.Token = token
r = &rpc.Result_{
Code: rpc.ErrorCode_Success,
UserObj: userInfo,
}
return
}
}
}
}
return
}
func (p *UserServer) CreateNewUser(ctx context.Context, nickName string, avatarAuto string, gold int64) (r *rpc.Result_, err error) {
logs.Debug("CreateNewUser nickName: %v", nickName)
var nextUserId int64
nextUserId, err = redisConf.RedisPool.Incr(redisConf.RedisKeyPrefix + "userId").Result()
token := ""
registerTime := time.Now()
if token, err = aesTool.Encrypt(strconv.Itoa(int(nextUserId)) + "-" + strconv.Itoa(int(registerTime.Unix()))); err == nil {
rand.Seed(time.Now().UnixNano())
vip := int8(rand.Intn(7))
userInfoRedisMap := map[string]interface{}{
"UserId": nextUserId,
"UserName": nickName,
"NickName": nickName,
"Sex": 0,
"HeadImg": 1,
"Lv": 1,
"Exp": 0,
"Vip": vip, //VIP级别随机给吧,
"Gems": gold,
"RoomId": 0,
"Power": 0,
"ReNameCount": 0,
"ReHeadCount": 0,
"RegisterDate": registerTime.Format("2006-01-02 15:04:05"),
"Ice": 10,
"Token": token,
}
if _, err = redisConf.RedisPool.HMSet(redisConf.RedisKeyPrefix+strconv.Itoa(int(nextUserId)), userInfoRedisMap).Result(); err == nil {
r = &rpc.Result_{
Code: rpc.ErrorCode_Success,
UserObj: &rpc.UserInfo{
UserId: nextUserId,
UserName: nickName,
NickName: nickName,
Sex: 0,
HeadImg: "1",
Lv: 1,
Exp: 0,
Vip: vip, //VIP级别随机给吧
Gems: gold,
RoomId: 0,
Power: 0,
ReNameCount: 0,
ReHeadCount: 0,
RegisterDate: registerTime.Format("2006-01-02 15:04:05"),
Ice: 10,
Token: token,
},
}
return
}
}
return
}
func (p *UserServer) GetUserInfoById(ctx context.Context, userId int32) (r *rpc.Result_, err error) {
logs.Debug("GetUserInfoById: %v", userId)
result, err := redisConf.RedisPool.HGetAll(redisConf.RedisKeyPrefix + strconv.Itoa(int(userId))).Result()
if err != nil {
return r, err
}
var Lv, Vip, Gems, RoomId, Power, Ice int
if Lv, err = strconv.Atoi(result["Lv"]); err != nil {
return r, err
}
if Vip, err = strconv.Atoi(result["Vip"]); err != nil {
return r, err
}
if RoomId, err = strconv.Atoi(result["RoomId"]); err != nil {
return r, err
}
if Gems, err = strconv.Atoi(result["Gems"]); err != nil {
return r, err
}
if Power, err = strconv.Atoi(result["Power"]); err != nil {
return r, err
}
if Ice, err = strconv.Atoi(result["Ice"]); err != nil {
return r, err
}
r = &rpc.Result_{
Code: rpc.ErrorCode_Success,
UserObj: &rpc.UserInfo{
UserId: int64(userId),
UserName: result["UserName"],
NickName: result["NickName"],
Sex: 0,
HeadImg: result["HeadImg"],
Lv: int32(Lv),
Exp: 0,
Vip: int8(Vip),
Gems: int64(Gems),
RoomId: int64(RoomId),
Power: int64(Power),
ReNameCount: 0,
ReHeadCount: 0,
RegisterDate: result["RegisterDate"],
Ice: int64(Ice),
Token: result["Token"],
},
}
return
}
func (p *UserServer) GetUserInfoByToken(ctx context.Context, token string) (r *rpc.Result_, err error) {
logs.Debug("GetUserInfoByToken: %v", token)
userIdStr := ""
if userIdStr, err = aesTool.Decrypt(token); err == nil {
userId := 0
tokenSplit := strings.Split(userIdStr, "-")
if len(tokenSplit) > 1 {
if userId, err = strconv.Atoi(tokenSplit[0]); err == nil {
return p.GetUserInfoById(context.Background(), int32(userId))
}
}
}
return
}
func (p *UserServer) ModifyUserInfoById(ctx context.Context, behavior string, userId int32, propType rpc.ModifyPropType, incr int64) (r *rpc.Result_, err error) {
logs.Debug("ModifyUserInfoById: %v", behavior)
var exists int64
userInfoKey := redisConf.RedisKeyPrefix + strconv.Itoa(int(userId))
if exists, err = common.AccountConf.RedisConf.RedisPool.Exists(userInfoKey).Result(); err == nil {
if exists == 1 {
switch propType {
case rpc.ModifyPropType_gems:
common.AccountConf.RedisConf.RedisPool.HIncrBy(userInfoKey, "Gems", incr)
case rpc.ModifyPropType_ice:
common.AccountConf.RedisConf.RedisPool.HIncrBy(userInfoKey, "Ice", incr)
case rpc.ModifyPropType_power:
common.AccountConf.RedisConf.RedisPool.HIncrBy(userInfoKey, "Power", incr)
case rpc.ModifyPropType_roomId:
common.AccountConf.RedisConf.RedisPool.HIncrBy(userInfoKey, "RoomId", incr)
}
return p.GetUserInfoById(context.Background(), userId)
}
err = fmt.Errorf("user [%d] doesnot exists", userId)
}
return
}
func (p *UserServer) GetMessage(ctx context.Context, messageType string) (r string, err error) {
logs.Debug("GetMessage messageType: %v", messageType)
var redisErr error
if messageType == "notice" {
r, redisErr = redisConf.RedisPool.Get(redisConf.RedisKeyPrefix + "notice").Result()
if r == "" || redisErr != nil {
r = "个人开发,仅可用于学习研究。"
}
} else {
r, redisErr = redisConf.RedisPool.Get(redisConf.RedisKeyPrefix + "fkgm").Result()
if r == "" || redisErr != nil {
r = "爸爸爱你"
}
}
return
}
func (p *UserServer) RenameUserById(ctx context.Context, userId int32, NewName string) (r *rpc.Result_, err error) {
return
}
================================================
FILE: common/api/thrift/account.thrift
================================================
namespace go rpc
enum ErrorCode{
Success=0
ServerError=5000,
VerifyError=5001,
UserNotExists=5002,
}
enum ModifyPropType{
gems = 0
roomId = 1
power = 2
ice = 3
}
struct qqInfo{
1:string openId
2:string figureUrl
3:string province
4:string city
5:i64 totalSpending
}
struct UserInfo{
1: i64 userId
2: string userName
3: string nickName
4: i8 sex
5: string headImg
6: i32 lv
7: i64 exp
8: i8 vip
9: i64 gems
10: i64 roomId
11: i64 power
12: i8 reNameCount
13: i8 reHeadCount
14: string registerDate
15: i64 ice
16: string token
17: qqInfo qqInfo
}
struct Result{
1: ErrorCode code
2: UserInfo user_obj
}
service UserService {
//创建临时用户
Result createNewUser(1: string nickName 2:string avatarAuto 3: i64 gold )//初始金币
//创建QQ用户
Result createQQUser(1: UserInfo UserInfo)
//使用openId获取用户
Result getUserInfoByOpenId(1:string openId)
//获取用户信息 BY userId
Result getUserInfoById(1:i32 userId)
//获取用户信息 BY token
Result getUserInfoByToken(1:string token)
//修改用户金币
Result modifyUserInfoById(1:string behavior, 2:i32 userId, 3: ModifyPropType propType, 4: i64 incr)
Result RenameUserById(1:i32 userId,2:string NewName)
string getMessage(1 :string messageType)
}
================================================
FILE: common/api/thrift/gen-go/rpc/GoUnusedProtection__.go
================================================
// Autogenerated by Thrift Compiler (0.12.0)
// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
package rpc
var GoUnusedProtection__ int;
================================================
FILE: common/api/thrift/gen-go/rpc/account-consts.go
================================================
// Autogenerated by Thrift Compiler (0.12.0)
// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
package rpc
import (
"bytes"
"context"
"reflect"
"fmt"
"github.com/apache/thrift/lib/go/thrift"
)
// (needed to ensure safety because of naive import list construction.)
var _ = thrift.ZERO
var _ = fmt.Printf
var _ = context.Background
var _ = reflect.DeepEqual
var _ = bytes.Equal
func init() {
}
================================================
FILE: common/api/thrift/gen-go/rpc/account.go
================================================
// Autogenerated by Thrift Compiler (0.12.0)
// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
package rpc
import (
"bytes"
"context"
"reflect"
"database/sql/driver"
"errors"
"fmt"
"github.com/apache/thrift/lib/go/thrift"
)
// (needed to ensure safety because of naive import list construction.)
var _ = thrift.ZERO
var _ = fmt.Printf
var _ = context.Background
var _ = reflect.DeepEqual
var _ = bytes.Equal
type ErrorCode int64
const (
ErrorCode_Success ErrorCode = 0
ErrorCode_ServerError ErrorCode = 5000
ErrorCode_VerifyError ErrorCode = 5001
ErrorCode_UserNotExists ErrorCode = 5002
)
func (p ErrorCode) String() string {
switch p {
case ErrorCode_Success: return "Success"
case ErrorCode_ServerError: return "ServerError"
case ErrorCode_VerifyError: return "VerifyError"
case ErrorCode_UserNotExists: return "UserNotExists"
}
return "<UNSET>"
}
func ErrorCodeFromString(s string) (ErrorCode, error) {
switch s {
case "Success": return ErrorCode_Success, nil
case "ServerError": return ErrorCode_ServerError, nil
case "VerifyError": return ErrorCode_VerifyError, nil
case "UserNotExists": return ErrorCode_UserNotExists, nil
}
return ErrorCode(0), fmt.Errorf("not a valid ErrorCode string")
}
func ErrorCodePtr(v ErrorCode) *ErrorCode { return &v }
func (p ErrorCode) MarshalText() ([]byte, error) {
return []byte(p.String()), nil
}
func (p *ErrorCode) UnmarshalText(text []byte) error {
q, err := ErrorCodeFromString(string(text))
if (err != nil) {
return err
}
*p = q
return nil
}
func (p *ErrorCode) Scan(value interface{}) error {
v, ok := value.(int64)
if !ok {
return errors.New("Scan value is not int64")
}
*p = ErrorCode(v)
return nil
}
func (p * ErrorCode) Value() (driver.Value, error) {
if p == nil {
return nil, nil
}
return int64(*p), nil
}
type ModifyPropType int64
const (
ModifyPropType_gems ModifyPropType = 0
ModifyPropType_roomId ModifyPropType = 1
ModifyPropType_power ModifyPropType = 2
ModifyPropType_ice ModifyPropType = 3
)
func (p ModifyPropType) String() string {
switch p {
case ModifyPropType_gems: return "gems"
case ModifyPropType_roomId: return "roomId"
case ModifyPropType_power: return "power"
case ModifyPropType_ice: return "ice"
}
return "<UNSET>"
}
func ModifyPropTypeFromString(s string) (ModifyPropType, error) {
switch s {
case "gems": return ModifyPropType_gems, nil
case "roomId": return ModifyPropType_roomId, nil
case "power": return ModifyPropType_power, nil
case "ice": return ModifyPropType_ice, nil
}
return ModifyPropType(0), fmt.Errorf("not a valid ModifyPropType string")
}
func ModifyPropTypePtr(v ModifyPropType) *ModifyPropType { return &v }
func (p ModifyPropType) MarshalText() ([]byte, error) {
return []byte(p.String()), nil
}
func (p *ModifyPropType) UnmarshalText(text []byte) error {
q, err := ModifyPropTypeFromString(string(text))
if (err != nil) {
return err
}
*p = q
return nil
}
func (p *ModifyPropType) Scan(value interface{}) error {
v, ok := value.(int64)
if !ok {
return errors.New("Scan value is not int64")
}
*p = ModifyPropType(v)
return nil
}
func (p * ModifyPropType) Value() (driver.Value, error) {
if p == nil {
return nil, nil
}
return int64(*p), nil
}
// Attributes:
// - OpenId
// - FigureUrl
// - Province
// - City
// - TotalSpending
type QqInfo struct {
OpenId string `thrift:"openId,1" db:"openId" json:"openId"`
FigureUrl string `thrift:"figureUrl,2" db:"figureUrl" json:"figureUrl"`
Province string `thrift:"province,3" db:"province" json:"province"`
City string `thrift:"city,4" db:"city" json:"city"`
TotalSpending int64 `thrift:"totalSpending,5" db:"totalSpending" json:"totalSpending"`
}
func NewQqInfo() *QqInfo {
return &QqInfo{}
}
func (p *QqInfo) GetOpenId() string {
return p.OpenId
}
func (p *QqInfo) GetFigureUrl() string {
return p.FigureUrl
}
func (p *QqInfo) GetProvince() string {
return p.Province
}
func (p *QqInfo) GetCity() string {
return p.City
}
func (p *QqInfo) GetTotalSpending() int64 {
return p.TotalSpending
}
func (p *QqInfo) Read(iprot thrift.TProtocol) error {
if _, err := iprot.ReadStructBegin(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
}
for {
_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
if err != nil {
return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
}
if fieldTypeId == thrift.STOP { break; }
switch fieldId {
case 1:
if fieldTypeId == thrift.STRING {
if err := p.ReadField1(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
case 2:
if fieldTypeId == thrift.STRING {
if err := p.ReadField2(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
case 3:
if fieldTypeId == thrift.STRING {
if err := p.ReadField3(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
case 4:
if fieldTypeId == thrift.STRING {
if err := p.ReadField4(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
case 5:
if fieldTypeId == thrift.I64 {
if err := p.ReadField5(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
default:
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
if err := iprot.ReadFieldEnd(); err != nil {
return err
}
}
if err := iprot.ReadStructEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
}
return nil
}
func (p *QqInfo) ReadField1(iprot thrift.TProtocol) error {
if v, err := iprot.ReadString(); err != nil {
return thrift.PrependError("error reading field 1: ", err)
} else {
p.OpenId = v
}
return nil
}
func (p *QqInfo) ReadField2(iprot thrift.TProtocol) error {
if v, err := iprot.ReadString(); err != nil {
return thrift.PrependError("error reading field 2: ", err)
} else {
p.FigureUrl = v
}
return nil
}
func (p *QqInfo) ReadField3(iprot thrift.TProtocol) error {
if v, err := iprot.ReadString(); err != nil {
return thrift.PrependError("error reading field 3: ", err)
} else {
p.Province = v
}
return nil
}
func (p *QqInfo) ReadField4(iprot thrift.TProtocol) error {
if v, err := iprot.ReadString(); err != nil {
return thrift.PrependError("error reading field 4: ", err)
} else {
p.City = v
}
return nil
}
func (p *QqInfo) ReadField5(iprot thrift.TProtocol) error {
if v, err := iprot.ReadI64(); err != nil {
return thrift.PrependError("error reading field 5: ", err)
} else {
p.TotalSpending = v
}
return nil
}
func (p *QqInfo) Write(oprot thrift.TProtocol) error {
if err := oprot.WriteStructBegin("qqInfo"); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
if p != nil {
if err := p.writeField1(oprot); err != nil { return err }
if err := p.writeField2(oprot); err != nil { return err }
if err := p.writeField3(oprot); err != nil { return err }
if err := p.writeField4(oprot); err != nil { return err }
if err := p.writeField5(oprot); err != nil { return err }
}
if err := oprot.WriteFieldStop(); err != nil {
return thrift.PrependError("write field stop error: ", err) }
if err := oprot.WriteStructEnd(); err != nil {
return thrift.PrependError("write struct stop error: ", err) }
return nil
}
func (p *QqInfo) writeField1(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("openId", thrift.STRING, 1); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:openId: ", p), err) }
if err := oprot.WriteString(string(p.OpenId)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.openId (1) field write error: ", p), err) }
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 1:openId: ", p), err) }
return err
}
func (p *QqInfo) writeField2(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("figureUrl", thrift.STRING, 2); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:figureUrl: ", p), err) }
if err := oprot.WriteString(string(p.FigureUrl)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.figureUrl (2) field write error: ", p), err) }
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 2:figureUrl: ", p), err) }
return err
}
func (p *QqInfo) writeField3(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("province", thrift.STRING, 3); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:province: ", p), err) }
if err := oprot.WriteString(string(p.Province)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.province (3) field write error: ", p), err) }
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 3:province: ", p), err) }
return err
}
func (p *QqInfo) writeField4(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("city", thrift.STRING, 4); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:city: ", p), err) }
if err := oprot.WriteString(string(p.City)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.city (4) field write error: ", p), err) }
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 4:city: ", p), err) }
return err
}
func (p *QqInfo) writeField5(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("totalSpending", thrift.I64, 5); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:totalSpending: ", p), err) }
if err := oprot.WriteI64(int64(p.TotalSpending)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.totalSpending (5) field write error: ", p), err) }
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 5:totalSpending: ", p), err) }
return err
}
func (p *QqInfo) String() string {
if p == nil {
return "<nil>"
}
return fmt.Sprintf("QqInfo(%+v)", *p)
}
// Attributes:
// - UserId
// - UserName
// - NickName
// - Sex
// - HeadImg
// - Lv
// - Exp
// - Vip
// - Gems
// - RoomId
// - Power
// - ReNameCount
// - ReHeadCount
// - RegisterDate
// - Ice
// - Token
// - QqInfo
type UserInfo struct {
UserId int64 `thrift:"userId,1" db:"userId" json:"userId"`
UserName string `thrift:"userName,2" db:"userName" json:"userName"`
NickName string `thrift:"nickName,3" db:"nickName" json:"nickName"`
Sex int8 `thrift:"sex,4" db:"sex" json:"sex"`
HeadImg string `thrift:"headImg,5" db:"headImg" json:"headImg"`
Lv int32 `thrift:"lv,6" db:"lv" json:"lv"`
Exp int64 `thrift:"exp,7" db:"exp" json:"exp"`
Vip int8 `thrift:"vip,8" db:"vip" json:"vip"`
Gems int64 `thrift:"gems,9" db:"gems" json:"gems"`
RoomId int64 `thrift:"roomId,10" db:"roomId" json:"roomId"`
Power int64 `thrift:"power,11" db:"power" json:"power"`
ReNameCount int8 `thrift:"reNameCount,12" db:"reNameCount" json:"reNameCount"`
ReHeadCount int8 `thrift:"reHeadCount,13" db:"reHeadCount" json:"reHeadCount"`
RegisterDate string `thrift:"registerDate,14" db:"registerDate" json:"registerDate"`
Ice int64 `thrift:"ice,15" db:"ice" json:"ice"`
Token string `thrift:"token,16" db:"token" json:"token"`
QqInfo *QqInfo `thrift:"qqInfo,17" db:"qqInfo" json:"qqInfo"`
}
func NewUserInfo() *UserInfo {
return &UserInfo{}
}
func (p *UserInfo) GetUserId() int64 {
return p.UserId
}
func (p *UserInfo) GetUserName() string {
return p.UserName
}
func (p *UserInfo) GetNickName() string {
return p.NickName
}
func (p *UserInfo) GetSex() int8 {
return p.Sex
}
func (p *UserInfo) GetHeadImg() string {
return p.HeadImg
}
func (p *UserInfo) GetLv() int32 {
return p.Lv
}
func (p *UserInfo) GetExp() int64 {
return p.Exp
}
func (p *UserInfo) GetVip() int8 {
return p.Vip
}
func (p *UserInfo) GetGems() int64 {
return p.Gems
}
func (p *UserInfo) GetRoomId() int64 {
return p.RoomId
}
func (p *UserInfo) GetPower() int64 {
return p.Power
}
func (p *UserInfo) GetReNameCount() int8 {
return p.ReNameCount
}
func (p *UserInfo) GetReHeadCount() int8 {
return p.ReHeadCount
}
func (p *UserInfo) GetRegisterDate() string {
return p.RegisterDate
}
func (p *UserInfo) GetIce() int64 {
return p.Ice
}
func (p *UserInfo) GetToken() string {
return p.Token
}
var UserInfo_QqInfo_DEFAULT *QqInfo
func (p *UserInfo) GetQqInfo() *QqInfo {
if !p.IsSetQqInfo() {
return UserInfo_QqInfo_DEFAULT
}
return p.QqInfo
}
func (p *UserInfo) IsSetQqInfo() bool {
return p.QqInfo != nil
}
func (p *UserInfo) Read(iprot thrift.TProtocol) error {
if _, err := iprot.ReadStructBegin(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
}
for {
_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
if err != nil {
return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
}
if fieldTypeId == thrift.STOP { break; }
switch fieldId {
case 1:
if fieldTypeId == thrift.I64 {
if err := p.ReadField1(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
case 2:
if fieldTypeId == thrift.STRING {
if err := p.ReadField2(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
case 3:
if fieldTypeId == thrift.STRING {
if err := p.ReadField3(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
case 4:
if fieldTypeId == thrift.BYTE {
if err := p.ReadField4(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
case 5:
if fieldTypeId == thrift.STRING {
if err := p.ReadField5(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
case 6:
if fieldTypeId == thrift.I32 {
if err := p.ReadField6(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
case 7:
if fieldTypeId == thrift.I64 {
if err := p.ReadField7(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
case 8:
if fieldTypeId == thrift.BYTE {
if err := p.ReadField8(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
case 9:
if fieldTypeId == thrift.I64 {
if err := p.ReadField9(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
case 10:
if fieldTypeId == thrift.I64 {
if err := p.ReadField10(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
case 11:
if fieldTypeId == thrift.I64 {
if err := p.ReadField11(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
case 12:
if fieldTypeId == thrift.BYTE {
if err := p.ReadField12(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
case 13:
if fieldTypeId == thrift.BYTE {
if err := p.ReadField13(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
case 14:
if fieldTypeId == thrift.STRING {
if err := p.ReadField14(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
case 15:
if fieldTypeId == thrift.I64 {
if err := p.ReadField15(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
case 16:
if fieldTypeId == thrift.STRING {
if err := p.ReadField16(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
case 17:
if fieldTypeId == thrift.STRUCT {
if err := p.ReadField17(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
default:
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
if err := iprot.ReadFieldEnd(); err != nil {
return err
}
}
if err := iprot.ReadStructEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
}
return nil
}
func (p *UserInfo) ReadField1(iprot thrift.TProtocol) error {
if v, err := iprot.ReadI64(); err != nil {
return thrift.PrependError("error reading field 1: ", err)
} else {
p.UserId = v
}
return nil
}
func (p *UserInfo) ReadField2(iprot thrift.TProtocol) error {
if v, err := iprot.ReadString(); err != nil {
return thrift.PrependError("error reading field 2: ", err)
} else {
p.UserName = v
}
return nil
}
func (p *UserInfo) ReadField3(iprot thrift.TProtocol) error {
if v, err := iprot.ReadString(); err != nil {
return thrift.PrependError("error reading field 3: ", err)
} else {
p.NickName = v
}
return nil
}
func (p *UserInfo) ReadField4(iprot thrift.TProtocol) error {
if v, err := iprot.ReadByte(); err != nil {
return thrift.PrependError("error reading field 4: ", err)
} else {
temp := int8(v)
p.Sex = temp
}
return nil
}
func (p *UserInfo) ReadField5(iprot thrift.TProtocol) error {
if v, err := iprot.ReadString(); err != nil {
return thrift.PrependError("error reading field 5: ", err)
} else {
p.HeadImg = v
}
return nil
}
func (p *UserInfo) ReadField6(iprot thrift.TProtocol) error {
if v, err := iprot.ReadI32(); err != nil {
return thrift.PrependError("error reading field 6: ", err)
} else {
p.Lv = v
}
return nil
}
func (p *UserInfo) ReadField7(iprot thrift.TProtocol) error {
if v, err := iprot.ReadI64(); err != nil {
return thrift.PrependError("error reading field 7: ", err)
} else {
p.Exp = v
}
return nil
}
func (p *UserInfo) ReadField8(iprot thrift.TProtocol) error {
if v, err := iprot.ReadByte(); err != nil {
return thrift.PrependError("error reading field 8: ", err)
} else {
temp := int8(v)
p.Vip = temp
}
return nil
}
func (p *UserInfo) ReadField9(iprot thrift.TProtocol) error {
if v, err := iprot.ReadI64(); err != nil {
return thrift.PrependError("error reading field 9: ", err)
} else {
p.Gems = v
}
return nil
}
func (p *UserInfo) ReadField10(iprot thrift.TProtocol) error {
if v, err := iprot.ReadI64(); err != nil {
return thrift.PrependError("error reading field 10: ", err)
} else {
p.RoomId = v
}
return nil
}
func (p *UserInfo) ReadField11(iprot thrift.TProtocol) error {
if v, err := iprot.ReadI64(); err != nil {
return thrift.PrependError("error reading field 11: ", err)
} else {
p.Power = v
}
return nil
}
func (p *UserInfo) ReadField12(iprot thrift.TProtocol) error {
if v, err := iprot.ReadByte(); err != nil {
return thrift.PrependError("error reading field 12: ", err)
} else {
temp := int8(v)
p.ReNameCount = temp
}
return nil
}
func (p *UserInfo) ReadField13(iprot thrift.TProtocol) error {
if v, err := iprot.ReadByte(); err != nil {
return thrift.PrependError("error reading field 13: ", err)
} else {
temp := int8(v)
p.ReHeadCount = temp
}
return nil
}
func (p *UserInfo) ReadField14(iprot thrift.TProtocol) error {
if v, err := iprot.ReadString(); err != nil {
return thrift.PrependError("error reading field 14: ", err)
} else {
p.RegisterDate = v
}
return nil
}
func (p *UserInfo) ReadField15(iprot thrift.TProtocol) error {
if v, err := iprot.ReadI64(); err != nil {
return thrift.PrependError("error reading field 15: ", err)
} else {
p.Ice = v
}
return nil
}
func (p *UserInfo) ReadField16(iprot thrift.TProtocol) error {
if v, err := iprot.ReadString(); err != nil {
return thrift.PrependError("error reading field 16: ", err)
} else {
p.Token = v
}
return nil
}
func (p *UserInfo) ReadField17(iprot thrift.TProtocol) error {
p.QqInfo = &QqInfo{}
if err := p.QqInfo.Read(iprot); err != nil {
return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.QqInfo), err)
}
return nil
}
func (p *UserInfo) Write(oprot thrift.TProtocol) error {
if err := oprot.WriteStructBegin("UserInfo"); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
if p != nil {
if err := p.writeField1(oprot); err != nil { return err }
if err := p.writeField2(oprot); err != nil { return err }
if err := p.writeField3(oprot); err != nil { return err }
if err := p.writeField4(oprot); err != nil { return err }
if err := p.writeField5(oprot); err != nil { return err }
if err := p.writeField6(oprot); err != nil { return err }
if err := p.writeField7(oprot); err != nil { return err }
if err := p.writeField8(oprot); err != nil { return err }
if err := p.writeField9(oprot); err != nil { return err }
if err := p.writeField10(oprot); err != nil { return err }
if err := p.writeField11(oprot); err != nil { return err }
if err := p.writeField12(oprot); err != nil { return err }
if err := p.writeField13(oprot); err != nil { return err }
if err := p.writeField14(oprot); err != nil { return err }
if err := p.writeField15(oprot); err != nil { return err }
if err := p.writeField16(oprot); err != nil { return err }
if err := p.writeField17(oprot); err != nil { return err }
}
if err := oprot.WriteFieldStop(); err != nil {
return thrift.PrependError("write field stop error: ", err) }
if err := oprot.WriteStructEnd(); err != nil {
return thrift.PrependError("write struct stop error: ", err) }
return nil
}
func (p *UserInfo) writeField1(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("userId", thrift.I64, 1); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:userId: ", p), err) }
if err := oprot.WriteI64(int64(p.UserId)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.userId (1) field write error: ", p), err) }
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 1:userId: ", p), err) }
return err
}
func (p *UserInfo) writeField2(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("userName", thrift.STRING, 2); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:userName: ", p), err) }
if err := oprot.WriteString(string(p.UserName)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.userName (2) field write error: ", p), err) }
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 2:userName: ", p), err) }
return err
}
func (p *UserInfo) writeField3(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("nickName", thrift.STRING, 3); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:nickName: ", p), err) }
if err := oprot.WriteString(string(p.NickName)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.nickName (3) field write error: ", p), err) }
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 3:nickName: ", p), err) }
return err
}
func (p *UserInfo) writeField4(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("sex", thrift.BYTE, 4); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:sex: ", p), err) }
if err := oprot.WriteByte(int8(p.Sex)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.sex (4) field write error: ", p), err) }
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 4:sex: ", p), err) }
return err
}
func (p *UserInfo) writeField5(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("headImg", thrift.STRING, 5); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:headImg: ", p), err) }
if err := oprot.WriteString(string(p.HeadImg)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.headImg (5) field write error: ", p), err) }
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 5:headImg: ", p), err) }
return err
}
func (p *UserInfo) writeField6(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("lv", thrift.I32, 6); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:lv: ", p), err) }
if err := oprot.WriteI32(int32(p.Lv)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.lv (6) field write error: ", p), err) }
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 6:lv: ", p), err) }
return err
}
func (p *UserInfo) writeField7(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("exp", thrift.I64, 7); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:exp: ", p), err) }
if err := oprot.WriteI64(int64(p.Exp)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.exp (7) field write error: ", p), err) }
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 7:exp: ", p), err) }
return err
}
func (p *UserInfo) writeField8(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("vip", thrift.BYTE, 8); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 8:vip: ", p), err) }
if err := oprot.WriteByte(int8(p.Vip)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.vip (8) field write error: ", p), err) }
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 8:vip: ", p), err) }
return err
}
func (p *UserInfo) writeField9(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("gems", thrift.I64, 9); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 9:gems: ", p), err) }
if err := oprot.WriteI64(int64(p.Gems)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.gems (9) field write error: ", p), err) }
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 9:gems: ", p), err) }
return err
}
func (p *UserInfo) writeField10(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("roomId", thrift.I64, 10); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 10:roomId: ", p), err) }
if err := oprot.WriteI64(int64(p.RoomId)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.roomId (10) field write error: ", p), err) }
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 10:roomId: ", p), err) }
return err
}
func (p *UserInfo) writeField11(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("power", thrift.I64, 11); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 11:power: ", p), err) }
if err := oprot.WriteI64(int64(p.Power)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.power (11) field write error: ", p), err) }
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 11:power: ", p), err) }
return err
}
func (p *UserInfo) writeField12(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("reNameCount", thrift.BYTE, 12); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 12:reNameCount: ", p), err) }
if err := oprot.WriteByte(int8(p.ReNameCount)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.reNameCount (12) field write error: ", p), err) }
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 12:reNameCount: ", p), err) }
return err
}
func (p *UserInfo) writeField13(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("reHeadCount", thrift.BYTE, 13); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 13:reHeadCount: ", p), err) }
if err := oprot.WriteByte(int8(p.ReHeadCount)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.reHeadCount (13) field write error: ", p), err) }
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 13:reHeadCount: ", p), err) }
return err
}
func (p *UserInfo) writeField14(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("registerDate", thrift.STRING, 14); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 14:registerDate: ", p), err) }
if err := oprot.WriteString(string(p.RegisterDate)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.registerDate (14) field write error: ", p), err) }
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 14:registerDate: ", p), err) }
return err
}
func (p *UserInfo) writeField15(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("ice", thrift.I64, 15); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 15:ice: ", p), err) }
if err := oprot.WriteI64(int64(p.Ice)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.ice (15) field write error: ", p), err) }
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 15:ice: ", p), err) }
return err
}
func (p *UserInfo) writeField16(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("token", thrift.STRING, 16); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 16:token: ", p), err) }
if err := oprot.WriteString(string(p.Token)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.token (16) field write error: ", p), err) }
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 16:token: ", p), err) }
return err
}
func (p *UserInfo) writeField17(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("qqInfo", thrift.STRUCT, 17); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 17:qqInfo: ", p), err) }
if err := p.QqInfo.Write(oprot); err != nil {
return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.QqInfo), err)
}
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 17:qqInfo: ", p), err) }
return err
}
func (p *UserInfo) String() string {
if p == nil {
return "<nil>"
}
return fmt.Sprintf("UserInfo(%+v)", *p)
}
// Attributes:
// - Code
// - UserObj
type Result_ struct {
Code ErrorCode `thrift:"code,1" db:"code" json:"code"`
UserObj *UserInfo `thrift:"user_obj,2" db:"user_obj" json:"user_obj"`
}
func NewResult_() *Result_ {
return &Result_{}
}
func (p *Result_) GetCode() ErrorCode {
return p.Code
}
var Result__UserObj_DEFAULT *UserInfo
func (p *Result_) GetUserObj() *UserInfo {
if !p.IsSetUserObj() {
return Result__UserObj_DEFAULT
}
return p.UserObj
}
func (p *Result_) IsSetUserObj() bool {
return p.UserObj != nil
}
func (p *Result_) Read(iprot thrift.TProtocol) error {
if _, err := iprot.ReadStructBegin(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
}
for {
_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
if err != nil {
return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
}
if fieldTypeId == thrift.STOP { break; }
switch fieldId {
case 1:
if fieldTypeId == thrift.I32 {
if err := p.ReadField1(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
case 2:
if fieldTypeId == thrift.STRUCT {
if err := p.ReadField2(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
default:
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
if err := iprot.ReadFieldEnd(); err != nil {
return err
}
}
if err := iprot.ReadStructEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
}
return nil
}
func (p *Result_) ReadField1(iprot thrift.TProtocol) error {
if v, err := iprot.ReadI32(); err != nil {
return thrift.PrependError("error reading field 1: ", err)
} else {
temp := ErrorCode(v)
p.Code = temp
}
return nil
}
func (p *Result_) ReadField2(iprot thrift.TProtocol) error {
p.UserObj = &UserInfo{}
if err := p.UserObj.Read(iprot); err != nil {
return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.UserObj), err)
}
return nil
}
func (p *Result_) Write(oprot thrift.TProtocol) error {
if err := oprot.WriteStructBegin("Result"); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
if p != nil {
if err := p.writeField1(oprot); err != nil { return err }
if err := p.writeField2(oprot); err != nil { return err }
}
if err := oprot.WriteFieldStop(); err != nil {
return thrift.PrependError("write field stop error: ", err) }
if err := oprot.WriteStructEnd(); err != nil {
return thrift.PrependError("write struct stop error: ", err) }
return nil
}
func (p *Result_) writeField1(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("code", thrift.I32, 1); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:code: ", p), err) }
if err := oprot.WriteI32(int32(p.Code)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.code (1) field write error: ", p), err) }
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 1:code: ", p), err) }
return err
}
func (p *Result_) writeField2(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("user_obj", thrift.STRUCT, 2); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:user_obj: ", p), err) }
if err := p.UserObj.Write(oprot); err != nil {
return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.UserObj), err)
}
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 2:user_obj: ", p), err) }
return err
}
func (p *Result_) String() string {
if p == nil {
return "<nil>"
}
return fmt.Sprintf("Result_(%+v)", *p)
}
type UserService interface {
// Parameters:
// - NickName
// - AvatarAuto
// - Gold
CreateNewUser(ctx context.Context, nickName string, avatarAuto string, gold int64) (r *Result_, err error)
// Parameters:
// - UserInfo
CreateQQUser(ctx context.Context, UserInfo *UserInfo) (r *Result_, err error)
// Parameters:
// - OpenId
GetUserInfoByOpenId(ctx context.Context, openId string) (r *Result_, err error)
// Parameters:
// - UserId
GetUserInfoById(ctx context.Context, userId int32) (r *Result_, err error)
// Parameters:
// - Token
GetUserInfoByToken(ctx context.Context, token string) (r *Result_, err error)
// Parameters:
// - Behavior
// - UserId
// - PropType
// - Incr
ModifyUserInfoById(ctx context.Context, behavior string, userId int32, propType ModifyPropType, incr int64) (r *Result_, err error)
// Parameters:
// - UserId
// - NewName_
RenameUserById(ctx context.Context, userId int32, NewName string) (r *Result_, err error)
// Parameters:
// - MessageType
GetMessage(ctx context.Context, messageType string) (r string, err error)
}
type UserServiceClient struct {
c thrift.TClient
}
func NewUserServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *UserServiceClient {
return &UserServiceClient{
c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)),
}
}
func NewUserServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *UserServiceClient {
return &UserServiceClient{
c: thrift.NewTStandardClient(iprot, oprot),
}
}
func NewUserServiceClient(c thrift.TClient) *UserServiceClient {
return &UserServiceClient{
c: c,
}
}
func (p *UserServiceClient) Client_() thrift.TClient {
return p.c
}
// Parameters:
// - NickName
// - AvatarAuto
// - Gold
func (p *UserServiceClient) CreateNewUser(ctx context.Context, nickName string, avatarAuto string, gold int64) (r *Result_, err error) {
var _args0 UserServiceCreateNewUserArgs
_args0.NickName = nickName
_args0.AvatarAuto = avatarAuto
_args0.Gold = gold
var _result1 UserServiceCreateNewUserResult
if err = p.Client_().Call(ctx, "createNewUser", &_args0, &_result1); err != nil {
return
}
return _result1.GetSuccess(), nil
}
// Parameters:
// - UserInfo
func (p *UserServiceClient) CreateQQUser(ctx context.Context, UserInfo *UserInfo) (r *Result_, err error) {
var _args2 UserServiceCreateQQUserArgs
_args2.UserInfo = UserInfo
var _result3 UserServiceCreateQQUserResult
if err = p.Client_().Call(ctx, "createQQUser", &_args2, &_result3); err != nil {
return
}
return _result3.GetSuccess(), nil
}
// Parameters:
// - OpenId
func (p *UserServiceClient) GetUserInfoByOpenId(ctx context.Context, openId string) (r *Result_, err error) {
var _args4 UserServiceGetUserInfoByOpenIdArgs
_args4.OpenId = openId
var _result5 UserServiceGetUserInfoByOpenIdResult
if err = p.Client_().Call(ctx, "getUserInfoByOpenId", &_args4, &_result5); err != nil {
return
}
return _result5.GetSuccess(), nil
}
// Parameters:
// - UserId
func (p *UserServiceClient) GetUserInfoById(ctx context.Context, userId int32) (r *Result_, err error) {
var _args6 UserServiceGetUserInfoByIdArgs
_args6.UserId = userId
var _result7 UserServiceGetUserInfoByIdResult
if err = p.Client_().Call(ctx, "getUserInfoById", &_args6, &_result7); err != nil {
return
}
return _result7.GetSuccess(), nil
}
// Parameters:
// - Token
func (p *UserServiceClient) GetUserInfoByToken(ctx context.Context, token string) (r *Result_, err error) {
var _args8 UserServiceGetUserInfoByTokenArgs
_args8.Token = token
var _result9 UserServiceGetUserInfoByTokenResult
if err = p.Client_().Call(ctx, "getUserInfoByToken", &_args8, &_result9); err != nil {
return
}
return _result9.GetSuccess(), nil
}
// Parameters:
// - Behavior
// - UserId
// - PropType
// - Incr
func (p *UserServiceClient) ModifyUserInfoById(ctx context.Context, behavior string, userId int32, propType ModifyPropType, incr int64) (r *Result_, err error) {
var _args10 UserServiceModifyUserInfoByIdArgs
_args10.Behavior = behavior
_args10.UserId = userId
_args10.PropType = propType
_args10.Incr = incr
var _result11 UserServiceModifyUserInfoByIdResult
if err = p.Client_().Call(ctx, "modifyUserInfoById", &_args10, &_result11); err != nil {
return
}
return _result11.GetSuccess(), nil
}
// Parameters:
// - UserId
// - NewName_
func (p *UserServiceClient) RenameUserById(ctx context.Context, userId int32, NewName string) (r *Result_, err error) {
var _args12 UserServiceRenameUserByIdArgs
_args12.UserId = userId
_args12.NewName_ = NewName
var _result13 UserServiceRenameUserByIdResult
if err = p.Client_().Call(ctx, "RenameUserById", &_args12, &_result13); err != nil {
return
}
return _result13.GetSuccess(), nil
}
// Parameters:
// - MessageType
func (p *UserServiceClient) GetMessage(ctx context.Context, messageType string) (r string, err error) {
var _args14 UserServiceGetMessageArgs
_args14.MessageType = messageType
var _result15 UserServiceGetMessageResult
if err = p.Client_().Call(ctx, "getMessage", &_args14, &_result15); err != nil {
return
}
return _result15.GetSuccess(), nil
}
type UserServiceProcessor struct {
processorMap map[string]thrift.TProcessorFunction
handler UserService
}
func (p *UserServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) {
p.processorMap[key] = processor
}
func (p *UserServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) {
processor, ok = p.processorMap[key]
return processor, ok
}
func (p *UserServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction {
return p.processorMap
}
func NewUserServiceProcessor(handler UserService) *UserServiceProcessor {
self16 := &UserServiceProcessor{handler:handler, processorMap:make(map[string]thrift.TProcessorFunction)}
self16.processorMap["createNewUser"] = &userServiceProcessorCreateNewUser{handler:handler}
self16.processorMap["createQQUser"] = &userServiceProcessorCreateQQUser{handler:handler}
self16.processorMap["getUserInfoByOpenId"] = &userServiceProcessorGetUserInfoByOpenId{handler:handler}
self16.processorMap["getUserInfoById"] = &userServiceProcessorGetUserInfoById{handler:handler}
self16.processorMap["getUserInfoByToken"] = &userServiceProcessorGetUserInfoByToken{handler:handler}
self16.processorMap["modifyUserInfoById"] = &userServiceProcessorModifyUserInfoById{handler:handler}
self16.processorMap["RenameUserById"] = &userServiceProcessorRenameUserById{handler:handler}
self16.processorMap["getMessage"] = &userServiceProcessorGetMessage{handler:handler}
return self16
}
func (p *UserServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
name, _, seqId, err := iprot.ReadMessageBegin()
if err != nil { return false, err }
if processor, ok := p.GetProcessorFunction(name); ok {
return processor.Process(ctx, seqId, iprot, oprot)
}
iprot.Skip(thrift.STRUCT)
iprot.ReadMessageEnd()
x17 := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function " + name)
oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId)
x17.Write(oprot)
oprot.WriteMessageEnd()
oprot.Flush(ctx)
return false, x17
}
type userServiceProcessorCreateNewUser struct {
handler UserService
}
func (p *userServiceProcessorCreateNewUser) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
args := UserServiceCreateNewUserArgs{}
if err = args.Read(iprot); err != nil {
iprot.ReadMessageEnd()
x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())
oprot.WriteMessageBegin("createNewUser", thrift.EXCEPTION, seqId)
x.Write(oprot)
oprot.WriteMessageEnd()
oprot.Flush(ctx)
return false, err
}
iprot.ReadMessageEnd()
result := UserServiceCreateNewUserResult{}
var retval *Result_
var err2 error
if retval, err2 = p.handler.CreateNewUser(ctx, args.NickName, args.AvatarAuto, args.Gold); err2 != nil {
x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing createNewUser: " + err2.Error())
oprot.WriteMessageBegin("createNewUser", thrift.EXCEPTION, seqId)
x.Write(oprot)
oprot.WriteMessageEnd()
oprot.Flush(ctx)
return true, err2
} else {
result.Success = retval
}
if err2 = oprot.WriteMessageBegin("createNewUser", thrift.REPLY, seqId); err2 != nil {
err = err2
}
if err2 = result.Write(oprot); err == nil && err2 != nil {
err = err2
}
if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil {
err = err2
}
if err2 = oprot.Flush(ctx); err == nil && err2 != nil {
err = err2
}
if err != nil {
return
}
return true, err
}
type userServiceProcessorCreateQQUser struct {
handler UserService
}
func (p *userServiceProcessorCreateQQUser) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
args := UserServiceCreateQQUserArgs{}
if err = args.Read(iprot); err != nil {
iprot.ReadMessageEnd()
x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())
oprot.WriteMessageBegin("createQQUser", thrift.EXCEPTION, seqId)
x.Write(oprot)
oprot.WriteMessageEnd()
oprot.Flush(ctx)
return false, err
}
iprot.ReadMessageEnd()
result := UserServiceCreateQQUserResult{}
var retval *Result_
var err2 error
if retval, err2 = p.handler.CreateQQUser(ctx, args.UserInfo); err2 != nil {
x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing createQQUser: " + err2.Error())
oprot.WriteMessageBegin("createQQUser", thrift.EXCEPTION, seqId)
x.Write(oprot)
oprot.WriteMessageEnd()
oprot.Flush(ctx)
return true, err2
} else {
result.Success = retval
}
if err2 = oprot.WriteMessageBegin("createQQUser", thrift.REPLY, seqId); err2 != nil {
err = err2
}
if err2 = result.Write(oprot); err == nil && err2 != nil {
err = err2
}
if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil {
err = err2
}
if err2 = oprot.Flush(ctx); err == nil && err2 != nil {
err = err2
}
if err != nil {
return
}
return true, err
}
type userServiceProcessorGetUserInfoByOpenId struct {
handler UserService
}
func (p *userServiceProcessorGetUserInfoByOpenId) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
args := UserServiceGetUserInfoByOpenIdArgs{}
if err = args.Read(iprot); err != nil {
iprot.ReadMessageEnd()
x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())
oprot.WriteMessageBegin("getUserInfoByOpenId", thrift.EXCEPTION, seqId)
x.Write(oprot)
oprot.WriteMessageEnd()
oprot.Flush(ctx)
return false, err
}
iprot.ReadMessageEnd()
result := UserServiceGetUserInfoByOpenIdResult{}
var retval *Result_
var err2 error
if retval, err2 = p.handler.GetUserInfoByOpenId(ctx, args.OpenId); err2 != nil {
x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getUserInfoByOpenId: " + err2.Error())
oprot.WriteMessageBegin("getUserInfoByOpenId", thrift.EXCEPTION, seqId)
x.Write(oprot)
oprot.WriteMessageEnd()
oprot.Flush(ctx)
return true, err2
} else {
result.Success = retval
}
if err2 = oprot.WriteMessageBegin("getUserInfoByOpenId", thrift.REPLY, seqId); err2 != nil {
err = err2
}
if err2 = result.Write(oprot); err == nil && err2 != nil {
err = err2
}
if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil {
err = err2
}
if err2 = oprot.Flush(ctx); err == nil && err2 != nil {
err = err2
}
if err != nil {
return
}
return true, err
}
type userServiceProcessorGetUserInfoById struct {
handler UserService
}
func (p *userServiceProcessorGetUserInfoById) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
args := UserServiceGetUserInfoByIdArgs{}
if err = args.Read(iprot); err != nil {
iprot.ReadMessageEnd()
x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())
oprot.WriteMessageBegin("getUserInfoById", thrift.EXCEPTION, seqId)
x.Write(oprot)
oprot.WriteMessageEnd()
oprot.Flush(ctx)
return false, err
}
iprot.ReadMessageEnd()
result := UserServiceGetUserInfoByIdResult{}
var retval *Result_
var err2 error
if retval, err2 = p.handler.GetUserInfoById(ctx, args.UserId); err2 != nil {
x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getUserInfoById: " + err2.Error())
oprot.WriteMessageBegin("getUserInfoById", thrift.EXCEPTION, seqId)
x.Write(oprot)
oprot.WriteMessageEnd()
oprot.Flush(ctx)
return true, err2
} else {
result.Success = retval
}
if err2 = oprot.WriteMessageBegin("getUserInfoById", thrift.REPLY, seqId); err2 != nil {
err = err2
}
if err2 = result.Write(oprot); err == nil && err2 != nil {
err = err2
}
if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil {
err = err2
}
if err2 = oprot.Flush(ctx); err == nil && err2 != nil {
err = err2
}
if err != nil {
return
}
return true, err
}
type userServiceProcessorGetUserInfoByToken struct {
handler UserService
}
func (p *userServiceProcessorGetUserInfoByToken) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
args := UserServiceGetUserInfoByTokenArgs{}
if err = args.Read(iprot); err != nil {
iprot.ReadMessageEnd()
x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())
oprot.WriteMessageBegin("getUserInfoByToken", thrift.EXCEPTION, seqId)
x.Write(oprot)
oprot.WriteMessageEnd()
oprot.Flush(ctx)
return false, err
}
iprot.ReadMessageEnd()
result := UserServiceGetUserInfoByTokenResult{}
var retval *Result_
var err2 error
if retval, err2 = p.handler.GetUserInfoByToken(ctx, args.Token); err2 != nil {
x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getUserInfoByToken: " + err2.Error())
oprot.WriteMessageBegin("getUserInfoByToken", thrift.EXCEPTION, seqId)
x.Write(oprot)
oprot.WriteMessageEnd()
oprot.Flush(ctx)
return true, err2
} else {
result.Success = retval
}
if err2 = oprot.WriteMessageBegin("getUserInfoByToken", thrift.REPLY, seqId); err2 != nil {
err = err2
}
if err2 = result.Write(oprot); err == nil && err2 != nil {
err = err2
}
if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil {
err = err2
}
if err2 = oprot.Flush(ctx); err == nil && err2 != nil {
err = err2
}
if err != nil {
return
}
return true, err
}
type userServiceProcessorModifyUserInfoById struct {
handler UserService
}
func (p *userServiceProcessorModifyUserInfoById) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
args := UserServiceModifyUserInfoByIdArgs{}
if err = args.Read(iprot); err != nil {
iprot.ReadMessageEnd()
x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())
oprot.WriteMessageBegin("modifyUserInfoById", thrift.EXCEPTION, seqId)
x.Write(oprot)
oprot.WriteMessageEnd()
oprot.Flush(ctx)
return false, err
}
iprot.ReadMessageEnd()
result := UserServiceModifyUserInfoByIdResult{}
var retval *Result_
var err2 error
if retval, err2 = p.handler.ModifyUserInfoById(ctx, args.Behavior, args.UserId, args.PropType, args.Incr); err2 != nil {
x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing modifyUserInfoById: " + err2.Error())
oprot.WriteMessageBegin("modifyUserInfoById", thrift.EXCEPTION, seqId)
x.Write(oprot)
oprot.WriteMessageEnd()
oprot.Flush(ctx)
return true, err2
} else {
result.Success = retval
}
if err2 = oprot.WriteMessageBegin("modifyUserInfoById", thrift.REPLY, seqId); err2 != nil {
err = err2
}
if err2 = result.Write(oprot); err == nil && err2 != nil {
err = err2
}
if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil {
err = err2
}
if err2 = oprot.Flush(ctx); err == nil && err2 != nil {
err = err2
}
if err != nil {
return
}
return true, err
}
type userServiceProcessorRenameUserById struct {
handler UserService
}
func (p *userServiceProcessorRenameUserById) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
args := UserServiceRenameUserByIdArgs{}
if err = args.Read(iprot); err != nil {
iprot.ReadMessageEnd()
x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())
oprot.WriteMessageBegin("RenameUserById", thrift.EXCEPTION, seqId)
x.Write(oprot)
oprot.WriteMessageEnd()
oprot.Flush(ctx)
return false, err
}
iprot.ReadMessageEnd()
result := UserServiceRenameUserByIdResult{}
var retval *Result_
var err2 error
if retval, err2 = p.handler.RenameUserById(ctx, args.UserId, args.NewName_); err2 != nil {
x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing RenameUserById: " + err2.Error())
oprot.WriteMessageBegin("RenameUserById", thrift.EXCEPTION, seqId)
x.Write(oprot)
oprot.WriteMessageEnd()
oprot.Flush(ctx)
return true, err2
} else {
result.Success = retval
}
if err2 = oprot.WriteMessageBegin("RenameUserById", thrift.REPLY, seqId); err2 != nil {
err = err2
}
if err2 = result.Write(oprot); err == nil && err2 != nil {
err = err2
}
if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil {
err = err2
}
if err2 = oprot.Flush(ctx); err == nil && err2 != nil {
err = err2
}
if err != nil {
return
}
return true, err
}
type userServiceProcessorGetMessage struct {
handler UserService
}
func (p *userServiceProcessorGetMessage) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
args := UserServiceGetMessageArgs{}
if err = args.Read(iprot); err != nil {
iprot.ReadMessageEnd()
x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())
oprot.WriteMessageBegin("getMessage", thrift.EXCEPTION, seqId)
x.Write(oprot)
oprot.WriteMessageEnd()
oprot.Flush(ctx)
return false, err
}
iprot.ReadMessageEnd()
result := UserServiceGetMessageResult{}
var retval string
var err2 error
if retval, err2 = p.handler.GetMessage(ctx, args.MessageType); err2 != nil {
x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getMessage: " + err2.Error())
oprot.WriteMessageBegin("getMessage", thrift.EXCEPTION, seqId)
x.Write(oprot)
oprot.WriteMessageEnd()
oprot.Flush(ctx)
return true, err2
} else {
result.Success = &retval
}
if err2 = oprot.WriteMessageBegin("getMessage", thrift.REPLY, seqId); err2 != nil {
err = err2
}
if err2 = result.Write(oprot); err == nil && err2 != nil {
err = err2
}
if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil {
err = err2
}
if err2 = oprot.Flush(ctx); err == nil && err2 != nil {
err = err2
}
if err != nil {
return
}
return true, err
}
// HELPER FUNCTIONS AND STRUCTURES
// Attributes:
// - NickName
// - AvatarAuto
// - Gold
type UserServiceCreateNewUserArgs struct {
NickName string `thrift:"nickName,1" db:"nickName" json:"nickName"`
AvatarAuto string `thrift:"avatarAuto,2" db:"avatarAuto" json:"avatarAuto"`
Gold int64 `thrift:"gold,3" db:"gold" json:"gold"`
}
func NewUserServiceCreateNewUserArgs() *UserServiceCreateNewUserArgs {
return &UserServiceCreateNewUserArgs{}
}
func (p *UserServiceCreateNewUserArgs) GetNickName() string {
return p.NickName
}
func (p *UserServiceCreateNewUserArgs) GetAvatarAuto() string {
return p.AvatarAuto
}
func (p *UserServiceCreateNewUserArgs) GetGold() int64 {
return p.Gold
}
func (p *UserServiceCreateNewUserArgs) Read(iprot thrift.TProtocol) error {
if _, err := iprot.ReadStructBegin(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
}
for {
_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
if err != nil {
return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
}
if fieldTypeId == thrift.STOP { break; }
switch fieldId {
case 1:
if fieldTypeId == thrift.STRING {
if err := p.ReadField1(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
case 2:
if fieldTypeId == thrift.STRING {
if err := p.ReadField2(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
case 3:
if fieldTypeId == thrift.I64 {
if err := p.ReadField3(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
default:
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
if err := iprot.ReadFieldEnd(); err != nil {
return err
}
}
if err := iprot.ReadStructEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
}
return nil
}
func (p *UserServiceCreateNewUserArgs) ReadField1(iprot thrift.TProtocol) error {
if v, err := iprot.ReadString(); err != nil {
return thrift.PrependError("error reading field 1: ", err)
} else {
p.NickName = v
}
return nil
}
func (p *UserServiceCreateNewUserArgs) ReadField2(iprot thrift.TProtocol) error {
if v, err := iprot.ReadString(); err != nil {
return thrift.PrependError("error reading field 2: ", err)
} else {
p.AvatarAuto = v
}
return nil
}
func (p *UserServiceCreateNewUserArgs) ReadField3(iprot thrift.TProtocol) error {
if v, err := iprot.ReadI64(); err != nil {
return thrift.PrependError("error reading field 3: ", err)
} else {
p.Gold = v
}
return nil
}
func (p *UserServiceCreateNewUserArgs) Write(oprot thrift.TProtocol) error {
if err := oprot.WriteStructBegin("createNewUser_args"); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
if p != nil {
if err := p.writeField1(oprot); err != nil { return err }
if err := p.writeField2(oprot); err != nil { return err }
if err := p.writeField3(oprot); err != nil { return err }
}
if err := oprot.WriteFieldStop(); err != nil {
return thrift.PrependError("write field stop error: ", err) }
if err := oprot.WriteStructEnd(); err != nil {
return thrift.PrependError("write struct stop error: ", err) }
return nil
}
func (p *UserServiceCreateNewUserArgs) writeField1(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("nickName", thrift.STRING, 1); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:nickName: ", p), err) }
if err := oprot.WriteString(string(p.NickName)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.nickName (1) field write error: ", p), err) }
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 1:nickName: ", p), err) }
return err
}
func (p *UserServiceCreateNewUserArgs) writeField2(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("avatarAuto", thrift.STRING, 2); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:avatarAuto: ", p), err) }
if err := oprot.WriteString(string(p.AvatarAuto)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.avatarAuto (2) field write error: ", p), err) }
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 2:avatarAuto: ", p), err) }
return err
}
func (p *UserServiceCreateNewUserArgs) writeField3(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("gold", thrift.I64, 3); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:gold: ", p), err) }
if err := oprot.WriteI64(int64(p.Gold)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.gold (3) field write error: ", p), err) }
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 3:gold: ", p), err) }
return err
}
func (p *UserServiceCreateNewUserArgs) String() string {
if p == nil {
return "<nil>"
}
return fmt.Sprintf("UserServiceCreateNewUserArgs(%+v)", *p)
}
// Attributes:
// - Success
type UserServiceCreateNewUserResult struct {
Success *Result_ `thrift:"success,0" db:"success" json:"success,omitempty"`
}
func NewUserServiceCreateNewUserResult() *UserServiceCreateNewUserResult {
return &UserServiceCreateNewUserResult{}
}
var UserServiceCreateNewUserResult_Success_DEFAULT *Result_
func (p *UserServiceCreateNewUserResult) GetSuccess() *Result_ {
if !p.IsSetSuccess() {
return UserServiceCreateNewUserResult_Success_DEFAULT
}
return p.Success
}
func (p *UserServiceCreateNewUserResult) IsSetSuccess() bool {
return p.Success != nil
}
func (p *UserServiceCreateNewUserResult) Read(iprot thrift.TProtocol) error {
if _, err := iprot.ReadStructBegin(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
}
for {
_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
if err != nil {
return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
}
if fieldTypeId == thrift.STOP { break; }
switch fieldId {
case 0:
if fieldTypeId == thrift.STRUCT {
if err := p.ReadField0(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
default:
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
if err := iprot.ReadFieldEnd(); err != nil {
return err
}
}
if err := iprot.ReadStructEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
}
return nil
}
func (p *UserServiceCreateNewUserResult) ReadField0(iprot thrift.TProtocol) error {
p.Success = &Result_{}
if err := p.Success.Read(iprot); err != nil {
return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err)
}
return nil
}
func (p *UserServiceCreateNewUserResult) Write(oprot thrift.TProtocol) error {
if err := oprot.WriteStructBegin("createNewUser_result"); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
if p != nil {
if err := p.writeField0(oprot); err != nil { return err }
}
if err := oprot.WriteFieldStop(); err != nil {
return thrift.PrependError("write field stop error: ", err) }
if err := oprot.WriteStructEnd(); err != nil {
return thrift.PrependError("write struct stop error: ", err) }
return nil
}
func (p *UserServiceCreateNewUserResult) writeField0(oprot thrift.TProtocol) (err error) {
if p.IsSetSuccess() {
if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) }
if err := p.Success.Write(oprot); err != nil {
return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err)
}
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) }
}
return err
}
func (p *UserServiceCreateNewUserResult) String() string {
if p == nil {
return "<nil>"
}
return fmt.Sprintf("UserServiceCreateNewUserResult(%+v)", *p)
}
// Attributes:
// - UserInfo
type UserServiceCreateQQUserArgs struct {
UserInfo *UserInfo `thrift:"UserInfo,1" db:"UserInfo" json:"UserInfo"`
}
func NewUserServiceCreateQQUserArgs() *UserServiceCreateQQUserArgs {
return &UserServiceCreateQQUserArgs{}
}
var UserServiceCreateQQUserArgs_UserInfo_DEFAULT *UserInfo
func (p *UserServiceCreateQQUserArgs) GetUserInfo() *UserInfo {
if !p.IsSetUserInfo() {
return UserServiceCreateQQUserArgs_UserInfo_DEFAULT
}
return p.UserInfo
}
func (p *UserServiceCreateQQUserArgs) IsSetUserInfo() bool {
return p.UserInfo != nil
}
func (p *UserServiceCreateQQUserArgs) Read(iprot thrift.TProtocol) error {
if _, err := iprot.ReadStructBegin(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
}
for {
_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
if err != nil {
return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
}
if fieldTypeId == thrift.STOP { break; }
switch fieldId {
case 1:
if fieldTypeId == thrift.STRUCT {
if err := p.ReadField1(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
default:
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
if err := iprot.ReadFieldEnd(); err != nil {
return err
}
}
if err := iprot.ReadStructEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
}
return nil
}
func (p *UserServiceCreateQQUserArgs) ReadField1(iprot thrift.TProtocol) error {
p.UserInfo = &UserInfo{}
if err := p.UserInfo.Read(iprot); err != nil {
return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.UserInfo), err)
}
return nil
}
func (p *UserServiceCreateQQUserArgs) Write(oprot thrift.TProtocol) error {
if err := oprot.WriteStructBegin("createQQUser_args"); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
if p != nil {
if err := p.writeField1(oprot); err != nil { return err }
}
if err := oprot.WriteFieldStop(); err != nil {
return thrift.PrependError("write field stop error: ", err) }
if err := oprot.WriteStructEnd(); err != nil {
return thrift.PrependError("write struct stop error: ", err) }
return nil
}
func (p *UserServiceCreateQQUserArgs) writeField1(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("UserInfo", thrift.STRUCT, 1); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:UserInfo: ", p), err) }
if err := p.UserInfo.Write(oprot); err != nil {
return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.UserInfo), err)
}
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 1:UserInfo: ", p), err) }
return err
}
func (p *UserServiceCreateQQUserArgs) String() string {
if p == nil {
return "<nil>"
}
return fmt.Sprintf("UserServiceCreateQQUserArgs(%+v)", *p)
}
// Attributes:
// - Success
type UserServiceCreateQQUserResult struct {
Success *Result_ `thrift:"success,0" db:"success" json:"success,omitempty"`
}
func NewUserServiceCreateQQUserResult() *UserServiceCreateQQUserResult {
return &UserServiceCreateQQUserResult{}
}
var UserServiceCreateQQUserResult_Success_DEFAULT *Result_
func (p *UserServiceCreateQQUserResult) GetSuccess() *Result_ {
if !p.IsSetSuccess() {
return UserServiceCreateQQUserResult_Success_DEFAULT
}
return p.Success
}
func (p *UserServiceCreateQQUserResult) IsSetSuccess() bool {
return p.Success != nil
}
func (p *UserServiceCreateQQUserResult) Read(iprot thrift.TProtocol) error {
if _, err := iprot.ReadStructBegin(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
}
for {
_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
if err != nil {
return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
}
if fieldTypeId == thrift.STOP { break; }
switch fieldId {
case 0:
if fieldTypeId == thrift.STRUCT {
if err := p.ReadField0(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
default:
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
if err := iprot.ReadFieldEnd(); err != nil {
return err
}
}
if err := iprot.ReadStructEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
}
return nil
}
func (p *UserServiceCreateQQUserResult) ReadField0(iprot thrift.TProtocol) error {
p.Success = &Result_{}
if err := p.Success.Read(iprot); err != nil {
return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err)
}
return nil
}
func (p *UserServiceCreateQQUserResult) Write(oprot thrift.TProtocol) error {
if err := oprot.WriteStructBegin("createQQUser_result"); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
if p != nil {
if err := p.writeField0(oprot); err != nil { return err }
}
if err := oprot.WriteFieldStop(); err != nil {
return thrift.PrependError("write field stop error: ", err) }
if err := oprot.WriteStructEnd(); err != nil {
return thrift.PrependError("write struct stop error: ", err) }
return nil
}
func (p *UserServiceCreateQQUserResult) writeField0(oprot thrift.TProtocol) (err error) {
if p.IsSetSuccess() {
if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) }
if err := p.Success.Write(oprot); err != nil {
return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err)
}
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) }
}
return err
}
func (p *UserServiceCreateQQUserResult) String() string {
if p == nil {
return "<nil>"
}
return fmt.Sprintf("UserServiceCreateQQUserResult(%+v)", *p)
}
// Attributes:
// - OpenId
type UserServiceGetUserInfoByOpenIdArgs struct {
OpenId string `thrift:"openId,1" db:"openId" json:"openId"`
}
func NewUserServiceGetUserInfoByOpenIdArgs() *UserServiceGetUserInfoByOpenIdArgs {
return &UserServiceGetUserInfoByOpenIdArgs{}
}
func (p *UserServiceGetUserInfoByOpenIdArgs) GetOpenId() string {
return p.OpenId
}
func (p *UserServiceGetUserInfoByOpenIdArgs) Read(iprot thrift.TProtocol) error {
if _, err := iprot.ReadStructBegin(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
}
for {
_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
if err != nil {
return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
}
if fieldTypeId == thrift.STOP { break; }
switch fieldId {
case 1:
if fieldTypeId == thrift.STRING {
if err := p.ReadField1(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
default:
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
if err := iprot.ReadFieldEnd(); err != nil {
return err
}
}
if err := iprot.ReadStructEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
}
return nil
}
func (p *UserServiceGetUserInfoByOpenIdArgs) ReadField1(iprot thrift.TProtocol) error {
if v, err := iprot.ReadString(); err != nil {
return thrift.PrependError("error reading field 1: ", err)
} else {
p.OpenId = v
}
return nil
}
func (p *UserServiceGetUserInfoByOpenIdArgs) Write(oprot thrift.TProtocol) error {
if err := oprot.WriteStructBegin("getUserInfoByOpenId_args"); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
if p != nil {
if err := p.writeField1(oprot); err != nil { return err }
}
if err := oprot.WriteFieldStop(); err != nil {
return thrift.PrependError("write field stop error: ", err) }
if err := oprot.WriteStructEnd(); err != nil {
return thrift.PrependError("write struct stop error: ", err) }
return nil
}
func (p *UserServiceGetUserInfoByOpenIdArgs) writeField1(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("openId", thrift.STRING, 1); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:openId: ", p), err) }
if err := oprot.WriteString(string(p.OpenId)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.openId (1) field write error: ", p), err) }
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 1:openId: ", p), err) }
return err
}
func (p *UserServiceGetUserInfoByOpenIdArgs) String() string {
if p == nil {
return "<nil>"
}
return fmt.Sprintf("UserServiceGetUserInfoByOpenIdArgs(%+v)", *p)
}
// Attributes:
// - Success
type UserServiceGetUserInfoByOpenIdResult struct {
Success *Result_ `thrift:"success,0" db:"success" json:"success,omitempty"`
}
func NewUserServiceGetUserInfoByOpenIdResult() *UserServiceGetUserInfoByOpenIdResult {
return &UserServiceGetUserInfoByOpenIdResult{}
}
var UserServiceGetUserInfoByOpenIdResult_Success_DEFAULT *Result_
func (p *UserServiceGetUserInfoByOpenIdResult) GetSuccess() *Result_ {
if !p.IsSetSuccess() {
return UserServiceGetUserInfoByOpenIdResult_Success_DEFAULT
}
return p.Success
}
func (p *UserServiceGetUserInfoByOpenIdResult) IsSetSuccess() bool {
return p.Success != nil
}
func (p *UserServiceGetUserInfoByOpenIdResult) Read(iprot thrift.TProtocol) error {
if _, err := iprot.ReadStructBegin(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
}
for {
_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
if err != nil {
return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
}
if fieldTypeId == thrift.STOP { break; }
switch fieldId {
case 0:
if fieldTypeId == thrift.STRUCT {
if err := p.ReadField0(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
default:
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
if err := iprot.ReadFieldEnd(); err != nil {
return err
}
}
if err := iprot.ReadStructEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
}
return nil
}
func (p *UserServiceGetUserInfoByOpenIdResult) ReadField0(iprot thrift.TProtocol) error {
p.Success = &Result_{}
if err := p.Success.Read(iprot); err != nil {
return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err)
}
return nil
}
func (p *UserServiceGetUserInfoByOpenIdResult) Write(oprot thrift.TProtocol) error {
if err := oprot.WriteStructBegin("getUserInfoByOpenId_result"); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
if p != nil {
if err := p.writeField0(oprot); err != nil { return err }
}
if err := oprot.WriteFieldStop(); err != nil {
return thrift.PrependError("write field stop error: ", err) }
if err := oprot.WriteStructEnd(); err != nil {
return thrift.PrependError("write struct stop error: ", err) }
return nil
}
func (p *UserServiceGetUserInfoByOpenIdResult) writeField0(oprot thrift.TProtocol) (err error) {
if p.IsSetSuccess() {
if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) }
if err := p.Success.Write(oprot); err != nil {
return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err)
}
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) }
}
return err
}
func (p *UserServiceGetUserInfoByOpenIdResult) String() string {
if p == nil {
return "<nil>"
}
return fmt.Sprintf("UserServiceGetUserInfoByOpenIdResult(%+v)", *p)
}
// Attributes:
// - UserId
type UserServiceGetUserInfoByIdArgs struct {
UserId int32 `thrift:"userId,1" db:"userId" json:"userId"`
}
func NewUserServiceGetUserInfoByIdArgs() *UserServiceGetUserInfoByIdArgs {
return &UserServiceGetUserInfoByIdArgs{}
}
func (p *UserServiceGetUserInfoByIdArgs) GetUserId() int32 {
return p.UserId
}
func (p *UserServiceGetUserInfoByIdArgs) Read(iprot thrift.TProtocol) error {
if _, err := iprot.ReadStructBegin(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
}
for {
_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
if err != nil {
return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
}
if fieldTypeId == thrift.STOP { break; }
switch fieldId {
case 1:
if fieldTypeId == thrift.I32 {
if err := p.ReadField1(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
default:
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
if err := iprot.ReadFieldEnd(); err != nil {
return err
}
}
if err := iprot.ReadStructEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
}
return nil
}
func (p *UserServiceGetUserInfoByIdArgs) ReadField1(iprot thrift.TProtocol) error {
if v, err := iprot.ReadI32(); err != nil {
return thrift.PrependError("error reading field 1: ", err)
} else {
p.UserId = v
}
return nil
}
func (p *UserServiceGetUserInfoByIdArgs) Write(oprot thrift.TProtocol) error {
if err := oprot.WriteStructBegin("getUserInfoById_args"); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
if p != nil {
if err := p.writeField1(oprot); err != nil { return err }
}
if err := oprot.WriteFieldStop(); err != nil {
return thrift.PrependError("write field stop error: ", err) }
if err := oprot.WriteStructEnd(); err != nil {
return thrift.PrependError("write struct stop error: ", err) }
return nil
}
func (p *UserServiceGetUserInfoByIdArgs) writeField1(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("userId", thrift.I32, 1); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:userId: ", p), err) }
if err := oprot.WriteI32(int32(p.UserId)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.userId (1) field write error: ", p), err) }
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 1:userId: ", p), err) }
return err
}
func (p *UserServiceGetUserInfoByIdArgs) String() string {
if p == nil {
return "<nil>"
}
return fmt.Sprintf("UserServiceGetUserInfoByIdArgs(%+v)", *p)
}
// Attributes:
// - Success
type UserServiceGetUserInfoByIdResult struct {
Success *Result_ `thrift:"success,0" db:"success" json:"success,omitempty"`
}
func NewUserServiceGetUserInfoByIdResult() *UserServiceGetUserInfoByIdResult {
return &UserServiceGetUserInfoByIdResult{}
}
var UserServiceGetUserInfoByIdResult_Success_DEFAULT *Result_
func (p *UserServiceGetUserInfoByIdResult) GetSuccess() *Result_ {
if !p.IsSetSuccess() {
return UserServiceGetUserInfoByIdResult_Success_DEFAULT
}
return p.Success
}
func (p *UserServiceGetUserInfoByIdResult) IsSetSuccess() bool {
return p.Success != nil
}
func (p *UserServiceGetUserInfoByIdResult) Read(iprot thrift.TProtocol) error {
if _, err := iprot.ReadStructBegin(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
}
for {
_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
if err != nil {
return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
}
if fieldTypeId == thrift.STOP { break; }
switch fieldId {
case 0:
if fieldTypeId == thrift.STRUCT {
if err := p.ReadField0(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
default:
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
if err := iprot.ReadFieldEnd(); err != nil {
return err
}
}
if err := iprot.ReadStructEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
}
return nil
}
func (p *UserServiceGetUserInfoByIdResult) ReadField0(iprot thrift.TProtocol) error {
p.Success = &Result_{}
if err := p.Success.Read(iprot); err != nil {
return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err)
}
return nil
}
func (p *UserServiceGetUserInfoByIdResult) Write(oprot thrift.TProtocol) error {
if err := oprot.WriteStructBegin("getUserInfoById_result"); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
if p != nil {
if err := p.writeField0(oprot); err != nil { return err }
}
if err := oprot.WriteFieldStop(); err != nil {
return thrift.PrependError("write field stop error: ", err) }
if err := oprot.WriteStructEnd(); err != nil {
return thrift.PrependError("write struct stop error: ", err) }
return nil
}
func (p *UserServiceGetUserInfoByIdResult) writeField0(oprot thrift.TProtocol) (err error) {
if p.IsSetSuccess() {
if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) }
if err := p.Success.Write(oprot); err != nil {
return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err)
}
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) }
}
return err
}
func (p *UserServiceGetUserInfoByIdResult) String() string {
if p == nil {
return "<nil>"
}
return fmt.Sprintf("UserServiceGetUserInfoByIdResult(%+v)", *p)
}
// Attributes:
// - Token
type UserServiceGetUserInfoByTokenArgs struct {
Token string `thrift:"token,1" db:"token" json:"token"`
}
func NewUserServiceGetUserInfoByTokenArgs() *UserServiceGetUserInfoByTokenArgs {
return &UserServiceGetUserInfoByTokenArgs{}
}
func (p *UserServiceGetUserInfoByTokenArgs) GetToken() string {
return p.Token
}
func (p *UserServiceGetUserInfoByTokenArgs) Read(iprot thrift.TProtocol) error {
if _, err := iprot.ReadStructBegin(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
}
for {
_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
if err != nil {
return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
}
if fieldTypeId == thrift.STOP { break; }
switch fieldId {
case 1:
if fieldTypeId == thrift.STRING {
if err := p.ReadField1(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
default:
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
if err := iprot.ReadFieldEnd(); err != nil {
return err
}
}
if err := iprot.ReadStructEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
}
return nil
}
func (p *UserServiceGetUserInfoByTokenArgs) ReadField1(iprot thrift.TProtocol) error {
if v, err := iprot.ReadString(); err != nil {
return thrift.PrependError("error reading field 1: ", err)
} else {
p.Token = v
}
return nil
}
func (p *UserServiceGetUserInfoByTokenArgs) Write(oprot thrift.TProtocol) error {
if err := oprot.WriteStructBegin("getUserInfoByToken_args"); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
if p != nil {
if err := p.writeField1(oprot); err != nil { return err }
}
if err := oprot.WriteFieldStop(); err != nil {
return thrift.PrependError("write field stop error: ", err) }
if err := oprot.WriteStructEnd(); err != nil {
return thrift.PrependError("write struct stop error: ", err) }
return nil
}
func (p *UserServiceGetUserInfoByTokenArgs) writeField1(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("token", thrift.STRING, 1); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:token: ", p), err) }
if err := oprot.WriteString(string(p.Token)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.token (1) field write error: ", p), err) }
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 1:token: ", p), err) }
return err
}
func (p *UserServiceGetUserInfoByTokenArgs) String() string {
if p == nil {
return "<nil>"
}
return fmt.Sprintf("UserServiceGetUserInfoByTokenArgs(%+v)", *p)
}
// Attributes:
// - Success
type UserServiceGetUserInfoByTokenResult struct {
Success *Result_ `thrift:"success,0" db:"success" json:"success,omitempty"`
}
func NewUserServiceGetUserInfoByTokenResult() *UserServiceGetUserInfoByTokenResult {
return &UserServiceGetUserInfoByTokenResult{}
}
var UserServiceGetUserInfoByTokenResult_Success_DEFAULT *Result_
func (p *UserServiceGetUserInfoByTokenResult) GetSuccess() *Result_ {
if !p.IsSetSuccess() {
return UserServiceGetUserInfoByTokenResult_Success_DEFAULT
}
return p.Success
}
func (p *UserServiceGetUserInfoByTokenResult) IsSetSuccess() bool {
return p.Success != nil
}
func (p *UserServiceGetUserInfoByTokenResult) Read(iprot thrift.TProtocol) error {
if _, err := iprot.ReadStructBegin(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
}
for {
_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
if err != nil {
return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
}
if fieldTypeId == thrift.STOP { break; }
switch fieldId {
case 0:
if fieldTypeId == thrift.STRUCT {
if err := p.ReadField0(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
default:
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
if err := iprot.ReadFieldEnd(); err != nil {
return err
}
}
if err := iprot.ReadStructEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
}
return nil
}
func (p *UserServiceGetUserInfoByTokenResult) ReadField0(iprot thrift.TProtocol) error {
p.Success = &Result_{}
if err := p.Success.Read(iprot); err != nil {
return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err)
}
return nil
}
func (p *UserServiceGetUserInfoByTokenResult) Write(oprot thrift.TProtocol) error {
if err := oprot.WriteStructBegin("getUserInfoByToken_result"); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
if p != nil {
if err := p.writeField0(oprot); err != nil { return err }
}
if err := oprot.WriteFieldStop(); err != nil {
return thrift.PrependError("write field stop error: ", err) }
if err := oprot.WriteStructEnd(); err != nil {
return thrift.PrependError("write struct stop error: ", err) }
return nil
}
func (p *UserServiceGetUserInfoByTokenResult) writeField0(oprot thrift.TProtocol) (err error) {
if p.IsSetSuccess() {
if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) }
if err := p.Success.Write(oprot); err != nil {
return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err)
}
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) }
}
return err
}
func (p *UserServiceGetUserInfoByTokenResult) String() string {
if p == nil {
return "<nil>"
}
return fmt.Sprintf("UserServiceGetUserInfoByTokenResult(%+v)", *p)
}
// Attributes:
// - Behavior
// - UserId
// - PropType
// - Incr
type UserServiceModifyUserInfoByIdArgs struct {
Behavior string `thrift:"behavior,1" db:"behavior" json:"behavior"`
UserId int32 `thrift:"userId,2" db:"userId" json:"userId"`
PropType ModifyPropType `thrift:"propType,3" db:"propType" json:"propType"`
Incr int64 `thrift:"incr,4" db:"incr" json:"incr"`
}
func NewUserServiceModifyUserInfoByIdArgs() *UserServiceModifyUserInfoByIdArgs {
return &UserServiceModifyUserInfoByIdArgs{}
}
func (p *UserServiceModifyUserInfoByIdArgs) GetBehavior() string {
return p.Behavior
}
func (p *UserServiceModifyUserInfoByIdArgs) GetUserId() int32 {
return p.UserId
}
func (p *UserServiceModifyUserInfoByIdArgs) GetPropType() ModifyPropType {
return p.PropType
}
func (p *UserServiceModifyUserInfoByIdArgs) GetIncr() int64 {
return p.Incr
}
func (p *UserServiceModifyUserInfoByIdArgs) Read(iprot thrift.TProtocol) error {
if _, err := iprot.ReadStructBegin(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
}
for {
_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
if err != nil {
return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
}
if fieldTypeId == thrift.STOP { break; }
switch fieldId {
case 1:
if fieldTypeId == thrift.STRING {
if err := p.ReadField1(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
case 2:
if fieldTypeId == thrift.I32 {
if err := p.ReadField2(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
case 3:
if fieldTypeId == thrift.I32 {
if err := p.ReadField3(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
case 4:
if fieldTypeId == thrift.I64 {
if err := p.ReadField4(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
default:
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
if err := iprot.ReadFieldEnd(); err != nil {
return err
}
}
if err := iprot.ReadStructEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
}
return nil
}
func (p *UserServiceModifyUserInfoByIdArgs) ReadField1(iprot thrift.TProtocol) error {
if v, err := iprot.ReadString(); err != nil {
return thrift.PrependError("error reading field 1: ", err)
} else {
p.Behavior = v
}
return nil
}
func (p *UserServiceModifyUserInfoByIdArgs) ReadField2(iprot thrift.TProtocol) error {
if v, err := iprot.ReadI32(); err != nil {
return thrift.PrependError("error reading field 2: ", err)
} else {
p.UserId = v
}
return nil
}
func (p *UserServiceModifyUserInfoByIdArgs) ReadField3(iprot thrift.TProtocol) error {
if v, err := iprot.ReadI32(); err != nil {
return thrift.PrependError("error reading field 3: ", err)
} else {
temp := ModifyPropType(v)
p.PropType = temp
}
return nil
}
func (p *UserServiceModifyUserInfoByIdArgs) ReadField4(iprot thrift.TProtocol) error {
if v, err := iprot.ReadI64(); err != nil {
return thrift.PrependError("error reading field 4: ", err)
} else {
p.Incr = v
}
return nil
}
func (p *UserServiceModifyUserInfoByIdArgs) Write(oprot thrift.TProtocol) error {
if err := oprot.WriteStructBegin("modifyUserInfoById_args"); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
if p != nil {
if err := p.writeField1(oprot); err != nil { return err }
if err := p.writeField2(oprot); err != nil { return err }
if err := p.writeField3(oprot); err != nil { return err }
if err := p.writeField4(oprot); err != nil { return err }
}
if err := oprot.WriteFieldStop(); err != nil {
return thrift.PrependError("write field stop error: ", err) }
if err := oprot.WriteStructEnd(); err != nil {
return thrift.PrependError("write struct stop error: ", err) }
return nil
}
func (p *UserServiceModifyUserInfoByIdArgs) writeField1(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("behavior", thrift.STRING, 1); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:behavior: ", p), err) }
if err := oprot.WriteString(string(p.Behavior)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.behavior (1) field write error: ", p), err) }
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 1:behavior: ", p), err) }
return err
}
func (p *UserServiceModifyUserInfoByIdArgs) writeField2(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("userId", thrift.I32, 2); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:userId: ", p), err) }
if err := oprot.WriteI32(int32(p.UserId)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.userId (2) field write error: ", p), err) }
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 2:userId: ", p), err) }
return err
}
func (p *UserServiceModifyUserInfoByIdArgs) writeField3(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("propType", thrift.I32, 3); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:propType: ", p), err) }
if err := oprot.WriteI32(int32(p.PropType)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.propType (3) field write error: ", p), err) }
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 3:propType: ", p), err) }
return err
}
func (p *UserServiceModifyUserInfoByIdArgs) writeField4(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("incr", thrift.I64, 4); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:incr: ", p), err) }
if err := oprot.WriteI64(int64(p.Incr)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.incr (4) field write error: ", p), err) }
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 4:incr: ", p), err) }
return err
}
func (p *UserServiceModifyUserInfoByIdArgs) String() string {
if p == nil {
return "<nil>"
}
return fmt.Sprintf("UserServiceModifyUserInfoByIdArgs(%+v)", *p)
}
// Attributes:
// - Success
type UserServiceModifyUserInfoByIdResult struct {
Success *Result_ `thrift:"success,0" db:"success" json:"success,omitempty"`
}
func NewUserServiceModifyUserInfoByIdResult() *UserServiceModifyUserInfoByIdResult {
return &UserServiceModifyUserInfoByIdResult{}
}
var UserServiceModifyUserInfoByIdResult_Success_DEFAULT *Result_
func (p *UserServiceModifyUserInfoByIdResult) GetSuccess() *Result_ {
if !p.IsSetSuccess() {
return UserServiceModifyUserInfoByIdResult_Success_DEFAULT
}
return p.Success
}
func (p *UserServiceModifyUserInfoByIdResult) IsSetSuccess() bool {
return p.Success != nil
}
func (p *UserServiceModifyUserInfoByIdResult) Read(iprot thrift.TProtocol) error {
if _, err := iprot.ReadStructBegin(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
}
for {
_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
if err != nil {
return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
}
if fieldTypeId == thrift.STOP { break; }
switch fieldId {
case 0:
if fieldTypeId == thrift.STRUCT {
if err := p.ReadField0(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
default:
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
if err := iprot.ReadFieldEnd(); err != nil {
return err
}
}
if err := iprot.ReadStructEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
}
return nil
}
func (p *UserServiceModifyUserInfoByIdResult) ReadField0(iprot thrift.TProtocol) error {
p.Success = &Result_{}
if err := p.Success.Read(iprot); err != nil {
return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err)
}
return nil
}
func (p *UserServiceModifyUserInfoByIdResult) Write(oprot thrift.TProtocol) error {
if err := oprot.WriteStructBegin("modifyUserInfoById_result"); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
if p != nil {
if err := p.writeField0(oprot); err != nil { return err }
}
if err := oprot.WriteFieldStop(); err != nil {
return thrift.PrependError("write field stop error: ", err) }
if err := oprot.WriteStructEnd(); err != nil {
return thrift.PrependError("write struct stop error: ", err) }
return nil
}
func (p *UserServiceModifyUserInfoByIdResult) writeField0(oprot thrift.TProtocol) (err error) {
if p.IsSetSuccess() {
if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) }
if err := p.Success.Write(oprot); err != nil {
return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err)
}
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) }
}
return err
}
func (p *UserServiceModifyUserInfoByIdResult) String() string {
if p == nil {
return "<nil>"
}
return fmt.Sprintf("UserServiceModifyUserInfoByIdResult(%+v)", *p)
}
// Attributes:
// - UserId
// - NewName_
type UserServiceRenameUserByIdArgs struct {
UserId int32 `thrift:"userId,1" db:"userId" json:"userId"`
NewName_ string `thrift:"NewName,2" db:"NewName" json:"NewName"`
}
func NewUserServiceRenameUserByIdArgs() *UserServiceRenameUserByIdArgs {
return &UserServiceRenameUserByIdArgs{}
}
func (p *UserServiceRenameUserByIdArgs) GetUserId() int32 {
return p.UserId
}
func (p *UserServiceRenameUserByIdArgs) GetNewName_() string {
return p.NewName_
}
func (p *UserServiceRenameUserByIdArgs) Read(iprot thrift.TProtocol) error {
if _, err := iprot.ReadStructBegin(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
}
for {
_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
if err != nil {
return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
}
if fieldTypeId == thrift.STOP { break; }
switch fieldId {
case 1:
if fieldTypeId == thrift.I32 {
if err := p.ReadField1(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
case 2:
if fieldTypeId == thrift.STRING {
if err := p.ReadField2(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
default:
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
if err := iprot.ReadFieldEnd(); err != nil {
return err
}
}
if err := iprot.ReadStructEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
}
return nil
}
func (p *UserServiceRenameUserByIdArgs) ReadField1(iprot thrift.TProtocol) error {
if v, err := iprot.ReadI32(); err != nil {
return thrift.PrependError("error reading field 1: ", err)
} else {
p.UserId = v
}
return nil
}
func (p *UserServiceRenameUserByIdArgs) ReadField2(iprot thrift.TProtocol) error {
if v, err := iprot.ReadString(); err != nil {
return thrift.PrependError("error reading field 2: ", err)
} else {
p.NewName_ = v
}
return nil
}
func (p *UserServiceRenameUserByIdArgs) Write(oprot thrift.TProtocol) error {
if err := oprot.WriteStructBegin("RenameUserById_args"); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
if p != nil {
if err := p.writeField1(oprot); err != nil { return err }
if err := p.writeField2(oprot); err != nil { return err }
}
if err := oprot.WriteFieldStop(); err != nil {
return thrift.PrependError("write field stop error: ", err) }
if err := oprot.WriteStructEnd(); err != nil {
return thrift.PrependError("write struct stop error: ", err) }
return nil
}
func (p *UserServiceRenameUserByIdArgs) writeField1(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("userId", thrift.I32, 1); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:userId: ", p), err) }
if err := oprot.WriteI32(int32(p.UserId)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.userId (1) field write error: ", p), err) }
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 1:userId: ", p), err) }
return err
}
func (p *UserServiceRenameUserByIdArgs) writeField2(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("NewName", thrift.STRING, 2); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:NewName: ", p), err) }
if err := oprot.WriteString(string(p.NewName_)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.NewName (2) field write error: ", p), err) }
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 2:NewName: ", p), err) }
return err
}
func (p *UserServiceRenameUserByIdArgs) String() string {
if p == nil {
return "<nil>"
}
return fmt.Sprintf("UserServiceRenameUserByIdArgs(%+v)", *p)
}
// Attributes:
// - Success
type UserServiceRenameUserByIdResult struct {
Success *Result_ `thrift:"success,0" db:"success" json:"success,omitempty"`
}
func NewUserServiceRenameUserByIdResult() *UserServiceRenameUserByIdResult {
return &UserServiceRenameUserByIdResult{}
}
var UserServiceRenameUserByIdResult_Success_DEFAULT *Result_
func (p *UserServiceRenameUserByIdResult) GetSuccess() *Result_ {
if !p.IsSetSuccess() {
return UserServiceRenameUserByIdResult_Success_DEFAULT
}
return p.Success
}
func (p *UserServiceRenameUserByIdResult) IsSetSuccess() bool {
return p.Success != nil
}
func (p *UserServiceRenameUserByIdResult) Read(iprot thrift.TProtocol) error {
if _, err := iprot.ReadStructBegin(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
}
for {
_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
if err != nil {
return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
}
if fieldTypeId == thrift.STOP { break; }
switch fieldId {
case 0:
if fieldTypeId == thrift.STRUCT {
if err := p.ReadField0(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
default:
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
if err := iprot.ReadFieldEnd(); err != nil {
return err
}
}
if err := iprot.ReadStructEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
}
return nil
}
func (p *UserServiceRenameUserByIdResult) ReadField0(iprot thrift.TProtocol) error {
p.Success = &Result_{}
if err := p.Success.Read(iprot); err != nil {
return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err)
}
return nil
}
func (p *UserServiceRenameUserByIdResult) Write(oprot thrift.TProtocol) error {
if err := oprot.WriteStructBegin("RenameUserById_result"); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
if p != nil {
if err := p.writeField0(oprot); err != nil { return err }
}
if err := oprot.WriteFieldStop(); err != nil {
return thrift.PrependError("write field stop error: ", err) }
if err := oprot.WriteStructEnd(); err != nil {
return thrift.PrependError("write struct stop error: ", err) }
return nil
}
func (p *UserServiceRenameUserByIdResult) writeField0(oprot thrift.TProtocol) (err error) {
if p.IsSetSuccess() {
if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) }
if err := p.Success.Write(oprot); err != nil {
return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err)
}
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) }
}
return err
}
func (p *UserServiceRenameUserByIdResult) String() string {
if p == nil {
return "<nil>"
}
return fmt.Sprintf("UserServiceRenameUserByIdResult(%+v)", *p)
}
// Attributes:
// - MessageType
type UserServiceGetMessageArgs struct {
MessageType string `thrift:"messageType,1" db:"messageType" json:"messageType"`
}
func NewUserServiceGetMessageArgs() *UserServiceGetMessageArgs {
return &UserServiceGetMessageArgs{}
}
func (p *UserServiceGetMessageArgs) GetMessageType() string {
return p.MessageType
}
func (p *UserServiceGetMessageArgs) Read(iprot thrift.TProtocol) error {
if _, err := iprot.ReadStructBegin(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
}
for {
_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
if err != nil {
return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
}
if fieldTypeId == thrift.STOP { break; }
switch fieldId {
case 1:
if fieldTypeId == thrift.STRING {
if err := p.ReadField1(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
default:
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
if err := iprot.ReadFieldEnd(); err != nil {
return err
}
}
if err := iprot.ReadStructEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
}
return nil
}
func (p *UserServiceGetMessageArgs) ReadField1(iprot thrift.TProtocol) error {
if v, err := iprot.ReadString(); err != nil {
return thrift.PrependError("error reading field 1: ", err)
} else {
p.MessageType = v
}
return nil
}
func (p *UserServiceGetMessageArgs) Write(oprot thrift.TProtocol) error {
if err := oprot.WriteStructBegin("getMessage_args"); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
if p != nil {
if err := p.writeField1(oprot); err != nil { return err }
}
if err := oprot.WriteFieldStop(); err != nil {
return thrift.PrependError("write field stop error: ", err) }
if err := oprot.WriteStructEnd(); err != nil {
return thrift.PrependError("write struct stop error: ", err) }
return nil
}
func (p *UserServiceGetMessageArgs) writeField1(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("messageType", thrift.STRING, 1); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:messageType: ", p), err) }
if err := oprot.WriteString(string(p.MessageType)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.messageType (1) field write error: ", p), err) }
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 1:messageType: ", p), err) }
return err
}
func (p *UserServiceGetMessageArgs) String() string {
if p == nil {
return "<nil>"
}
return fmt.Sprintf("UserServiceGetMessageArgs(%+v)", *p)
}
// Attributes:
// - Success
type UserServiceGetMessageResult struct {
Success *string `thrift:"success,0" db:"success" json:"success,omitempty"`
}
func NewUserServiceGetMessageResult() *UserServiceGetMessageResult {
return &UserServiceGetMessageResult{}
}
var UserServiceGetMessageResult_Success_DEFAULT string
func (p *UserServiceGetMessageResult) GetSuccess() string {
if !p.IsSetSuccess() {
return UserServiceGetMessageResult_Success_DEFAULT
}
return *p.Success
}
func (p *UserServiceGetMessageResult) IsSetSuccess() bool {
return p.Success != nil
}
func (p *UserServiceGetMessageResult) Read(iprot thrift.TProtocol) error {
if _, err := iprot.ReadStructBegin(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
}
for {
_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
if err != nil {
return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
}
if fieldTypeId == thrift.STOP { break; }
switch fieldId {
case 0:
if fieldTypeId == thrift.STRING {
if err := p.ReadField0(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
default:
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
if err := iprot.ReadFieldEnd(); err != nil {
return err
}
}
if err := iprot.ReadStructEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
}
return nil
}
func (p *UserServiceGetMessageResult) ReadField0(iprot thrift.TProtocol) error {
if v, err := iprot.ReadString(); err != nil {
return thrift.PrependError("error reading field 0: ", err)
} else {
p.Success = &v
}
return nil
}
func (p *UserServiceGetMessageResult) Write(oprot thrift.TProtocol) error {
if err := oprot.WriteStructBegin("getMessage_result"); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
if p != nil {
if err := p.writeField0(oprot); err != nil { return err }
}
if err := oprot.WriteFieldStop(); err != nil {
return thrift.PrependError("write field stop error: ", err) }
if err := oprot.WriteStructEnd(); err != nil {
return thrift.PrependError("write struct stop error: ", err) }
return nil
}
func (p *UserServiceGetMessageResult) writeField0(oprot thrift.TProtocol) (err error) {
if p.IsSetSuccess() {
if err := oprot.WriteFieldBegin("success", thrift.STRING, 0); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) }
if err := oprot.WriteString(string(*p.Success)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.success (0) field write error: ", p), err) }
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) }
}
return err
}
func (p *UserServiceGetMessageResult) String() string {
if p == nil {
return "<nil>"
}
return fmt.Sprintf("UserServiceGetMessageResult(%+v)", *p)
}
================================================
FILE: common/api/thrift/gen-go/rpc/user_service-remote/user_service-remote.go
================================================
// Autogenerated by Thrift Compiler (0.12.0)
// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
package main
import (
"context"
"flag"
"fmt"
"math"
"net"
"net/url"
"os"
"strconv"
"strings"
"github.com/apache/thrift/lib/go/thrift"
"rpc"
)
func Usage() {
fmt.Fprintln(os.Stderr, "Usage of ", os.Args[0], " [-h host:port] [-u url] [-f[ramed]] function [arg1 [arg2...]]:")
flag.PrintDefaults()
fmt.Fprintln(os.Stderr, "\nFunctions:")
fmt.Fprintln(os.Stderr, " Result createNewUser(string nickName, string avatarAuto, i64 gold)")
fmt.Fprintln(os.Stderr, " Result createQQUser(UserInfo UserInfo)")
fmt.Fprintln(os.Stderr, " Result getUserInfoByOpenId(string openId)")
fmt.Fprintln(os.Stderr, " Result getUserInfoById(i32 userId)")
fmt.Fprintln(os.Stderr, " Result getUserInfoByToken(string token)")
fmt.Fprintln(os.Stderr, " Result modifyUserInfoById(string behavior, i32 userId, ModifyPropType propType, i64 incr)")
fmt.Fprintln(os.Stderr, " Result RenameUserById(i32 userId, string NewName)")
fmt.Fprintln(os.Stderr, " string getMessage(string messageType)")
fmt.Fprintln(os.Stderr)
os.Exit(0)
}
type httpHeaders map[string]string
func (h httpHeaders) String() string {
var m map[string]string = h
return fmt.Sprintf("%s", m)
}
func (h httpHeaders) Set(value string) error {
parts := strings.Split(value, ": ")
if len(parts) != 2 {
return fmt.Errorf("header should be of format 'Key: Value'")
}
h[parts[0]] = parts[1]
return nil
}
func main() {
flag.Usage = Usage
var host string
var port int
var protocol string
var urlString string
var framed bool
var useHttp bool
headers := make(httpHeaders)
var parsedUrl *url.URL
var trans thrift.TTransport
_ = strconv.Atoi
_ = math.Abs
flag.Usage = Usage
flag.StringVar(&host, "h", "localhost", "Specify host and port")
flag.IntVar(&port, "p", 9090, "Specify port")
flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
flag.StringVar(&urlString, "u", "", "Specify the url")
flag.BoolVar(&framed, "framed", false, "Use framed transport")
flag.BoolVar(&useHttp, "http", false, "Use http")
flag.Var(headers, "H", "Headers to set on the http(s) request (e.g. -H \"Key: Value\")")
flag.Parse()
if len(urlString) > 0 {
var err error
parsedUrl, err = url.Parse(urlString)
if err != nil {
fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
flag.Usage()
}
host = parsedUrl.Host
useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http" || parsedUrl.Scheme == "https"
} else if useHttp {
_, err := url.Parse(fmt.Sprint("http://", host, ":", port))
if err != nil {
fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
flag.Usage()
}
}
cmd := flag.Arg(0)
var err error
if useHttp {
trans, err = thrift.NewTHttpClient(parsedUrl.String())
if len(headers) > 0 {
httptrans := trans.(*thrift.THttpClient)
for key, value := range headers {
httptrans.SetHeader(key, value)
}
}
} else {
portStr := fmt.Sprint(port)
if strings.Contains(host, ":") {
host, portStr, err = net.SplitHostPort(host)
if err != nil {
fmt.Fprintln(os.Stderr, "error with host:", err)
os.Exit(1)
}
}
trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
if err != nil {
fmt.Fprintln(os.Stderr, "error resolving address:", err)
os.Exit(1)
}
if framed {
trans = thrift.NewTFramedTransport(trans)
}
}
if err != nil {
fmt.Fprintln(os.Stderr, "Error creating transport", err)
os.Exit(1)
}
defer trans.Close()
var protocolFactory thrift.TProtocolFactory
switch protocol {
case "compact":
protocolFactory = thrift.NewTCompactProtocolFactory()
break
case "simplejson":
protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
break
case "json":
protocolFactory = thrift.NewTJSONProtocolFactory()
break
case "binary", "":
protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
break
default:
fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
Usage()
os.Exit(1)
}
iprot := protocolFactory.GetProtocol(trans)
oprot := protocolFactory.GetProtocol(trans)
client := rpc.NewUserServiceClient(thrift.NewTStandardClient(iprot, oprot))
if err := trans.Open(); err != nil {
fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
os.Exit(1)
}
switch cmd {
case "createNewUser":
if flag.NArg() - 1 != 3 {
fmt.Fprintln(os.Stderr, "CreateNewUser requires 3 args")
flag.Usage()
}
argvalue0 := flag.Arg(1)
value0 := argvalue0
argvalue1 := flag.Arg(2)
value1 := argvalue1
argvalue2, err20 := (strconv.ParseInt(flag.Arg(3), 10, 64))
if err20 != nil {
Usage()
return
}
value2 := argvalue2
fmt.Print(client.CreateNewUser(context.Background(), value0, value1, value2))
fmt.Print("\n")
break
case "createQQUser":
if flag.NArg() - 1 != 1 {
fmt.Fprintln(os.Stderr, "CreateQQUser requires 1 args")
flag.Usage()
}
arg21 := flag.Arg(1)
mbTrans22 := thrift.NewTMemoryBufferLen(len(arg21))
defer mbTrans22.Close()
_, err23 := mbTrans22.WriteString(arg21)
if err23 != nil {
Usage()
return
}
factory24 := thrift.NewTJSONProtocolFactory()
jsProt25 := factory24.GetProtocol(mbTrans22)
argvalue0 := rpc.NewUserInfo()
err26 := argvalue0.Read(jsProt25)
if err26 != nil {
Usage()
return
}
value0 := argvalue0
fmt.Print(client.CreateQQUser(context.Background(), value0))
fmt.Print("\n")
break
case "getUserInfoByOpenId":
if flag.NArg() - 1 != 1 {
fmt.Fprintln(os.Stderr, "GetUserInfoByOpenId requires 1 args")
flag.Usage()
}
argvalue0 := flag.Arg(1)
value0 := argvalue0
fmt.Print(client.GetUserInfoByOpenId(context.Background(), value0))
fmt.Print("\n")
break
case "getUserInfoById":
if flag.NArg() - 1 != 1 {
fmt.Fprintln(os.Stderr, "GetUserInfoById requires 1 args")
flag.Usage()
}
tmp0, err28 := (strconv.Atoi(flag.Arg(1)))
if err28 != nil {
Usage()
return
}
argvalue0 := int32(tmp0)
value0 := argvalue0
fmt.Print(client.GetUserInfoById(context.Background(), value0))
fmt.Print("\n")
break
case "getUserInfoByToken":
if flag.NArg() - 1 != 1 {
fmt.Fprintln(os.Stderr, "GetUserInfoByToken requires 1 args")
flag.Usage()
}
argvalue0 := flag.Arg(1)
value0 := argvalue0
fmt.Print(client.GetUserInfoByToken(context.Background(), value0))
fmt.Print("\n")
break
case "modifyUserInfoById":
if flag.NArg() - 1 != 4 {
fmt.Fprintln(os.Stderr, "ModifyUserInfoById requires 4 args")
flag.Usage()
}
argvalue0 := flag.Arg(1)
value0 := argvalue0
tmp1, err31 := (strconv.Atoi(flag.Arg(2)))
if err31 != nil {
Usage()
return
}
argvalue1 := int32(tmp1)
value1 := argvalue1
tmp2, err := (strconv.Atoi(flag.Arg(3)))
if err != nil {
Usage()
return
}
argvalue2 := rpc.ModifyPropType(tmp2)
value2 := argvalue2
argvalue3, err32 := (strconv.ParseInt(flag.Arg(4), 10, 64))
if err32 != nil {
Usage()
return
}
value3 := argvalue3
fmt.Print(client.ModifyUserInfoById(context.Background(), value0, value1, value2, value3))
fmt.Print("\n")
break
case "RenameUserById":
if flag.NArg() - 1 != 2 {
fmt.Fprintln(os.Stderr, "RenameUserById requires 2 args")
flag.Usage()
}
tmp0, err33 := (strconv.Atoi(flag.Arg(1)))
if err33 != nil {
Usage()
return
}
argvalue0 := int32(tmp0)
value0 := argvalue0
argvalue1 := flag.Arg(2)
value1 := argvalue1
fmt.Print(client.RenameUserById(context.Background(), value0, value1))
fmt.Print("\n")
break
case "getMessage":
if flag.NArg() - 1 != 1 {
fmt.Fprintln(os.Stderr, "GetMessage requires 1 args")
flag.Usage()
}
argvalue0 := flag.Arg(1)
value0 := argvalue0
fmt.Print(client.GetMessage(context.Background(), value0))
fmt.Print("\n")
break
case "":
Usage()
break
default:
fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
}
}
================================================
FILE: common/conf/account.conf
================================================
;[dev]
account_host=127.0.0.1
account_port=4000
account_aes_key=bb6c59d065966e6236fcc635f88f8543
;日志
log_path=./logs/account.log
log_level=debug
;mysql mycat或mysql配置
mysql_addr=localhost:3306
mysql_user=root
mysql_password=root
mysql_db=fish
;redis cluster 集群配置
redis_addrs=127.0.0.1:7000;127.0.0.1:7001;127.0.0.1:7002;127.0.0.1:8000;127.0.0.1:8001;127.0.0.1:8002
redis_key_prefix=fish_
================================================
FILE: common/conf/game.conf
================================================
;[dev]
game_host=127.0.0.1
game_port=4002
;日志
log_path=./logs/game.log
log_level=debug
================================================
FILE: common/conf/hall.conf
================================================
;[dev]
hall_host=127.0.0.1
hall_port=9000
hall_secret=7Cw2ALPkht676IUB
;日志
log_path=./logs/hall.log
log_level=debug
version=20190101
app_id=01673379
app_key=c18b1b56f2f88ef423bfeadbad9a816c
redirect_uri=http://fish.blzz.shop/qq/message
================================================
FILE: common/conf/traces.json
================================================
{
"201": [[[-548, 1002], [1914, -390]], [[-548, 1002], [1914, -312]], [[-548, 1002], [1914, -234]], [[-548, 1080], [1914, -390]], [[-548, 1080], [1914, -312]], [[-548, 1080], [1914, -234]]],
"202": [[[-548, 1158], [1914, -390]], [[-548, 1158], [1914, -312]], [[-548, 1158], [1914, -234]]],
"203": [[[1914, -390], [-548, 1002]], [[1914, -390], [-548, 1080]], [[1914, -390], [-548, 1158]]],
"204": [[[1914, -312], [-548, 1002]], [[1914, -312], [-548, 1080]], [[1914, -312], [-548, 1158]]],
"205": [[[1914, -234], [-548, 1002]], [[1914, -234], [-548, 1080]], [[1914, -234], [-548, 1158]]],
"206": [[[-548, 362], [1914, 412]], [[-548, 462], [1914, 384]], [[-548, 462], [1914, 306]]],
"207": [[[-548, 384], [1914, 462]], [[-548, 304], [1914, 384]], [[-548, 384], [1914, 306]]],
"208": [[[-548, 406], [1914, 462]], [[-548, 326], [1914, 384]], [[-548, 306], [1914, 366]]],
"209": [[[1914, 462], [-548, 462]], [[1914, 462], [-548, 384]], [[1914, 462], [-548, 306]]],
"210": [[[1914, 384], [-548, 462]], [[1914, 384], [-548, 384]], [[1914, 384], [-548, 306]]],
"211": [[[1914, 306], [-548, 462]], [[1914, 306], [-548, 384]], [[1914, 306], [-548, 306]]],
"212": [[[-548, -390], [1914, 1002]], [[-548, -390], [1914, 1080]], [[-548, -624], [1914, 1158]]],
"213": [[[-548, -312], [1914, 1002]], [[-548, -312], [1914, 1080]], [[-548, -312], [1914, 1158]]],
"214": [[[-548, -234], [1914, 1002]], [[-548, -234], [1914, 1080]], [[-548, -234], [1914, 1158]]],
"215": [[[1914, 1002], [-548, -390]], [[1914, 1002], [-548, -312]], [[1914, 1002], [-548, -234]]],
"216": [[[1914, 1080], [-548, -390]], [[1914, 1080], [-548, -312]], [[1914, 1080], [-548, -234]]],
"217": [[[1914, 1158], [-548, -390]], [[1914, 1158], [-548, -312]], [[1914, 1158], [-548, -234]]],
"1": [[[10, -500], [0, 768], [2000, 1268]], [[50, -500], [0, 768], [2000, 1268]], [[210, -500], [0, 768], [2000, 1268]], [[250, -500], [0, 768], [2000, 1268]]],
"2": [[[2000, -500], [0, 768], [10, 1268]], [[2100, -500], [0, 768], [10, 1268]], [[2150, -500], [0, 768], [10, 1268]], [[2200, -500], [0, 768], [10, 1268]]],
"3": [[[-500, 10], [0, 768], [1866, 384]], [[-500, 110], [0, 768], [1866, 484]], [[-500, 210], [0, 768], [1866, 584]], [[-500, 310], [0, 68], [1866, 684]], [[-500, 410], [0, 768], [1866, 784]]],
"4": [[[10, 1268], [0, 0], [2083, -500]], [[30, 1268], [0, 0], [2083, -500]]],
"5": [[[70, 1268], [0, 0], [1783, -500]], [[110, 1268], [0, 0], [1783, -500]], [[170, 1268], [0, 0], [1783, -500]], [[210, 1268], [0, 0], [1783, -500]]],
"6": [[[610, 1268], [0, 0], [1283, -500]], [[710, 1268], [0, 0], [1383, -500]]],
"7": [[[1866, 10], [1366, 768], [-500, 384]], [[1866, 110], [1366, 768], [-500, 484]], [[1866, 210], [1366, 768], [-500, 584]], [[1866, 310], [1366, 768], [-500, 684]], [[1866, 410], [1366, 768], [-500, 784]]],
"8": [[[60, 1268], [1366, 384], [60, -500]], [[160, 1268], [1366, 384], [160, -500]], [[260, 1268], [1366, 384], [260, -500]], [[360, 1268], [1366, 384], [360, -500]], [[460, 1268], [1366, 384], [460, -500]], [[560, 1268], [1366, 384], [560, -500]], [[660, 1268], [1366, 384], [660, -500]], [[860, 1268], [0, 384], [860, -500]], [[960, 1268], [0, 384], [960, -500]]],
"9": [[[1060, 1268], [0, 384], [1060, -500]], [[1160, 1268], [0, 384], [1160, -500]], [[1260, 1268], [0, 384], [1260, -500]]],
"10": [[[-500, 60], [683, 768], [1866, 60]], [[-500, 160], [683, 768], [1866, 160]], [[-500, 260], [683, 768], [1866, 260]], [[-500, 360], [683, 768], [1866, 360]], [[-500, 460], [683, 0], [1866, 460]], [[-500, 560], [683, 0], [1866, 560]], [[-500, 660], [683, 0], [1866, 660]], [[-500, 760], [683, 0], [1866, 760]]],
"101": [[[-100, 384], [800, 1384], [566, -616], [1466, 384]], [[1466, 384], [566, -616], [800, 1384], [-100, 384]]],
"102": [[[683, 868], [1866, 284], [-500, 484], [683, -100]], [[683, -100], [-500, 484], [1866, 284], [683, 868]]],
"103": [[[-68, -38], [0, 1368], [1366, -600], [1434, 806]], [[1434, 806], [1366, -600], [0, 1368], [-68, -38]]],
"104": [[[-68, -238], [0, 1168], [1366, -800], [1434, 606]], [[1366, 606], [1366, -800], [0, 1168], [-68, -238]]],
"105": [[[483, 868], [1666, 284], [-700, 484], [483, -100]], [[483, -100], [-700, 484], [1666, 284], [483, 868]]],
"106": [[[-100, 284], [800, 1284], [566, -716], [1466, 284]], [[1466, 284], [566, -716], [800, 1284], [-100, 284]]],
"107": [[[-68, 162], [0, 1568], [1366, -400], [1434, 1006]], [[1434, 1006], [1366, -400], [0, 1568], [-68, 162]]],
"108": [[[883, 868], [2066, 284], [-300, 484], [883, -100]], [[883, -100], [-300, 484], [2066, 284], [883, 868]]],
"109": [[[-100, 484], [800, 1484], [566, -516], [1466, 484]], [[1466, 484], [566, -516], [800, 1484], [-100, 484]]],
"110": [[[-68, -38], [1200, 1368], [166, -600], [1434, 806]], [[1434, 851], [166, -600], [1200, 1368], [-68, -38]]]
}
================================================
FILE: common/tools/aes.go
================================================
package tools
import (
"crypto/aes"
"crypto/cipher"
"fmt"
"encoding/hex"
)
func NewAesTool(appSecret string) (aesTool *AesEncrypt,err error) {
if len(appSecret) <16 {
err = fmt.Errorf("invalid param appsecret of %s",appSecret)
return
}
aesTool = &AesEncrypt{AppSecret:appSecret}
return
}
type AesEncrypt struct {
AppSecret string
}
func (p *AesEncrypt) getKey() []byte {
strKey := p.AppSecret
keyLen := len(strKey)
if keyLen < 16 {
panic("res key 长度不能小于16")
}
arrKey := []byte(strKey)
if keyLen >= 32 {
//取前32个字节
return arrKey[:32]
}
if keyLen >= 24 {
//取前24个字节
return arrKey[:24]
}
//取前16个字节
return arrKey[:16]
}
//加密字符串
func (p *AesEncrypt) Encrypt(strMesg string) (string, error) {
key := p.getKey()
var iv = []byte(key)[:aes.BlockSize]
encrypted := make([]byte, len(strMesg))
aesBlockEncrypter, err := aes.NewCipher(key)
if err != nil {
return "", err
}
aesEncrypter := cipher.NewCFBEncrypter(aesBlockEncrypter, iv)
aesEncrypter.XORKeyStream(encrypted, []byte(strMesg))
encodeString := fmt.Sprintf("%x",encrypted)
//encodeString := base64.StdEncoding.EncodeToString([]byte(encrypted))
return encodeString, nil
}
//解密字符串
func (p *AesEncrypt) Decrypt(aesEncryptString string) (strDesc string, err error) {
src, err := hex.DecodeString(aesEncryptString)
//src, err := base64.StdEncoding.DecodeString(aesEncryptString)
if err != nil {
return
}
defer func() {
//错误处理
if e := recover(); e != nil {
err = e.(error)
}
}()
key := p.getKey()
var iv = []byte(key)[:aes.BlockSize]
decrypted := make([]byte, len(src))
var aesBlockDecrypter cipher.Block
aesBlockDecrypter, err = aes.NewCipher([]byte(key))
if err != nil {
return "", err
}
aesDecrypter := cipher.NewCFBDecrypter(aesBlockDecrypter, iv)
aesDecrypter.XORKeyStream(decrypted, src)
return string(decrypted), nil
}
================================================
FILE: common/tools/call_rpc.go
================================================
package tools
import (
"fish/common/api/thrift/gen-go/rpc"
"fmt"
"github.com/apache/thrift/lib/go/thrift"
"net"
)
func GetRpcClient(host,port string) (client *rpc.UserServiceClient, closeTransport func() error, err error) {
var transport thrift.TTransport
transport, err = thrift.NewTSocket(net.JoinHostPort(host,port))
if err != nil {
err = fmt.Errorf("NewTSocket failed. err: [%v]\n", err)
return
}
transport, err = thrift.NewTBufferedTransportFactory(8192).GetTransport(transport)
if err != nil {
err = fmt.Errorf("NewTransport failed. err: [%v]\n", err)
return
}
closeTransport = transport.Close
if err = transport.Open(); err != nil {
err = fmt.Errorf("Transport.Open failed. err: [%v]\n", err)
return
}
protocolFactory := thrift.NewTCompactProtocolFactory()
iprot := protocolFactory.GetProtocol(transport)
oprot := protocolFactory.GetProtocol(transport)
client = rpc.NewUserServiceClient(thrift.NewTStandardClient(iprot, oprot))
return
}
================================================
FILE: common/tools/snowFlake.go
================================================
package tools
import (
"errors"
"sync"
"time"
)
const (
nodeBits uint8 = 10
stepBits uint8 = 12
nodeMax int64 = -1 ^ (-1 << nodeBits)
stepMax int64 = -1 ^ (-1 << stepBits)
timeShift uint8 = nodeBits + stepBits
nodeShift uint8 = stepBits
)
var (
Epoch int64 = 1546272000000
)
type Node struct {
mu sync.Mutex
timestamp int64
node int64
step int64
GenerateChan chan int64
stop chan bool
}
func GenerateUid(nodeNum int64) (err error, generateChan <-chan int64) {
var node *Node
if node, err = NewNode(nodeNum);err == nil {
generateChan = node.GenerateChan
go node.run()
return
}
return
}
func (n *Node) run() {
for {
n.GenerateChan <- n.Generate()
}
}
func NewNode(nodeNum int64) (*Node, error) {
if nodeNum < 0 || nodeNum > nodeMax {
return nil, errors.New("Node number must be between 0 and 1023")
}
return &Node{
timestamp: 0,
node: nodeNum,
step: 0,
GenerateChan: make(chan int64),
stop: make(chan bool),
}, nil
}
func (n *Node) Generate() int64 {
n.mu.Lock()
defer n.mu.Unlock()
now := time.Now().UnixNano() / 1e6
if n.timestamp == now {
n.step++
if n.step > stepMax {
for now <= n.timestamp {
now = time.Now().UnixNano() / 1e6
}
n.step = 0
}
} else {
n.timestamp = now
n.step = 0
}
return (now-Epoch)<<timeShift | n.node<<nodeShift | n.step
}
================================================
FILE: common/tools/tools.go
================================================
package tools
import (
"crypto/md5"
"fmt"
"time"
"io"
)
func CreateUid() (uuid string) {
t := time.Now()
h := md5.New()
io.WriteString(h, "crazyof.me")
io.WriteString(h, t.String())
uuid = fmt.Sprintf("%x", h.Sum(nil))
return
}
================================================
FILE: game/common/config.go
================================================
package common
var (
GameConf = &GameServerConf{}
)
type GameServerConf struct {
AccountHost string
AccountPort int
HallHost string
HallPort int
HallSecret string
GameHost string
GamePort int
LogPath string
LogLevel string
}
================================================
FILE: game/controllers/create_public_room.go
================================================
package controllers
import (
"encoding/json"
"github.com/astaxie/beego/logs"
"net/http"
"time"
)
func CreatePublicRoom(w http.ResponseWriter, r *http.Request) {
defer func() {
if r := recover(); r != nil {
logs.Error("CreatePublicRoom panic:%v ", r)
}
}()
//logs.Debug("new request url:[%s]",r.URL)
ret := make(map[string]interface{})
ret["time"] = time.Now().Format("2006-01-02 15:04:05")
defer func() {
data, err := json.Marshal(ret)
if err != nil {
logs.Error("json marsha1 failed err:%v", err)
return
}
w.Header().Set("Access-Control-Allow-Origin", "*")
if _, err := w.Write(data); err != nil {
logs.Error("CreateRoom err: %v",err)
}
}()
}
================================================
FILE: game/controllers/create_room.go
================================================
package controllers
import (
"encoding/json"
"github.com/astaxie/beego/logs"
"net/http"
"time"
)
func CreateRoom(w http.ResponseWriter, r *http.Request) {
defer func() {
if r := recover(); r != nil {
logs.Error("CreateRoom panic:%v ", r)
}
}()
//logs.Debug("new request url:[%s]",r.URL)
ret := make(map[string]interface{})
ret["time"] = time.Now().Format("2006-01-02 15:04:05")
defer func() {
data, err := json.Marshal(ret)
if err != nil {
logs.Error("json marsha1 failed err:%v", err)
return
}
w.Header().Set("Access-Control-Allow-Origin", "*")
if _, err := w.Write(data); err != nil {
logs.Error("CreateRoom err: %v",err)
}
}()
}
================================================
FILE: game/controllers/enter_public_room.go
================================================
package controllers
import (
"context"
"crypto/md5"
"encoding/json"
"fish/common/api/thrift/gen-go/rpc"
"fish/common/tools"
"fish/game/common"
"fish/game/service"
"fmt"
"github.com/astaxie/beego/logs"
"net/http"
"strconv"
"time"
)
func EnterPublicRoom(w http.ResponseWriter, r *http.Request) {
logs.Debug("new request EnterPublicRoom")
defer func() {
if r := recover(); r != nil {
logs.Error("EnterPublicRoom panic:%v ", r)
}
}()
account := r.FormValue("account")
if len(account) == 0 {
return
}
baseParam := r.FormValue("baseParam")
if len(baseParam) == 0 {
return
}
baseScore, err := strconv.Atoi(baseParam)
if err != nil {
logs.Debug("request enterPublicRoom err invalid baseParam %v", baseParam)
return
}
sign := r.FormValue("sign")
if len(sign) == 0 {
return
}
token := r.FormValue("token")
if len(token) == 0 {
return
}
t := r.FormValue("t")
if len(token) == 0 {
return
}
ret := map[string]interface{}{
"errcode": -1,
"errmsg": "enter room failed.",
}
defer func() {
data, err := json.Marshal(ret)
if err != nil {
logs.Error("json marsha1 failed err:%v", err)
return
}
w.Header().Set("Access-Control-Allow-Origin", "*")
if _, err := w.Write(data); err != nil {
logs.Error("CreateRoom err: %v", err)
}
}()
if client, closeTransportHandler, err := tools.GetRpcClient(common.GameConf.AccountHost, strconv.Itoa(common.GameConf.AccountPort)); err == nil {
defer func() {
if err := closeTransportHandler(); err != nil {
logs.Error("close rpc err: %v", err)
}
}()
if res, err := client.GetUserInfoByToken(context.Background(), sign); err == nil {
if res.Code == rpc.ErrorCode_Success {
userId := service.UserId(res.UserObj.UserId)
if token == fmt.Sprintf("%x", md5.Sum([]byte("t"+t))) {
// todo lock 🔒
var roomId service.RoomId
service.RoomMgr.RoomLock.Lock()
logs.Info("EnterPublicRoom get lock...")
defer service.RoomMgr.RoomLock.Unlock()
defer logs.Info("EnterPublicRoom set free lock...")
for RoomId, RoomInfo := range service.RoomMgr.RoomsInfo {
for _, roomUserId := range RoomInfo.UserInfo {
if userId == roomUserId {
ret = map[string]interface{}{
"errcode": 0,
"errmsg": "ok",
"ip": common.GameConf.GameHost,
"port": common.GameConf.GamePort,
"roomId": RoomId,
"sign": sign,
"time": time.Now().Unix() * 1000,
"token": token,
}
return
}
}
if roomId == 0 && len(RoomInfo.UserInfo) < 4 && RoomInfo.BaseScore == baseScore {
roomId = RoomId
}
}
if roomId == 0 { //房间全满
roomId = service.CreatePublicRoom(&service.RoomConf{
BaseScore: baseScore,
MinHaveScore: service.MinHaveScore,
MaxHaveScore: service.MaxHaveScore,
TaxRatio: service.TaxRatio,
Creator: userId,
})
}
cannonKindVip := map[int]int{
0: 1,
1: 4,
2: 7,
3: 10,
4: 13,
5: 16,
6: 19,
}
if roomInfo, ok := service.RoomMgr.RoomsInfo[roomId]; ok {
resChan := make(chan error)
roomInfo.HttpReqChan <- &service.HttpReqData{
UserInfo: service.UserInfo{
UserId: userId,
Score: int(res.UserObj.Gems),
Name: res.UserObj.NickName,
Ready: false,
SeatIndex: 0,
Vip: int(res.UserObj.Vip),
CannonKind: cannonKindVip[int(res.UserObj.Vip)],
Power: float64(res.UserObj.Power) / 1000,
LockFishId: 0,
}, ErrChan: resChan,
}
timeOut := time.After(time.Second)
select {
case <-timeOut:
return
case err := <-resChan:
if err != nil {
logs.Error("EnterPublicRoom enter room [%d] err: %v", roomId, err)
} else {
exists := false
for _, roomUserId := range service.RoomMgr.RoomsInfo[roomId].UserInfo {
if roomUserId == userId {
exists = true
}
}
if !exists {
roomInfo.UserInfo = append(service.RoomMgr.RoomsInfo[roomId].UserInfo, userId)
}
ret = map[string]interface{}{
"errcode": 0,
"errmsg": "ok",
"ip": common.GameConf.GameHost,
"port": common.GameConf.GamePort,
"roomId": strconv.Itoa(int(roomId)),
"sign": sign,
"time": time.Now().Unix() * 1000,
"token": token,
"mark": 1,
}
return
}
}
}
} else {
logs.Error("EnterPublicRoom check token err")
}
}
} else {
logs.Error("get UserInfo by token err: %v", err)
}
}
}
================================================
FILE: game/controllers/enter_room.go
================================================
package controllers
import (
"encoding/json"
"github.com/astaxie/beego/logs"
"net/http"
"time"
)
func EnterRoom(w http.ResponseWriter, r *http.Request) {
defer func() {
if r := recover(); r != nil {
logs.Error("EnterRoom panic:%v ", r)
}
}()
//logs.Debug("new request url:[%s]",r.URL)
ret := make(map[string]interface{})
ret["time"] = time.Now().Format("2006-01-02 15:04:05")
defer func() {
data, err := json.Marshal(ret)
if err != nil {
logs.Error("json marsha1 failed err:%v", err)
return
}
w.Header().Set("Access-Control-Allow-Origin", "*")
if _, err := w.Write(data); err != nil {
logs.Error("CreateRoom err: %v",err)
}
}()
}
================================================
FILE: game/controllers/get_server_info.go
================================================
package controllers
import (
"encoding/json"
"github.com/astaxie/beego/logs"
"net/http"
"time"
)
func GetServerInfo(w http.ResponseWriter, r *http.Request) {
defer func() {
if r := recover(); r != nil {
logs.Error("GetServerInfo panic:%v ", r)
}
}()
//logs.Debug("new request url:[%s]",r.URL)
ret := make(map[string]interface{})
ret["time"] = time.Now().Format("2006-01-02 15:04:05")
defer func() {
data, err := json.Marshal(ret)
if err != nil {
logs.Error("json marsha1 failed err:%v", err)
return
}
w.Header().Set("Access-Control-Allow-Origin", "*")
if _, err := w.Write(data); err != nil {
logs.Error("CreateRoom err: %v",err)
}
}()
}
================================================
FILE: game/controllers/is_room_running.go
================================================
package controllers
import (
"encoding/json"
"github.com/astaxie/beego/logs"
"net/http"
"time"
)
func IsRoomRunning(w http.ResponseWriter, r *http.Request) {
defer func() {
if r := recover(); r != nil {
logs.Error("IsRoomRunning panic:%v ", r)
}
}()
//logs.Debug("new request url:[%s]",r.URL)
ret := make(map[string]interface{})
ret["time"] = time.Now().Format("2006-01-02 15:04:05")
defer func() {
data, err := json.Marshal(ret)
if err != nil {
logs.Error("json marsha1 failed err:%v", err)
return
}
w.Header().Set("Access-Control-Allow-Origin", "*")
if _, err := w.Write(data); err != nil {
logs.Error("CreateRoom err: %v",err)
}
}()
}
================================================
FILE: game/controllers/ping.go
================================================
package controllers
import (
"encoding/json"
"github.com/astaxie/beego/logs"
"net/http"
"time"
)
func Ping(w http.ResponseWriter, r *http.Request) {
defer func() {
if r := recover(); r != nil {
logs.Error("Ping panic:%v ", r)
}
}()
//logs.Debug("new request url:[%s]",r.URL)
ret := make(map[string]interface{})
ret["time"] = time.Now().Format("2006-01-02 15:04:05")
defer func() {
data, err := json.Marshal(ret)
if err != nil {
logs.Error("json marsha1 failed err:%v", err)
return
}
w.Header().Set("Access-Control-Allow-Origin", "*")
if _, err := w.Write(data); err != nil {
logs.Error("CreateRoom err: %v",err)
}
}()
}
================================================
FILE: game/main/config.go
================================================
package main
import (
"fish/game/common"
"fmt"
"github.com/astaxie/beego/config"
)
func initConf() (err error) {
accountConf, err := config.NewConfig("ini", "./common/conf/account.conf")
if err != nil {
fmt.Println("new account config failed,err:", err)
return
}
common.GameConf.AccountHost = accountConf.String("account_host")
if common.GameConf.AccountHost == "" {
return fmt.Errorf("conf err: account_host is null")
}
common.GameConf.AccountPort, err = accountConf.Int("account_port")
if err != nil {
return
}
hallConf, err := config.NewConfig("ini", "./common/conf/hall.conf")
if err != nil {
fmt.Println("new account config failed,err:", err)
return
}
common.GameConf.HallHost = hallConf.String("hall_host")
if common.GameConf.HallHost == "" {
return fmt.Errorf("conf err: account_host is null")
}
common.GameConf.HallSecret = hallConf.String("hall_secret")
if common.GameConf.HallSecret == "" {
return fmt.Errorf("conf err: hall_secret is null")
}
common.GameConf.HallPort, err = hallConf.Int("hall_port")
if err != nil {
return
}
conf,err := config.NewConfig("ini","./common/conf/game.conf")
if err != nil {
fmt.Println("new config failed,err:",err)
return
}
common.GameConf.GameHost = conf.String("game_host")
if common.GameConf.GameHost == "" {
return fmt.Errorf("conf err: game_host is null")
}
common.GameConf.GamePort,err = conf.Int("game_port")
if err != nil {
return
}
common.GameConf.LogPath = conf.String("log_path")
if common.GameConf.LogPath == "" {
return fmt.Errorf("conf err: log_path is null")
}
common.GameConf.LogLevel = conf.String("log_level")
if common.GameConf.LogLevel == "" {
return fmt.Errorf("conf err: log_level is null")
}
return
}
================================================
FILE: game/main/init.go
================================================
package main
import (
"encoding/json"
"fish/game/common"
"github.com/astaxie/beego/logs"
_ "github.com/go-sql-driver/mysql"
)
func conversionLogLevel(logLevel string) int {
switch logLevel {
case "debug":
return logs.LevelDebug
case "warn":
return logs.LevelWarn
case "info":
return logs.LevelInfo
case "trace":
return logs.LevelTrace
}
return logs.LevelDebug
}
func initLogger() (err error) {
config := make(map[string]interface{})
config["filename"] = common.GameConf.LogPath
config["level"] = conversionLogLevel(common.GameConf.LogLevel)
configStr, err := json.Marshal(config)
if err != nil {
return
}
err = logs.SetLogger(logs.AdapterFile, string(configStr))
return
}
func initSec() (err error) {
err = initLogger()
if err != nil {
return
}
return
}
================================================
FILE: game/main/main.go
================================================
package main
import (
"crypto/md5"
"fish/game/common"
_ "fish/game/router"
"fish/game/service"
"flag"
"fmt"
"github.com/astaxie/beego/logs"
"io/ioutil"
"net/http"
"net/url"
"strconv"
"time"
)
func main() {
err := service.LoadTraceFile("./common/conf/traces.json")
if err != nil {
logs.Error("LoadTraceFile err: %v", err)
return
}
fmt.Println("run")
err = initConf()
if err != nil {
logs.Error("init conf err: %v", err)
return
}
logs.Debug("init config succ")
err = initSec()
if err != nil {
logs.Error("init sec err: %v", err)
return
}
logs.Debug("initSec succ")
var addr = flag.String("addr", fmt.Sprintf(":%d", common.GameConf.GamePort), "http service address")
logs.Debug("game server listen port %v", *addr)
go func() {
heartBeatTicker := time.NewTicker(time.Second * 2)
for {
select {
case <-heartBeatTicker.C:
params := url.Values{}
Url, err := url.Parse(fmt.Sprintf("http://%s:%d/register_game_server", common.GameConf.HallHost, common.GameConf.HallPort))
if err != nil {
panic(err.Error())
}
params.Set("gameHost", common.GameConf.GameHost)
params.Set("gamePort", strconv.Itoa(common.GameConf.GamePort))
t := time.Now().Unix()
params.Set("t", strconv.Itoa(int(t)))
sign := fmt.Sprintf("%x", md5.Sum([]byte(common.GameConf.HallSecret+strconv.Itoa(int(t)))))
params.Set("sign", sign)
service.RoomMgr.RoomLock.Lock()
params.Set("load", strconv.Itoa(len(service.RoomMgr.RoomsInfo))) //只传房间数,因为游戏服务器总是优先填满不满员的房间
service.RoomMgr.RoomLock.Unlock()
Url.RawQuery = params.Encode()
urlPath := Url.String()
resp, err := http.Get(urlPath)
s, err := ioutil.ReadAll(resp.Body)
if string(s) != "success" {
logs.Info("register game server response:", string(s))
}
_ = resp.Body.Close()
}
}
}()
err = http.ListenAndServe(*addr, nil)
if err != nil {
logs.Error("ListenAndServe err: %v", err)
}
}
================================================
FILE: game/router/router.go
================================================
package router
import (
"fish/game/controllers"
"fish/game/service"
"net/http"
)
func init() {
http.HandleFunc("/get_server_info", controllers.GetServerInfo)
http.HandleFunc("/create_room", controllers.CreateRoom)
http.HandleFunc("/create_public_room", controllers.CreatePublicRoom)
http.HandleFunc("/enter_room", controllers.EnterRoom)
http.HandleFunc("/ping", controllers.Ping)
http.HandleFunc("/is_room_running", controllers.IsRoomRunning)
http.HandleFunc("/enter_public_room", controllers.EnterPublicRoom)
http.HandleFunc("/socket.io/",service.ServeWs)
}
================================================
FILE: game/service/client.go
================================================
package service
import (
"bytes"
"context"
"encoding/json"
"fish/common/api/thrift/gen-go/rpc"
"fish/common/tools"
"fish/game/common"
"fmt"
"github.com/astaxie/beego/logs"
"github.com/gorilla/websocket"
"math/rand"
"net/http"
"strconv"
"strings"
"time"
)
const (
writeWait = 1 * time.Second
pongWait = 60 * time.Second
pingPeriod = (pongWait * 9) / 10
maxMessageSize = 512
)
var (
newline = []byte{'\n'}
space = []byte{' '}
)
var upgrader = websocket.Upgrader{
ReadBufferSize: 1024,
WriteBufferSize: 1024,
CheckOrigin: func(r *http.Request) bool { return true }, //不验证origin
}
type Client struct {
conn *websocket.Conn
UserInfo *UserInfo
Room *room
msgChan chan []byte
closeChan chan bool
}
type UserId int64
type UserInfo struct {
UserId UserId `json:"userId"`
Score int `json:"-"`
Bill int `json:"-"` //账单
ConversionScore float64 `json:"score"`
Name string `json:"name"`
Ready bool `json:"ready"`
SeatIndex int `json:"seatIndex"`
Vip int `json:"vip"`
CannonKind int `json:"cannonKind"`
Power float64 `json:"power"`
LockFishId FishId `json:"lockFishId"`
Online bool `json:"online"`
client *Client `json:"-"`
Ip string `json:"ip"`
}
type BulletId string
type Bullet struct {
UserId UserId `json:"userId"`
ChairId int `json:"chairId"`
BulletKind int `json:"bulletKind"`
BulletId BulletId `json:"bulletId"`
Angle float64 `json:"angle"`
Sign string `json:"sign"`
LockFishId FishId `json:"lockFishId"`
}
type catchFishReq struct {
BulletId BulletId `json:"bulletId"`
FishId FishId `json:"fishId"`
}
func (c *Client) sendMsg(msg []byte) {
if c.UserInfo != nil {
//logs.Debug("user [%v] send msg %v", c.UserInfo.UserId, string(msg))
}
c.msgChan <- msg //为什么此处不担心发送数据到一个已关闭的chan? 因为channel没有手动关闭而是交给gc处理 :)
}
func (c *Client) sendToClient(data []interface{}) {
if dataByte, err := json.Marshal(data); err != nil {
logs.Error("broadcast [%v] json marshal err :%v ", data, err)
} else {
dataByte = append([]byte{'4', '2'}, dataByte...)
c.sendMsg(dataByte)
}
}
func (c *Client) sendToOthers(data []interface{}) {
if dataByte, err := json.Marshal(data); err != nil {
logs.Error("broadcast [%v] json marshal err :%v ", data, err)
} else {
dataByte = append([]byte{'4', '2'}, dataByte...)
for _, userInfo := range c.Room.Users {
if userInfo.UserId == c.UserInfo.UserId || userInfo.client == nil {
continue
}
userInfo.client.sendMsg(dataByte)
}
}
}
func (c *Client) writePump() {
PingTicker := time.NewTicker(pingPeriod)
defer func() {
PingTicker.Stop()
//close(c.closeChan)
RoomMgr.RoomLock.Lock()
defer RoomMgr.RoomLock.Unlock()
if c.Room != nil { //客户端在房间内
if _, ok := RoomMgr.RoomsInfo[c.Room.RoomId]; ok { //房间没销毁
c.Room.ClientReqChan <- &clientReqData{c, []string{"client_exit"}}
}
}
if c.UserInfo != nil {
logs.Info("user %v write goroutine exit...", c.UserInfo.UserId)
}
}()
for {
select {
case msg := <-c.msgChan:
err := c.conn.SetWriteDeadline(time.Now().Add(writeWait))
if err != nil {
logs.Error("sendMsg SetWriteDeadline err, %v", err)
}
w, err := c.conn.NextWriter(websocket.TextMessage)
if err != nil {
logs.Error("sendMsg NextWriter err, %v", err)
return
}
if _, err = w.Write(msg); err != nil {
logs.Error("sendMsg Write err, %v", err)
}
if err = w.Close(); err != nil {
_ = c.conn.Close()
}
case <-PingTicker.C:
c.conn.SetWriteDeadline(time.Now().Add(writeWait))
if err := c.conn.WriteMessage(websocket.PingMessage, nil); err != nil {
logs.Debug("PingTicker write message err : %v", err)
return
}
case <-c.closeChan:
if err := c.conn.Close(); err != nil {
if c.UserInfo != nil {
logs.Info("user %v client conn close err : %v", err)
}
}
return
}
}
}
func (c *Client) readPump() {
defer func() {
c.conn.Close()
//RoomMgr.RoomLock.Lock()
//defer RoomMgr.RoomLock.Unlock()
//if c.Room != nil { //客户端在房间内
// if _, ok := RoomMgr.RoomsInfo[c.Room.RoomId]; ok { //房间没销毁
// c.Room.ClientReqChan <- &clientReqData{c, []string{"client_exit"}}
// }
//}
if c.UserInfo != nil {
logs.Info("user %v read goroutine exit...", c.UserInfo.UserId)
}
}()
c.conn.SetReadLimit(maxMessageSize)
c.conn.SetReadDeadline(time.Now().Add(pongWait))
c.conn.SetPongHandler(func(string) error { c.conn.SetReadDeadline(time.Now().Add(pongWait)); return nil })
for {
_, message, err := c.conn.ReadMessage()
if err != nil {
if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway, websocket.CloseAbnormalClosure) {
if c.UserInfo != nil { //client.userInfo == nil && client.Room != nil 是因为他没有先登录房间
logs.Error("websocket userId [%v] UserInfo [%d] unexpected close error: %v", c.UserInfo.UserId, &c.UserInfo, err)
////todo test
//if c.Room != nil {
// logs.Debug("users count %v", len(c.Room.Users))
// for userId, userInfo := range c.Room.Users {
// logs.Debug("user id %v, name %v", userId, userInfo.Name)
// }
//}
} else {
logs.Error("websocket unexpected close error: %v", err)
}
}
return
}
message = bytes.TrimSpace(bytes.Replace(message, newline, space, -1))
if err != nil {
if c.UserInfo != nil {
logs.Error("message unMarsha1 err, user_id[%d] err:%v", c.UserInfo.UserId, err)
} else {
logs.Error("message unMarsha1 err:%v", err)
}
} else {
wsRequest(message, c)
}
}
}
func ServeWs(w http.ResponseWriter, r *http.Request) {
conn, err := upgrader.Upgrade(w, r, nil)
if err != nil {
logs.Error("upgrader err:%v", err)
return
}
client := &Client{conn: conn, msgChan: make(chan []byte, 100), closeChan: make(chan bool, 1), UserInfo: &UserInfo{}}
logs.Debug("new client...")
go client.readPump()
go client.writePump()
if msg, err := json.Marshal(map[string]interface{}{
"pingInterval": 25000,
"pingTimeout": 5000,
"sid": "1JDAUJeOA81mbc00AAAA",
"upgrades": make([]int, 0),
}); err != nil {
logs.Error("new client send msg err : %v", err)
} else {
client.sendMsg(append([]byte{'0'}, msg...))
client.sendMsg(append([]byte{'4', '0'}, ))
}
}
func (c *Client) Fire(bullet *Bullet) {
if bullet.BulletKind == 22 { //激光炮
// todo 激光炮
c.UserInfo.Power = 0
c.sendToOthers([]interface{}{
"user_fire_Reply",
bullet,
})
return
}
c.Room.AliveBullet[bullet.BulletId] = bullet
c.sendToOthers([]interface{}{"user_fire_Reply", bullet})
c.UserInfo.Score -= c.Room.Conf.BaseScore * GetBulletMulti(bullet.BulletKind)
c.UserInfo.Bill -= c.Room.Conf.BaseScore * GetBulletMulti(bullet.BulletKind)
addPower, _ := strconv.ParseFloat(fmt.Sprintf("%.5f", float64(GetBulletMulti(bullet.BulletKind))/3000), 64)
if c.UserInfo.Power < 1 {
c.UserInfo.Power += addPower
}
}
func (c *Client) catchFish(fishId FishId, bulletId BulletId) {
if bullet, ok := c.Room.AliveBullet[bulletId]; ok {
if bullet.UserId == c.UserInfo.UserId {
if fish, ok := c.Room.AliveFish[fishId]; ok {
if IsHit(fish) {
//logs.Debug("user %v,catchFish %v", c.UserInfo.UserId, fishId)
killedFishes := []*Fish{fish}
if fish.FishKind == FishKind30 { //全屏炸弹
killedFishes = append(killedFishes, c.Room.getBombFish()...)
} else if fish.FishKind >= FishKind23 && fish.FishKind <= FishKind26 { //一网打尽
killedFishes = c.Room.getAllInOne(fish)
} else if fish.FishKind >= FishKind31 && fish.FishKind <= FishKind33 {
killedFishes = c.Room.getSameFish(fish)
}
//加钱
addScore := 0
for _, fish := range killedFishes {
addScore += GetFishMulti(fish) * GetBulletMulti(bullet.BulletKind) * c.Room.Conf.BaseScore
}
//if addScore > c.Room.Conf.BaseScore*200 { //不允许超过200倍
// logs.Error("user %v catch fish kind [%v] add score = %v,base score = %v ,beyond 200 time of base score...", c.UserInfo.UserId, fish.FishKind, addScore, c.Room.Conf.BaseScore)
// addScore = c.Room.Conf.BaseScore * 200
//}
c.UserInfo.Score += addScore
c.UserInfo.Bill += addScore //记账
//todo %1的概率获取冰冻道具
rand.Seed(time.Now().UnixNano())
item := ""
if rand.Intn(100) == 0 {
item = "ice"
}
fishes := make([]string, 0)
for _, fish := range killedFishes {
fishes = append(fishes, strconv.Itoa(int(fish.FishId)))
}
catchFishAddScore, _ := strconv.ParseFloat(fmt.Sprintf("%.5f", float64(addScore)/1000), 64)
catchResult := []interface{}{"catch_fish_reply",
map[string]interface{}{
"userId": c.UserInfo.UserId,
"chairId": bullet.ChairId,
"bulletId": bullet.BulletId,
"fishId": strings.Join(fishes, ","),
"addScore": catchFishAddScore,
"item": item,
}}
c.Room.broadcast(catchResult)
//logs.Debug("catch fish add score %v,catchFishAddScore %v", addScore, catchFishAddScore)
for _, fish := range killedFishes {
delete(c.Room.AliveFish, fish.FishId)
}
} else {
//logs.Debug("hit fish failed...")
}
} else {
logs.Debug("user [%v] catch fish fishId [%v] not in alive fish array...", c.UserInfo.UserId, fishId)
}
} else {
logs.Debug("user [%v] catch fish bullet [%v] belong to user [%v] ...", c.UserInfo.UserId, bullet.BulletId, bullet.UserId)
}
delete(c.Room.AliveBullet, bulletId)
} else {
//客户端会多传命中,愚蠢的客户端
//logs.Debug("user [%v] catch fish bullet [%v] not exists ...", c.UserInfo.UserId, bulletId)
}
}
func (c *Client) frozenScene(startTime time.Time) { //冰冻屏幕
if c.Room.FrozenEndTime.Unix() > time.Now().Unix() {
return
}
logs.Debug("frozenScene")
c.Room.Status = GameStatusFrozen
c.Room.Utils.StopBuildFish <- true
c.Room.FrozenEndTime = startTime.Add(time.Second * 10)
cutDown := c.Room.FrozenEndTime.Sub(time.Now())
replyData := []interface{}{"user_frozen_reply", map[string]time.Duration{"cutDownTime": cutDown / 1e6}}
c.sendToOthers(replyData)
c.Room.frozenEndTimer = time.After(cutDown)
}
func (c *Client) exitRoom() {
delete(c.Room.Users, c.UserInfo.UserId)
//todo 持久化结算
}
func (c *Client) clearBill() {
go func(userId UserId, bill int, roomId RoomId, power float64) {
if client, closeTransportHandler, err := tools.GetRpcClient(common.GameConf.AccountHost, strconv.Itoa(common.GameConf.AccountPort)); err == nil {
defer func() {
if err := closeTransportHandler(); err != nil {
logs.Error("close rpc err: %v", err)
}
}()
if res, err := client.ModifyUserInfoById(context.Background(), "FISH_GAME_MODIFY", int32(userId), rpc.ModifyPropType_gems, int64(bill)); err == nil {
if res.Code == rpc.ErrorCode_Success {
logs.Debug("user [%v] clear bill success :in room [%v] fish game , add score : %v", userId, roomId, int64(bill))
} else {
logs.Debug("user [%v] clear bill failed :in room [%v] fish game , add score : %v,err code = %v", userId, roomId, int64(bill), res.Code)
}
} else {
logs.Error("user [%v] clearBill [%v] err: %v", userId, bill, err)
}
if res, err := client.ModifyUserInfoById(context.Background(), "FISH_GAME_MODIFY", int32(userId), rpc.ModifyPropType_power, int64(power)); err == nil {
if res.Code == rpc.ErrorCode_Success {
logs.Debug("user [%v] clear power success :in room [%v] fish game , add power : %v", userId, roomId, int64(power))
} else {
logs.Debug("user [%v] clear power failed :in room [%v] fish game , add power : %v,err code = %v", userId, roomId, int64(power), res.Code)
}
} else {
logs.Error("user [%v] clearBill [%v] err: %v", userId, bill, err)
}
}
}(c.UserInfo.UserId, c.UserInfo.Bill, c.Room.RoomId, c.UserInfo.Power*1000)
// 不允许其他协程修改client,默认结算成功。如果需要确认,可以在房间加结算消息chan。
c.UserInfo.Bill = 0
}
================================================
FILE: game/service/define.go
================================================
package service
import (
"encoding/json"
"fmt"
"io"
"os"
"strconv"
)
/*
// 座位号
-------------
0 1 2
7 3
6 5 4
-------------
*/
var (
SwitchSceneTimer = 60 * 5 // 5分钟切一次场景
//鱼阵场景
SceneKind1 = 0
SceneKind2 = 1
SceneKind3 = 2
SceneKind4 = 3
SceneKind5 = 4
SceneKind6 = 5
SceneKind7 = 6
SceneKind8 = 7
//鱼的种类
FishKind1 = 1
FishKind2 = 2
FishKind3 = 3
FishKind4 = 4
FishKind5 = 5
FishKind6 = 6
FishKind7 = 7
FishKind8 = 8
FishKind9 = 9
FishKind10 = 10
FishKind11 = 11
FishKind12 = 12
FishKind13 = 13
FishKind14 = 14
FishKind15 = 15
FishKind16 = 16
FishKind17 = 17
FishKind18 = 18
FishKind19 = 19
FishKind20 = 20
FishKind21 = 21
FishKind22 = 22
FishKind23 = 23 // 一网打尽
FishKind24 = 24 // 一网打尽
FishKind25 = 25 // 一网打尽
FishKind26 = 26 // 一网打尽
FishKind27 = 27
FishKind28 = 28
FishKind29 = 29
FishKind30 = 30 // 全屏炸弹
FishKind31 = 31 // 同类炸弹
FishKind32 = 32 // 同类炸弹
FishKind33 = 33 // 同类炸弹
FishKind34 = 34
FishKind35 = 35
FishMulti = map[int]int{
1: 2,
2: 2,
3: 3,
4: 4,
5: 5,
6: 5,
7: 6,
8: 7,
9: 8,
10: 9,
11: 10,
12: 11,
13: 12,
14: 18,
15: 25,
16: 30,
17: 35,
18: 40,
19: 45,
20: 50,
21: 80,
22: 100,
23: 45, //45-150, // 一网打尽
24: 45, //45-150, // 一网打尽
25: 45, //45-150, // 一网打尽
26: 45, //45-150, // 一网打尽
27: 50,
28: 60,
29: 70,
30: 100, // 全屏炸弹
31: 110, // 同类炸弹
32: 110, // 同类炸弹
33: 110, // 同类炸弹
34: 120,
35: 200,
}
BulletKind = map[string]int{
"bullet_kind_normal_1": 0,
"bullet_kind_normal_2": 1,
"bullet_kind_normal_3": 2,
"bullet_kind_vip1_1": 3,
"bullet_kind_vip1_2": 4,
"bullet_kind_vip1_3": 5,
"bullet_kind_vip2_1": 6,
"bullet_kind_vip2_2": 7,
"bullet_kind_vip2_3": 8,
"bullet_kind_vip3_1": 9,
"bullet_kind_vip3_2": 10,
"bullet_kind_vip3_3": 11,
"bullet_kind_vip4_1": 12,
"bullet_kind_vip4_2": 13,
"bullet_kind_vip4_3": 14,
"bullet_kind_vip5_1": 15,
"bullet_kind_vip5_2": 16,
"bullet_kind_vip5_3": 17,
"bullet_kind_vip6_1": 19,
"bullet_kind_vip6_2": 20,
"bullet_kind_vip6_3": 21,
"bullet_kind_laser": 22,
}
BulletMulti = map[int]int{
1: 1,
2: 2,
3: 3,
4: 1,
5: 3,
6: 5,
7: 1,
8: 3,
9: 5,
10: 1,
11: 3,
12: 5,
13: 1,
14: 3,
15: 5,
16: 1,
17: 3,
18: 5,
19: 1,
20: 3,
21: 5,
22: 1, // 激光炮
}
)
const (
//SUB_S_GAME_CONFIG = "SUB_S_GAME_CONFIG"
//SUB_S_FISH_TRACE = "SUB_S_FISH_TRACE"
//SUB_S_EXCHANGE_FISHSCORE = "SUB_S_FISH_TRACE"
//SUB_S_USER_FIRE = "SUB_S_FISH_TRACE"
//SUB_S_CATCH_FISH = "SUB_S_FISH_TRACE"
//SUB_S_BULLET_ION_TIMEOUT = "SUB_S_BULLET_ION_TIMEOUT"
//SUB_S_LOCK_TIMEOUT = "SUB_S_LOCK_TIMEOUT"
//SUB_S_CATCH_SWEEP_FISH = "SUB_S_CATCH_SWEEP_FISH"
//SUB_S_CATCH_SWEEP_FISH_RESULT = "SUB_S_CATCH_SWEEP_FISH_RESULT"
//SUB_S_HIT_FISH_LK = "SUB_S_HIT_FISH_LK"
//SUB_S_SWITCH_SCENE = "SUB_S_SWITCH_SCENE"
//SUB_S_STOCK_OPERATE_RESULT = 111 //库存操作
//SUB_S_SCENE_END = 112 //场景结束
//SUB_S_CATCH_FISHRESULT = 113 //捉鱼结果
//SUB_S_SETTLE_FISHSCORE = 114 //解决鱼分数
//SUB_S_SWIM_SCENE = 115 //游泳场景
//SUB_S_SPECIAL_PRICE1 = 116 //特价1
//SUB_S_ADD_PRICE1_SCORE = 117 //添加价格分数
//SUB_S_END_SPECIAL1 = 118 //结束特别
//SUB_S_SPECIAL_PRICE2 = 119
//SUB_S_UPDATE_POS = 120
//SUB_S_END_SPECIAL2 = 121
//SUB_S_SPECIAL_PRICE3 = 122
//SUB_S_END_SPECIAL3 = 123
//SUB_S_LOCK_FISH = 124 //锁定鱼
//SUB_S_BLACK_LIST = 125 //黑名单
//SUB_S_WHITE_LIST = 126 //白名单
//SUB_S_BIGFISH_LIST = 127 //大鱼名单
//SUB_S_LINE_TRACE = 128 //线追踪
//SUB_S_SHOAL_TRACE = 129 //浅追踪
//基础分值,底分
GameBaseScore = 1
//最小携带金币
MinHaveScore = 1
//最大携带金币
MaxHaveScore = 100
//抽水比例,千分比,5代表千分之5
TaxRatio = 5
)
var pathMap = make(map[string][][][]int)
func LoadTraceFile(path string) (err error) {
_, err = os.Stat(path)
if os.IsNotExist(err) {
return fmt.Errorf("file %v not exists", path)
}
file, err := os.Open(path)
if err != nil {
panic(err)
}
defer file.Close()
var jsonStrByte []byte
for {
buf := make([]byte, 1024)
readNum, err := file.Read(buf)
if err != nil && err != io.EOF {
panic(err)
}
for i := 0; i < readNum; i++ {
jsonStrByte = append(jsonStrByte, buf[i])
}
if 0 == readNum {
break
}
}
err = json.Unmarshal(jsonStrByte, &pathMap)
if err != nil {
fmt.Printf("json unmarsha1 err:%v \n", err)
return
} else {
fmt.Println("success")
}
return
}
func getPathMap(id int) [][][]int {
return pathMap[strconv.Itoa(id)]
}
================================================
FILE: game/service/fish_utils.go
================================================
package service
import (
"github.com/astaxie/beego/logs"
"math/rand"
"time"
)
type FishUtil struct {
//ActiveFish []*Fish
//Lock sync.Mutex
CurrentFishId FishId
BuildFishChan chan *Fish
StopBuildFish chan bool //暂停出鱼
RestartBuildFish chan bool //重新开始出鱼
Exit chan bool //接收信号
}
type FishId int
//普通鱼
type Fish struct {
FishKind int `json:"fishKind"`
Trace [][]int `json:"trace"`
Speed int `json:"speed"`
FishId FishId `json:"fishId"`
ActiveTime time.Time `json:"-"`
FrontActiveTime int64 `json:"activeTime"` //给客户端的时间
}
//组合鱼
type ArrayFish struct {
FishKind int `json:"fishKind"`
TraceKind int `json:"traceKind"`
FishId FishId `json:"fishId"`
Speed int `json:"speed"`
}
type FishArrayRet struct {
FormationKind int `json:"formationKind"`
FishArray [][]*ArrayFish `json:"fishArray"`
EndTime time.Time `json:"-"`
EndTimeStamp int64 `json:"endTime"`
}
func (p *FishUtil) GenerateFishId() FishId {
p.CurrentFishId++
return p.CurrentFishId
}
func (p *FishUtil) BuildFishTrace() {
var buildTrace = func() int {
// 线路随机生成
var traceId = 101
//var traceRandom = Math.floor(Math.random() * 1000) + 1
rand.Seed(time.Now().UnixNano())
var traceKind = rand.Int()
randNum := rand.Int()
switch traceKind%3 + 1 {
case 1: // 直线 201-217
traceId = randNum%17 + 201
break
case 2: // 二阶曲线 1-10
traceId = randNum%10 + 1
break
case 3: // 三阶曲线 101 -110
traceId = randNum%10 + 101
break
}
return traceId
}
c1 := time.NewTicker(time.Second * 2)
c2 := time.NewTicker(time.Second*10 + time.Millisecond*100)
c3 := time.NewTicker(time.Second*30 + time.Millisecond*200)
c4 := time.NewTicker(time.Second * 61)
go func() {
defer func() {
logs.Trace("exit utils")
}()
defer func() {
c1.Stop()
c2.Stop()
c3.Stop()
c4.Stop()
close(p.BuildFishChan)
close(p.StopBuildFish)
close(p.RestartBuildFish)
}()
//logs.Debug("utils start running ...")
var buildNormalFish = func() {
rand.Seed(time.Now().UnixNano())
traceKind := buildTrace()
fishKind := rand.Intn(15) + 1
traces := getPathMap(traceKind)
//logs.Debug("add normal fish tick run")
for i := 0; i < len(traces); i++ {
fishId := p.GenerateFishId()
p.AddFish(fishKind, traces[i], fishId)
}
}
buildNormalFish()
for {
//logs.Error("for loop......")
select {
case <-c1.C: //随机生成鱼 1-15
buildNormalFish()
case <-c2.C: // 16-20
//logs.Error("<-c2.C in")
rand.Seed(time.Now().UnixNano())
fishKind := rand.Intn(5) + 16
fishId := p.GenerateFishId()
traceKind := buildTrace()
traces := getPathMap(traceKind)
p.AddFish(fishKind, traces[0], fishId)
case <-c3.C: // 21-34
//logs.Error("<-c3.C in")
rand.Seed(time.Now().UnixNano())
fishKind := rand.Intn(14) + 21
fishId := p.GenerateFishId()
traceKind := buildTrace()
traces := getPathMap(traceKind)
p.AddFish(fishKind, traces[1], fishId)
case <-c4.C: // 鱼王
//logs.Error("<-c4.C in")
fishKind := 35
fishId := p.GenerateFishId()
rand.Seed(time.Now().UnixNano())
traceKind := rand.Intn(10) + 101
traces := getPathMap(traceKind)
p.AddFish(fishKind, traces[1], fishId)
case <-p.StopBuildFish: //停止出鱼
logs.Trace("build util StopBuildFish...")
c1.Stop()
c2.Stop()
c3.Stop()
c4.Stop()
//logs.Debug("<-p.StopBuildFish")
case <-p.RestartBuildFish:
logs.Trace("build util RestartBuildFish...")
c1 = time.NewTicker(time.Second * 2)
c2 = time.NewTicker(time.Second*10 + time.Millisecond*100)
c3 = time.NewTicker(time.Second*30 + time.Millisecond*200)
c4 = time.NewTicker(time.Second * 61)
//logs.Debug("<-p.RestartBuildFish")
//return
case <-p.Exit:
//logs.Error("<-p.Exit")
//退出关闭资源
//close(p.StopBuildFish)
//close(p.RestartBuildFish)
close(p.Exit)
//logs.Debug("<-p.Exit")
return
}
}
}()
}
func (p *FishUtil) AddFish(fishKind int, trace [][]int, fishId FishId) {
var speed = 6
if fishId >= 35 {
speed = 3
} else if fishId >= 30 {
speed = 4
} else if fishId >= 20 {
speed = 5
}
p.BuildFishChan <- &Fish{
FishKind: fishKind,
Trace: trace,
Speed: speed,
FishId: fishId,
ActiveTime: time.Now(),
FrontActiveTime: time.Now().UnixNano() / 1e6,
}
}
//启动鱼阵
func BuildFishArray() (ret *FishArrayRet) {
var fishId FishId
var generateFishId = func() FishId {
fishId++
return fishId
}
var fishArray = make([][]*ArrayFish, 0)
var duration = 0
//直线鱼阵
var buildFormationLine = func() {
duration = 60
fishArray = append(fishArray, make([]*ArrayFish, 0))
fishArray = append(fishArray, make([]*ArrayFish, 0))
var kind = 14
for i := 0; i < 30; i++ {
kind = i/3 + 10
fishArray[0] = append(fishArray[0], &ArrayFish{
FishKind: kind,
TraceKind: 0,
FishId: generateFishId(),
Speed: 0,
})
fishArray[1] = append(fishArray[1], &ArrayFish{
FishKind: kind,
TraceKind: 0,
FishId: generateFishId(),
Speed: 0,
})
}
}
//环形鱼阵
var buildCircleGroupFish = func() {
duration = 60
kind, fishNum := 1, 20
for i := 0; i < 10; i++ {
kind += 2
fishArray = append(fishArray, make([]*ArrayFish, 0))
if i > 20 {
fishNum = 10
}
for j := 0; j < fishNum; j++ {
fishArray[i] = append(fishArray[i], &ArrayFish{
FishKind: kind,
TraceKind: 0,
FishId: generateFishId(),
Speed: 0,
})
}
}
}
// 两个螺旋形数组
var buildSpiralGroupFish = func() {
duration = 60
fishArray = append(fishArray, make([]*ArrayFish, 0))
fishArray = append(fishArray, make([]*ArrayFish, 0))
kind := 1
for i := 1; i <= 30; i++ {
kind = ((i-1)/10 + 1) * 5
fishArray[0] = append(fishArray[0],&ArrayFish{
FishKind: kind,
TraceKind: 0,
FishId: generateFishId(),
Speed: 0,
})
fishArray[1] = append(fishArray[1],&ArrayFish{
FishKind: kind,
TraceKind: 0,
FishId: generateFishId(),
Speed: 0,
})
}
}
ret = &FishArrayRet{}
ret.FormationKind = rand.Intn(3) + 1
//ret.FormationKind = 1
switch ret.FormationKind {
case 1:
buildFormationLine()
case 2:
buildCircleGroupFish()
case 3:
buildSpiralGroupFish()
}
ret.FishArray = fishArray
ret.EndTime = time.Now().Add(time.Second * time.Duration(duration))
ret.EndTimeStamp = ret.EndTime.Unix() * 1e3
return
}
//是否命中
func IsHit(f *Fish) bool {
rand.Seed(time.Now().UnixNano())
// todo 调整概率
return rand.Intn(GetFishMulti(f)) == 0
//return rand.Intn(GetFishMulti(f)*3/5) == 0
//return true
}
func GetFishMulti(fish *Fish) int {
if multi, ok := FishMulti[fish.FishKind]; ok {
return multi
} else {
return 2
}
}
// 根据id取得子弹的倍数
func GetBulletMulti(BulletKind int) int {
if multi, ok := BulletMulti[BulletKind]; ok {
return multi
} else {
return 1
}
}
================================================
FILE: game/service/request.go
================================================
package service
import (
"context"
"encoding/json"
"fish/common/api/thrift/gen-go/rpc"
"fish/common/tools"
"fish/game/common"
"fmt"
"github.com/astaxie/beego/logs"
"strconv"
"strings"
"time"
)
type UserLockFishReq struct {
UserId UserId `json:"userId"`
ChairId int `json:"chairId"`
FishId FishId `json:"fishId"`
}
type LaserCatchReq struct {
UserId UserId `json:"userId"`
ChairId int `json:"chairId"`
Fishes string `json:"fishes"`
Sign string `json:"sign"`
}
type UserFireLaserReq struct {
UserId UserId `json:"userId"`
ChairId int `json:"chairId"`
BulletKind int `json:"bulletKind"`
BulletId int `json:"bulletId"`
Angle float64 `json:"angle"`
Sign string `json:"sign"`
LockFishId FishId `json:"lockFishId"`
}
func wsRequest(req []byte, client *Client) {
defer func() {
if r := recover(); r != nil {
logs.Error("wsRequest panic:%v ", r)
}
}()
if req[0] == '4' && req[1] == '2' {
reqJson := make([]string, 0)
err := json.Unmarshal(req[2:], &reqJson)
if err != nil {
logs.Error("wsRequest json unmarshal err :%v", err)
return
}
if client.Room == nil { //未登录
logs.Info("未登录 login msg : %v", reqJson[0])
if reqJson[0] == "login" {
if len(reqJson) < 2 {
return
}
//if reqByteData, ok := reqJson[1].([]byte); ok {
reqData := make(map[string]string)
if err := json.Unmarshal([]byte(reqJson[1]), &reqData); err != nil {
roomIdStr := reqData["roomId"]
if roomIdStr == "" { //客户端重连时roomId用的int类型。。。心累
reqDataReconnect := make(map[string]int)
if err := json.Unmarshal([]byte(reqJson[1]), &reqDataReconnect); err != nil {
roomIdInt := reqDataReconnect["roomId"]
roomIdStr = strconv.Itoa(roomIdInt)
}
}
if roomIdInt, err := strconv.Atoi(roomIdStr); err == nil {
roomId := RoomId(roomIdInt)
RoomMgr.RoomLock.Lock()
logs.Info("login get lock...")
defer RoomMgr.RoomLock.Unlock()
defer logs.Info("login set free lock...")
if room, ok := RoomMgr.Rooms[roomId]; ok {
//if room.Status == GameStatusWaitBegin {
// room.Status = GameStatusFree
// room.Utils.BuildFishTrace()
//}
logs.Debug("send succ")
client.Room = room
room.ClientReqChan <- &clientReqData{
client,
reqJson,
}
} else {
logs.Error("room %v, not exists", roomId)
}
} else {
logs.Error("roomId %v err : %v", roomIdStr, err)
}
}
//}
} else {
logs.Error("invalid act %v", reqJson[0])
}
} else {
//logs.Debug("send req to room [%d] succ 2", client.Room.RoomId)
client.Room.ClientReqChan <- &clientReqData{
client,
reqJson,
}
}
} else {
logs.Error("invalid message %v", req)
}
}
//todo 弱类型语言写的东西重构简直堪比火葬场
func handleUserRequest(clientReq *clientReqData) {
reqJson := clientReq.reqData
client := clientReq.client
if len(reqJson) > 0 {
act := reqJson[0]
switch act {
case "login":
//logs.Debug("login")
if len(reqJson) < 2 {
return
}
reqData := make(map[string]interface{})
if err := json.Unmarshal([]byte(reqJson[1]), &reqData); err == nil {
token := reqData["sign"]
if token, ok := token.(string); ok {
logs.Debug("token %v", token)
if rpcClient, closeTransportHandler, err := tools.GetRpcClient(common.GameConf.AccountHost, strconv.Itoa(common.GameConf.AccountPort)); err == nil {
defer func() {
if err := closeTransportHandler(); err != nil {
logs.Error("close rpc err: %v", err)
}
}()
if res, err := rpcClient.GetUserInfoByToken(context.Background(), token); err == nil {
//logs.Debug("rpc res : %v", res.Code)
if res.Code == rpc.ErrorCode_Success {
userId := UserId(res.UserObj.UserId)
for _, userInfo := range client.Room.Users {
if userId == userInfo.UserId {
userInfo.client = client
userInfo.Online = true
userInfo.Ip = "::1"
client.UserInfo = userInfo
logs.Debug("client userInfo get data...")
seats := make([]interface{}, 0)
cannonKindVip := map[int]int{0: 1, 1: 4, 2: 7, 3: 10, 4: 13, 5: 16, 6: 19}
//todo check sign
//score, _ := strconv.ParseFloat(fmt.Sprintf("%.3f", float64(userInfo.Score)/1000), 64)
userInfo.ConversionScore, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", float64(userInfo.Score)/1000), 64)
for _, userInfo := range client.Room.Users {
seats = append(seats, map[string]interface{}{
"userId": userInfo.UserId,
"ip": "",
"score": userInfo.ConversionScore,
"name": userInfo.Name,
"vip": userInfo.Vip,
"online": true,
"ready": userInfo.Ready,
"seatIndex": userInfo.SeatIndex,
// 正在使用哪种炮 todo 换为真实vip
"cannonKind": cannonKindVip[0],
// 能量值
"power": 0,
})
}
client.sendToClient([]interface{}{
"login_result",
map[string]interface{}{
"errcode": 0,
"errmsg": "ok",
"data": map[string]interface{}{
"roomId": strconv.Itoa(int(client.Room.RoomId)),
"conf": client.Room.Conf,
"numofgames": 0,
"seats": seats,
gitextract_5x4ila4d/ ├── .gitignore ├── README.md ├── account/ │ ├── common/ │ │ ├── config.go │ │ └── model.go │ ├── main/ │ │ ├── config.go │ │ ├── init.go │ │ └── main.go │ └── service/ │ └── handle.go ├── common/ │ ├── api/ │ │ └── thrift/ │ │ ├── account.thrift │ │ └── gen-go/ │ │ └── rpc/ │ │ ├── GoUnusedProtection__.go │ │ ├── account-consts.go │ │ ├── account.go │ │ └── user_service-remote/ │ │ └── user_service-remote.go │ ├── conf/ │ │ ├── account.conf │ │ ├── game.conf │ │ ├── hall.conf │ │ └── traces.json │ └── tools/ │ ├── aes.go │ ├── call_rpc.go │ ├── snowFlake.go │ └── tools.go ├── game/ │ ├── common/ │ │ └── config.go │ ├── controllers/ │ │ ├── create_public_room.go │ │ ├── create_room.go │ │ ├── enter_public_room.go │ │ ├── enter_room.go │ │ ├── get_server_info.go │ │ ├── is_room_running.go │ │ └── ping.go │ ├── main/ │ │ ├── config.go │ │ ├── init.go │ │ └── main.go │ ├── router/ │ │ └── router.go │ └── service/ │ ├── client.go │ ├── define.go │ ├── fish_utils.go │ ├── request.go │ └── room.go ├── go.mod ├── go.sum ├── hall/ │ ├── common/ │ │ └── config.go │ ├── controllers/ │ │ ├── enter_public_room.go │ │ ├── get_message.go │ │ ├── get_server_info.go │ │ ├── get_user_status.go │ │ ├── guest.go │ │ ├── login.go │ │ ├── qq_callback.go │ │ ├── qq_login.go │ │ └── register_game_server.go │ ├── main/ │ │ ├── config.go │ │ ├── init.go │ │ └── main.go │ └── router/ │ └── router.go ├── start_account.bat ├── start_fish.bat ├── start_hall.bat └── z-start_all_server.bat
SYMBOL INDEX (449 symbols across 44 files)
FILE: account/common/config.go
type AccountServiceConf (line 15) | type AccountServiceConf struct
type RedisConf (line 24) | type RedisConf struct
type MysqlConf (line 31) | type MysqlConf struct
FILE: account/common/model.go
type FishUser (line 3) | type FishUser struct
type InvestUserStake (line 23) | type InvestUserStake struct
FILE: account/main/config.go
function initConf (line 10) | func initConf() (err error) {
FILE: account/main/init.go
function conversionLogLevel (line 13) | func conversionLogLevel(logLevel string) int {
function initLogger (line 27) | func initLogger() (err error) {
function initMysql (line 40) | func initMysql() (err error) {
function initRedis (line 52) | func initRedis() (err error) {
function initSec (line 70) | func initSec() (err error) {
FILE: account/main/main.go
function main (line 12) | func main() {
FILE: account/service/handle.go
type UserServer (line 21) | type UserServer struct
method GetUserInfoByOpenId (line 31) | func (p *UserServer) GetUserInfoByOpenId(ctx context.Context, openId s...
method CreateQQUser (line 48) | func (p *UserServer) CreateQQUser(ctx context.Context, userInfo *rpc.U...
method CreateNewUser (line 102) | func (p *UserServer) CreateNewUser(ctx context.Context, nickName strin...
method GetUserInfoById (line 158) | func (p *UserServer) GetUserInfoById(ctx context.Context, userId int32...
method GetUserInfoByToken (line 208) | func (p *UserServer) GetUserInfoByToken(ctx context.Context, token str...
method ModifyUserInfoById (line 223) | func (p *UserServer) ModifyUserInfoById(ctx context.Context, behavior ...
method GetMessage (line 246) | func (p *UserServer) GetMessage(ctx context.Context, messageType strin...
method RenameUserById (line 262) | func (p *UserServer) RenameUserById(ctx context.Context, userId int32,...
function InitAesTool (line 24) | func InitAesTool() {
FILE: common/api/thrift/gen-go/rpc/account-consts.go
function init (line 22) | func init() {
FILE: common/api/thrift/gen-go/rpc/account.go
type ErrorCode (line 23) | type ErrorCode
method String (line 31) | func (p ErrorCode) String() string {
method MarshalText (line 54) | func (p ErrorCode) MarshalText() ([]byte, error) {
method UnmarshalText (line 58) | func (p *ErrorCode) UnmarshalText(text []byte) error {
method Scan (line 67) | func (p *ErrorCode) Scan(value interface{}) error {
method Value (line 76) | func (p * ErrorCode) Value() (driver.Value, error) {
constant ErrorCode_Success (line 25) | ErrorCode_Success ErrorCode = 0
constant ErrorCode_ServerError (line 26) | ErrorCode_ServerError ErrorCode = 5000
constant ErrorCode_VerifyError (line 27) | ErrorCode_VerifyError ErrorCode = 5001
constant ErrorCode_UserNotExists (line 28) | ErrorCode_UserNotExists ErrorCode = 5002
function ErrorCodeFromString (line 41) | func ErrorCodeFromString(s string) (ErrorCode, error) {
function ErrorCodePtr (line 52) | func ErrorCodePtr(v ErrorCode) *ErrorCode { return &v }
type ModifyPropType (line 82) | type ModifyPropType
method String (line 90) | func (p ModifyPropType) String() string {
method MarshalText (line 113) | func (p ModifyPropType) MarshalText() ([]byte, error) {
method UnmarshalText (line 117) | func (p *ModifyPropType) UnmarshalText(text []byte) error {
method Scan (line 126) | func (p *ModifyPropType) Scan(value interface{}) error {
method Value (line 135) | func (p * ModifyPropType) Value() (driver.Value, error) {
constant ModifyPropType_gems (line 84) | ModifyPropType_gems ModifyPropType = 0
constant ModifyPropType_roomId (line 85) | ModifyPropType_roomId ModifyPropType = 1
constant ModifyPropType_power (line 86) | ModifyPropType_power ModifyPropType = 2
constant ModifyPropType_ice (line 87) | ModifyPropType_ice ModifyPropType = 3
function ModifyPropTypeFromString (line 100) | func ModifyPropTypeFromString(s string) (ModifyPropType, error) {
function ModifyPropTypePtr (line 111) | func ModifyPropTypePtr(v ModifyPropType) *ModifyPropType { return &v }
type QqInfo (line 147) | type QqInfo struct
method GetOpenId (line 160) | func (p *QqInfo) GetOpenId() string {
method GetFigureUrl (line 164) | func (p *QqInfo) GetFigureUrl() string {
method GetProvince (line 168) | func (p *QqInfo) GetProvince() string {
method GetCity (line 172) | func (p *QqInfo) GetCity() string {
method GetTotalSpending (line 176) | func (p *QqInfo) GetTotalSpending() int64 {
method Read (line 179) | func (p *QqInfo) Read(iprot thrift.TProtocol) error {
method ReadField1 (line 257) | func (p *QqInfo) ReadField1(iprot thrift.TProtocol) error {
method ReadField2 (line 266) | func (p *QqInfo) ReadField2(iprot thrift.TProtocol) error {
method ReadField3 (line 275) | func (p *QqInfo) ReadField3(iprot thrift.TProtocol) error {
method ReadField4 (line 284) | func (p *QqInfo) ReadField4(iprot thrift.TProtocol) error {
method ReadField5 (line 293) | func (p *QqInfo) ReadField5(iprot thrift.TProtocol) error {
method Write (line 302) | func (p *QqInfo) Write(oprot thrift.TProtocol) error {
method writeField1 (line 319) | func (p *QqInfo) writeField1(oprot thrift.TProtocol) (err error) {
method writeField2 (line 329) | func (p *QqInfo) writeField2(oprot thrift.TProtocol) (err error) {
method writeField3 (line 339) | func (p *QqInfo) writeField3(oprot thrift.TProtocol) (err error) {
method writeField4 (line 349) | func (p *QqInfo) writeField4(oprot thrift.TProtocol) (err error) {
method writeField5 (line 359) | func (p *QqInfo) writeField5(oprot thrift.TProtocol) (err error) {
method String (line 369) | func (p *QqInfo) String() string {
function NewQqInfo (line 155) | func NewQqInfo() *QqInfo {
type UserInfo (line 394) | type UserInfo struct
method GetUserId (line 419) | func (p *UserInfo) GetUserId() int64 {
method GetUserName (line 423) | func (p *UserInfo) GetUserName() string {
method GetNickName (line 427) | func (p *UserInfo) GetNickName() string {
method GetSex (line 431) | func (p *UserInfo) GetSex() int8 {
method GetHeadImg (line 435) | func (p *UserInfo) GetHeadImg() string {
method GetLv (line 439) | func (p *UserInfo) GetLv() int32 {
method GetExp (line 443) | func (p *UserInfo) GetExp() int64 {
method GetVip (line 447) | func (p *UserInfo) GetVip() int8 {
method GetGems (line 451) | func (p *UserInfo) GetGems() int64 {
method GetRoomId (line 455) | func (p *UserInfo) GetRoomId() int64 {
method GetPower (line 459) | func (p *UserInfo) GetPower() int64 {
method GetReNameCount (line 463) | func (p *UserInfo) GetReNameCount() int8 {
method GetReHeadCount (line 467) | func (p *UserInfo) GetReHeadCount() int8 {
method GetRegisterDate (line 471) | func (p *UserInfo) GetRegisterDate() string {
method GetIce (line 475) | func (p *UserInfo) GetIce() int64 {
method GetToken (line 479) | func (p *UserInfo) GetToken() string {
method GetQqInfo (line 483) | func (p *UserInfo) GetQqInfo() *QqInfo {
method IsSetQqInfo (line 489) | func (p *UserInfo) IsSetQqInfo() bool {
method Read (line 493) | func (p *UserInfo) Read(iprot thrift.TProtocol) error {
method ReadField1 (line 691) | func (p *UserInfo) ReadField1(iprot thrift.TProtocol) error {
method ReadField2 (line 700) | func (p *UserInfo) ReadField2(iprot thrift.TProtocol) error {
method ReadField3 (line 709) | func (p *UserInfo) ReadField3(iprot thrift.TProtocol) error {
method ReadField4 (line 718) | func (p *UserInfo) ReadField4(iprot thrift.TProtocol) error {
method ReadField5 (line 728) | func (p *UserInfo) ReadField5(iprot thrift.TProtocol) error {
method ReadField6 (line 737) | func (p *UserInfo) ReadField6(iprot thrift.TProtocol) error {
method ReadField7 (line 746) | func (p *UserInfo) ReadField7(iprot thrift.TProtocol) error {
method ReadField8 (line 755) | func (p *UserInfo) ReadField8(iprot thrift.TProtocol) error {
method ReadField9 (line 765) | func (p *UserInfo) ReadField9(iprot thrift.TProtocol) error {
method ReadField10 (line 774) | func (p *UserInfo) ReadField10(iprot thrift.TProtocol) error {
method ReadField11 (line 783) | func (p *UserInfo) ReadField11(iprot thrift.TProtocol) error {
method ReadField12 (line 792) | func (p *UserInfo) ReadField12(iprot thrift.TProtocol) error {
method ReadField13 (line 802) | func (p *UserInfo) ReadField13(iprot thrift.TProtocol) error {
method ReadField14 (line 812) | func (p *UserInfo) ReadField14(iprot thrift.TProtocol) error {
method ReadField15 (line 821) | func (p *UserInfo) ReadField15(iprot thrift.TProtocol) error {
method ReadField16 (line 830) | func (p *UserInfo) ReadField16(iprot thrift.TProtocol) error {
method ReadField17 (line 839) | func (p *UserInfo) ReadField17(iprot thrift.TProtocol) error {
method Write (line 847) | func (p *UserInfo) Write(oprot thrift.TProtocol) error {
method writeField1 (line 876) | func (p *UserInfo) writeField1(oprot thrift.TProtocol) (err error) {
method writeField2 (line 886) | func (p *UserInfo) writeField2(oprot thrift.TProtocol) (err error) {
method writeField3 (line 896) | func (p *UserInfo) writeField3(oprot thrift.TProtocol) (err error) {
method writeField4 (line 906) | func (p *UserInfo) writeField4(oprot thrift.TProtocol) (err error) {
method writeField5 (line 916) | func (p *UserInfo) writeField5(oprot thrift.TProtocol) (err error) {
method writeField6 (line 926) | func (p *UserInfo) writeField6(oprot thrift.TProtocol) (err error) {
method writeField7 (line 936) | func (p *UserInfo) writeField7(oprot thrift.TProtocol) (err error) {
method writeField8 (line 946) | func (p *UserInfo) writeField8(oprot thrift.TProtocol) (err error) {
method writeField9 (line 956) | func (p *UserInfo) writeField9(oprot thrift.TProtocol) (err error) {
method writeField10 (line 966) | func (p *UserInfo) writeField10(oprot thrift.TProtocol) (err error) {
method writeField11 (line 976) | func (p *UserInfo) writeField11(oprot thrift.TProtocol) (err error) {
method writeField12 (line 986) | func (p *UserInfo) writeField12(oprot thrift.TProtocol) (err error) {
method writeField13 (line 996) | func (p *UserInfo) writeField13(oprot thrift.TProtocol) (err error) {
method writeField14 (line 1006) | func (p *UserInfo) writeField14(oprot thrift.TProtocol) (err error) {
method writeField15 (line 1016) | func (p *UserInfo) writeField15(oprot thrift.TProtocol) (err error) {
method writeField16 (line 1026) | func (p *UserInfo) writeField16(oprot thrift.TProtocol) (err error) {
method writeField17 (line 1036) | func (p *UserInfo) writeField17(oprot thrift.TProtocol) (err error) {
method String (line 1047) | func (p *UserInfo) String() string {
function NewUserInfo (line 414) | func NewUserInfo() *UserInfo {
type Result_ (line 1057) | type Result_ struct
method GetCode (line 1067) | func (p *Result_) GetCode() ErrorCode {
method GetUserObj (line 1071) | func (p *Result_) GetUserObj() *UserInfo {
method IsSetUserObj (line 1077) | func (p *Result_) IsSetUserObj() bool {
method Read (line 1081) | func (p *Result_) Read(iprot thrift.TProtocol) error {
method ReadField1 (line 1129) | func (p *Result_) ReadField1(iprot thrift.TProtocol) error {
method ReadField2 (line 1139) | func (p *Result_) ReadField2(iprot thrift.TProtocol) error {
method Write (line 1147) | func (p *Result_) Write(oprot thrift.TProtocol) error {
method writeField1 (line 1161) | func (p *Result_) writeField1(oprot thrift.TProtocol) (err error) {
method writeField2 (line 1171) | func (p *Result_) writeField2(oprot thrift.TProtocol) (err error) {
method String (line 1182) | func (p *Result_) String() string {
function NewResult_ (line 1062) | func NewResult_() *Result_ {
type UserService (line 1189) | type UserService interface
type UserServiceClient (line 1222) | type UserServiceClient struct
method Client_ (line 1244) | func (p *UserServiceClient) Client_() thrift.TClient {
method CreateNewUser (line 1251) | func (p *UserServiceClient) CreateNewUser(ctx context.Context, nickNam...
method CreateQQUser (line 1265) | func (p *UserServiceClient) CreateQQUser(ctx context.Context, UserInfo...
method GetUserInfoByOpenId (line 1277) | func (p *UserServiceClient) GetUserInfoByOpenId(ctx context.Context, o...
method GetUserInfoById (line 1289) | func (p *UserServiceClient) GetUserInfoById(ctx context.Context, userI...
method GetUserInfoByToken (line 1301) | func (p *UserServiceClient) GetUserInfoByToken(ctx context.Context, to...
method ModifyUserInfoById (line 1316) | func (p *UserServiceClient) ModifyUserInfoById(ctx context.Context, be...
method RenameUserById (line 1332) | func (p *UserServiceClient) RenameUserById(ctx context.Context, userId...
method GetMessage (line 1345) | func (p *UserServiceClient) GetMessage(ctx context.Context, messageTyp...
function NewUserServiceClientFactory (line 1226) | func NewUserServiceClientFactory(t thrift.TTransport, f thrift.TProtocol...
function NewUserServiceClientProtocol (line 1232) | func NewUserServiceClientProtocol(t thrift.TTransport, iprot thrift.TPro...
function NewUserServiceClient (line 1238) | func NewUserServiceClient(c thrift.TClient) *UserServiceClient {
type UserServiceProcessor (line 1355) | type UserServiceProcessor struct
method AddToProcessorMap (line 1360) | func (p *UserServiceProcessor) AddToProcessorMap(key string, processor...
method GetProcessorFunction (line 1364) | func (p *UserServiceProcessor) GetProcessorFunction(key string) (proce...
method ProcessorMap (line 1369) | func (p *UserServiceProcessor) ProcessorMap() map[string]thrift.TProce...
method Process (line 1387) | func (p *UserServiceProcessor) Process(ctx context.Context, iprot, opr...
function NewUserServiceProcessor (line 1373) | func NewUserServiceProcessor(handler UserService) *UserServiceProcessor {
type userServiceProcessorCreateNewUser (line 1404) | type userServiceProcessorCreateNewUser struct
method Process (line 1408) | func (p *userServiceProcessorCreateNewUser) Process(ctx context.Contex...
type userServiceProcessorCreateQQUser (line 1452) | type userServiceProcessorCreateQQUser struct
method Process (line 1456) | func (p *userServiceProcessorCreateQQUser) Process(ctx context.Context...
type userServiceProcessorGetUserInfoByOpenId (line 1500) | type userServiceProcessorGetUserInfoByOpenId struct
method Process (line 1504) | func (p *userServiceProcessorGetUserInfoByOpenId) Process(ctx context....
type userServiceProcessorGetUserInfoById (line 1548) | type userServiceProcessorGetUserInfoById struct
method Process (line 1552) | func (p *userServiceProcessorGetUserInfoById) Process(ctx context.Cont...
type userServiceProcessorGetUserInfoByToken (line 1596) | type userServiceProcessorGetUserInfoByToken struct
method Process (line 1600) | func (p *userServiceProcessorGetUserInfoByToken) Process(ctx context.C...
type userServiceProcessorModifyUserInfoById (line 1644) | type userServiceProcessorModifyUserInfoById struct
method Process (line 1648) | func (p *userServiceProcessorModifyUserInfoById) Process(ctx context.C...
type userServiceProcessorRenameUserById (line 1692) | type userServiceProcessorRenameUserById struct
method Process (line 1696) | func (p *userServiceProcessorRenameUserById) Process(ctx context.Conte...
type userServiceProcessorGetMessage (line 1740) | type userServiceProcessorGetMessage struct
method Process (line 1744) | func (p *userServiceProcessorGetMessage) Process(ctx context.Context, ...
type UserServiceCreateNewUserArgs (line 1795) | type UserServiceCreateNewUserArgs struct
method GetNickName (line 1806) | func (p *UserServiceCreateNewUserArgs) GetNickName() string {
method GetAvatarAuto (line 1810) | func (p *UserServiceCreateNewUserArgs) GetAvatarAuto() string {
method GetGold (line 1814) | func (p *UserServiceCreateNewUserArgs) GetGold() int64 {
method Read (line 1817) | func (p *UserServiceCreateNewUserArgs) Read(iprot thrift.TProtocol) er...
method ReadField1 (line 1875) | func (p *UserServiceCreateNewUserArgs) ReadField1(iprot thrift.TProto...
method ReadField2 (line 1884) | func (p *UserServiceCreateNewUserArgs) ReadField2(iprot thrift.TProto...
method ReadField3 (line 1893) | func (p *UserServiceCreateNewUserArgs) ReadField3(iprot thrift.TProto...
method Write (line 1902) | func (p *UserServiceCreateNewUserArgs) Write(oprot thrift.TProtocol) e...
method writeField1 (line 1917) | func (p *UserServiceCreateNewUserArgs) writeField1(oprot thrift.TProto...
method writeField2 (line 1927) | func (p *UserServiceCreateNewUserArgs) writeField2(oprot thrift.TProto...
method writeField3 (line 1937) | func (p *UserServiceCreateNewUserArgs) writeField3(oprot thrift.TProto...
method String (line 1947) | func (p *UserServiceCreateNewUserArgs) String() string {
function NewUserServiceCreateNewUserArgs (line 1801) | func NewUserServiceCreateNewUserArgs() *UserServiceCreateNewUserArgs {
type UserServiceCreateNewUserResult (line 1956) | type UserServiceCreateNewUserResult struct
method GetSuccess (line 1965) | func (p *UserServiceCreateNewUserResult) GetSuccess() *Result_ {
method IsSetSuccess (line 1971) | func (p *UserServiceCreateNewUserResult) IsSetSuccess() bool {
method Read (line 1975) | func (p *UserServiceCreateNewUserResult) Read(iprot thrift.TProtocol) ...
method ReadField0 (line 2013) | func (p *UserServiceCreateNewUserResult) ReadField0(iprot thrift.TPro...
method Write (line 2021) | func (p *UserServiceCreateNewUserResult) Write(oprot thrift.TProtocol)...
method writeField0 (line 2034) | func (p *UserServiceCreateNewUserResult) writeField0(oprot thrift.TPro...
method String (line 2047) | func (p *UserServiceCreateNewUserResult) String() string {
function NewUserServiceCreateNewUserResult (line 1960) | func NewUserServiceCreateNewUserResult() *UserServiceCreateNewUserResult {
type UserServiceCreateQQUserArgs (line 2056) | type UserServiceCreateQQUserArgs struct
method GetUserInfo (line 2065) | func (p *UserServiceCreateQQUserArgs) GetUserInfo() *UserInfo {
method IsSetUserInfo (line 2071) | func (p *UserServiceCreateQQUserArgs) IsSetUserInfo() bool {
method Read (line 2075) | func (p *UserServiceCreateQQUserArgs) Read(iprot thrift.TProtocol) err...
method ReadField1 (line 2113) | func (p *UserServiceCreateQQUserArgs) ReadField1(iprot thrift.TProtoc...
method Write (line 2121) | func (p *UserServiceCreateQQUserArgs) Write(oprot thrift.TProtocol) er...
method writeField1 (line 2134) | func (p *UserServiceCreateQQUserArgs) writeField1(oprot thrift.TProtoc...
method String (line 2145) | func (p *UserServiceCreateQQUserArgs) String() string {
function NewUserServiceCreateQQUserArgs (line 2060) | func NewUserServiceCreateQQUserArgs() *UserServiceCreateQQUserArgs {
type UserServiceCreateQQUserResult (line 2154) | type UserServiceCreateQQUserResult struct
method GetSuccess (line 2163) | func (p *UserServiceCreateQQUserResult) GetSuccess() *Result_ {
method IsSetSuccess (line 2169) | func (p *UserServiceCreateQQUserResult) IsSetSuccess() bool {
method Read (line 2173) | func (p *UserServiceCreateQQUserResult) Read(iprot thrift.TProtocol) e...
method ReadField0 (line 2211) | func (p *UserServiceCreateQQUserResult) ReadField0(iprot thrift.TProt...
method Write (line 2219) | func (p *UserServiceCreateQQUserResult) Write(oprot thrift.TProtocol) ...
method writeField0 (line 2232) | func (p *UserServiceCreateQQUserResult) writeField0(oprot thrift.TProt...
method String (line 2245) | func (p *UserServiceCreateQQUserResult) String() string {
function NewUserServiceCreateQQUserResult (line 2158) | func NewUserServiceCreateQQUserResult() *UserServiceCreateQQUserResult {
type UserServiceGetUserInfoByOpenIdArgs (line 2254) | type UserServiceGetUserInfoByOpenIdArgs struct
method GetOpenId (line 2263) | func (p *UserServiceGetUserInfoByOpenIdArgs) GetOpenId() string {
method Read (line 2266) | func (p *UserServiceGetUserInfoByOpenIdArgs) Read(iprot thrift.TProtoc...
method ReadField1 (line 2304) | func (p *UserServiceGetUserInfoByOpenIdArgs) ReadField1(iprot thrift....
method Write (line 2313) | func (p *UserServiceGetUserInfoByOpenIdArgs) Write(oprot thrift.TProto...
method writeField1 (line 2326) | func (p *UserServiceGetUserInfoByOpenIdArgs) writeField1(oprot thrift....
method String (line 2336) | func (p *UserServiceGetUserInfoByOpenIdArgs) String() string {
function NewUserServiceGetUserInfoByOpenIdArgs (line 2258) | func NewUserServiceGetUserInfoByOpenIdArgs() *UserServiceGetUserInfoByOp...
type UserServiceGetUserInfoByOpenIdResult (line 2345) | type UserServiceGetUserInfoByOpenIdResult struct
method GetSuccess (line 2354) | func (p *UserServiceGetUserInfoByOpenIdResult) GetSuccess() *Result_ {
method IsSetSuccess (line 2360) | func (p *UserServiceGetUserInfoByOpenIdResult) IsSetSuccess() bool {
method Read (line 2364) | func (p *UserServiceGetUserInfoByOpenIdResult) Read(iprot thrift.TProt...
method ReadField0 (line 2402) | func (p *UserServiceGetUserInfoByOpenIdResult) ReadField0(iprot thrif...
method Write (line 2410) | func (p *UserServiceGetUserInfoByOpenIdResult) Write(oprot thrift.TPro...
method writeField0 (line 2423) | func (p *UserServiceGetUserInfoByOpenIdResult) writeField0(oprot thrif...
method String (line 2436) | func (p *UserServiceGetUserInfoByOpenIdResult) String() string {
function NewUserServiceGetUserInfoByOpenIdResult (line 2349) | func NewUserServiceGetUserInfoByOpenIdResult() *UserServiceGetUserInfoBy...
type UserServiceGetUserInfoByIdArgs (line 2445) | type UserServiceGetUserInfoByIdArgs struct
method GetUserId (line 2454) | func (p *UserServiceGetUserInfoByIdArgs) GetUserId() int32 {
method Read (line 2457) | func (p *UserServiceGetUserInfoByIdArgs) Read(iprot thrift.TProtocol) ...
method ReadField1 (line 2495) | func (p *UserServiceGetUserInfoByIdArgs) ReadField1(iprot thrift.TPro...
method Write (line 2504) | func (p *UserServiceGetUserInfoByIdArgs) Write(oprot thrift.TProtocol)...
method writeField1 (line 2517) | func (p *UserServiceGetUserInfoByIdArgs) writeField1(oprot thrift.TPro...
method String (line 2527) | func (p *UserServiceGetUserInfoByIdArgs) String() string {
function NewUserServiceGetUserInfoByIdArgs (line 2449) | func NewUserServiceGetUserInfoByIdArgs() *UserServiceGetUserInfoByIdArgs {
type UserServiceGetUserInfoByIdResult (line 2536) | type UserServiceGetUserInfoByIdResult struct
method GetSuccess (line 2545) | func (p *UserServiceGetUserInfoByIdResult) GetSuccess() *Result_ {
method IsSetSuccess (line 2551) | func (p *UserServiceGetUserInfoByIdResult) IsSetSuccess() bool {
method Read (line 2555) | func (p *UserServiceGetUserInfoByIdResult) Read(iprot thrift.TProtocol...
method ReadField0 (line 2593) | func (p *UserServiceGetUserInfoByIdResult) ReadField0(iprot thrift.TP...
method Write (line 2601) | func (p *UserServiceGetUserInfoByIdResult) Write(oprot thrift.TProtoco...
method writeField0 (line 2614) | func (p *UserServiceGetUserInfoByIdResult) writeField0(oprot thrift.TP...
method String (line 2627) | func (p *UserServiceGetUserInfoByIdResult) String() string {
function NewUserServiceGetUserInfoByIdResult (line 2540) | func NewUserServiceGetUserInfoByIdResult() *UserServiceGetUserInfoByIdRe...
type UserServiceGetUserInfoByTokenArgs (line 2636) | type UserServiceGetUserInfoByTokenArgs struct
method GetToken (line 2645) | func (p *UserServiceGetUserInfoByTokenArgs) GetToken() string {
method Read (line 2648) | func (p *UserServiceGetUserInfoByTokenArgs) Read(iprot thrift.TProtoco...
method ReadField1 (line 2686) | func (p *UserServiceGetUserInfoByTokenArgs) ReadField1(iprot thrift.T...
method Write (line 2695) | func (p *UserServiceGetUserInfoByTokenArgs) Write(oprot thrift.TProtoc...
method writeField1 (line 2708) | func (p *UserServiceGetUserInfoByTokenArgs) writeField1(oprot thrift.T...
method String (line 2718) | func (p *UserServiceGetUserInfoByTokenArgs) String() string {
function NewUserServiceGetUserInfoByTokenArgs (line 2640) | func NewUserServiceGetUserInfoByTokenArgs() *UserServiceGetUserInfoByTok...
type UserServiceGetUserInfoByTokenResult (line 2727) | type UserServiceGetUserInfoByTokenResult struct
method GetSuccess (line 2736) | func (p *UserServiceGetUserInfoByTokenResult) GetSuccess() *Result_ {
method IsSetSuccess (line 2742) | func (p *UserServiceGetUserInfoByTokenResult) IsSetSuccess() bool {
method Read (line 2746) | func (p *UserServiceGetUserInfoByTokenResult) Read(iprot thrift.TProto...
method ReadField0 (line 2784) | func (p *UserServiceGetUserInfoByTokenResult) ReadField0(iprot thrift...
method Write (line 2792) | func (p *UserServiceGetUserInfoByTokenResult) Write(oprot thrift.TProt...
method writeField0 (line 2805) | func (p *UserServiceGetUserInfoByTokenResult) writeField0(oprot thrift...
method String (line 2818) | func (p *UserServiceGetUserInfoByTokenResult) String() string {
function NewUserServiceGetUserInfoByTokenResult (line 2731) | func NewUserServiceGetUserInfoByTokenResult() *UserServiceGetUserInfoByT...
type UserServiceModifyUserInfoByIdArgs (line 2830) | type UserServiceModifyUserInfoByIdArgs struct
method GetBehavior (line 2842) | func (p *UserServiceModifyUserInfoByIdArgs) GetBehavior() string {
method GetUserId (line 2846) | func (p *UserServiceModifyUserInfoByIdArgs) GetUserId() int32 {
method GetPropType (line 2850) | func (p *UserServiceModifyUserInfoByIdArgs) GetPropType() ModifyPropTy...
method GetIncr (line 2854) | func (p *UserServiceModifyUserInfoByIdArgs) GetIncr() int64 {
method Read (line 2857) | func (p *UserServiceModifyUserInfoByIdArgs) Read(iprot thrift.TProtoco...
method ReadField1 (line 2925) | func (p *UserServiceModifyUserInfoByIdArgs) ReadField1(iprot thrift.T...
method ReadField2 (line 2934) | func (p *UserServiceModifyUserInfoByIdArgs) ReadField2(iprot thrift.T...
method ReadField3 (line 2943) | func (p *UserServiceModifyUserInfoByIdArgs) ReadField3(iprot thrift.T...
method ReadField4 (line 2953) | func (p *UserServiceModifyUserInfoByIdArgs) ReadField4(iprot thrift.T...
method Write (line 2962) | func (p *UserServiceModifyUserInfoByIdArgs) Write(oprot thrift.TProtoc...
method writeField1 (line 2978) | func (p *UserServiceModifyUserInfoByIdArgs) writeField1(oprot thrift.T...
method writeField2 (line 2988) | func (p *UserServiceModifyUserInfoByIdArgs) writeField2(oprot thrift.T...
method writeField3 (line 2998) | func (p *UserServiceModifyUserInfoByIdArgs) writeField3(oprot thrift.T...
method writeField4 (line 3008) | func (p *UserServiceModifyUserInfoByIdArgs) writeField4(oprot thrift.T...
method String (line 3018) | func (p *UserServiceModifyUserInfoByIdArgs) String() string {
function NewUserServiceModifyUserInfoByIdArgs (line 2837) | func NewUserServiceModifyUserInfoByIdArgs() *UserServiceModifyUserInfoBy...
type UserServiceModifyUserInfoByIdResult (line 3027) | type UserServiceModifyUserInfoByIdResult struct
method GetSuccess (line 3036) | func (p *UserServiceModifyUserInfoByIdResult) GetSuccess() *Result_ {
method IsSetSuccess (line 3042) | func (p *UserServiceModifyUserInfoByIdResult) IsSetSuccess() bool {
method Read (line 3046) | func (p *UserServiceModifyUserInfoByIdResult) Read(iprot thrift.TProto...
method ReadField0 (line 3084) | func (p *UserServiceModifyUserInfoByIdResult) ReadField0(iprot thrift...
method Write (line 3092) | func (p *UserServiceModifyUserInfoByIdResult) Write(oprot thrift.TProt...
method writeField0 (line 3105) | func (p *UserServiceModifyUserInfoByIdResult) writeField0(oprot thrift...
method String (line 3118) | func (p *UserServiceModifyUserInfoByIdResult) String() string {
function NewUserServiceModifyUserInfoByIdResult (line 3031) | func NewUserServiceModifyUserInfoByIdResult() *UserServiceModifyUserInfo...
type UserServiceRenameUserByIdArgs (line 3128) | type UserServiceRenameUserByIdArgs struct
method GetUserId (line 3138) | func (p *UserServiceRenameUserByIdArgs) GetUserId() int32 {
method GetNewName_ (line 3142) | func (p *UserServiceRenameUserByIdArgs) GetNewName_() string {
method Read (line 3145) | func (p *UserServiceRenameUserByIdArgs) Read(iprot thrift.TProtocol) e...
method ReadField1 (line 3193) | func (p *UserServiceRenameUserByIdArgs) ReadField1(iprot thrift.TProt...
method ReadField2 (line 3202) | func (p *UserServiceRenameUserByIdArgs) ReadField2(iprot thrift.TProt...
method Write (line 3211) | func (p *UserServiceRenameUserByIdArgs) Write(oprot thrift.TProtocol) ...
method writeField1 (line 3225) | func (p *UserServiceRenameUserByIdArgs) writeField1(oprot thrift.TProt...
method writeField2 (line 3235) | func (p *UserServiceRenameUserByIdArgs) writeField2(oprot thrift.TProt...
method String (line 3245) | func (p *UserServiceRenameUserByIdArgs) String() string {
function NewUserServiceRenameUserByIdArgs (line 3133) | func NewUserServiceRenameUserByIdArgs() *UserServiceRenameUserByIdArgs {
type UserServiceRenameUserByIdResult (line 3254) | type UserServiceRenameUserByIdResult struct
method GetSuccess (line 3263) | func (p *UserServiceRenameUserByIdResult) GetSuccess() *Result_ {
method IsSetSuccess (line 3269) | func (p *UserServiceRenameUserByIdResult) IsSetSuccess() bool {
method Read (line 3273) | func (p *UserServiceRenameUserByIdResult) Read(iprot thrift.TProtocol)...
method ReadField0 (line 3311) | func (p *UserServiceRenameUserByIdResult) ReadField0(iprot thrift.TPr...
method Write (line 3319) | func (p *UserServiceRenameUserByIdResult) Write(oprot thrift.TProtocol...
method writeField0 (line 3332) | func (p *UserServiceRenameUserByIdResult) writeField0(oprot thrift.TPr...
method String (line 3345) | func (p *UserServiceRenameUserByIdResult) String() string {
function NewUserServiceRenameUserByIdResult (line 3258) | func NewUserServiceRenameUserByIdResult() *UserServiceRenameUserByIdResu...
type UserServiceGetMessageArgs (line 3354) | type UserServiceGetMessageArgs struct
method GetMessageType (line 3363) | func (p *UserServiceGetMessageArgs) GetMessageType() string {
method Read (line 3366) | func (p *UserServiceGetMessageArgs) Read(iprot thrift.TProtocol) error {
method ReadField1 (line 3404) | func (p *UserServiceGetMessageArgs) ReadField1(iprot thrift.TProtocol...
method Write (line 3413) | func (p *UserServiceGetMessageArgs) Write(oprot thrift.TProtocol) error {
method writeField1 (line 3426) | func (p *UserServiceGetMessageArgs) writeField1(oprot thrift.TProtocol...
method String (line 3436) | func (p *UserServiceGetMessageArgs) String() string {
function NewUserServiceGetMessageArgs (line 3358) | func NewUserServiceGetMessageArgs() *UserServiceGetMessageArgs {
type UserServiceGetMessageResult (line 3445) | type UserServiceGetMessageResult struct
method GetSuccess (line 3454) | func (p *UserServiceGetMessageResult) GetSuccess() string {
method IsSetSuccess (line 3460) | func (p *UserServiceGetMessageResult) IsSetSuccess() bool {
method Read (line 3464) | func (p *UserServiceGetMessageResult) Read(iprot thrift.TProtocol) err...
method ReadField0 (line 3502) | func (p *UserServiceGetMessageResult) ReadField0(iprot thrift.TProtoc...
method Write (line 3511) | func (p *UserServiceGetMessageResult) Write(oprot thrift.TProtocol) er...
method writeField0 (line 3524) | func (p *UserServiceGetMessageResult) writeField0(oprot thrift.TProtoc...
method String (line 3536) | func (p *UserServiceGetMessageResult) String() string {
function NewUserServiceGetMessageResult (line 3449) | func NewUserServiceGetMessageResult() *UserServiceGetMessageResult {
FILE: common/api/thrift/gen-go/rpc/user_service-remote/user_service-remote.go
function Usage (line 21) | func Usage() {
type httpHeaders (line 37) | type httpHeaders
method String (line 39) | func (h httpHeaders) String() string {
method Set (line 44) | func (h httpHeaders) Set(value string) error {
function main (line 53) | func main() {
FILE: common/tools/aes.go
function NewAesTool (line 10) | func NewAesTool(appSecret string) (aesTool *AesEncrypt,err error) {
type AesEncrypt (line 19) | type AesEncrypt struct
method getKey (line 23) | func (p *AesEncrypt) getKey() []byte {
method Encrypt (line 43) | func (p *AesEncrypt) Encrypt(strMesg string) (string, error) {
method Decrypt (line 59) | func (p *AesEncrypt) Decrypt(aesEncryptString string) (strDesc string,...
FILE: common/tools/call_rpc.go
function GetRpcClient (line 10) | func GetRpcClient(host,port string) (client *rpc.UserServiceClient, clos...
FILE: common/tools/snowFlake.go
constant nodeBits (line 10) | nodeBits uint8 = 10
constant stepBits (line 11) | stepBits uint8 = 12
constant nodeMax (line 12) | nodeMax int64 = -1 ^ (-1 << nodeBits)
constant stepMax (line 13) | stepMax int64 = -1 ^ (-1 << stepBits)
constant timeShift (line 14) | timeShift uint8 = nodeBits + stepBits
constant nodeShift (line 15) | nodeShift uint8 = stepBits
type Node (line 22) | type Node struct
method run (line 42) | func (n *Node) run() {
method Generate (line 61) | func (n *Node) Generate() int64 {
function GenerateUid (line 31) | func GenerateUid(nodeNum int64) (err error, generateChan <-chan int64) {
function NewNode (line 48) | func NewNode(nodeNum int64) (*Node, error) {
FILE: common/tools/tools.go
function CreateUid (line 10) | func CreateUid() (uuid string) {
FILE: game/common/config.go
type GameServerConf (line 7) | type GameServerConf struct
FILE: game/controllers/create_public_room.go
function CreatePublicRoom (line 10) | func CreatePublicRoom(w http.ResponseWriter, r *http.Request) {
FILE: game/controllers/create_room.go
function CreateRoom (line 10) | func CreateRoom(w http.ResponseWriter, r *http.Request) {
FILE: game/controllers/enter_public_room.go
function EnterPublicRoom (line 18) | func EnterPublicRoom(w http.ResponseWriter, r *http.Request) {
FILE: game/controllers/enter_room.go
function EnterRoom (line 10) | func EnterRoom(w http.ResponseWriter, r *http.Request) {
FILE: game/controllers/get_server_info.go
function GetServerInfo (line 10) | func GetServerInfo(w http.ResponseWriter, r *http.Request) {
FILE: game/controllers/is_room_running.go
function IsRoomRunning (line 10) | func IsRoomRunning(w http.ResponseWriter, r *http.Request) {
FILE: game/controllers/ping.go
function Ping (line 10) | func Ping(w http.ResponseWriter, r *http.Request) {
FILE: game/main/config.go
function initConf (line 9) | func initConf() (err error) {
FILE: game/main/init.go
function conversionLogLevel (line 10) | func conversionLogLevel(logLevel string) int {
function initLogger (line 24) | func initLogger() (err error) {
function initSec (line 37) | func initSec() (err error) {
FILE: game/main/main.go
function main (line 18) | func main() {
FILE: game/router/router.go
function init (line 9) | func init() {
FILE: game/service/client.go
constant writeWait (line 21) | writeWait = 1 * time.Second
constant pongWait (line 22) | pongWait = 60 * time.Second
constant pingPeriod (line 23) | pingPeriod = (pongWait * 9) / 10
constant maxMessageSize (line 24) | maxMessageSize = 512
type Client (line 38) | type Client struct
method sendMsg (line 80) | func (c *Client) sendMsg(msg []byte) {
method sendToClient (line 87) | func (c *Client) sendToClient(data []interface{}) {
method sendToOthers (line 96) | func (c *Client) sendToOthers(data []interface{}) {
method writePump (line 110) | func (c *Client) writePump() {
method readPump (line 162) | func (c *Client) readPump() {
method Fire (line 236) | func (c *Client) Fire(bullet *Bullet) {
method catchFish (line 257) | func (c *Client) catchFish(fishId FishId, bulletId BulletId) {
method frozenScene (line 323) | func (c *Client) frozenScene(startTime time.Time) { //冰冻屏幕
method exitRoom (line 337) | func (c *Client) exitRoom() {
method clearBill (line 342) | func (c *Client) clearBill() {
type UserId (line 46) | type UserId
type UserInfo (line 48) | type UserInfo struct
type BulletId (line 65) | type BulletId
type Bullet (line 66) | type Bullet struct
type catchFishReq (line 75) | type catchFishReq struct
function ServeWs (line 211) | func ServeWs(w http.ResponseWriter, r *http.Request) {
FILE: game/service/define.go
constant GameBaseScore (line 192) | GameBaseScore = 1
constant MinHaveScore (line 194) | MinHaveScore = 1
constant MaxHaveScore (line 196) | MaxHaveScore = 100
constant TaxRatio (line 198) | TaxRatio = 5
function LoadTraceFile (line 203) | func LoadTraceFile(path string) (err error) {
function getPathMap (line 238) | func getPathMap(id int) [][][]int {
FILE: game/service/fish_utils.go
type FishUtil (line 9) | type FishUtil struct
method GenerateFishId (line 46) | func (p *FishUtil) GenerateFishId() FishId {
method BuildFishTrace (line 51) | func (p *FishUtil) BuildFishTrace() {
method AddFish (line 162) | func (p *FishUtil) AddFish(fishKind int, trace [][]int, fishId FishId) {
type FishId (line 19) | type FishId
type Fish (line 22) | type Fish struct
type ArrayFish (line 32) | type ArrayFish struct
type FishArrayRet (line 39) | type FishArrayRet struct
function BuildFishArray (line 183) | func BuildFishArray() (ret *FishArrayRet) {
function IsHit (line 275) | func IsHit(f *Fish) bool {
function GetFishMulti (line 283) | func GetFishMulti(fish *Fish) int {
function GetBulletMulti (line 292) | func GetBulletMulti(BulletKind int) int {
FILE: game/service/request.go
type UserLockFishReq (line 16) | type UserLockFishReq struct
type LaserCatchReq (line 22) | type LaserCatchReq struct
type UserFireLaserReq (line 29) | type UserFireLaserReq struct
function wsRequest (line 39) | func wsRequest(req []byte, client *Client) {
function handleUserRequest (line 110) | func handleUserRequest(clientReq *clientReqData) {
function clientExit (line 401) | func clientExit(client *Client, closeClient bool) {
FILE: game/service/room.go
type roomMgr (line 12) | type roomMgr struct
type RoomInfo (line 19) | type RoomInfo struct
constant GameStatusWaitBegin (line 35) | GameStatusWaitBegin = iota
constant GameStatusFree (line 36) | GameStatusFree
constant GameStatusPlay (line 37) | GameStatusPlay
constant GameStatusFormation (line 38) | GameStatusFormation
constant GameStatusFrozen (line 39) | GameStatusFrozen
type RoomId (line 42) | type RoomId
type room (line 44) | type room struct
method EnterRoom (line 134) | func (room *room) EnterRoom(userInfo *UserInfo) (err error) {
method begin (line 162) | func (room *room) begin() {
method flushFish (line 233) | func (room *room) flushFish() {
method buildFormation (line 255) | func (room *room) buildFormation() {
method getBombFish (line 280) | func (room *room) getBombFish() (killedFishes []*Fish) {
method getAllInOne (line 293) | func (room *room) getAllInOne(oneFish *Fish) (killedFishes []*Fish) {
method getSameFish (line 303) | func (room *room) getSameFish(oneFish *Fish) (killedFishes []*Fish) {
method broadcast (line 327) | func (room *room) broadcast(data []interface{}) {
type clientReqData (line 63) | type clientReqData struct
type HttpReqData (line 68) | type HttpReqData struct
type RoomConf (line 73) | type RoomConf struct
function init (line 81) | func init() {
function initGenerateUidTool (line 87) | func initGenerateUidTool() (err error) {
function CreatePublicRoom (line 95) | func CreatePublicRoom(roomConf *RoomConf) (roomId RoomId) {
FILE: hall/common/config.go
type HallServiceConf (line 7) | type HallServiceConf struct
FILE: hall/controllers/enter_public_room.go
function EnterPublicRoom (line 12) | func EnterPublicRoom(w http.ResponseWriter, r *http.Request) {
FILE: hall/controllers/get_message.go
function GetMessage (line 13) | func GetMessage(w http.ResponseWriter, r *http.Request) {
FILE: hall/controllers/get_server_info.go
function GetServerInfo (line 11) | func GetServerInfo(w http.ResponseWriter, r *http.Request) {
FILE: hall/controllers/get_user_status.go
function GetUserStatus (line 14) | func GetUserStatus(w http.ResponseWriter, r *http.Request) {
FILE: hall/controllers/guest.go
function Guest (line 17) | func Guest(w http.ResponseWriter, r *http.Request) {
FILE: hall/controllers/login.go
function Login (line 15) | func Login(w http.ResponseWriter, r *http.Request) {
FILE: hall/controllers/qq_callback.go
type qqUserInfo (line 19) | type qqUserInfo struct
function QQCallback (line 43) | func QQCallback(w http.ResponseWriter, r *http.Request) {
FILE: hall/controllers/qq_login.go
function QQLogin (line 13) | func QQLogin(w http.ResponseWriter, r *http.Request) {
FILE: hall/controllers/register_game_server.go
function RegisterGameServer (line 17) | func RegisterGameServer(w http.ResponseWriter, r *http.Request) {
FILE: hall/main/config.go
function initConf (line 9) | func initConf() (err error) {
FILE: hall/main/init.go
function conversionLogLevel (line 9) | func conversionLogLevel(logLevel string) int {
function initLogger (line 23) | func initLogger() (err error) {
function initSec (line 36) | func initSec() (err error) {
FILE: hall/main/main.go
function main (line 12) | func main() {
FILE: hall/router/router.go
function init (line 8) | func init() {
Condensed preview — 58 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (267K chars).
[
{
"path": ".gitignore",
"chars": 18,
"preview": ".idea/\n*.exe\n*.log"
},
{
"path": "README.md",
"chars": 1844,
"preview": "# 捕鱼\n\n运行步骤:\n\n1.下载源码:\n\n git clone https://github.com/dwg255/fish\n\n2.编译:\n\n cd fish\\\n go build -o account.exe acco"
},
{
"path": "account/common/config.go",
"chars": 636,
"preview": "package common\n\nimport (\n\t\"github.com/go-redis/redis\"\n\t\"github.com/jmoiron/sqlx\"\n)\n\nvar (\n\tAccountConf = &AccountService"
},
{
"path": "account/common/model.go",
"chars": 1594,
"preview": "package common\n\ntype FishUser struct {\n\tUserId int `json:\"userid\" dB:\"UsERID\"`\n\tAccount string `json:\"accoun"
},
{
"path": "account/main/config.go",
"chars": 2159,
"preview": "package main\n\nimport (\n\t\"fish/account/common\"\n\t\"fmt\"\n\t\"github.com/astaxie/beego/config\"\n\t\"github.com/astaxie/beego/logs\""
},
{
"path": "account/main/init.go",
"chars": 1731,
"preview": "package main\n\nimport (\n\t\"encoding/json\"\n\t\"fish/account/common\"\n\t\"fmt\"\n\t\"github.com/astaxie/beego/logs\"\n\t\"github.com/go-r"
},
{
"path": "account/main/main.go",
"chars": 1007,
"preview": "package main\n\nimport (\n\t\"fish/account/common\"\n\t\"fish/account/service\"\n\t\"fish/common/api/thrift/gen-go/rpc\"\n\t\"fmt\"\n\t\"gith"
},
{
"path": "account/service/handle.go",
"chars": 8427,
"preview": "package service\n\nimport (\n\t\"context\"\n\t\"fish/account/common\"\n\t\"fish/common/api/thrift/gen-go/rpc\"\n\t\"fish/common/tools\"\n\t\""
},
{
"path": "common/api/thrift/account.thrift",
"chars": 1356,
"preview": "namespace go rpc\n\nenum ErrorCode{\n Success=0\n ServerError=5000,\n VerifyError=5001,\n UserNotExists=5002,\n}\n\ne"
},
{
"path": "common/api/thrift/gen-go/rpc/GoUnusedProtection__.go",
"chars": 158,
"preview": "// Autogenerated by Thrift Compiler (0.12.0)\n// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n\npackag"
},
{
"path": "common/api/thrift/gen-go/rpc/account-consts.go",
"chars": 422,
"preview": "// Autogenerated by Thrift Compiler (0.12.0)\n// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n\npackag"
},
{
"path": "common/api/thrift/gen-go/rpc/account.go",
"chars": 114042,
"preview": "// Autogenerated by Thrift Compiler (0.12.0)\n// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n\npackag"
},
{
"path": "common/api/thrift/gen-go/rpc/user_service-remote/user_service-remote.go",
"chars": 8529,
"preview": "// Autogenerated by Thrift Compiler (0.12.0)\n// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n\npackag"
},
{
"path": "common/conf/account.conf",
"chars": 393,
"preview": ";[dev]\n\naccount_host=127.0.0.1\naccount_port=4000\n\naccount_aes_key=bb6c59d065966e6236fcc635f88f8543\n\n;日志\nlog_path=./logs"
},
{
"path": "common/conf/game.conf",
"chars": 90,
"preview": ";[dev]\n\ngame_host=127.0.0.1\ngame_port=4002\n\n;日志\nlog_path=./logs/game.log\nlog_level=debug\n"
},
{
"path": "common/conf/hall.conf",
"chars": 240,
"preview": ";[dev]\n\nhall_host=127.0.0.1\nhall_port=9000\nhall_secret=7Cw2ALPkht676IUB\n\n;日志\nlog_path=./logs/hall.log\nlog_level=debug\n\n"
},
{
"path": "common/conf/traces.json",
"chars": 4822,
"preview": "{\n \"201\": [[[-548, 1002], [1914, -390]], [[-548, 1002], [1914, -312]], [[-548, 1002], [1914, -234]], [[-548, 1080], [19"
},
{
"path": "common/tools/aes.go",
"chars": 1846,
"preview": "package tools\n\nimport (\n\t\"crypto/aes\"\n\t\"crypto/cipher\"\n\t\"fmt\"\n\t\"encoding/hex\"\n)\n\nfunc NewAesTool(appSecret string) (aesT"
},
{
"path": "common/tools/call_rpc.go",
"chars": 978,
"preview": "package tools\n\nimport (\n\t\"fish/common/api/thrift/gen-go/rpc\"\n\t\"fmt\"\n\t\"github.com/apache/thrift/lib/go/thrift\"\n\t\"net\"\n)\n\n"
},
{
"path": "common/tools/snowFlake.go",
"chars": 1401,
"preview": "package tools\n\nimport (\n\t\"errors\"\n\t\"sync\"\n\t\"time\"\n)\n\nconst (\n\tnodeBits uint8 = 10\n\tstepBits uint8 = 12\n\tnodeMax int6"
},
{
"path": "common/tools/tools.go",
"chars": 239,
"preview": "package tools\n\nimport (\n\t\"crypto/md5\"\n\t\"fmt\"\n\t\"time\"\n\t\"io\"\n)\n\nfunc CreateUid() (uuid string) {\n\tt := time.Now()\n\th := md"
},
{
"path": "game/common/config.go",
"chars": 244,
"preview": "package common\n\nvar (\n\tGameConf = &GameServerConf{}\n)\n\ntype GameServerConf struct {\n\tAccountHost string\n\tAccountPort int"
},
{
"path": "game/controllers/create_public_room.go",
"chars": 685,
"preview": "package controllers\n\nimport (\n\t\"encoding/json\"\n\t\"github.com/astaxie/beego/logs\"\n\t\"net/http\"\n\t\"time\"\n)\n\nfunc CreatePublic"
},
{
"path": "game/controllers/create_room.go",
"chars": 673,
"preview": "package controllers\n\nimport (\n\t\"encoding/json\"\n\t\"github.com/astaxie/beego/logs\"\n\t\"net/http\"\n\t\"time\"\n)\n\nfunc CreateRoom(w"
},
{
"path": "game/controllers/enter_public_room.go",
"chars": 4724,
"preview": "package controllers\n\nimport (\n\t\"context\"\n\t\"crypto/md5\"\n\t\"encoding/json\"\n\t\"fish/common/api/thrift/gen-go/rpc\"\n\t\"fish/comm"
},
{
"path": "game/controllers/enter_room.go",
"chars": 671,
"preview": "package controllers\n\nimport (\n\t\"encoding/json\"\n\t\"github.com/astaxie/beego/logs\"\n\t\"net/http\"\n\t\"time\"\n)\n\nfunc EnterRoom(w "
},
{
"path": "game/controllers/get_server_info.go",
"chars": 679,
"preview": "package controllers\n\nimport (\n\t\"encoding/json\"\n\t\"github.com/astaxie/beego/logs\"\n\t\"net/http\"\n\t\"time\"\n)\n\nfunc GetServerInf"
},
{
"path": "game/controllers/is_room_running.go",
"chars": 679,
"preview": "package controllers\n\nimport (\n\t\"encoding/json\"\n\t\"github.com/astaxie/beego/logs\"\n\t\"net/http\"\n\t\"time\"\n)\n\nfunc IsRoomRunnin"
},
{
"path": "game/controllers/ping.go",
"chars": 661,
"preview": "package controllers\n\nimport (\n\t\"encoding/json\"\n\t\"github.com/astaxie/beego/logs\"\n\t\"net/http\"\n\t\"time\"\n)\n\nfunc Ping(w http."
},
{
"path": "game/main/config.go",
"chars": 1746,
"preview": "package main\n\nimport (\n\t\"fish/game/common\"\n\t\"fmt\"\n\t\"github.com/astaxie/beego/config\"\n)\n\nfunc initConf() (err error) {\n\ta"
},
{
"path": "game/main/init.go",
"chars": 794,
"preview": "package main\n\nimport (\n\t\"encoding/json\"\n\t\"fish/game/common\"\n\t\"github.com/astaxie/beego/logs\"\n\t_ \"github.com/go-sql-drive"
},
{
"path": "game/main/main.go",
"chars": 1946,
"preview": "package main\n\nimport (\n\t\"crypto/md5\"\n\t\"fish/game/common\"\n\t_ \"fish/game/router\"\n\t\"fish/game/service\"\n\t\"flag\"\n\t\"fmt\"\n\t\"git"
},
{
"path": "game/router/router.go",
"chars": 574,
"preview": "package router\n\nimport (\n\t\"fish/game/controllers\"\n\t\"fish/game/service\"\n\t\"net/http\"\n)\n\nfunc init() {\n\thttp.HandleFunc(\"/"
},
{
"path": "game/service/client.go",
"chars": 11880,
"preview": "package service\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"encoding/json\"\n\t\"fish/common/api/thrift/gen-go/rpc\"\n\t\"fish/common/tools\""
},
{
"path": "game/service/define.go",
"chars": 4776,
"preview": "package service\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strconv\"\n)\n\n/*\n // 座位号\n -------------\n 0 1 2\n 7 "
},
{
"path": "game/service/fish_utils.go",
"chars": 6966,
"preview": "package service\n\nimport (\n\t\"github.com/astaxie/beego/logs\"\n\t\"math/rand\"\n\t\"time\"\n)\n\ntype FishUtil struct {\n\t//ActiveFish "
},
{
"path": "game/service/request.go",
"chars": 13514,
"preview": "package service\n\nimport (\n\t\"context\"\n\t\"encoding/json\"\n\t\"fish/common/api/thrift/gen-go/rpc\"\n\t\"fish/common/tools\"\n\t\"fish/g"
},
{
"path": "game/service/room.go",
"chars": 8556,
"preview": "package service\n\nimport (\n\t\"encoding/json\"\n\t\"fish/common/tools\"\n\t\"fmt\"\n\t\"github.com/astaxie/beego/logs\"\n\t\"sync\"\n\t\"time\"\n"
},
{
"path": "go.mod",
"chars": 890,
"preview": "module fish\n\ngo 1.12\n\nreplace (\n\tgolang.org/x/crypto v0.0.0-20181127143415-eb0de9b17e85 => github.com/golang/crypto v0.0"
},
{
"path": "go.sum",
"chars": 5461,
"preview": "git.apache.org/thrift.git v0.12.0 h1:CMxsZlAmxKs+VAZMlDDL0wXciMblJcutQbEe3A9CYUM=\ngit.apache.org/thrift.git v0.12.0/go.m"
},
{
"path": "hall/common/config.go",
"chars": 308,
"preview": "package common\n\nvar (\n\tHallConf = &HallServiceConf{}\n)\n\ntype HallServiceConf struct {\n\tAccountHost string\n\tAccountPort i"
},
{
"path": "hall/controllers/enter_public_room.go",
"chars": 1049,
"preview": "package controllers\n\nimport (\n\t\"crypto/md5\"\n\t\"fmt\"\n\t\"github.com/astaxie/beego/logs\"\n\t\"net/http\"\n\t\"strconv\"\n\t\"time\"\n)\n\nfu"
},
{
"path": "hall/controllers/get_message.go",
"chars": 1451,
"preview": "package controllers\n\nimport (\n\t\"context\"\n\t\"encoding/json\"\n\t\"fish/common/tools\"\n\t\"fish/hall/common\"\n\t\"github.com/astaxie/"
},
{
"path": "hall/controllers/get_server_info.go",
"chars": 795,
"preview": "package controllers\n\nimport (\n\t\"encoding/json\"\n\t\"fish/hall/common\"\n\t\"github.com/astaxie/beego/logs\"\n\t\"net/http\"\n\t\"strcon"
},
{
"path": "hall/controllers/get_user_status.go",
"chars": 1472,
"preview": "package controllers\n\nimport (\n\t\"context\"\n\t\"encoding/json\"\n\t\"fish/common/api/thrift/gen-go/rpc\"\n\t\"fish/common/tools\"\n\t\"fi"
},
{
"path": "hall/controllers/guest.go",
"chars": 4903,
"preview": "package controllers\n\nimport (\n\t\"context\"\n\t\"encoding/json\"\n\t\"fish/common/api/thrift/gen-go/rpc\"\n\t\"fish/common/tools\"\n\t\"fi"
},
{
"path": "hall/controllers/login.go",
"chars": 2128,
"preview": "package controllers\n\nimport (\n\t\"context\"\n\t\"encoding/json\"\n\t\"fish/common/api/thrift/gen-go/rpc\"\n\t\"fish/common/tools\"\n\t\"fi"
},
{
"path": "hall/controllers/qq_callback.go",
"chars": 4437,
"preview": "package controllers\n\nimport (\n\t\"context\"\n\t\"encoding/json\"\n\t\"fish/common/api/thrift/gen-go/rpc\"\n\t\"fish/common/tools\"\n\t\"fi"
},
{
"path": "hall/controllers/qq_login.go",
"chars": 778,
"preview": "package controllers\n\nimport (\n\t\"fmt\"\n\t\"github.com/astaxie/beego/logs\"\n\t\"net/http\"\n)\nvar (\n\tappId = 101673379\n\tAppKey = \""
},
{
"path": "hall/controllers/register_game_server.go",
"chars": 1695,
"preview": "package controllers\n\nimport (\n\t\"crypto/md5\"\n\t\"fish/hall/common\"\n\t\"fmt\"\n\t\"github.com/astaxie/beego/logs\"\n\t\"net/http\"\n\t\"st"
},
{
"path": "hall/main/config.go",
"chars": 1998,
"preview": "package main\n\nimport (\n\t\"fish/hall/common\"\n\t\"fmt\"\n\t\"github.com/astaxie/beego/config\"\n)\n\nfunc initConf() (err error) {\n\tc"
},
{
"path": "hall/main/init.go",
"chars": 758,
"preview": "package main\n\nimport (\n\t\"encoding/json\"\n\t\"fish/hall/common\"\n\t\"github.com/astaxie/beego/logs\"\n)\n\nfunc conversionLogLevel("
},
{
"path": "hall/main/main.go",
"chars": 570,
"preview": "package main\n\nimport (\n\t\"fish/hall/common\"\n\t_ \"fish/hall/router\"\n\t\"flag\"\n\t\"fmt\"\n\t\"github.com/astaxie/beego/logs\"\n\t\"net/h"
},
{
"path": "hall/router/router.go",
"chars": 607,
"preview": "package router\n\nimport (\n\t\"fish/hall/controllers\"\n\t\"net/http\"\n)\n\nfunc init() {\n\thttp.HandleFunc(\"/get_serverinfo\", contr"
},
{
"path": "start_account.bat",
"chars": 22,
"preview": "call account.exe\npause"
},
{
"path": "start_fish.bat",
"chars": 19,
"preview": "call fish.exe\npause"
},
{
"path": "start_hall.bat",
"chars": 19,
"preview": "call hall.exe\npause"
},
{
"path": "z-start_all_server.bat",
"chars": 83,
"preview": "start %~dp0\\start_account.bat\nstart %~dp0\\start_hall.bat\nstart %~dp0\\start_fish.bat"
}
]
About this extraction
This page contains the full source code of the dwg255/fish GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 58 files (235.5 KB), approximately 75.4k tokens, and a symbol index with 449 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.