[
  {
    "path": ".gitignore",
    "content": ".idea/\n*.exe\n*.log"
  },
  {
    "path": "README.md",
    "content": "# 捕鱼\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 account\\main\\main.go account\\main\\init.go account\\main\\config.go\n    go build -o hall.exe hall\\main\\main.go hall\\main\\init.go hall\\main\\config.go\n    go build -o fish.exe game\\main\\main.go game\\main\\init.go game\\main\\config.go\n\n3.解压客户端:\n    tar -zxvf fish.tar.gz /var/www/html/client/fish\n\n4.配置nginx:\n```\n    server {\n        listen       80;\n        server_name  fish.com;\n        charset utf8;\n        index index.html index.htm;\n        location /qq {\n            add_header Access-Control-Allow-Origin *;\n            proxy_set_header X-Target $request_uri;\n            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n            proxy_pass http://127.0.0.1:9000;\n        }\n        location / {\n            root /var/www/html/client/fish;\n            add_header Access-Control-Allow-Origin *;\n            expires 7d;\n        }\n    }\n```\n     配置文件位置 /common/conf 内含redis配置和qq第三方登录配置，请自行修改。\n\n5.在线示例:\n     http://fish.blzz.shop\n    \n---\n\nLicense\n\nThis project is released under the terms of the MIT license. See [LICENSE](LICENSE) for more\ninformation or see https://opensource.org/licenses/MIT.\n   \n   \n---\n\n![](https://github.com/dwg255/fish/blob/master/client/qg_%E5%89%AF%E6%9C%AC.jpg?raw=true)\n![](https://raw.githubusercontent.com/dwg255/fish/master/client/1.jpg)\n![](https://raw.githubusercontent.com/dwg255/fish/master/client/2.jpg)\n![](https://raw.githubusercontent.com/dwg255/fish/master/client/3.jpg)\n![](https://raw.githubusercontent.com/dwg255/fish/master/client/4.jpg)\n![](https://raw.githubusercontent.com/dwg255/fish/master/client/5.jpg)\n![](https://raw.githubusercontent.com/dwg255/fish/master/client/6.jpg)\n![](https://github.com/dwg255/fish/blob/master/client/qg_%E5%89%AF%E6%9C%AC.jpg?raw=true)\n"
  },
  {
    "path": "account/common/config.go",
    "content": "package common\n\nimport (\n\t\"github.com/go-redis/redis\"\n\t\"github.com/jmoiron/sqlx\"\n)\n\nvar (\n\tAccountConf = &AccountServiceConf{\n\t\tRedisConf: &RedisConf{},\n\t\tMysqlConf: &MysqlConf{},\n\t}\n)\n\ntype AccountServiceConf struct {\n\tAccountAesKey string\n\tThriftPort    int\n\tLogPath       string\n\tLogLevel      string\n\tRedisConf     *RedisConf\n\tMysqlConf     *MysqlConf\n}\n\ntype RedisConf struct {\n\tRedisAddrs     []string\n\tRedisKeyPrefix string\n\t//RedisPool      *redis.ClusterClient\n\tRedisPool *redis.Client\n}\n\ntype MysqlConf struct {\n\tMysqlAddr     string\n\tMysqlUser     string\n\tMysqlPassword string\n\tMysqlDatabase string\n\tPool          *sqlx.DB\n}\n"
  },
  {
    "path": "account/common/model.go",
    "content": "package common\n\ntype FishUser struct {\n\tUserId      int    `json:\"userid\" dB:\"UsERID\"`\n\tAccount     string `json:\"account\" DB:\"account\"`\n\tName        string `json:\"name\" DB:\"name\"`\n\tSex         int    `json:\"sex\" dB:\"sex\"`\n\tHeadImg     string `json:\"headimg\" DB:\"headimg\"`\n\tLv          int    `json:\"lv\" DB:\"LV\"`\n\tExp         int    `json:\"exP\" Db:\"exP\"`\n\tCoins       int    `json:\"coins\" db:\"coins\"`\n\tVip         int    `json:\"vip\" db:\"vip\"`\n\tMoney       int    `json:\"money\" DB:\"money\"`\n\tGems        int    `json:\"gems\" db:\"gems\"`\n\tRoomId      string `json:\"roomid\" DB:\"roomid\"`\n\tHistory     string `json:\"history\" dB:\"history\"`\n\tPower       int    `json:\"power\" DB:\"power\"`\n\tReNameCount int    `json:\"renamecount\" db:\"renamecount\"`\n\tReHeadCount int    `json:\"reheadcount\" db:\"reheadcount\"`\n\tPropId      int    `json:\"propid\" db:\"propid\"`\n}\n\ntype InvestUserStake struct {\n\tId           int    `json:\"id\" db:\"id\"`\n\tGameTimesId  string `json:\"game_times_id\" db:\"game_times_id\"`\n\tPeriods      int    `json:\"record_id\" db:\"periods\"`\n\tRoomId       int    `json:\"room_id\" db:\"room_id\"`\n\tRoomType     int    `json:\"room_type\" db:\"room_type\"`\n\tUserId       int    `json:\"user_id\" db:\"user_id\"`\n\tNickname     string `json:\"nickname\" db:\"nickname\"`\n\tUserAllStake int    `json:\"stake_gold\" db:\"user_all_stake\"`\n\tWinGold      int    `json:\"get_gold\" db:\"get_gold\"`\n\tStakeDetail  string `json:\"stake_detail\" db:\"stake_detail\"`\n\tGameResult   int    `json:\"game_result\" db:\"game_result\"`\n\tPool         int    `json:\"game_pool\" db:\"game_pool\"`\n\tStakeTime    string `json:\"stake_time\" db:\"last_stake_time\"`\n}\n"
  },
  {
    "path": "account/main/config.go",
    "content": "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\"\n)\n\nfunc initConf() (err error) {\n\tconf, err := config.NewConfig(\"ini\", \"./common/conf/account.conf\")\n\tif err != nil {\n\t\tfmt.Println(\"new config failed,err:\", err)\n\t\treturn\n\t}\n\n\tcommon.AccountConf.ThriftPort, err = conf.Int(\"account_port\")\n\tif err != nil {\n\t\treturn\n\t}\n\tcommon.AccountConf.AccountAesKey = conf.String(\"account_aes_key\")\n\tif common.AccountConf.AccountAesKey == \"\" || len(common.AccountConf.AccountAesKey) < 16 {\n\t\treturn fmt.Errorf(\"conf err: invalid account_aes_key :%v\", common.AccountConf.AccountAesKey)\n\t}\n\tlogs.Debug(\"account_aes_key :%v\",common.AccountConf.AccountAesKey)\n\n\tcommon.AccountConf.LogPath = conf.String(\"log_path\")\n\tif common.AccountConf.LogPath == \"\" {\n\t\treturn fmt.Errorf(\"conf err: log_path is null\")\n\t}\n\n\tcommon.AccountConf.LogLevel = conf.String(\"log_level\")\n\tif common.AccountConf.LogLevel == \"\" {\n\t\treturn fmt.Errorf(\"conf err: log_level is null\")\n\t}\n\n\t//redis配置\n\tcommon.AccountConf.RedisConf.RedisAddrs = conf.Strings(\"redis_addrs\")\n\tif len(common.AccountConf.RedisConf.RedisAddrs) == 0 {\n\t\treturn fmt.Errorf(\"conf err: redis addr is null\")\n\t}\n\tcommon.AccountConf.RedisConf.RedisKeyPrefix = conf.String(\"redis_key_prefix\")\n\tif len(common.AccountConf.RedisConf.RedisKeyPrefix) == 0 {\n\t\treturn fmt.Errorf(\"conf err: redis_key_prefix is null\")\n\t}\n\n\t//mysql配置\n\tcommon.AccountConf.MysqlConf.MysqlAddr = conf.String(\"mysql_addr\")\n\tif len(common.AccountConf.MysqlConf.MysqlAddr) == 0 {\n\t\treturn fmt.Errorf(\"conf err: mysql_addr is null\")\n\t}\n\tcommon.AccountConf.MysqlConf.MysqlUser = conf.String(\"mysql_user\")\n\tif len(common.AccountConf.MysqlConf.MysqlUser) == 0 {\n\t\treturn fmt.Errorf(\"conf err: mysql_user is null\")\n\t}\n\tcommon.AccountConf.MysqlConf.MysqlPassword = conf.String(\"mysql_password\")\n\tif len(common.AccountConf.MysqlConf.MysqlPassword) == 0 {\n\t\treturn fmt.Errorf(\"conf err: mysql_password is null\")\n\t}\n\tcommon.AccountConf.MysqlConf.MysqlDatabase = conf.String(\"mysql_db\")\n\tif len(common.AccountConf.MysqlConf.MysqlDatabase) == 0 {\n\t\treturn fmt.Errorf(\"conf err: mysql_db is null\")\n\t}\n\treturn\n}\n"
  },
  {
    "path": "account/main/init.go",
    "content": "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-redis/redis\"\n\t_ \"github.com/go-sql-driver/mysql\"\n\t\"github.com/jmoiron/sqlx\"\n)\n\nfunc conversionLogLevel(logLevel string) int {\n\tswitch logLevel {\n\tcase \"debug\":\n\t\treturn logs.LevelDebug\n\tcase \"warn\":\n\t\treturn logs.LevelWarn\n\tcase \"info\":\n\t\treturn logs.LevelInfo\n\tcase \"trace\":\n\t\treturn logs.LevelTrace\n\t}\n\treturn logs.LevelDebug\n}\n\nfunc initLogger() (err error) {\n\tconfig := make(map[string]interface{})\n\tconfig[\"filename\"] = common.AccountConf.LogPath\n\tconfig[\"level\"] = conversionLogLevel(common.AccountConf.LogLevel)\n\n\tconfigStr, err := json.Marshal(config)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = logs.SetLogger(logs.AdapterFile, string(configStr))\n\treturn\n}\n\nfunc initMysql() (err error) {\n\tconf := common.AccountConf.MysqlConf\n\tdsn := fmt.Sprintf(\"%s:%s@tcp(%s)/%s\", conf.MysqlUser, conf.MysqlPassword, conf.MysqlAddr, conf.MysqlDatabase)\n\tlogs.Debug(dsn)\n\tdatabase, err := sqlx.Open(\"mysql\", dsn)\n\tif err != nil {\n\t\treturn\n\t}\n\tcommon.AccountConf.MysqlConf.Pool = database\n\treturn\n}\n\nfunc initRedis() (err error) {\n\t//client := redis.NewClusterClient(&redis.ClusterOptions{\n\t//\tAddrs: common.AccountConf.RedisConf.RedisAddrs,\n\t//})\n\t//_, err = client.Ping().Result()\n\t//if err != nil {\n\t//\treturn\n\t//}\n\t//common.AccountConf.RedisConf.RedisPool = client\n\tclient := redis.NewClient(&redis.Options{\n\t\tAddr:     \"localhost:6379\",\n\t\tPassword: \"\",\n\t\tDB:       0,\n\t})\n\tcommon.AccountConf.RedisConf.RedisPool = client\n\treturn\n}\n\nfunc initSec() (err error) {\n\terr = initLogger()\n\tif err != nil {\n\t\treturn\n\t}\n\n\terr = initRedis()\n\tif err != nil {\n\t\treturn\n\t}\n\n\t/*err = initMysql()\n\tif err != nil {\n\t\treturn\n\t}*/\n\treturn\n}\n"
  },
  {
    "path": "account/main/main.go",
    "content": "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\"github.com/apache/thrift/lib/go/thrift\"\n\t\"github.com/astaxie/beego/logs\"\n)\n\nfunc main() {\n\terr := initConf()\n\tif err != nil {\n\t\tlogs.Error(\"init conf err:%v\",err)\n\t\treturn\n\t}\n\tlogs.Debug(\"init conf success\")\n\tservice.InitAesTool()\n\terr = initSec()\n\tif err != nil {\n\t\tlogs.Error(\"initSec err:%v\",err)\n\t\treturn\n\t}\n\tlogs.Debug(\"init sec success\")\n\n\tport := fmt.Sprintf(\":%d\",common.AccountConf.ThriftPort)\n\ttransport, err := thrift.NewTServerSocket(port)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\thandler := &service.UserServer{}\n\tprocessor := rpc.NewUserServiceProcessor(handler)\n\n\ttransportFactory := thrift.NewTBufferedTransportFactory(8192)\n\tprotocolFactory := thrift.NewTCompactProtocolFactory()\n\n\tserver := thrift.NewTSimpleServer4(\n\t\tprocessor,\n\t\ttransport,\n\t\ttransportFactory,\n\t\tprotocolFactory,\n\t)\n\tlogs.Debug(\"account server %s\",port)\n\tif err := server.Serve(); err != nil {\n\t\tpanic(err)\n\t}\n}"
  },
  {
    "path": "account/service/handle.go",
    "content": "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\"fmt\"\n\t\"github.com/astaxie/beego/logs\"\n\t\"math/rand\"\n\t\"strconv\"\n\t\"strings\"\n\t\"time\"\n)\n\nvar (\n\tredisConf = common.AccountConf.RedisConf\n\taesTool   *tools.AesEncrypt\n)\n\ntype UserServer struct {\n}\n\nfunc InitAesTool() {\n\tvar err error\n\tif aesTool, err = tools.NewAesTool(common.AccountConf.AccountAesKey); err != nil {\n\t\tpanic(\"new aes tool err: \" + err.Error())\n\t}\n}\n\nfunc (p *UserServer) GetUserInfoByOpenId(ctx context.Context, openId string) (r *rpc.Result_, err error) {\n\tlogs.Debug(\"getUserInfoByOpenId openId: %v\", openId)\n\tvar existsUserId string\n\tvar userId int\n\tif existsUserId, err = redisConf.RedisPool.HGet(redisConf.RedisKeyPrefix+\"open_id2user_id\", openId).Result(); err == nil {\n\t\tif userId, err = strconv.Atoi(existsUserId); err == nil {\n\t\t\treturn p.GetUserInfoById(ctx, int32(userId))\n\t\t}\n\t} else {\n\t\tr = &rpc.Result_{\n\t\t\tCode: rpc.ErrorCode_UserNotExists,\n\t\t}\n\t\terr = fmt.Errorf(\"user openId=%v not exists\", openId)\n\t}\n\treturn\n}\n\nfunc (p *UserServer) CreateQQUser(ctx context.Context, userInfo *rpc.UserInfo) (r *rpc.Result_, err error) {\n\tlogs.Debug(\"CreateQQUser nickName: %v\", userInfo.NickName)\n\tvar nextUserId int64\n\tvar existsUserId string\n\tvar userId int\n\tif existsUserId, err = redisConf.RedisPool.HGet(redisConf.RedisKeyPrefix+\"open_id2user_id\", userInfo.QqInfo.OpenId).Result(); err == nil {\n\t\tif userId, err = strconv.Atoi(existsUserId); err == nil {\n\t\t\treturn p.GetUserInfoById(ctx, int32(userId))\n\t\t}\n\t} else {\n\t\tnextUserId, err = redisConf.RedisPool.Incr(redisConf.RedisKeyPrefix + \"userId\").Result()\n\t\ttoken := \"\"\n\t\tregisterTime := time.Now()\n\t\tif token, err = aesTool.Encrypt(strconv.Itoa(int(nextUserId)) + \"-\" + strconv.Itoa(int(registerTime.Unix()))); err == nil {\n\t\t\trand.Seed(time.Now().UnixNano())\n\t\t\tuserInfoRedisMap := map[string]interface{}{\n\t\t\t\t\"UserId\":        nextUserId,\n\t\t\t\t\"UserName\":      userInfo.UserName,\n\t\t\t\t\"NickName\":      userInfo.NickName,\n\t\t\t\t\"Sex\":           userInfo.Sex,\n\t\t\t\t\"HeadImg\":       userInfo.HeadImg,\n\t\t\t\t\"Lv\":            userInfo.Lv,\n\t\t\t\t\"Exp\":           userInfo.Exp,\n\t\t\t\t\"Vip\":           userInfo.Vip, //VIP级别随机给吧,\n\t\t\t\t\"Gems\":          userInfo.Gems,\n\t\t\t\t\"RoomId\":        0,\n\t\t\t\t\"Power\":         userInfo.Power,\n\t\t\t\t\"ReNameCount\":   userInfo.ReNameCount,\n\t\t\t\t\"ReHeadCount\":   userInfo.ReHeadCount,\n\t\t\t\t\"RegisterDate\":  registerTime.Format(\"2006-01-02 15:04:05\"),\n\t\t\t\t\"Ice\":           10,\n\t\t\t\t\"Token\":         token,\n\t\t\t\t\"openId\":        userInfo.QqInfo.OpenId,\n\t\t\t\t\"FigureUrl\":     userInfo.QqInfo.FigureUrl,\n\t\t\t\t\"Province\":      userInfo.QqInfo.Province,\n\t\t\t\t\"City\":          userInfo.QqInfo.City,\n\t\t\t\t\"TotalSpending\": userInfo.QqInfo.TotalSpending,\n\t\t\t}\n\t\t\tif _, err = redisConf.RedisPool.HMSet(redisConf.RedisKeyPrefix+strconv.Itoa(int(nextUserId)), userInfoRedisMap).Result(); err == nil {\n\t\t\t\tif _, err = redisConf.RedisPool.HSet(redisConf.RedisKeyPrefix+\"open_id2user_id\", userInfo.QqInfo.OpenId, nextUserId).Result(); err == nil {\n\t\t\t\t\tuserInfo.UserId = nextUserId\n\t\t\t\t\tuserInfo.Token = token\n\t\t\t\t\tr = &rpc.Result_{\n\t\t\t\t\t\tCode:    rpc.ErrorCode_Success,\n\t\t\t\t\t\tUserObj: userInfo,\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn\n}\n\nfunc (p *UserServer) CreateNewUser(ctx context.Context, nickName string, avatarAuto string, gold int64) (r *rpc.Result_, err error) {\n\tlogs.Debug(\"CreateNewUser nickName: %v\", nickName)\n\tvar nextUserId int64\n\tnextUserId, err = redisConf.RedisPool.Incr(redisConf.RedisKeyPrefix + \"userId\").Result()\n\ttoken := \"\"\n\tregisterTime := time.Now()\n\tif token, err = aesTool.Encrypt(strconv.Itoa(int(nextUserId)) + \"-\" + strconv.Itoa(int(registerTime.Unix()))); err == nil {\n\t\trand.Seed(time.Now().UnixNano())\n\t\tvip := int8(rand.Intn(7))\n\t\tuserInfoRedisMap := map[string]interface{}{\n\t\t\t\"UserId\":       nextUserId,\n\t\t\t\"UserName\":     nickName,\n\t\t\t\"NickName\":     nickName,\n\t\t\t\"Sex\":          0,\n\t\t\t\"HeadImg\":      1,\n\t\t\t\"Lv\":           1,\n\t\t\t\"Exp\":          0,\n\t\t\t\"Vip\":          vip, //VIP级别随机给吧,\n\t\t\t\"Gems\":         gold,\n\t\t\t\"RoomId\":       0,\n\t\t\t\"Power\":        0,\n\t\t\t\"ReNameCount\":  0,\n\t\t\t\"ReHeadCount\":  0,\n\t\t\t\"RegisterDate\": registerTime.Format(\"2006-01-02 15:04:05\"),\n\t\t\t\"Ice\":          10,\n\t\t\t\"Token\":        token,\n\t\t}\n\t\tif _, err = redisConf.RedisPool.HMSet(redisConf.RedisKeyPrefix+strconv.Itoa(int(nextUserId)), userInfoRedisMap).Result(); err == nil {\n\n\t\t\tr = &rpc.Result_{\n\t\t\t\tCode: rpc.ErrorCode_Success,\n\t\t\t\tUserObj: &rpc.UserInfo{\n\t\t\t\t\tUserId:       nextUserId,\n\t\t\t\t\tUserName:     nickName,\n\t\t\t\t\tNickName:     nickName,\n\t\t\t\t\tSex:          0,\n\t\t\t\t\tHeadImg:      \"1\",\n\t\t\t\t\tLv:           1,\n\t\t\t\t\tExp:          0,\n\t\t\t\t\tVip:          vip, //VIP级别随机给吧\n\t\t\t\t\tGems:         gold,\n\t\t\t\t\tRoomId:       0,\n\t\t\t\t\tPower:        0,\n\t\t\t\t\tReNameCount:  0,\n\t\t\t\t\tReHeadCount:  0,\n\t\t\t\t\tRegisterDate: registerTime.Format(\"2006-01-02 15:04:05\"),\n\t\t\t\t\tIce:          10,\n\t\t\t\t\tToken:        token,\n\t\t\t\t},\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t}\n\treturn\n}\n\nfunc (p *UserServer) GetUserInfoById(ctx context.Context, userId int32) (r *rpc.Result_, err error) {\n\tlogs.Debug(\"GetUserInfoById: %v\", userId)\n\tresult, err := redisConf.RedisPool.HGetAll(redisConf.RedisKeyPrefix + strconv.Itoa(int(userId))).Result()\n\tif err != nil {\n\t\treturn r, err\n\t}\n\tvar Lv, Vip, Gems, RoomId, Power, Ice int\n\tif Lv, err = strconv.Atoi(result[\"Lv\"]); err != nil {\n\t\treturn r, err\n\t}\n\tif Vip, err = strconv.Atoi(result[\"Vip\"]); err != nil {\n\t\treturn r, err\n\t}\n\tif RoomId, err = strconv.Atoi(result[\"RoomId\"]); err != nil {\n\t\treturn r, err\n\t}\n\tif Gems, err = strconv.Atoi(result[\"Gems\"]); err != nil {\n\t\treturn r, err\n\t}\n\tif Power, err = strconv.Atoi(result[\"Power\"]); err != nil {\n\t\treturn r, err\n\t}\n\tif Ice, err = strconv.Atoi(result[\"Ice\"]); err != nil {\n\t\treturn r, err\n\t}\n\n\tr = &rpc.Result_{\n\t\tCode: rpc.ErrorCode_Success,\n\t\tUserObj: &rpc.UserInfo{\n\t\t\tUserId:       int64(userId),\n\t\t\tUserName:     result[\"UserName\"],\n\t\t\tNickName:     result[\"NickName\"],\n\t\t\tSex:          0,\n\t\t\tHeadImg:      result[\"HeadImg\"],\n\t\t\tLv:           int32(Lv),\n\t\t\tExp:          0,\n\t\t\tVip:          int8(Vip),\n\t\t\tGems:         int64(Gems),\n\t\t\tRoomId:       int64(RoomId),\n\t\t\tPower:        int64(Power),\n\t\t\tReNameCount:  0,\n\t\t\tReHeadCount:  0,\n\t\t\tRegisterDate: result[\"RegisterDate\"],\n\t\t\tIce:          int64(Ice),\n\t\t\tToken:        result[\"Token\"],\n\t\t},\n\t}\n\treturn\n}\n\nfunc (p *UserServer) GetUserInfoByToken(ctx context.Context, token string) (r *rpc.Result_, err error) {\n\tlogs.Debug(\"GetUserInfoByToken: %v\", token)\n\tuserIdStr := \"\"\n\tif userIdStr, err = aesTool.Decrypt(token); err == nil {\n\t\tuserId := 0\n\t\ttokenSplit := strings.Split(userIdStr, \"-\")\n\t\tif len(tokenSplit) > 1 {\n\t\t\tif userId, err = strconv.Atoi(tokenSplit[0]); err == nil {\n\t\t\t\treturn p.GetUserInfoById(context.Background(), int32(userId))\n\t\t\t}\n\t\t}\n\t}\n\treturn\n}\n\nfunc (p *UserServer) ModifyUserInfoById(ctx context.Context, behavior string, userId int32, propType rpc.ModifyPropType, incr int64) (r *rpc.Result_, err error) {\n\tlogs.Debug(\"ModifyUserInfoById: %v\", behavior)\n\tvar exists int64\n\tuserInfoKey := redisConf.RedisKeyPrefix + strconv.Itoa(int(userId))\n\tif exists, err = common.AccountConf.RedisConf.RedisPool.Exists(userInfoKey).Result(); err == nil {\n\t\tif exists == 1 {\n\t\t\tswitch propType {\n\t\t\tcase rpc.ModifyPropType_gems:\n\t\t\t\tcommon.AccountConf.RedisConf.RedisPool.HIncrBy(userInfoKey, \"Gems\", incr)\n\t\t\tcase rpc.ModifyPropType_ice:\n\t\t\t\tcommon.AccountConf.RedisConf.RedisPool.HIncrBy(userInfoKey, \"Ice\", incr)\n\t\t\tcase rpc.ModifyPropType_power:\n\t\t\t\tcommon.AccountConf.RedisConf.RedisPool.HIncrBy(userInfoKey, \"Power\", incr)\n\t\t\tcase rpc.ModifyPropType_roomId:\n\t\t\t\tcommon.AccountConf.RedisConf.RedisPool.HIncrBy(userInfoKey, \"RoomId\", incr)\n\t\t\t}\n\t\t\treturn p.GetUserInfoById(context.Background(), userId)\n\t\t}\n\t\terr = fmt.Errorf(\"user [%d] doesnot exists\", userId)\n\t}\n\treturn\n}\n\nfunc (p *UserServer) GetMessage(ctx context.Context, messageType string) (r string, err error) {\n\tlogs.Debug(\"GetMessage messageType: %v\", messageType)\n\tvar redisErr error\n\tif messageType == \"notice\" {\n\t\tr, redisErr = redisConf.RedisPool.Get(redisConf.RedisKeyPrefix + \"notice\").Result()\n\t\tif r == \"\" || redisErr != nil {\n\t\t\tr = \"个人开发，仅可用于学习研究。\"\n\t\t}\n\t} else {\n\t\tr, redisErr = redisConf.RedisPool.Get(redisConf.RedisKeyPrefix + \"fkgm\").Result()\n\t\tif r == \"\" || redisErr != nil {\n\t\t\tr = \"爸爸爱你\"\n\t\t}\n\t}\n\treturn\n}\nfunc (p *UserServer) RenameUserById(ctx context.Context, userId int32, NewName string) (r *rpc.Result_, err error) {\n\treturn\n}\n"
  },
  {
    "path": "common/api/thrift/account.thrift",
    "content": "namespace go rpc\n\nenum ErrorCode{\n    Success=0\n    ServerError=5000,\n    VerifyError=5001,\n    UserNotExists=5002,\n}\n\nenum ModifyPropType{\n    gems = 0\n    roomId = 1\n    power = 2\n    ice = 3\n}\n\nstruct qqInfo{\n    1:string openId\n    2:string figureUrl\n    3:string province\n    4:string city\n    5:i64 totalSpending\n}\nstruct UserInfo{\n     1: i64 userId\n     2: string userName\n     3: string nickName\n     4: i8 sex\n     5: string headImg\n     6: i32 lv\n     7: i64 exp\n     8: i8 vip\n     9: i64 gems\n     10: i64 roomId\n     11: i64 power\n     12: i8 reNameCount\n     13: i8 reHeadCount\n     14: string registerDate\n     15: i64 ice\n     16: string token\n     17: qqInfo qqInfo\n}\n\nstruct Result{\n    1:  ErrorCode code\n    2: UserInfo user_obj\n}\n\nservice UserService {\n\n    //创建临时用户\n    Result createNewUser(1: string nickName 2:string avatarAuto 3: i64 gold )//初始金币\n\n    //创建QQ用户\n    Result createQQUser(1: UserInfo UserInfo)\n\n    //使用openId获取用户\n    Result getUserInfoByOpenId(1:string openId)\n\n   //获取用户信息 BY userId\n    Result getUserInfoById(1:i32 userId)\n\n    //获取用户信息 BY token\n    Result getUserInfoByToken(1:string token)\n\n    //修改用户金币\n    Result modifyUserInfoById(1:string behavior, 2:i32 userId, 3: ModifyPropType propType, 4: i64 incr)\n    Result RenameUserById(1:i32 userId,2:string NewName)\n    string getMessage(1 :string messageType)\n}\n"
  },
  {
    "path": "common/api/thrift/gen-go/rpc/GoUnusedProtection__.go",
    "content": "// Autogenerated by Thrift Compiler (0.12.0)\n// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n\npackage rpc\n\nvar GoUnusedProtection__ int;\n\n"
  },
  {
    "path": "common/api/thrift/gen-go/rpc/account-consts.go",
    "content": "// Autogenerated by Thrift Compiler (0.12.0)\n// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n\npackage rpc\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"reflect\"\n\t\"fmt\"\n\t\"github.com/apache/thrift/lib/go/thrift\"\n)\n\n// (needed to ensure safety because of naive import list construction.)\nvar _ = thrift.ZERO\nvar _ = fmt.Printf\nvar _ = context.Background\nvar _ = reflect.DeepEqual\nvar _ = bytes.Equal\n\n\nfunc init() {\n}\n\n"
  },
  {
    "path": "common/api/thrift/gen-go/rpc/account.go",
    "content": "// Autogenerated by Thrift Compiler (0.12.0)\n// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n\npackage rpc\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"reflect\"\n\t\"database/sql/driver\"\n\t\"errors\"\n\t\"fmt\"\n\t\"github.com/apache/thrift/lib/go/thrift\"\n)\n\n// (needed to ensure safety because of naive import list construction.)\nvar _ = thrift.ZERO\nvar _ = fmt.Printf\nvar _ = context.Background\nvar _ = reflect.DeepEqual\nvar _ = bytes.Equal\n\ntype ErrorCode int64\nconst (\n  ErrorCode_Success ErrorCode = 0\n  ErrorCode_ServerError ErrorCode = 5000\n  ErrorCode_VerifyError ErrorCode = 5001\n  ErrorCode_UserNotExists ErrorCode = 5002\n)\n\nfunc (p ErrorCode) String() string {\n  switch p {\n  case ErrorCode_Success: return \"Success\"\n  case ErrorCode_ServerError: return \"ServerError\"\n  case ErrorCode_VerifyError: return \"VerifyError\"\n  case ErrorCode_UserNotExists: return \"UserNotExists\"\n  }\n  return \"<UNSET>\"\n}\n\nfunc ErrorCodeFromString(s string) (ErrorCode, error) {\n  switch s {\n  case \"Success\": return ErrorCode_Success, nil \n  case \"ServerError\": return ErrorCode_ServerError, nil \n  case \"VerifyError\": return ErrorCode_VerifyError, nil \n  case \"UserNotExists\": return ErrorCode_UserNotExists, nil \n  }\n  return ErrorCode(0), fmt.Errorf(\"not a valid ErrorCode string\")\n}\n\n\nfunc ErrorCodePtr(v ErrorCode) *ErrorCode { return &v }\n\nfunc (p ErrorCode) MarshalText() ([]byte, error) {\nreturn []byte(p.String()), nil\n}\n\nfunc (p *ErrorCode) UnmarshalText(text []byte) error {\nq, err := ErrorCodeFromString(string(text))\nif (err != nil) {\nreturn err\n}\n*p = q\nreturn nil\n}\n\nfunc (p *ErrorCode) Scan(value interface{}) error {\nv, ok := value.(int64)\nif !ok {\nreturn errors.New(\"Scan value is not int64\")\n}\n*p = ErrorCode(v)\nreturn nil\n}\n\nfunc (p * ErrorCode) Value() (driver.Value, error) {\n  if p == nil {\n    return nil, nil\n  }\nreturn int64(*p), nil\n}\ntype ModifyPropType int64\nconst (\n  ModifyPropType_gems ModifyPropType = 0\n  ModifyPropType_roomId ModifyPropType = 1\n  ModifyPropType_power ModifyPropType = 2\n  ModifyPropType_ice ModifyPropType = 3\n)\n\nfunc (p ModifyPropType) String() string {\n  switch p {\n  case ModifyPropType_gems: return \"gems\"\n  case ModifyPropType_roomId: return \"roomId\"\n  case ModifyPropType_power: return \"power\"\n  case ModifyPropType_ice: return \"ice\"\n  }\n  return \"<UNSET>\"\n}\n\nfunc ModifyPropTypeFromString(s string) (ModifyPropType, error) {\n  switch s {\n  case \"gems\": return ModifyPropType_gems, nil \n  case \"roomId\": return ModifyPropType_roomId, nil \n  case \"power\": return ModifyPropType_power, nil \n  case \"ice\": return ModifyPropType_ice, nil \n  }\n  return ModifyPropType(0), fmt.Errorf(\"not a valid ModifyPropType string\")\n}\n\n\nfunc ModifyPropTypePtr(v ModifyPropType) *ModifyPropType { return &v }\n\nfunc (p ModifyPropType) MarshalText() ([]byte, error) {\nreturn []byte(p.String()), nil\n}\n\nfunc (p *ModifyPropType) UnmarshalText(text []byte) error {\nq, err := ModifyPropTypeFromString(string(text))\nif (err != nil) {\nreturn err\n}\n*p = q\nreturn nil\n}\n\nfunc (p *ModifyPropType) Scan(value interface{}) error {\nv, ok := value.(int64)\nif !ok {\nreturn errors.New(\"Scan value is not int64\")\n}\n*p = ModifyPropType(v)\nreturn nil\n}\n\nfunc (p * ModifyPropType) Value() (driver.Value, error) {\n  if p == nil {\n    return nil, nil\n  }\nreturn int64(*p), nil\n}\n// Attributes:\n//  - OpenId\n//  - FigureUrl\n//  - Province\n//  - City\n//  - TotalSpending\ntype QqInfo struct {\n  OpenId string `thrift:\"openId,1\" db:\"openId\" json:\"openId\"`\n  FigureUrl string `thrift:\"figureUrl,2\" db:\"figureUrl\" json:\"figureUrl\"`\n  Province string `thrift:\"province,3\" db:\"province\" json:\"province\"`\n  City string `thrift:\"city,4\" db:\"city\" json:\"city\"`\n  TotalSpending int64 `thrift:\"totalSpending,5\" db:\"totalSpending\" json:\"totalSpending\"`\n}\n\nfunc NewQqInfo() *QqInfo {\n  return &QqInfo{}\n}\n\n\nfunc (p *QqInfo) GetOpenId() string {\n  return p.OpenId\n}\n\nfunc (p *QqInfo) GetFigureUrl() string {\n  return p.FigureUrl\n}\n\nfunc (p *QqInfo) GetProvince() string {\n  return p.Province\n}\n\nfunc (p *QqInfo) GetCity() string {\n  return p.City\n}\n\nfunc (p *QqInfo) GetTotalSpending() int64 {\n  return p.TotalSpending\n}\nfunc (p *QqInfo) Read(iprot thrift.TProtocol) error {\n  if _, err := iprot.ReadStructBegin(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T read error: \", p), err)\n  }\n\n\n  for {\n    _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()\n    if err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T field %d read error: \", p, fieldId), err)\n    }\n    if fieldTypeId == thrift.STOP { break; }\n    switch fieldId {\n    case 1:\n      if fieldTypeId == thrift.STRING {\n        if err := p.ReadField1(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    case 2:\n      if fieldTypeId == thrift.STRING {\n        if err := p.ReadField2(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    case 3:\n      if fieldTypeId == thrift.STRING {\n        if err := p.ReadField3(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    case 4:\n      if fieldTypeId == thrift.STRING {\n        if err := p.ReadField4(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    case 5:\n      if fieldTypeId == thrift.I64 {\n        if err := p.ReadField5(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    default:\n      if err := iprot.Skip(fieldTypeId); err != nil {\n        return err\n      }\n    }\n    if err := iprot.ReadFieldEnd(); err != nil {\n      return err\n    }\n  }\n  if err := iprot.ReadStructEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T read struct end error: \", p), err)\n  }\n  return nil\n}\n\nfunc (p *QqInfo)  ReadField1(iprot thrift.TProtocol) error {\n  if v, err := iprot.ReadString(); err != nil {\n  return thrift.PrependError(\"error reading field 1: \", err)\n} else {\n  p.OpenId = v\n}\n  return nil\n}\n\nfunc (p *QqInfo)  ReadField2(iprot thrift.TProtocol) error {\n  if v, err := iprot.ReadString(); err != nil {\n  return thrift.PrependError(\"error reading field 2: \", err)\n} else {\n  p.FigureUrl = v\n}\n  return nil\n}\n\nfunc (p *QqInfo)  ReadField3(iprot thrift.TProtocol) error {\n  if v, err := iprot.ReadString(); err != nil {\n  return thrift.PrependError(\"error reading field 3: \", err)\n} else {\n  p.Province = v\n}\n  return nil\n}\n\nfunc (p *QqInfo)  ReadField4(iprot thrift.TProtocol) error {\n  if v, err := iprot.ReadString(); err != nil {\n  return thrift.PrependError(\"error reading field 4: \", err)\n} else {\n  p.City = v\n}\n  return nil\n}\n\nfunc (p *QqInfo)  ReadField5(iprot thrift.TProtocol) error {\n  if v, err := iprot.ReadI64(); err != nil {\n  return thrift.PrependError(\"error reading field 5: \", err)\n} else {\n  p.TotalSpending = v\n}\n  return nil\n}\n\nfunc (p *QqInfo) Write(oprot thrift.TProtocol) error {\n  if err := oprot.WriteStructBegin(\"qqInfo\"); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write struct begin error: \", p), err) }\n  if p != nil {\n    if err := p.writeField1(oprot); err != nil { return err }\n    if err := p.writeField2(oprot); err != nil { return err }\n    if err := p.writeField3(oprot); err != nil { return err }\n    if err := p.writeField4(oprot); err != nil { return err }\n    if err := p.writeField5(oprot); err != nil { return err }\n  }\n  if err := oprot.WriteFieldStop(); err != nil {\n    return thrift.PrependError(\"write field stop error: \", err) }\n  if err := oprot.WriteStructEnd(); err != nil {\n    return thrift.PrependError(\"write struct stop error: \", err) }\n  return nil\n}\n\nfunc (p *QqInfo) writeField1(oprot thrift.TProtocol) (err error) {\n  if err := oprot.WriteFieldBegin(\"openId\", thrift.STRING, 1); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 1:openId: \", p), err) }\n  if err := oprot.WriteString(string(p.OpenId)); err != nil {\n  return thrift.PrependError(fmt.Sprintf(\"%T.openId (1) field write error: \", p), err) }\n  if err := oprot.WriteFieldEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field end error 1:openId: \", p), err) }\n  return err\n}\n\nfunc (p *QqInfo) writeField2(oprot thrift.TProtocol) (err error) {\n  if err := oprot.WriteFieldBegin(\"figureUrl\", thrift.STRING, 2); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 2:figureUrl: \", p), err) }\n  if err := oprot.WriteString(string(p.FigureUrl)); err != nil {\n  return thrift.PrependError(fmt.Sprintf(\"%T.figureUrl (2) field write error: \", p), err) }\n  if err := oprot.WriteFieldEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field end error 2:figureUrl: \", p), err) }\n  return err\n}\n\nfunc (p *QqInfo) writeField3(oprot thrift.TProtocol) (err error) {\n  if err := oprot.WriteFieldBegin(\"province\", thrift.STRING, 3); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 3:province: \", p), err) }\n  if err := oprot.WriteString(string(p.Province)); err != nil {\n  return thrift.PrependError(fmt.Sprintf(\"%T.province (3) field write error: \", p), err) }\n  if err := oprot.WriteFieldEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field end error 3:province: \", p), err) }\n  return err\n}\n\nfunc (p *QqInfo) writeField4(oprot thrift.TProtocol) (err error) {\n  if err := oprot.WriteFieldBegin(\"city\", thrift.STRING, 4); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 4:city: \", p), err) }\n  if err := oprot.WriteString(string(p.City)); err != nil {\n  return thrift.PrependError(fmt.Sprintf(\"%T.city (4) field write error: \", p), err) }\n  if err := oprot.WriteFieldEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field end error 4:city: \", p), err) }\n  return err\n}\n\nfunc (p *QqInfo) writeField5(oprot thrift.TProtocol) (err error) {\n  if err := oprot.WriteFieldBegin(\"totalSpending\", thrift.I64, 5); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 5:totalSpending: \", p), err) }\n  if err := oprot.WriteI64(int64(p.TotalSpending)); err != nil {\n  return thrift.PrependError(fmt.Sprintf(\"%T.totalSpending (5) field write error: \", p), err) }\n  if err := oprot.WriteFieldEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field end error 5:totalSpending: \", p), err) }\n  return err\n}\n\nfunc (p *QqInfo) String() string {\n  if p == nil {\n    return \"<nil>\"\n  }\n  return fmt.Sprintf(\"QqInfo(%+v)\", *p)\n}\n\n// Attributes:\n//  - UserId\n//  - UserName\n//  - NickName\n//  - Sex\n//  - HeadImg\n//  - Lv\n//  - Exp\n//  - Vip\n//  - Gems\n//  - RoomId\n//  - Power\n//  - ReNameCount\n//  - ReHeadCount\n//  - RegisterDate\n//  - Ice\n//  - Token\n//  - QqInfo\ntype UserInfo struct {\n  UserId int64 `thrift:\"userId,1\" db:\"userId\" json:\"userId\"`\n  UserName string `thrift:\"userName,2\" db:\"userName\" json:\"userName\"`\n  NickName string `thrift:\"nickName,3\" db:\"nickName\" json:\"nickName\"`\n  Sex int8 `thrift:\"sex,4\" db:\"sex\" json:\"sex\"`\n  HeadImg string `thrift:\"headImg,5\" db:\"headImg\" json:\"headImg\"`\n  Lv int32 `thrift:\"lv,6\" db:\"lv\" json:\"lv\"`\n  Exp int64 `thrift:\"exp,7\" db:\"exp\" json:\"exp\"`\n  Vip int8 `thrift:\"vip,8\" db:\"vip\" json:\"vip\"`\n  Gems int64 `thrift:\"gems,9\" db:\"gems\" json:\"gems\"`\n  RoomId int64 `thrift:\"roomId,10\" db:\"roomId\" json:\"roomId\"`\n  Power int64 `thrift:\"power,11\" db:\"power\" json:\"power\"`\n  ReNameCount int8 `thrift:\"reNameCount,12\" db:\"reNameCount\" json:\"reNameCount\"`\n  ReHeadCount int8 `thrift:\"reHeadCount,13\" db:\"reHeadCount\" json:\"reHeadCount\"`\n  RegisterDate string `thrift:\"registerDate,14\" db:\"registerDate\" json:\"registerDate\"`\n  Ice int64 `thrift:\"ice,15\" db:\"ice\" json:\"ice\"`\n  Token string `thrift:\"token,16\" db:\"token\" json:\"token\"`\n  QqInfo *QqInfo `thrift:\"qqInfo,17\" db:\"qqInfo\" json:\"qqInfo\"`\n}\n\nfunc NewUserInfo() *UserInfo {\n  return &UserInfo{}\n}\n\n\nfunc (p *UserInfo) GetUserId() int64 {\n  return p.UserId\n}\n\nfunc (p *UserInfo) GetUserName() string {\n  return p.UserName\n}\n\nfunc (p *UserInfo) GetNickName() string {\n  return p.NickName\n}\n\nfunc (p *UserInfo) GetSex() int8 {\n  return p.Sex\n}\n\nfunc (p *UserInfo) GetHeadImg() string {\n  return p.HeadImg\n}\n\nfunc (p *UserInfo) GetLv() int32 {\n  return p.Lv\n}\n\nfunc (p *UserInfo) GetExp() int64 {\n  return p.Exp\n}\n\nfunc (p *UserInfo) GetVip() int8 {\n  return p.Vip\n}\n\nfunc (p *UserInfo) GetGems() int64 {\n  return p.Gems\n}\n\nfunc (p *UserInfo) GetRoomId() int64 {\n  return p.RoomId\n}\n\nfunc (p *UserInfo) GetPower() int64 {\n  return p.Power\n}\n\nfunc (p *UserInfo) GetReNameCount() int8 {\n  return p.ReNameCount\n}\n\nfunc (p *UserInfo) GetReHeadCount() int8 {\n  return p.ReHeadCount\n}\n\nfunc (p *UserInfo) GetRegisterDate() string {\n  return p.RegisterDate\n}\n\nfunc (p *UserInfo) GetIce() int64 {\n  return p.Ice\n}\n\nfunc (p *UserInfo) GetToken() string {\n  return p.Token\n}\nvar UserInfo_QqInfo_DEFAULT *QqInfo\nfunc (p *UserInfo) GetQqInfo() *QqInfo {\n  if !p.IsSetQqInfo() {\n    return UserInfo_QqInfo_DEFAULT\n  }\nreturn p.QqInfo\n}\nfunc (p *UserInfo) IsSetQqInfo() bool {\n  return p.QqInfo != nil\n}\n\nfunc (p *UserInfo) Read(iprot thrift.TProtocol) error {\n  if _, err := iprot.ReadStructBegin(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T read error: \", p), err)\n  }\n\n\n  for {\n    _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()\n    if err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T field %d read error: \", p, fieldId), err)\n    }\n    if fieldTypeId == thrift.STOP { break; }\n    switch fieldId {\n    case 1:\n      if fieldTypeId == thrift.I64 {\n        if err := p.ReadField1(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    case 2:\n      if fieldTypeId == thrift.STRING {\n        if err := p.ReadField2(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    case 3:\n      if fieldTypeId == thrift.STRING {\n        if err := p.ReadField3(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    case 4:\n      if fieldTypeId == thrift.BYTE {\n        if err := p.ReadField4(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    case 5:\n      if fieldTypeId == thrift.STRING {\n        if err := p.ReadField5(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    case 6:\n      if fieldTypeId == thrift.I32 {\n        if err := p.ReadField6(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    case 7:\n      if fieldTypeId == thrift.I64 {\n        if err := p.ReadField7(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    case 8:\n      if fieldTypeId == thrift.BYTE {\n        if err := p.ReadField8(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    case 9:\n      if fieldTypeId == thrift.I64 {\n        if err := p.ReadField9(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    case 10:\n      if fieldTypeId == thrift.I64 {\n        if err := p.ReadField10(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    case 11:\n      if fieldTypeId == thrift.I64 {\n        if err := p.ReadField11(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    case 12:\n      if fieldTypeId == thrift.BYTE {\n        if err := p.ReadField12(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    case 13:\n      if fieldTypeId == thrift.BYTE {\n        if err := p.ReadField13(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    case 14:\n      if fieldTypeId == thrift.STRING {\n        if err := p.ReadField14(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    case 15:\n      if fieldTypeId == thrift.I64 {\n        if err := p.ReadField15(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    case 16:\n      if fieldTypeId == thrift.STRING {\n        if err := p.ReadField16(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    case 17:\n      if fieldTypeId == thrift.STRUCT {\n        if err := p.ReadField17(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    default:\n      if err := iprot.Skip(fieldTypeId); err != nil {\n        return err\n      }\n    }\n    if err := iprot.ReadFieldEnd(); err != nil {\n      return err\n    }\n  }\n  if err := iprot.ReadStructEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T read struct end error: \", p), err)\n  }\n  return nil\n}\n\nfunc (p *UserInfo)  ReadField1(iprot thrift.TProtocol) error {\n  if v, err := iprot.ReadI64(); err != nil {\n  return thrift.PrependError(\"error reading field 1: \", err)\n} else {\n  p.UserId = v\n}\n  return nil\n}\n\nfunc (p *UserInfo)  ReadField2(iprot thrift.TProtocol) error {\n  if v, err := iprot.ReadString(); err != nil {\n  return thrift.PrependError(\"error reading field 2: \", err)\n} else {\n  p.UserName = v\n}\n  return nil\n}\n\nfunc (p *UserInfo)  ReadField3(iprot thrift.TProtocol) error {\n  if v, err := iprot.ReadString(); err != nil {\n  return thrift.PrependError(\"error reading field 3: \", err)\n} else {\n  p.NickName = v\n}\n  return nil\n}\n\nfunc (p *UserInfo)  ReadField4(iprot thrift.TProtocol) error {\n  if v, err := iprot.ReadByte(); err != nil {\n  return thrift.PrependError(\"error reading field 4: \", err)\n} else {\n  temp := int8(v)\n  p.Sex = temp\n}\n  return nil\n}\n\nfunc (p *UserInfo)  ReadField5(iprot thrift.TProtocol) error {\n  if v, err := iprot.ReadString(); err != nil {\n  return thrift.PrependError(\"error reading field 5: \", err)\n} else {\n  p.HeadImg = v\n}\n  return nil\n}\n\nfunc (p *UserInfo)  ReadField6(iprot thrift.TProtocol) error {\n  if v, err := iprot.ReadI32(); err != nil {\n  return thrift.PrependError(\"error reading field 6: \", err)\n} else {\n  p.Lv = v\n}\n  return nil\n}\n\nfunc (p *UserInfo)  ReadField7(iprot thrift.TProtocol) error {\n  if v, err := iprot.ReadI64(); err != nil {\n  return thrift.PrependError(\"error reading field 7: \", err)\n} else {\n  p.Exp = v\n}\n  return nil\n}\n\nfunc (p *UserInfo)  ReadField8(iprot thrift.TProtocol) error {\n  if v, err := iprot.ReadByte(); err != nil {\n  return thrift.PrependError(\"error reading field 8: \", err)\n} else {\n  temp := int8(v)\n  p.Vip = temp\n}\n  return nil\n}\n\nfunc (p *UserInfo)  ReadField9(iprot thrift.TProtocol) error {\n  if v, err := iprot.ReadI64(); err != nil {\n  return thrift.PrependError(\"error reading field 9: \", err)\n} else {\n  p.Gems = v\n}\n  return nil\n}\n\nfunc (p *UserInfo)  ReadField10(iprot thrift.TProtocol) error {\n  if v, err := iprot.ReadI64(); err != nil {\n  return thrift.PrependError(\"error reading field 10: \", err)\n} else {\n  p.RoomId = v\n}\n  return nil\n}\n\nfunc (p *UserInfo)  ReadField11(iprot thrift.TProtocol) error {\n  if v, err := iprot.ReadI64(); err != nil {\n  return thrift.PrependError(\"error reading field 11: \", err)\n} else {\n  p.Power = v\n}\n  return nil\n}\n\nfunc (p *UserInfo)  ReadField12(iprot thrift.TProtocol) error {\n  if v, err := iprot.ReadByte(); err != nil {\n  return thrift.PrependError(\"error reading field 12: \", err)\n} else {\n  temp := int8(v)\n  p.ReNameCount = temp\n}\n  return nil\n}\n\nfunc (p *UserInfo)  ReadField13(iprot thrift.TProtocol) error {\n  if v, err := iprot.ReadByte(); err != nil {\n  return thrift.PrependError(\"error reading field 13: \", err)\n} else {\n  temp := int8(v)\n  p.ReHeadCount = temp\n}\n  return nil\n}\n\nfunc (p *UserInfo)  ReadField14(iprot thrift.TProtocol) error {\n  if v, err := iprot.ReadString(); err != nil {\n  return thrift.PrependError(\"error reading field 14: \", err)\n} else {\n  p.RegisterDate = v\n}\n  return nil\n}\n\nfunc (p *UserInfo)  ReadField15(iprot thrift.TProtocol) error {\n  if v, err := iprot.ReadI64(); err != nil {\n  return thrift.PrependError(\"error reading field 15: \", err)\n} else {\n  p.Ice = v\n}\n  return nil\n}\n\nfunc (p *UserInfo)  ReadField16(iprot thrift.TProtocol) error {\n  if v, err := iprot.ReadString(); err != nil {\n  return thrift.PrependError(\"error reading field 16: \", err)\n} else {\n  p.Token = v\n}\n  return nil\n}\n\nfunc (p *UserInfo)  ReadField17(iprot thrift.TProtocol) error {\n  p.QqInfo = &QqInfo{}\n  if err := p.QqInfo.Read(iprot); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T error reading struct: \", p.QqInfo), err)\n  }\n  return nil\n}\n\nfunc (p *UserInfo) Write(oprot thrift.TProtocol) error {\n  if err := oprot.WriteStructBegin(\"UserInfo\"); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write struct begin error: \", p), err) }\n  if p != nil {\n    if err := p.writeField1(oprot); err != nil { return err }\n    if err := p.writeField2(oprot); err != nil { return err }\n    if err := p.writeField3(oprot); err != nil { return err }\n    if err := p.writeField4(oprot); err != nil { return err }\n    if err := p.writeField5(oprot); err != nil { return err }\n    if err := p.writeField6(oprot); err != nil { return err }\n    if err := p.writeField7(oprot); err != nil { return err }\n    if err := p.writeField8(oprot); err != nil { return err }\n    if err := p.writeField9(oprot); err != nil { return err }\n    if err := p.writeField10(oprot); err != nil { return err }\n    if err := p.writeField11(oprot); err != nil { return err }\n    if err := p.writeField12(oprot); err != nil { return err }\n    if err := p.writeField13(oprot); err != nil { return err }\n    if err := p.writeField14(oprot); err != nil { return err }\n    if err := p.writeField15(oprot); err != nil { return err }\n    if err := p.writeField16(oprot); err != nil { return err }\n    if err := p.writeField17(oprot); err != nil { return err }\n  }\n  if err := oprot.WriteFieldStop(); err != nil {\n    return thrift.PrependError(\"write field stop error: \", err) }\n  if err := oprot.WriteStructEnd(); err != nil {\n    return thrift.PrependError(\"write struct stop error: \", err) }\n  return nil\n}\n\nfunc (p *UserInfo) writeField1(oprot thrift.TProtocol) (err error) {\n  if err := oprot.WriteFieldBegin(\"userId\", thrift.I64, 1); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 1:userId: \", p), err) }\n  if err := oprot.WriteI64(int64(p.UserId)); err != nil {\n  return thrift.PrependError(fmt.Sprintf(\"%T.userId (1) field write error: \", p), err) }\n  if err := oprot.WriteFieldEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field end error 1:userId: \", p), err) }\n  return err\n}\n\nfunc (p *UserInfo) writeField2(oprot thrift.TProtocol) (err error) {\n  if err := oprot.WriteFieldBegin(\"userName\", thrift.STRING, 2); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 2:userName: \", p), err) }\n  if err := oprot.WriteString(string(p.UserName)); err != nil {\n  return thrift.PrependError(fmt.Sprintf(\"%T.userName (2) field write error: \", p), err) }\n  if err := oprot.WriteFieldEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field end error 2:userName: \", p), err) }\n  return err\n}\n\nfunc (p *UserInfo) writeField3(oprot thrift.TProtocol) (err error) {\n  if err := oprot.WriteFieldBegin(\"nickName\", thrift.STRING, 3); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 3:nickName: \", p), err) }\n  if err := oprot.WriteString(string(p.NickName)); err != nil {\n  return thrift.PrependError(fmt.Sprintf(\"%T.nickName (3) field write error: \", p), err) }\n  if err := oprot.WriteFieldEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field end error 3:nickName: \", p), err) }\n  return err\n}\n\nfunc (p *UserInfo) writeField4(oprot thrift.TProtocol) (err error) {\n  if err := oprot.WriteFieldBegin(\"sex\", thrift.BYTE, 4); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 4:sex: \", p), err) }\n  if err := oprot.WriteByte(int8(p.Sex)); err != nil {\n  return thrift.PrependError(fmt.Sprintf(\"%T.sex (4) field write error: \", p), err) }\n  if err := oprot.WriteFieldEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field end error 4:sex: \", p), err) }\n  return err\n}\n\nfunc (p *UserInfo) writeField5(oprot thrift.TProtocol) (err error) {\n  if err := oprot.WriteFieldBegin(\"headImg\", thrift.STRING, 5); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 5:headImg: \", p), err) }\n  if err := oprot.WriteString(string(p.HeadImg)); err != nil {\n  return thrift.PrependError(fmt.Sprintf(\"%T.headImg (5) field write error: \", p), err) }\n  if err := oprot.WriteFieldEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field end error 5:headImg: \", p), err) }\n  return err\n}\n\nfunc (p *UserInfo) writeField6(oprot thrift.TProtocol) (err error) {\n  if err := oprot.WriteFieldBegin(\"lv\", thrift.I32, 6); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 6:lv: \", p), err) }\n  if err := oprot.WriteI32(int32(p.Lv)); err != nil {\n  return thrift.PrependError(fmt.Sprintf(\"%T.lv (6) field write error: \", p), err) }\n  if err := oprot.WriteFieldEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field end error 6:lv: \", p), err) }\n  return err\n}\n\nfunc (p *UserInfo) writeField7(oprot thrift.TProtocol) (err error) {\n  if err := oprot.WriteFieldBegin(\"exp\", thrift.I64, 7); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 7:exp: \", p), err) }\n  if err := oprot.WriteI64(int64(p.Exp)); err != nil {\n  return thrift.PrependError(fmt.Sprintf(\"%T.exp (7) field write error: \", p), err) }\n  if err := oprot.WriteFieldEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field end error 7:exp: \", p), err) }\n  return err\n}\n\nfunc (p *UserInfo) writeField8(oprot thrift.TProtocol) (err error) {\n  if err := oprot.WriteFieldBegin(\"vip\", thrift.BYTE, 8); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 8:vip: \", p), err) }\n  if err := oprot.WriteByte(int8(p.Vip)); err != nil {\n  return thrift.PrependError(fmt.Sprintf(\"%T.vip (8) field write error: \", p), err) }\n  if err := oprot.WriteFieldEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field end error 8:vip: \", p), err) }\n  return err\n}\n\nfunc (p *UserInfo) writeField9(oprot thrift.TProtocol) (err error) {\n  if err := oprot.WriteFieldBegin(\"gems\", thrift.I64, 9); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 9:gems: \", p), err) }\n  if err := oprot.WriteI64(int64(p.Gems)); err != nil {\n  return thrift.PrependError(fmt.Sprintf(\"%T.gems (9) field write error: \", p), err) }\n  if err := oprot.WriteFieldEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field end error 9:gems: \", p), err) }\n  return err\n}\n\nfunc (p *UserInfo) writeField10(oprot thrift.TProtocol) (err error) {\n  if err := oprot.WriteFieldBegin(\"roomId\", thrift.I64, 10); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 10:roomId: \", p), err) }\n  if err := oprot.WriteI64(int64(p.RoomId)); err != nil {\n  return thrift.PrependError(fmt.Sprintf(\"%T.roomId (10) field write error: \", p), err) }\n  if err := oprot.WriteFieldEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field end error 10:roomId: \", p), err) }\n  return err\n}\n\nfunc (p *UserInfo) writeField11(oprot thrift.TProtocol) (err error) {\n  if err := oprot.WriteFieldBegin(\"power\", thrift.I64, 11); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 11:power: \", p), err) }\n  if err := oprot.WriteI64(int64(p.Power)); err != nil {\n  return thrift.PrependError(fmt.Sprintf(\"%T.power (11) field write error: \", p), err) }\n  if err := oprot.WriteFieldEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field end error 11:power: \", p), err) }\n  return err\n}\n\nfunc (p *UserInfo) writeField12(oprot thrift.TProtocol) (err error) {\n  if err := oprot.WriteFieldBegin(\"reNameCount\", thrift.BYTE, 12); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 12:reNameCount: \", p), err) }\n  if err := oprot.WriteByte(int8(p.ReNameCount)); err != nil {\n  return thrift.PrependError(fmt.Sprintf(\"%T.reNameCount (12) field write error: \", p), err) }\n  if err := oprot.WriteFieldEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field end error 12:reNameCount: \", p), err) }\n  return err\n}\n\nfunc (p *UserInfo) writeField13(oprot thrift.TProtocol) (err error) {\n  if err := oprot.WriteFieldBegin(\"reHeadCount\", thrift.BYTE, 13); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 13:reHeadCount: \", p), err) }\n  if err := oprot.WriteByte(int8(p.ReHeadCount)); err != nil {\n  return thrift.PrependError(fmt.Sprintf(\"%T.reHeadCount (13) field write error: \", p), err) }\n  if err := oprot.WriteFieldEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field end error 13:reHeadCount: \", p), err) }\n  return err\n}\n\nfunc (p *UserInfo) writeField14(oprot thrift.TProtocol) (err error) {\n  if err := oprot.WriteFieldBegin(\"registerDate\", thrift.STRING, 14); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 14:registerDate: \", p), err) }\n  if err := oprot.WriteString(string(p.RegisterDate)); err != nil {\n  return thrift.PrependError(fmt.Sprintf(\"%T.registerDate (14) field write error: \", p), err) }\n  if err := oprot.WriteFieldEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field end error 14:registerDate: \", p), err) }\n  return err\n}\n\nfunc (p *UserInfo) writeField15(oprot thrift.TProtocol) (err error) {\n  if err := oprot.WriteFieldBegin(\"ice\", thrift.I64, 15); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 15:ice: \", p), err) }\n  if err := oprot.WriteI64(int64(p.Ice)); err != nil {\n  return thrift.PrependError(fmt.Sprintf(\"%T.ice (15) field write error: \", p), err) }\n  if err := oprot.WriteFieldEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field end error 15:ice: \", p), err) }\n  return err\n}\n\nfunc (p *UserInfo) writeField16(oprot thrift.TProtocol) (err error) {\n  if err := oprot.WriteFieldBegin(\"token\", thrift.STRING, 16); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 16:token: \", p), err) }\n  if err := oprot.WriteString(string(p.Token)); err != nil {\n  return thrift.PrependError(fmt.Sprintf(\"%T.token (16) field write error: \", p), err) }\n  if err := oprot.WriteFieldEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field end error 16:token: \", p), err) }\n  return err\n}\n\nfunc (p *UserInfo) writeField17(oprot thrift.TProtocol) (err error) {\n  if err := oprot.WriteFieldBegin(\"qqInfo\", thrift.STRUCT, 17); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 17:qqInfo: \", p), err) }\n  if err := p.QqInfo.Write(oprot); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T error writing struct: \", p.QqInfo), err)\n  }\n  if err := oprot.WriteFieldEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field end error 17:qqInfo: \", p), err) }\n  return err\n}\n\nfunc (p *UserInfo) String() string {\n  if p == nil {\n    return \"<nil>\"\n  }\n  return fmt.Sprintf(\"UserInfo(%+v)\", *p)\n}\n\n// Attributes:\n//  - Code\n//  - UserObj\ntype Result_ struct {\n  Code ErrorCode `thrift:\"code,1\" db:\"code\" json:\"code\"`\n  UserObj *UserInfo `thrift:\"user_obj,2\" db:\"user_obj\" json:\"user_obj\"`\n}\n\nfunc NewResult_() *Result_ {\n  return &Result_{}\n}\n\n\nfunc (p *Result_) GetCode() ErrorCode {\n  return p.Code\n}\nvar Result__UserObj_DEFAULT *UserInfo\nfunc (p *Result_) GetUserObj() *UserInfo {\n  if !p.IsSetUserObj() {\n    return Result__UserObj_DEFAULT\n  }\nreturn p.UserObj\n}\nfunc (p *Result_) IsSetUserObj() bool {\n  return p.UserObj != nil\n}\n\nfunc (p *Result_) Read(iprot thrift.TProtocol) error {\n  if _, err := iprot.ReadStructBegin(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T read error: \", p), err)\n  }\n\n\n  for {\n    _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()\n    if err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T field %d read error: \", p, fieldId), err)\n    }\n    if fieldTypeId == thrift.STOP { break; }\n    switch fieldId {\n    case 1:\n      if fieldTypeId == thrift.I32 {\n        if err := p.ReadField1(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    case 2:\n      if fieldTypeId == thrift.STRUCT {\n        if err := p.ReadField2(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    default:\n      if err := iprot.Skip(fieldTypeId); err != nil {\n        return err\n      }\n    }\n    if err := iprot.ReadFieldEnd(); err != nil {\n      return err\n    }\n  }\n  if err := iprot.ReadStructEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T read struct end error: \", p), err)\n  }\n  return nil\n}\n\nfunc (p *Result_)  ReadField1(iprot thrift.TProtocol) error {\n  if v, err := iprot.ReadI32(); err != nil {\n  return thrift.PrependError(\"error reading field 1: \", err)\n} else {\n  temp := ErrorCode(v)\n  p.Code = temp\n}\n  return nil\n}\n\nfunc (p *Result_)  ReadField2(iprot thrift.TProtocol) error {\n  p.UserObj = &UserInfo{}\n  if err := p.UserObj.Read(iprot); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T error reading struct: \", p.UserObj), err)\n  }\n  return nil\n}\n\nfunc (p *Result_) Write(oprot thrift.TProtocol) error {\n  if err := oprot.WriteStructBegin(\"Result\"); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write struct begin error: \", p), err) }\n  if p != nil {\n    if err := p.writeField1(oprot); err != nil { return err }\n    if err := p.writeField2(oprot); err != nil { return err }\n  }\n  if err := oprot.WriteFieldStop(); err != nil {\n    return thrift.PrependError(\"write field stop error: \", err) }\n  if err := oprot.WriteStructEnd(); err != nil {\n    return thrift.PrependError(\"write struct stop error: \", err) }\n  return nil\n}\n\nfunc (p *Result_) writeField1(oprot thrift.TProtocol) (err error) {\n  if err := oprot.WriteFieldBegin(\"code\", thrift.I32, 1); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 1:code: \", p), err) }\n  if err := oprot.WriteI32(int32(p.Code)); err != nil {\n  return thrift.PrependError(fmt.Sprintf(\"%T.code (1) field write error: \", p), err) }\n  if err := oprot.WriteFieldEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field end error 1:code: \", p), err) }\n  return err\n}\n\nfunc (p *Result_) writeField2(oprot thrift.TProtocol) (err error) {\n  if err := oprot.WriteFieldBegin(\"user_obj\", thrift.STRUCT, 2); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 2:user_obj: \", p), err) }\n  if err := p.UserObj.Write(oprot); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T error writing struct: \", p.UserObj), err)\n  }\n  if err := oprot.WriteFieldEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field end error 2:user_obj: \", p), err) }\n  return err\n}\n\nfunc (p *Result_) String() string {\n  if p == nil {\n    return \"<nil>\"\n  }\n  return fmt.Sprintf(\"Result_(%+v)\", *p)\n}\n\ntype UserService interface {\n  // Parameters:\n  //  - NickName\n  //  - AvatarAuto\n  //  - Gold\n  CreateNewUser(ctx context.Context, nickName string, avatarAuto string, gold int64) (r *Result_, err error)\n  // Parameters:\n  //  - UserInfo\n  CreateQQUser(ctx context.Context, UserInfo *UserInfo) (r *Result_, err error)\n  // Parameters:\n  //  - OpenId\n  GetUserInfoByOpenId(ctx context.Context, openId string) (r *Result_, err error)\n  // Parameters:\n  //  - UserId\n  GetUserInfoById(ctx context.Context, userId int32) (r *Result_, err error)\n  // Parameters:\n  //  - Token\n  GetUserInfoByToken(ctx context.Context, token string) (r *Result_, err error)\n  // Parameters:\n  //  - Behavior\n  //  - UserId\n  //  - PropType\n  //  - Incr\n  ModifyUserInfoById(ctx context.Context, behavior string, userId int32, propType ModifyPropType, incr int64) (r *Result_, err error)\n  // Parameters:\n  //  - UserId\n  //  - NewName_\n  RenameUserById(ctx context.Context, userId int32, NewName string) (r *Result_, err error)\n  // Parameters:\n  //  - MessageType\n  GetMessage(ctx context.Context, messageType string) (r string, err error)\n}\n\ntype UserServiceClient struct {\n  c thrift.TClient\n}\n\nfunc NewUserServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *UserServiceClient {\n  return &UserServiceClient{\n    c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)),\n  }\n}\n\nfunc NewUserServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *UserServiceClient {\n  return &UserServiceClient{\n    c: thrift.NewTStandardClient(iprot, oprot),\n  }\n}\n\nfunc NewUserServiceClient(c thrift.TClient) *UserServiceClient {\n  return &UserServiceClient{\n    c: c,\n  }\n}\n\nfunc (p *UserServiceClient) Client_() thrift.TClient {\n  return p.c\n}\n// Parameters:\n//  - NickName\n//  - AvatarAuto\n//  - Gold\nfunc (p *UserServiceClient) CreateNewUser(ctx context.Context, nickName string, avatarAuto string, gold int64) (r *Result_, err error) {\n  var _args0 UserServiceCreateNewUserArgs\n  _args0.NickName = nickName\n  _args0.AvatarAuto = avatarAuto\n  _args0.Gold = gold\n  var _result1 UserServiceCreateNewUserResult\n  if err = p.Client_().Call(ctx, \"createNewUser\", &_args0, &_result1); err != nil {\n    return\n  }\n  return _result1.GetSuccess(), nil\n}\n\n// Parameters:\n//  - UserInfo\nfunc (p *UserServiceClient) CreateQQUser(ctx context.Context, UserInfo *UserInfo) (r *Result_, err error) {\n  var _args2 UserServiceCreateQQUserArgs\n  _args2.UserInfo = UserInfo\n  var _result3 UserServiceCreateQQUserResult\n  if err = p.Client_().Call(ctx, \"createQQUser\", &_args2, &_result3); err != nil {\n    return\n  }\n  return _result3.GetSuccess(), nil\n}\n\n// Parameters:\n//  - OpenId\nfunc (p *UserServiceClient) GetUserInfoByOpenId(ctx context.Context, openId string) (r *Result_, err error) {\n  var _args4 UserServiceGetUserInfoByOpenIdArgs\n  _args4.OpenId = openId\n  var _result5 UserServiceGetUserInfoByOpenIdResult\n  if err = p.Client_().Call(ctx, \"getUserInfoByOpenId\", &_args4, &_result5); err != nil {\n    return\n  }\n  return _result5.GetSuccess(), nil\n}\n\n// Parameters:\n//  - UserId\nfunc (p *UserServiceClient) GetUserInfoById(ctx context.Context, userId int32) (r *Result_, err error) {\n  var _args6 UserServiceGetUserInfoByIdArgs\n  _args6.UserId = userId\n  var _result7 UserServiceGetUserInfoByIdResult\n  if err = p.Client_().Call(ctx, \"getUserInfoById\", &_args6, &_result7); err != nil {\n    return\n  }\n  return _result7.GetSuccess(), nil\n}\n\n// Parameters:\n//  - Token\nfunc (p *UserServiceClient) GetUserInfoByToken(ctx context.Context, token string) (r *Result_, err error) {\n  var _args8 UserServiceGetUserInfoByTokenArgs\n  _args8.Token = token\n  var _result9 UserServiceGetUserInfoByTokenResult\n  if err = p.Client_().Call(ctx, \"getUserInfoByToken\", &_args8, &_result9); err != nil {\n    return\n  }\n  return _result9.GetSuccess(), nil\n}\n\n// Parameters:\n//  - Behavior\n//  - UserId\n//  - PropType\n//  - Incr\nfunc (p *UserServiceClient) ModifyUserInfoById(ctx context.Context, behavior string, userId int32, propType ModifyPropType, incr int64) (r *Result_, err error) {\n  var _args10 UserServiceModifyUserInfoByIdArgs\n  _args10.Behavior = behavior\n  _args10.UserId = userId\n  _args10.PropType = propType\n  _args10.Incr = incr\n  var _result11 UserServiceModifyUserInfoByIdResult\n  if err = p.Client_().Call(ctx, \"modifyUserInfoById\", &_args10, &_result11); err != nil {\n    return\n  }\n  return _result11.GetSuccess(), nil\n}\n\n// Parameters:\n//  - UserId\n//  - NewName_\nfunc (p *UserServiceClient) RenameUserById(ctx context.Context, userId int32, NewName string) (r *Result_, err error) {\n  var _args12 UserServiceRenameUserByIdArgs\n  _args12.UserId = userId\n  _args12.NewName_ = NewName\n  var _result13 UserServiceRenameUserByIdResult\n  if err = p.Client_().Call(ctx, \"RenameUserById\", &_args12, &_result13); err != nil {\n    return\n  }\n  return _result13.GetSuccess(), nil\n}\n\n// Parameters:\n//  - MessageType\nfunc (p *UserServiceClient) GetMessage(ctx context.Context, messageType string) (r string, err error) {\n  var _args14 UserServiceGetMessageArgs\n  _args14.MessageType = messageType\n  var _result15 UserServiceGetMessageResult\n  if err = p.Client_().Call(ctx, \"getMessage\", &_args14, &_result15); err != nil {\n    return\n  }\n  return _result15.GetSuccess(), nil\n}\n\ntype UserServiceProcessor struct {\n  processorMap map[string]thrift.TProcessorFunction\n  handler UserService\n}\n\nfunc (p *UserServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) {\n  p.processorMap[key] = processor\n}\n\nfunc (p *UserServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) {\n  processor, ok = p.processorMap[key]\n  return processor, ok\n}\n\nfunc (p *UserServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction {\n  return p.processorMap\n}\n\nfunc NewUserServiceProcessor(handler UserService) *UserServiceProcessor {\n\n  self16 := &UserServiceProcessor{handler:handler, processorMap:make(map[string]thrift.TProcessorFunction)}\n  self16.processorMap[\"createNewUser\"] = &userServiceProcessorCreateNewUser{handler:handler}\n  self16.processorMap[\"createQQUser\"] = &userServiceProcessorCreateQQUser{handler:handler}\n  self16.processorMap[\"getUserInfoByOpenId\"] = &userServiceProcessorGetUserInfoByOpenId{handler:handler}\n  self16.processorMap[\"getUserInfoById\"] = &userServiceProcessorGetUserInfoById{handler:handler}\n  self16.processorMap[\"getUserInfoByToken\"] = &userServiceProcessorGetUserInfoByToken{handler:handler}\n  self16.processorMap[\"modifyUserInfoById\"] = &userServiceProcessorModifyUserInfoById{handler:handler}\n  self16.processorMap[\"RenameUserById\"] = &userServiceProcessorRenameUserById{handler:handler}\n  self16.processorMap[\"getMessage\"] = &userServiceProcessorGetMessage{handler:handler}\nreturn self16\n}\n\nfunc (p *UserServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {\n  name, _, seqId, err := iprot.ReadMessageBegin()\n  if err != nil { return false, err }\n  if processor, ok := p.GetProcessorFunction(name); ok {\n    return processor.Process(ctx, seqId, iprot, oprot)\n  }\n  iprot.Skip(thrift.STRUCT)\n  iprot.ReadMessageEnd()\n  x17 := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, \"Unknown function \" + name)\n  oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId)\n  x17.Write(oprot)\n  oprot.WriteMessageEnd()\n  oprot.Flush(ctx)\n  return false, x17\n\n}\n\ntype userServiceProcessorCreateNewUser struct {\n  handler UserService\n}\n\nfunc (p *userServiceProcessorCreateNewUser) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {\n  args := UserServiceCreateNewUserArgs{}\n  if err = args.Read(iprot); err != nil {\n    iprot.ReadMessageEnd()\n    x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())\n    oprot.WriteMessageBegin(\"createNewUser\", thrift.EXCEPTION, seqId)\n    x.Write(oprot)\n    oprot.WriteMessageEnd()\n    oprot.Flush(ctx)\n    return false, err\n  }\n\n  iprot.ReadMessageEnd()\n  result := UserServiceCreateNewUserResult{}\nvar retval *Result_\n  var err2 error\n  if retval, err2 = p.handler.CreateNewUser(ctx, args.NickName, args.AvatarAuto, args.Gold); err2 != nil {\n    x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, \"Internal error processing createNewUser: \" + err2.Error())\n    oprot.WriteMessageBegin(\"createNewUser\", thrift.EXCEPTION, seqId)\n    x.Write(oprot)\n    oprot.WriteMessageEnd()\n    oprot.Flush(ctx)\n    return true, err2\n  } else {\n    result.Success = retval\n}\n  if err2 = oprot.WriteMessageBegin(\"createNewUser\", thrift.REPLY, seqId); err2 != nil {\n    err = err2\n  }\n  if err2 = result.Write(oprot); err == nil && err2 != nil {\n    err = err2\n  }\n  if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil {\n    err = err2\n  }\n  if err2 = oprot.Flush(ctx); err == nil && err2 != nil {\n    err = err2\n  }\n  if err != nil {\n    return\n  }\n  return true, err\n}\n\ntype userServiceProcessorCreateQQUser struct {\n  handler UserService\n}\n\nfunc (p *userServiceProcessorCreateQQUser) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {\n  args := UserServiceCreateQQUserArgs{}\n  if err = args.Read(iprot); err != nil {\n    iprot.ReadMessageEnd()\n    x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())\n    oprot.WriteMessageBegin(\"createQQUser\", thrift.EXCEPTION, seqId)\n    x.Write(oprot)\n    oprot.WriteMessageEnd()\n    oprot.Flush(ctx)\n    return false, err\n  }\n\n  iprot.ReadMessageEnd()\n  result := UserServiceCreateQQUserResult{}\nvar retval *Result_\n  var err2 error\n  if retval, err2 = p.handler.CreateQQUser(ctx, args.UserInfo); err2 != nil {\n    x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, \"Internal error processing createQQUser: \" + err2.Error())\n    oprot.WriteMessageBegin(\"createQQUser\", thrift.EXCEPTION, seqId)\n    x.Write(oprot)\n    oprot.WriteMessageEnd()\n    oprot.Flush(ctx)\n    return true, err2\n  } else {\n    result.Success = retval\n}\n  if err2 = oprot.WriteMessageBegin(\"createQQUser\", thrift.REPLY, seqId); err2 != nil {\n    err = err2\n  }\n  if err2 = result.Write(oprot); err == nil && err2 != nil {\n    err = err2\n  }\n  if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil {\n    err = err2\n  }\n  if err2 = oprot.Flush(ctx); err == nil && err2 != nil {\n    err = err2\n  }\n  if err != nil {\n    return\n  }\n  return true, err\n}\n\ntype userServiceProcessorGetUserInfoByOpenId struct {\n  handler UserService\n}\n\nfunc (p *userServiceProcessorGetUserInfoByOpenId) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {\n  args := UserServiceGetUserInfoByOpenIdArgs{}\n  if err = args.Read(iprot); err != nil {\n    iprot.ReadMessageEnd()\n    x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())\n    oprot.WriteMessageBegin(\"getUserInfoByOpenId\", thrift.EXCEPTION, seqId)\n    x.Write(oprot)\n    oprot.WriteMessageEnd()\n    oprot.Flush(ctx)\n    return false, err\n  }\n\n  iprot.ReadMessageEnd()\n  result := UserServiceGetUserInfoByOpenIdResult{}\nvar retval *Result_\n  var err2 error\n  if retval, err2 = p.handler.GetUserInfoByOpenId(ctx, args.OpenId); err2 != nil {\n    x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, \"Internal error processing getUserInfoByOpenId: \" + err2.Error())\n    oprot.WriteMessageBegin(\"getUserInfoByOpenId\", thrift.EXCEPTION, seqId)\n    x.Write(oprot)\n    oprot.WriteMessageEnd()\n    oprot.Flush(ctx)\n    return true, err2\n  } else {\n    result.Success = retval\n}\n  if err2 = oprot.WriteMessageBegin(\"getUserInfoByOpenId\", thrift.REPLY, seqId); err2 != nil {\n    err = err2\n  }\n  if err2 = result.Write(oprot); err == nil && err2 != nil {\n    err = err2\n  }\n  if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil {\n    err = err2\n  }\n  if err2 = oprot.Flush(ctx); err == nil && err2 != nil {\n    err = err2\n  }\n  if err != nil {\n    return\n  }\n  return true, err\n}\n\ntype userServiceProcessorGetUserInfoById struct {\n  handler UserService\n}\n\nfunc (p *userServiceProcessorGetUserInfoById) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {\n  args := UserServiceGetUserInfoByIdArgs{}\n  if err = args.Read(iprot); err != nil {\n    iprot.ReadMessageEnd()\n    x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())\n    oprot.WriteMessageBegin(\"getUserInfoById\", thrift.EXCEPTION, seqId)\n    x.Write(oprot)\n    oprot.WriteMessageEnd()\n    oprot.Flush(ctx)\n    return false, err\n  }\n\n  iprot.ReadMessageEnd()\n  result := UserServiceGetUserInfoByIdResult{}\nvar retval *Result_\n  var err2 error\n  if retval, err2 = p.handler.GetUserInfoById(ctx, args.UserId); err2 != nil {\n    x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, \"Internal error processing getUserInfoById: \" + err2.Error())\n    oprot.WriteMessageBegin(\"getUserInfoById\", thrift.EXCEPTION, seqId)\n    x.Write(oprot)\n    oprot.WriteMessageEnd()\n    oprot.Flush(ctx)\n    return true, err2\n  } else {\n    result.Success = retval\n}\n  if err2 = oprot.WriteMessageBegin(\"getUserInfoById\", thrift.REPLY, seqId); err2 != nil {\n    err = err2\n  }\n  if err2 = result.Write(oprot); err == nil && err2 != nil {\n    err = err2\n  }\n  if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil {\n    err = err2\n  }\n  if err2 = oprot.Flush(ctx); err == nil && err2 != nil {\n    err = err2\n  }\n  if err != nil {\n    return\n  }\n  return true, err\n}\n\ntype userServiceProcessorGetUserInfoByToken struct {\n  handler UserService\n}\n\nfunc (p *userServiceProcessorGetUserInfoByToken) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {\n  args := UserServiceGetUserInfoByTokenArgs{}\n  if err = args.Read(iprot); err != nil {\n    iprot.ReadMessageEnd()\n    x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())\n    oprot.WriteMessageBegin(\"getUserInfoByToken\", thrift.EXCEPTION, seqId)\n    x.Write(oprot)\n    oprot.WriteMessageEnd()\n    oprot.Flush(ctx)\n    return false, err\n  }\n\n  iprot.ReadMessageEnd()\n  result := UserServiceGetUserInfoByTokenResult{}\nvar retval *Result_\n  var err2 error\n  if retval, err2 = p.handler.GetUserInfoByToken(ctx, args.Token); err2 != nil {\n    x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, \"Internal error processing getUserInfoByToken: \" + err2.Error())\n    oprot.WriteMessageBegin(\"getUserInfoByToken\", thrift.EXCEPTION, seqId)\n    x.Write(oprot)\n    oprot.WriteMessageEnd()\n    oprot.Flush(ctx)\n    return true, err2\n  } else {\n    result.Success = retval\n}\n  if err2 = oprot.WriteMessageBegin(\"getUserInfoByToken\", thrift.REPLY, seqId); err2 != nil {\n    err = err2\n  }\n  if err2 = result.Write(oprot); err == nil && err2 != nil {\n    err = err2\n  }\n  if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil {\n    err = err2\n  }\n  if err2 = oprot.Flush(ctx); err == nil && err2 != nil {\n    err = err2\n  }\n  if err != nil {\n    return\n  }\n  return true, err\n}\n\ntype userServiceProcessorModifyUserInfoById struct {\n  handler UserService\n}\n\nfunc (p *userServiceProcessorModifyUserInfoById) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {\n  args := UserServiceModifyUserInfoByIdArgs{}\n  if err = args.Read(iprot); err != nil {\n    iprot.ReadMessageEnd()\n    x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())\n    oprot.WriteMessageBegin(\"modifyUserInfoById\", thrift.EXCEPTION, seqId)\n    x.Write(oprot)\n    oprot.WriteMessageEnd()\n    oprot.Flush(ctx)\n    return false, err\n  }\n\n  iprot.ReadMessageEnd()\n  result := UserServiceModifyUserInfoByIdResult{}\nvar retval *Result_\n  var err2 error\n  if retval, err2 = p.handler.ModifyUserInfoById(ctx, args.Behavior, args.UserId, args.PropType, args.Incr); err2 != nil {\n    x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, \"Internal error processing modifyUserInfoById: \" + err2.Error())\n    oprot.WriteMessageBegin(\"modifyUserInfoById\", thrift.EXCEPTION, seqId)\n    x.Write(oprot)\n    oprot.WriteMessageEnd()\n    oprot.Flush(ctx)\n    return true, err2\n  } else {\n    result.Success = retval\n}\n  if err2 = oprot.WriteMessageBegin(\"modifyUserInfoById\", thrift.REPLY, seqId); err2 != nil {\n    err = err2\n  }\n  if err2 = result.Write(oprot); err == nil && err2 != nil {\n    err = err2\n  }\n  if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil {\n    err = err2\n  }\n  if err2 = oprot.Flush(ctx); err == nil && err2 != nil {\n    err = err2\n  }\n  if err != nil {\n    return\n  }\n  return true, err\n}\n\ntype userServiceProcessorRenameUserById struct {\n  handler UserService\n}\n\nfunc (p *userServiceProcessorRenameUserById) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {\n  args := UserServiceRenameUserByIdArgs{}\n  if err = args.Read(iprot); err != nil {\n    iprot.ReadMessageEnd()\n    x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())\n    oprot.WriteMessageBegin(\"RenameUserById\", thrift.EXCEPTION, seqId)\n    x.Write(oprot)\n    oprot.WriteMessageEnd()\n    oprot.Flush(ctx)\n    return false, err\n  }\n\n  iprot.ReadMessageEnd()\n  result := UserServiceRenameUserByIdResult{}\nvar retval *Result_\n  var err2 error\n  if retval, err2 = p.handler.RenameUserById(ctx, args.UserId, args.NewName_); err2 != nil {\n    x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, \"Internal error processing RenameUserById: \" + err2.Error())\n    oprot.WriteMessageBegin(\"RenameUserById\", thrift.EXCEPTION, seqId)\n    x.Write(oprot)\n    oprot.WriteMessageEnd()\n    oprot.Flush(ctx)\n    return true, err2\n  } else {\n    result.Success = retval\n}\n  if err2 = oprot.WriteMessageBegin(\"RenameUserById\", thrift.REPLY, seqId); err2 != nil {\n    err = err2\n  }\n  if err2 = result.Write(oprot); err == nil && err2 != nil {\n    err = err2\n  }\n  if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil {\n    err = err2\n  }\n  if err2 = oprot.Flush(ctx); err == nil && err2 != nil {\n    err = err2\n  }\n  if err != nil {\n    return\n  }\n  return true, err\n}\n\ntype userServiceProcessorGetMessage struct {\n  handler UserService\n}\n\nfunc (p *userServiceProcessorGetMessage) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {\n  args := UserServiceGetMessageArgs{}\n  if err = args.Read(iprot); err != nil {\n    iprot.ReadMessageEnd()\n    x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())\n    oprot.WriteMessageBegin(\"getMessage\", thrift.EXCEPTION, seqId)\n    x.Write(oprot)\n    oprot.WriteMessageEnd()\n    oprot.Flush(ctx)\n    return false, err\n  }\n\n  iprot.ReadMessageEnd()\n  result := UserServiceGetMessageResult{}\nvar retval string\n  var err2 error\n  if retval, err2 = p.handler.GetMessage(ctx, args.MessageType); err2 != nil {\n    x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, \"Internal error processing getMessage: \" + err2.Error())\n    oprot.WriteMessageBegin(\"getMessage\", thrift.EXCEPTION, seqId)\n    x.Write(oprot)\n    oprot.WriteMessageEnd()\n    oprot.Flush(ctx)\n    return true, err2\n  } else {\n    result.Success = &retval\n}\n  if err2 = oprot.WriteMessageBegin(\"getMessage\", thrift.REPLY, seqId); err2 != nil {\n    err = err2\n  }\n  if err2 = result.Write(oprot); err == nil && err2 != nil {\n    err = err2\n  }\n  if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil {\n    err = err2\n  }\n  if err2 = oprot.Flush(ctx); err == nil && err2 != nil {\n    err = err2\n  }\n  if err != nil {\n    return\n  }\n  return true, err\n}\n\n\n// HELPER FUNCTIONS AND STRUCTURES\n\n// Attributes:\n//  - NickName\n//  - AvatarAuto\n//  - Gold\ntype UserServiceCreateNewUserArgs struct {\n  NickName string `thrift:\"nickName,1\" db:\"nickName\" json:\"nickName\"`\n  AvatarAuto string `thrift:\"avatarAuto,2\" db:\"avatarAuto\" json:\"avatarAuto\"`\n  Gold int64 `thrift:\"gold,3\" db:\"gold\" json:\"gold\"`\n}\n\nfunc NewUserServiceCreateNewUserArgs() *UserServiceCreateNewUserArgs {\n  return &UserServiceCreateNewUserArgs{}\n}\n\n\nfunc (p *UserServiceCreateNewUserArgs) GetNickName() string {\n  return p.NickName\n}\n\nfunc (p *UserServiceCreateNewUserArgs) GetAvatarAuto() string {\n  return p.AvatarAuto\n}\n\nfunc (p *UserServiceCreateNewUserArgs) GetGold() int64 {\n  return p.Gold\n}\nfunc (p *UserServiceCreateNewUserArgs) Read(iprot thrift.TProtocol) error {\n  if _, err := iprot.ReadStructBegin(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T read error: \", p), err)\n  }\n\n\n  for {\n    _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()\n    if err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T field %d read error: \", p, fieldId), err)\n    }\n    if fieldTypeId == thrift.STOP { break; }\n    switch fieldId {\n    case 1:\n      if fieldTypeId == thrift.STRING {\n        if err := p.ReadField1(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    case 2:\n      if fieldTypeId == thrift.STRING {\n        if err := p.ReadField2(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    case 3:\n      if fieldTypeId == thrift.I64 {\n        if err := p.ReadField3(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    default:\n      if err := iprot.Skip(fieldTypeId); err != nil {\n        return err\n      }\n    }\n    if err := iprot.ReadFieldEnd(); err != nil {\n      return err\n    }\n  }\n  if err := iprot.ReadStructEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T read struct end error: \", p), err)\n  }\n  return nil\n}\n\nfunc (p *UserServiceCreateNewUserArgs)  ReadField1(iprot thrift.TProtocol) error {\n  if v, err := iprot.ReadString(); err != nil {\n  return thrift.PrependError(\"error reading field 1: \", err)\n} else {\n  p.NickName = v\n}\n  return nil\n}\n\nfunc (p *UserServiceCreateNewUserArgs)  ReadField2(iprot thrift.TProtocol) error {\n  if v, err := iprot.ReadString(); err != nil {\n  return thrift.PrependError(\"error reading field 2: \", err)\n} else {\n  p.AvatarAuto = v\n}\n  return nil\n}\n\nfunc (p *UserServiceCreateNewUserArgs)  ReadField3(iprot thrift.TProtocol) error {\n  if v, err := iprot.ReadI64(); err != nil {\n  return thrift.PrependError(\"error reading field 3: \", err)\n} else {\n  p.Gold = v\n}\n  return nil\n}\n\nfunc (p *UserServiceCreateNewUserArgs) Write(oprot thrift.TProtocol) error {\n  if err := oprot.WriteStructBegin(\"createNewUser_args\"); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write struct begin error: \", p), err) }\n  if p != nil {\n    if err := p.writeField1(oprot); err != nil { return err }\n    if err := p.writeField2(oprot); err != nil { return err }\n    if err := p.writeField3(oprot); err != nil { return err }\n  }\n  if err := oprot.WriteFieldStop(); err != nil {\n    return thrift.PrependError(\"write field stop error: \", err) }\n  if err := oprot.WriteStructEnd(); err != nil {\n    return thrift.PrependError(\"write struct stop error: \", err) }\n  return nil\n}\n\nfunc (p *UserServiceCreateNewUserArgs) writeField1(oprot thrift.TProtocol) (err error) {\n  if err := oprot.WriteFieldBegin(\"nickName\", thrift.STRING, 1); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 1:nickName: \", p), err) }\n  if err := oprot.WriteString(string(p.NickName)); err != nil {\n  return thrift.PrependError(fmt.Sprintf(\"%T.nickName (1) field write error: \", p), err) }\n  if err := oprot.WriteFieldEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field end error 1:nickName: \", p), err) }\n  return err\n}\n\nfunc (p *UserServiceCreateNewUserArgs) writeField2(oprot thrift.TProtocol) (err error) {\n  if err := oprot.WriteFieldBegin(\"avatarAuto\", thrift.STRING, 2); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 2:avatarAuto: \", p), err) }\n  if err := oprot.WriteString(string(p.AvatarAuto)); err != nil {\n  return thrift.PrependError(fmt.Sprintf(\"%T.avatarAuto (2) field write error: \", p), err) }\n  if err := oprot.WriteFieldEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field end error 2:avatarAuto: \", p), err) }\n  return err\n}\n\nfunc (p *UserServiceCreateNewUserArgs) writeField3(oprot thrift.TProtocol) (err error) {\n  if err := oprot.WriteFieldBegin(\"gold\", thrift.I64, 3); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 3:gold: \", p), err) }\n  if err := oprot.WriteI64(int64(p.Gold)); err != nil {\n  return thrift.PrependError(fmt.Sprintf(\"%T.gold (3) field write error: \", p), err) }\n  if err := oprot.WriteFieldEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field end error 3:gold: \", p), err) }\n  return err\n}\n\nfunc (p *UserServiceCreateNewUserArgs) String() string {\n  if p == nil {\n    return \"<nil>\"\n  }\n  return fmt.Sprintf(\"UserServiceCreateNewUserArgs(%+v)\", *p)\n}\n\n// Attributes:\n//  - Success\ntype UserServiceCreateNewUserResult struct {\n  Success *Result_ `thrift:\"success,0\" db:\"success\" json:\"success,omitempty\"`\n}\n\nfunc NewUserServiceCreateNewUserResult() *UserServiceCreateNewUserResult {\n  return &UserServiceCreateNewUserResult{}\n}\n\nvar UserServiceCreateNewUserResult_Success_DEFAULT *Result_\nfunc (p *UserServiceCreateNewUserResult) GetSuccess() *Result_ {\n  if !p.IsSetSuccess() {\n    return UserServiceCreateNewUserResult_Success_DEFAULT\n  }\nreturn p.Success\n}\nfunc (p *UserServiceCreateNewUserResult) IsSetSuccess() bool {\n  return p.Success != nil\n}\n\nfunc (p *UserServiceCreateNewUserResult) Read(iprot thrift.TProtocol) error {\n  if _, err := iprot.ReadStructBegin(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T read error: \", p), err)\n  }\n\n\n  for {\n    _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()\n    if err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T field %d read error: \", p, fieldId), err)\n    }\n    if fieldTypeId == thrift.STOP { break; }\n    switch fieldId {\n    case 0:\n      if fieldTypeId == thrift.STRUCT {\n        if err := p.ReadField0(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    default:\n      if err := iprot.Skip(fieldTypeId); err != nil {\n        return err\n      }\n    }\n    if err := iprot.ReadFieldEnd(); err != nil {\n      return err\n    }\n  }\n  if err := iprot.ReadStructEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T read struct end error: \", p), err)\n  }\n  return nil\n}\n\nfunc (p *UserServiceCreateNewUserResult)  ReadField0(iprot thrift.TProtocol) error {\n  p.Success = &Result_{}\n  if err := p.Success.Read(iprot); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T error reading struct: \", p.Success), err)\n  }\n  return nil\n}\n\nfunc (p *UserServiceCreateNewUserResult) Write(oprot thrift.TProtocol) error {\n  if err := oprot.WriteStructBegin(\"createNewUser_result\"); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write struct begin error: \", p), err) }\n  if p != nil {\n    if err := p.writeField0(oprot); err != nil { return err }\n  }\n  if err := oprot.WriteFieldStop(); err != nil {\n    return thrift.PrependError(\"write field stop error: \", err) }\n  if err := oprot.WriteStructEnd(); err != nil {\n    return thrift.PrependError(\"write struct stop error: \", err) }\n  return nil\n}\n\nfunc (p *UserServiceCreateNewUserResult) writeField0(oprot thrift.TProtocol) (err error) {\n  if p.IsSetSuccess() {\n    if err := oprot.WriteFieldBegin(\"success\", thrift.STRUCT, 0); err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 0:success: \", p), err) }\n    if err := p.Success.Write(oprot); err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T error writing struct: \", p.Success), err)\n    }\n    if err := oprot.WriteFieldEnd(); err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T write field end error 0:success: \", p), err) }\n  }\n  return err\n}\n\nfunc (p *UserServiceCreateNewUserResult) String() string {\n  if p == nil {\n    return \"<nil>\"\n  }\n  return fmt.Sprintf(\"UserServiceCreateNewUserResult(%+v)\", *p)\n}\n\n// Attributes:\n//  - UserInfo\ntype UserServiceCreateQQUserArgs struct {\n  UserInfo *UserInfo `thrift:\"UserInfo,1\" db:\"UserInfo\" json:\"UserInfo\"`\n}\n\nfunc NewUserServiceCreateQQUserArgs() *UserServiceCreateQQUserArgs {\n  return &UserServiceCreateQQUserArgs{}\n}\n\nvar UserServiceCreateQQUserArgs_UserInfo_DEFAULT *UserInfo\nfunc (p *UserServiceCreateQQUserArgs) GetUserInfo() *UserInfo {\n  if !p.IsSetUserInfo() {\n    return UserServiceCreateQQUserArgs_UserInfo_DEFAULT\n  }\nreturn p.UserInfo\n}\nfunc (p *UserServiceCreateQQUserArgs) IsSetUserInfo() bool {\n  return p.UserInfo != nil\n}\n\nfunc (p *UserServiceCreateQQUserArgs) Read(iprot thrift.TProtocol) error {\n  if _, err := iprot.ReadStructBegin(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T read error: \", p), err)\n  }\n\n\n  for {\n    _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()\n    if err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T field %d read error: \", p, fieldId), err)\n    }\n    if fieldTypeId == thrift.STOP { break; }\n    switch fieldId {\n    case 1:\n      if fieldTypeId == thrift.STRUCT {\n        if err := p.ReadField1(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    default:\n      if err := iprot.Skip(fieldTypeId); err != nil {\n        return err\n      }\n    }\n    if err := iprot.ReadFieldEnd(); err != nil {\n      return err\n    }\n  }\n  if err := iprot.ReadStructEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T read struct end error: \", p), err)\n  }\n  return nil\n}\n\nfunc (p *UserServiceCreateQQUserArgs)  ReadField1(iprot thrift.TProtocol) error {\n  p.UserInfo = &UserInfo{}\n  if err := p.UserInfo.Read(iprot); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T error reading struct: \", p.UserInfo), err)\n  }\n  return nil\n}\n\nfunc (p *UserServiceCreateQQUserArgs) Write(oprot thrift.TProtocol) error {\n  if err := oprot.WriteStructBegin(\"createQQUser_args\"); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write struct begin error: \", p), err) }\n  if p != nil {\n    if err := p.writeField1(oprot); err != nil { return err }\n  }\n  if err := oprot.WriteFieldStop(); err != nil {\n    return thrift.PrependError(\"write field stop error: \", err) }\n  if err := oprot.WriteStructEnd(); err != nil {\n    return thrift.PrependError(\"write struct stop error: \", err) }\n  return nil\n}\n\nfunc (p *UserServiceCreateQQUserArgs) writeField1(oprot thrift.TProtocol) (err error) {\n  if err := oprot.WriteFieldBegin(\"UserInfo\", thrift.STRUCT, 1); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 1:UserInfo: \", p), err) }\n  if err := p.UserInfo.Write(oprot); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T error writing struct: \", p.UserInfo), err)\n  }\n  if err := oprot.WriteFieldEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field end error 1:UserInfo: \", p), err) }\n  return err\n}\n\nfunc (p *UserServiceCreateQQUserArgs) String() string {\n  if p == nil {\n    return \"<nil>\"\n  }\n  return fmt.Sprintf(\"UserServiceCreateQQUserArgs(%+v)\", *p)\n}\n\n// Attributes:\n//  - Success\ntype UserServiceCreateQQUserResult struct {\n  Success *Result_ `thrift:\"success,0\" db:\"success\" json:\"success,omitempty\"`\n}\n\nfunc NewUserServiceCreateQQUserResult() *UserServiceCreateQQUserResult {\n  return &UserServiceCreateQQUserResult{}\n}\n\nvar UserServiceCreateQQUserResult_Success_DEFAULT *Result_\nfunc (p *UserServiceCreateQQUserResult) GetSuccess() *Result_ {\n  if !p.IsSetSuccess() {\n    return UserServiceCreateQQUserResult_Success_DEFAULT\n  }\nreturn p.Success\n}\nfunc (p *UserServiceCreateQQUserResult) IsSetSuccess() bool {\n  return p.Success != nil\n}\n\nfunc (p *UserServiceCreateQQUserResult) Read(iprot thrift.TProtocol) error {\n  if _, err := iprot.ReadStructBegin(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T read error: \", p), err)\n  }\n\n\n  for {\n    _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()\n    if err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T field %d read error: \", p, fieldId), err)\n    }\n    if fieldTypeId == thrift.STOP { break; }\n    switch fieldId {\n    case 0:\n      if fieldTypeId == thrift.STRUCT {\n        if err := p.ReadField0(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    default:\n      if err := iprot.Skip(fieldTypeId); err != nil {\n        return err\n      }\n    }\n    if err := iprot.ReadFieldEnd(); err != nil {\n      return err\n    }\n  }\n  if err := iprot.ReadStructEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T read struct end error: \", p), err)\n  }\n  return nil\n}\n\nfunc (p *UserServiceCreateQQUserResult)  ReadField0(iprot thrift.TProtocol) error {\n  p.Success = &Result_{}\n  if err := p.Success.Read(iprot); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T error reading struct: \", p.Success), err)\n  }\n  return nil\n}\n\nfunc (p *UserServiceCreateQQUserResult) Write(oprot thrift.TProtocol) error {\n  if err := oprot.WriteStructBegin(\"createQQUser_result\"); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write struct begin error: \", p), err) }\n  if p != nil {\n    if err := p.writeField0(oprot); err != nil { return err }\n  }\n  if err := oprot.WriteFieldStop(); err != nil {\n    return thrift.PrependError(\"write field stop error: \", err) }\n  if err := oprot.WriteStructEnd(); err != nil {\n    return thrift.PrependError(\"write struct stop error: \", err) }\n  return nil\n}\n\nfunc (p *UserServiceCreateQQUserResult) writeField0(oprot thrift.TProtocol) (err error) {\n  if p.IsSetSuccess() {\n    if err := oprot.WriteFieldBegin(\"success\", thrift.STRUCT, 0); err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 0:success: \", p), err) }\n    if err := p.Success.Write(oprot); err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T error writing struct: \", p.Success), err)\n    }\n    if err := oprot.WriteFieldEnd(); err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T write field end error 0:success: \", p), err) }\n  }\n  return err\n}\n\nfunc (p *UserServiceCreateQQUserResult) String() string {\n  if p == nil {\n    return \"<nil>\"\n  }\n  return fmt.Sprintf(\"UserServiceCreateQQUserResult(%+v)\", *p)\n}\n\n// Attributes:\n//  - OpenId\ntype UserServiceGetUserInfoByOpenIdArgs struct {\n  OpenId string `thrift:\"openId,1\" db:\"openId\" json:\"openId\"`\n}\n\nfunc NewUserServiceGetUserInfoByOpenIdArgs() *UserServiceGetUserInfoByOpenIdArgs {\n  return &UserServiceGetUserInfoByOpenIdArgs{}\n}\n\n\nfunc (p *UserServiceGetUserInfoByOpenIdArgs) GetOpenId() string {\n  return p.OpenId\n}\nfunc (p *UserServiceGetUserInfoByOpenIdArgs) Read(iprot thrift.TProtocol) error {\n  if _, err := iprot.ReadStructBegin(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T read error: \", p), err)\n  }\n\n\n  for {\n    _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()\n    if err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T field %d read error: \", p, fieldId), err)\n    }\n    if fieldTypeId == thrift.STOP { break; }\n    switch fieldId {\n    case 1:\n      if fieldTypeId == thrift.STRING {\n        if err := p.ReadField1(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    default:\n      if err := iprot.Skip(fieldTypeId); err != nil {\n        return err\n      }\n    }\n    if err := iprot.ReadFieldEnd(); err != nil {\n      return err\n    }\n  }\n  if err := iprot.ReadStructEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T read struct end error: \", p), err)\n  }\n  return nil\n}\n\nfunc (p *UserServiceGetUserInfoByOpenIdArgs)  ReadField1(iprot thrift.TProtocol) error {\n  if v, err := iprot.ReadString(); err != nil {\n  return thrift.PrependError(\"error reading field 1: \", err)\n} else {\n  p.OpenId = v\n}\n  return nil\n}\n\nfunc (p *UserServiceGetUserInfoByOpenIdArgs) Write(oprot thrift.TProtocol) error {\n  if err := oprot.WriteStructBegin(\"getUserInfoByOpenId_args\"); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write struct begin error: \", p), err) }\n  if p != nil {\n    if err := p.writeField1(oprot); err != nil { return err }\n  }\n  if err := oprot.WriteFieldStop(); err != nil {\n    return thrift.PrependError(\"write field stop error: \", err) }\n  if err := oprot.WriteStructEnd(); err != nil {\n    return thrift.PrependError(\"write struct stop error: \", err) }\n  return nil\n}\n\nfunc (p *UserServiceGetUserInfoByOpenIdArgs) writeField1(oprot thrift.TProtocol) (err error) {\n  if err := oprot.WriteFieldBegin(\"openId\", thrift.STRING, 1); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 1:openId: \", p), err) }\n  if err := oprot.WriteString(string(p.OpenId)); err != nil {\n  return thrift.PrependError(fmt.Sprintf(\"%T.openId (1) field write error: \", p), err) }\n  if err := oprot.WriteFieldEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field end error 1:openId: \", p), err) }\n  return err\n}\n\nfunc (p *UserServiceGetUserInfoByOpenIdArgs) String() string {\n  if p == nil {\n    return \"<nil>\"\n  }\n  return fmt.Sprintf(\"UserServiceGetUserInfoByOpenIdArgs(%+v)\", *p)\n}\n\n// Attributes:\n//  - Success\ntype UserServiceGetUserInfoByOpenIdResult struct {\n  Success *Result_ `thrift:\"success,0\" db:\"success\" json:\"success,omitempty\"`\n}\n\nfunc NewUserServiceGetUserInfoByOpenIdResult() *UserServiceGetUserInfoByOpenIdResult {\n  return &UserServiceGetUserInfoByOpenIdResult{}\n}\n\nvar UserServiceGetUserInfoByOpenIdResult_Success_DEFAULT *Result_\nfunc (p *UserServiceGetUserInfoByOpenIdResult) GetSuccess() *Result_ {\n  if !p.IsSetSuccess() {\n    return UserServiceGetUserInfoByOpenIdResult_Success_DEFAULT\n  }\nreturn p.Success\n}\nfunc (p *UserServiceGetUserInfoByOpenIdResult) IsSetSuccess() bool {\n  return p.Success != nil\n}\n\nfunc (p *UserServiceGetUserInfoByOpenIdResult) Read(iprot thrift.TProtocol) error {\n  if _, err := iprot.ReadStructBegin(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T read error: \", p), err)\n  }\n\n\n  for {\n    _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()\n    if err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T field %d read error: \", p, fieldId), err)\n    }\n    if fieldTypeId == thrift.STOP { break; }\n    switch fieldId {\n    case 0:\n      if fieldTypeId == thrift.STRUCT {\n        if err := p.ReadField0(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    default:\n      if err := iprot.Skip(fieldTypeId); err != nil {\n        return err\n      }\n    }\n    if err := iprot.ReadFieldEnd(); err != nil {\n      return err\n    }\n  }\n  if err := iprot.ReadStructEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T read struct end error: \", p), err)\n  }\n  return nil\n}\n\nfunc (p *UserServiceGetUserInfoByOpenIdResult)  ReadField0(iprot thrift.TProtocol) error {\n  p.Success = &Result_{}\n  if err := p.Success.Read(iprot); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T error reading struct: \", p.Success), err)\n  }\n  return nil\n}\n\nfunc (p *UserServiceGetUserInfoByOpenIdResult) Write(oprot thrift.TProtocol) error {\n  if err := oprot.WriteStructBegin(\"getUserInfoByOpenId_result\"); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write struct begin error: \", p), err) }\n  if p != nil {\n    if err := p.writeField0(oprot); err != nil { return err }\n  }\n  if err := oprot.WriteFieldStop(); err != nil {\n    return thrift.PrependError(\"write field stop error: \", err) }\n  if err := oprot.WriteStructEnd(); err != nil {\n    return thrift.PrependError(\"write struct stop error: \", err) }\n  return nil\n}\n\nfunc (p *UserServiceGetUserInfoByOpenIdResult) writeField0(oprot thrift.TProtocol) (err error) {\n  if p.IsSetSuccess() {\n    if err := oprot.WriteFieldBegin(\"success\", thrift.STRUCT, 0); err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 0:success: \", p), err) }\n    if err := p.Success.Write(oprot); err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T error writing struct: \", p.Success), err)\n    }\n    if err := oprot.WriteFieldEnd(); err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T write field end error 0:success: \", p), err) }\n  }\n  return err\n}\n\nfunc (p *UserServiceGetUserInfoByOpenIdResult) String() string {\n  if p == nil {\n    return \"<nil>\"\n  }\n  return fmt.Sprintf(\"UserServiceGetUserInfoByOpenIdResult(%+v)\", *p)\n}\n\n// Attributes:\n//  - UserId\ntype UserServiceGetUserInfoByIdArgs struct {\n  UserId int32 `thrift:\"userId,1\" db:\"userId\" json:\"userId\"`\n}\n\nfunc NewUserServiceGetUserInfoByIdArgs() *UserServiceGetUserInfoByIdArgs {\n  return &UserServiceGetUserInfoByIdArgs{}\n}\n\n\nfunc (p *UserServiceGetUserInfoByIdArgs) GetUserId() int32 {\n  return p.UserId\n}\nfunc (p *UserServiceGetUserInfoByIdArgs) Read(iprot thrift.TProtocol) error {\n  if _, err := iprot.ReadStructBegin(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T read error: \", p), err)\n  }\n\n\n  for {\n    _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()\n    if err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T field %d read error: \", p, fieldId), err)\n    }\n    if fieldTypeId == thrift.STOP { break; }\n    switch fieldId {\n    case 1:\n      if fieldTypeId == thrift.I32 {\n        if err := p.ReadField1(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    default:\n      if err := iprot.Skip(fieldTypeId); err != nil {\n        return err\n      }\n    }\n    if err := iprot.ReadFieldEnd(); err != nil {\n      return err\n    }\n  }\n  if err := iprot.ReadStructEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T read struct end error: \", p), err)\n  }\n  return nil\n}\n\nfunc (p *UserServiceGetUserInfoByIdArgs)  ReadField1(iprot thrift.TProtocol) error {\n  if v, err := iprot.ReadI32(); err != nil {\n  return thrift.PrependError(\"error reading field 1: \", err)\n} else {\n  p.UserId = v\n}\n  return nil\n}\n\nfunc (p *UserServiceGetUserInfoByIdArgs) Write(oprot thrift.TProtocol) error {\n  if err := oprot.WriteStructBegin(\"getUserInfoById_args\"); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write struct begin error: \", p), err) }\n  if p != nil {\n    if err := p.writeField1(oprot); err != nil { return err }\n  }\n  if err := oprot.WriteFieldStop(); err != nil {\n    return thrift.PrependError(\"write field stop error: \", err) }\n  if err := oprot.WriteStructEnd(); err != nil {\n    return thrift.PrependError(\"write struct stop error: \", err) }\n  return nil\n}\n\nfunc (p *UserServiceGetUserInfoByIdArgs) writeField1(oprot thrift.TProtocol) (err error) {\n  if err := oprot.WriteFieldBegin(\"userId\", thrift.I32, 1); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 1:userId: \", p), err) }\n  if err := oprot.WriteI32(int32(p.UserId)); err != nil {\n  return thrift.PrependError(fmt.Sprintf(\"%T.userId (1) field write error: \", p), err) }\n  if err := oprot.WriteFieldEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field end error 1:userId: \", p), err) }\n  return err\n}\n\nfunc (p *UserServiceGetUserInfoByIdArgs) String() string {\n  if p == nil {\n    return \"<nil>\"\n  }\n  return fmt.Sprintf(\"UserServiceGetUserInfoByIdArgs(%+v)\", *p)\n}\n\n// Attributes:\n//  - Success\ntype UserServiceGetUserInfoByIdResult struct {\n  Success *Result_ `thrift:\"success,0\" db:\"success\" json:\"success,omitempty\"`\n}\n\nfunc NewUserServiceGetUserInfoByIdResult() *UserServiceGetUserInfoByIdResult {\n  return &UserServiceGetUserInfoByIdResult{}\n}\n\nvar UserServiceGetUserInfoByIdResult_Success_DEFAULT *Result_\nfunc (p *UserServiceGetUserInfoByIdResult) GetSuccess() *Result_ {\n  if !p.IsSetSuccess() {\n    return UserServiceGetUserInfoByIdResult_Success_DEFAULT\n  }\nreturn p.Success\n}\nfunc (p *UserServiceGetUserInfoByIdResult) IsSetSuccess() bool {\n  return p.Success != nil\n}\n\nfunc (p *UserServiceGetUserInfoByIdResult) Read(iprot thrift.TProtocol) error {\n  if _, err := iprot.ReadStructBegin(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T read error: \", p), err)\n  }\n\n\n  for {\n    _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()\n    if err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T field %d read error: \", p, fieldId), err)\n    }\n    if fieldTypeId == thrift.STOP { break; }\n    switch fieldId {\n    case 0:\n      if fieldTypeId == thrift.STRUCT {\n        if err := p.ReadField0(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    default:\n      if err := iprot.Skip(fieldTypeId); err != nil {\n        return err\n      }\n    }\n    if err := iprot.ReadFieldEnd(); err != nil {\n      return err\n    }\n  }\n  if err := iprot.ReadStructEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T read struct end error: \", p), err)\n  }\n  return nil\n}\n\nfunc (p *UserServiceGetUserInfoByIdResult)  ReadField0(iprot thrift.TProtocol) error {\n  p.Success = &Result_{}\n  if err := p.Success.Read(iprot); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T error reading struct: \", p.Success), err)\n  }\n  return nil\n}\n\nfunc (p *UserServiceGetUserInfoByIdResult) Write(oprot thrift.TProtocol) error {\n  if err := oprot.WriteStructBegin(\"getUserInfoById_result\"); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write struct begin error: \", p), err) }\n  if p != nil {\n    if err := p.writeField0(oprot); err != nil { return err }\n  }\n  if err := oprot.WriteFieldStop(); err != nil {\n    return thrift.PrependError(\"write field stop error: \", err) }\n  if err := oprot.WriteStructEnd(); err != nil {\n    return thrift.PrependError(\"write struct stop error: \", err) }\n  return nil\n}\n\nfunc (p *UserServiceGetUserInfoByIdResult) writeField0(oprot thrift.TProtocol) (err error) {\n  if p.IsSetSuccess() {\n    if err := oprot.WriteFieldBegin(\"success\", thrift.STRUCT, 0); err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 0:success: \", p), err) }\n    if err := p.Success.Write(oprot); err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T error writing struct: \", p.Success), err)\n    }\n    if err := oprot.WriteFieldEnd(); err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T write field end error 0:success: \", p), err) }\n  }\n  return err\n}\n\nfunc (p *UserServiceGetUserInfoByIdResult) String() string {\n  if p == nil {\n    return \"<nil>\"\n  }\n  return fmt.Sprintf(\"UserServiceGetUserInfoByIdResult(%+v)\", *p)\n}\n\n// Attributes:\n//  - Token\ntype UserServiceGetUserInfoByTokenArgs struct {\n  Token string `thrift:\"token,1\" db:\"token\" json:\"token\"`\n}\n\nfunc NewUserServiceGetUserInfoByTokenArgs() *UserServiceGetUserInfoByTokenArgs {\n  return &UserServiceGetUserInfoByTokenArgs{}\n}\n\n\nfunc (p *UserServiceGetUserInfoByTokenArgs) GetToken() string {\n  return p.Token\n}\nfunc (p *UserServiceGetUserInfoByTokenArgs) Read(iprot thrift.TProtocol) error {\n  if _, err := iprot.ReadStructBegin(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T read error: \", p), err)\n  }\n\n\n  for {\n    _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()\n    if err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T field %d read error: \", p, fieldId), err)\n    }\n    if fieldTypeId == thrift.STOP { break; }\n    switch fieldId {\n    case 1:\n      if fieldTypeId == thrift.STRING {\n        if err := p.ReadField1(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    default:\n      if err := iprot.Skip(fieldTypeId); err != nil {\n        return err\n      }\n    }\n    if err := iprot.ReadFieldEnd(); err != nil {\n      return err\n    }\n  }\n  if err := iprot.ReadStructEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T read struct end error: \", p), err)\n  }\n  return nil\n}\n\nfunc (p *UserServiceGetUserInfoByTokenArgs)  ReadField1(iprot thrift.TProtocol) error {\n  if v, err := iprot.ReadString(); err != nil {\n  return thrift.PrependError(\"error reading field 1: \", err)\n} else {\n  p.Token = v\n}\n  return nil\n}\n\nfunc (p *UserServiceGetUserInfoByTokenArgs) Write(oprot thrift.TProtocol) error {\n  if err := oprot.WriteStructBegin(\"getUserInfoByToken_args\"); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write struct begin error: \", p), err) }\n  if p != nil {\n    if err := p.writeField1(oprot); err != nil { return err }\n  }\n  if err := oprot.WriteFieldStop(); err != nil {\n    return thrift.PrependError(\"write field stop error: \", err) }\n  if err := oprot.WriteStructEnd(); err != nil {\n    return thrift.PrependError(\"write struct stop error: \", err) }\n  return nil\n}\n\nfunc (p *UserServiceGetUserInfoByTokenArgs) writeField1(oprot thrift.TProtocol) (err error) {\n  if err := oprot.WriteFieldBegin(\"token\", thrift.STRING, 1); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 1:token: \", p), err) }\n  if err := oprot.WriteString(string(p.Token)); err != nil {\n  return thrift.PrependError(fmt.Sprintf(\"%T.token (1) field write error: \", p), err) }\n  if err := oprot.WriteFieldEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field end error 1:token: \", p), err) }\n  return err\n}\n\nfunc (p *UserServiceGetUserInfoByTokenArgs) String() string {\n  if p == nil {\n    return \"<nil>\"\n  }\n  return fmt.Sprintf(\"UserServiceGetUserInfoByTokenArgs(%+v)\", *p)\n}\n\n// Attributes:\n//  - Success\ntype UserServiceGetUserInfoByTokenResult struct {\n  Success *Result_ `thrift:\"success,0\" db:\"success\" json:\"success,omitempty\"`\n}\n\nfunc NewUserServiceGetUserInfoByTokenResult() *UserServiceGetUserInfoByTokenResult {\n  return &UserServiceGetUserInfoByTokenResult{}\n}\n\nvar UserServiceGetUserInfoByTokenResult_Success_DEFAULT *Result_\nfunc (p *UserServiceGetUserInfoByTokenResult) GetSuccess() *Result_ {\n  if !p.IsSetSuccess() {\n    return UserServiceGetUserInfoByTokenResult_Success_DEFAULT\n  }\nreturn p.Success\n}\nfunc (p *UserServiceGetUserInfoByTokenResult) IsSetSuccess() bool {\n  return p.Success != nil\n}\n\nfunc (p *UserServiceGetUserInfoByTokenResult) Read(iprot thrift.TProtocol) error {\n  if _, err := iprot.ReadStructBegin(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T read error: \", p), err)\n  }\n\n\n  for {\n    _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()\n    if err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T field %d read error: \", p, fieldId), err)\n    }\n    if fieldTypeId == thrift.STOP { break; }\n    switch fieldId {\n    case 0:\n      if fieldTypeId == thrift.STRUCT {\n        if err := p.ReadField0(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    default:\n      if err := iprot.Skip(fieldTypeId); err != nil {\n        return err\n      }\n    }\n    if err := iprot.ReadFieldEnd(); err != nil {\n      return err\n    }\n  }\n  if err := iprot.ReadStructEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T read struct end error: \", p), err)\n  }\n  return nil\n}\n\nfunc (p *UserServiceGetUserInfoByTokenResult)  ReadField0(iprot thrift.TProtocol) error {\n  p.Success = &Result_{}\n  if err := p.Success.Read(iprot); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T error reading struct: \", p.Success), err)\n  }\n  return nil\n}\n\nfunc (p *UserServiceGetUserInfoByTokenResult) Write(oprot thrift.TProtocol) error {\n  if err := oprot.WriteStructBegin(\"getUserInfoByToken_result\"); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write struct begin error: \", p), err) }\n  if p != nil {\n    if err := p.writeField0(oprot); err != nil { return err }\n  }\n  if err := oprot.WriteFieldStop(); err != nil {\n    return thrift.PrependError(\"write field stop error: \", err) }\n  if err := oprot.WriteStructEnd(); err != nil {\n    return thrift.PrependError(\"write struct stop error: \", err) }\n  return nil\n}\n\nfunc (p *UserServiceGetUserInfoByTokenResult) writeField0(oprot thrift.TProtocol) (err error) {\n  if p.IsSetSuccess() {\n    if err := oprot.WriteFieldBegin(\"success\", thrift.STRUCT, 0); err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 0:success: \", p), err) }\n    if err := p.Success.Write(oprot); err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T error writing struct: \", p.Success), err)\n    }\n    if err := oprot.WriteFieldEnd(); err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T write field end error 0:success: \", p), err) }\n  }\n  return err\n}\n\nfunc (p *UserServiceGetUserInfoByTokenResult) String() string {\n  if p == nil {\n    return \"<nil>\"\n  }\n  return fmt.Sprintf(\"UserServiceGetUserInfoByTokenResult(%+v)\", *p)\n}\n\n// Attributes:\n//  - Behavior\n//  - UserId\n//  - PropType\n//  - Incr\ntype UserServiceModifyUserInfoByIdArgs struct {\n  Behavior string `thrift:\"behavior,1\" db:\"behavior\" json:\"behavior\"`\n  UserId int32 `thrift:\"userId,2\" db:\"userId\" json:\"userId\"`\n  PropType ModifyPropType `thrift:\"propType,3\" db:\"propType\" json:\"propType\"`\n  Incr int64 `thrift:\"incr,4\" db:\"incr\" json:\"incr\"`\n}\n\nfunc NewUserServiceModifyUserInfoByIdArgs() *UserServiceModifyUserInfoByIdArgs {\n  return &UserServiceModifyUserInfoByIdArgs{}\n}\n\n\nfunc (p *UserServiceModifyUserInfoByIdArgs) GetBehavior() string {\n  return p.Behavior\n}\n\nfunc (p *UserServiceModifyUserInfoByIdArgs) GetUserId() int32 {\n  return p.UserId\n}\n\nfunc (p *UserServiceModifyUserInfoByIdArgs) GetPropType() ModifyPropType {\n  return p.PropType\n}\n\nfunc (p *UserServiceModifyUserInfoByIdArgs) GetIncr() int64 {\n  return p.Incr\n}\nfunc (p *UserServiceModifyUserInfoByIdArgs) Read(iprot thrift.TProtocol) error {\n  if _, err := iprot.ReadStructBegin(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T read error: \", p), err)\n  }\n\n\n  for {\n    _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()\n    if err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T field %d read error: \", p, fieldId), err)\n    }\n    if fieldTypeId == thrift.STOP { break; }\n    switch fieldId {\n    case 1:\n      if fieldTypeId == thrift.STRING {\n        if err := p.ReadField1(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    case 2:\n      if fieldTypeId == thrift.I32 {\n        if err := p.ReadField2(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    case 3:\n      if fieldTypeId == thrift.I32 {\n        if err := p.ReadField3(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    case 4:\n      if fieldTypeId == thrift.I64 {\n        if err := p.ReadField4(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    default:\n      if err := iprot.Skip(fieldTypeId); err != nil {\n        return err\n      }\n    }\n    if err := iprot.ReadFieldEnd(); err != nil {\n      return err\n    }\n  }\n  if err := iprot.ReadStructEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T read struct end error: \", p), err)\n  }\n  return nil\n}\n\nfunc (p *UserServiceModifyUserInfoByIdArgs)  ReadField1(iprot thrift.TProtocol) error {\n  if v, err := iprot.ReadString(); err != nil {\n  return thrift.PrependError(\"error reading field 1: \", err)\n} else {\n  p.Behavior = v\n}\n  return nil\n}\n\nfunc (p *UserServiceModifyUserInfoByIdArgs)  ReadField2(iprot thrift.TProtocol) error {\n  if v, err := iprot.ReadI32(); err != nil {\n  return thrift.PrependError(\"error reading field 2: \", err)\n} else {\n  p.UserId = v\n}\n  return nil\n}\n\nfunc (p *UserServiceModifyUserInfoByIdArgs)  ReadField3(iprot thrift.TProtocol) error {\n  if v, err := iprot.ReadI32(); err != nil {\n  return thrift.PrependError(\"error reading field 3: \", err)\n} else {\n  temp := ModifyPropType(v)\n  p.PropType = temp\n}\n  return nil\n}\n\nfunc (p *UserServiceModifyUserInfoByIdArgs)  ReadField4(iprot thrift.TProtocol) error {\n  if v, err := iprot.ReadI64(); err != nil {\n  return thrift.PrependError(\"error reading field 4: \", err)\n} else {\n  p.Incr = v\n}\n  return nil\n}\n\nfunc (p *UserServiceModifyUserInfoByIdArgs) Write(oprot thrift.TProtocol) error {\n  if err := oprot.WriteStructBegin(\"modifyUserInfoById_args\"); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write struct begin error: \", p), err) }\n  if p != nil {\n    if err := p.writeField1(oprot); err != nil { return err }\n    if err := p.writeField2(oprot); err != nil { return err }\n    if err := p.writeField3(oprot); err != nil { return err }\n    if err := p.writeField4(oprot); err != nil { return err }\n  }\n  if err := oprot.WriteFieldStop(); err != nil {\n    return thrift.PrependError(\"write field stop error: \", err) }\n  if err := oprot.WriteStructEnd(); err != nil {\n    return thrift.PrependError(\"write struct stop error: \", err) }\n  return nil\n}\n\nfunc (p *UserServiceModifyUserInfoByIdArgs) writeField1(oprot thrift.TProtocol) (err error) {\n  if err := oprot.WriteFieldBegin(\"behavior\", thrift.STRING, 1); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 1:behavior: \", p), err) }\n  if err := oprot.WriteString(string(p.Behavior)); err != nil {\n  return thrift.PrependError(fmt.Sprintf(\"%T.behavior (1) field write error: \", p), err) }\n  if err := oprot.WriteFieldEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field end error 1:behavior: \", p), err) }\n  return err\n}\n\nfunc (p *UserServiceModifyUserInfoByIdArgs) writeField2(oprot thrift.TProtocol) (err error) {\n  if err := oprot.WriteFieldBegin(\"userId\", thrift.I32, 2); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 2:userId: \", p), err) }\n  if err := oprot.WriteI32(int32(p.UserId)); err != nil {\n  return thrift.PrependError(fmt.Sprintf(\"%T.userId (2) field write error: \", p), err) }\n  if err := oprot.WriteFieldEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field end error 2:userId: \", p), err) }\n  return err\n}\n\nfunc (p *UserServiceModifyUserInfoByIdArgs) writeField3(oprot thrift.TProtocol) (err error) {\n  if err := oprot.WriteFieldBegin(\"propType\", thrift.I32, 3); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 3:propType: \", p), err) }\n  if err := oprot.WriteI32(int32(p.PropType)); err != nil {\n  return thrift.PrependError(fmt.Sprintf(\"%T.propType (3) field write error: \", p), err) }\n  if err := oprot.WriteFieldEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field end error 3:propType: \", p), err) }\n  return err\n}\n\nfunc (p *UserServiceModifyUserInfoByIdArgs) writeField4(oprot thrift.TProtocol) (err error) {\n  if err := oprot.WriteFieldBegin(\"incr\", thrift.I64, 4); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 4:incr: \", p), err) }\n  if err := oprot.WriteI64(int64(p.Incr)); err != nil {\n  return thrift.PrependError(fmt.Sprintf(\"%T.incr (4) field write error: \", p), err) }\n  if err := oprot.WriteFieldEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field end error 4:incr: \", p), err) }\n  return err\n}\n\nfunc (p *UserServiceModifyUserInfoByIdArgs) String() string {\n  if p == nil {\n    return \"<nil>\"\n  }\n  return fmt.Sprintf(\"UserServiceModifyUserInfoByIdArgs(%+v)\", *p)\n}\n\n// Attributes:\n//  - Success\ntype UserServiceModifyUserInfoByIdResult struct {\n  Success *Result_ `thrift:\"success,0\" db:\"success\" json:\"success,omitempty\"`\n}\n\nfunc NewUserServiceModifyUserInfoByIdResult() *UserServiceModifyUserInfoByIdResult {\n  return &UserServiceModifyUserInfoByIdResult{}\n}\n\nvar UserServiceModifyUserInfoByIdResult_Success_DEFAULT *Result_\nfunc (p *UserServiceModifyUserInfoByIdResult) GetSuccess() *Result_ {\n  if !p.IsSetSuccess() {\n    return UserServiceModifyUserInfoByIdResult_Success_DEFAULT\n  }\nreturn p.Success\n}\nfunc (p *UserServiceModifyUserInfoByIdResult) IsSetSuccess() bool {\n  return p.Success != nil\n}\n\nfunc (p *UserServiceModifyUserInfoByIdResult) Read(iprot thrift.TProtocol) error {\n  if _, err := iprot.ReadStructBegin(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T read error: \", p), err)\n  }\n\n\n  for {\n    _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()\n    if err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T field %d read error: \", p, fieldId), err)\n    }\n    if fieldTypeId == thrift.STOP { break; }\n    switch fieldId {\n    case 0:\n      if fieldTypeId == thrift.STRUCT {\n        if err := p.ReadField0(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    default:\n      if err := iprot.Skip(fieldTypeId); err != nil {\n        return err\n      }\n    }\n    if err := iprot.ReadFieldEnd(); err != nil {\n      return err\n    }\n  }\n  if err := iprot.ReadStructEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T read struct end error: \", p), err)\n  }\n  return nil\n}\n\nfunc (p *UserServiceModifyUserInfoByIdResult)  ReadField0(iprot thrift.TProtocol) error {\n  p.Success = &Result_{}\n  if err := p.Success.Read(iprot); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T error reading struct: \", p.Success), err)\n  }\n  return nil\n}\n\nfunc (p *UserServiceModifyUserInfoByIdResult) Write(oprot thrift.TProtocol) error {\n  if err := oprot.WriteStructBegin(\"modifyUserInfoById_result\"); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write struct begin error: \", p), err) }\n  if p != nil {\n    if err := p.writeField0(oprot); err != nil { return err }\n  }\n  if err := oprot.WriteFieldStop(); err != nil {\n    return thrift.PrependError(\"write field stop error: \", err) }\n  if err := oprot.WriteStructEnd(); err != nil {\n    return thrift.PrependError(\"write struct stop error: \", err) }\n  return nil\n}\n\nfunc (p *UserServiceModifyUserInfoByIdResult) writeField0(oprot thrift.TProtocol) (err error) {\n  if p.IsSetSuccess() {\n    if err := oprot.WriteFieldBegin(\"success\", thrift.STRUCT, 0); err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 0:success: \", p), err) }\n    if err := p.Success.Write(oprot); err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T error writing struct: \", p.Success), err)\n    }\n    if err := oprot.WriteFieldEnd(); err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T write field end error 0:success: \", p), err) }\n  }\n  return err\n}\n\nfunc (p *UserServiceModifyUserInfoByIdResult) String() string {\n  if p == nil {\n    return \"<nil>\"\n  }\n  return fmt.Sprintf(\"UserServiceModifyUserInfoByIdResult(%+v)\", *p)\n}\n\n// Attributes:\n//  - UserId\n//  - NewName_\ntype UserServiceRenameUserByIdArgs struct {\n  UserId int32 `thrift:\"userId,1\" db:\"userId\" json:\"userId\"`\n  NewName_ string `thrift:\"NewName,2\" db:\"NewName\" json:\"NewName\"`\n}\n\nfunc NewUserServiceRenameUserByIdArgs() *UserServiceRenameUserByIdArgs {\n  return &UserServiceRenameUserByIdArgs{}\n}\n\n\nfunc (p *UserServiceRenameUserByIdArgs) GetUserId() int32 {\n  return p.UserId\n}\n\nfunc (p *UserServiceRenameUserByIdArgs) GetNewName_() string {\n  return p.NewName_\n}\nfunc (p *UserServiceRenameUserByIdArgs) Read(iprot thrift.TProtocol) error {\n  if _, err := iprot.ReadStructBegin(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T read error: \", p), err)\n  }\n\n\n  for {\n    _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()\n    if err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T field %d read error: \", p, fieldId), err)\n    }\n    if fieldTypeId == thrift.STOP { break; }\n    switch fieldId {\n    case 1:\n      if fieldTypeId == thrift.I32 {\n        if err := p.ReadField1(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    case 2:\n      if fieldTypeId == thrift.STRING {\n        if err := p.ReadField2(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    default:\n      if err := iprot.Skip(fieldTypeId); err != nil {\n        return err\n      }\n    }\n    if err := iprot.ReadFieldEnd(); err != nil {\n      return err\n    }\n  }\n  if err := iprot.ReadStructEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T read struct end error: \", p), err)\n  }\n  return nil\n}\n\nfunc (p *UserServiceRenameUserByIdArgs)  ReadField1(iprot thrift.TProtocol) error {\n  if v, err := iprot.ReadI32(); err != nil {\n  return thrift.PrependError(\"error reading field 1: \", err)\n} else {\n  p.UserId = v\n}\n  return nil\n}\n\nfunc (p *UserServiceRenameUserByIdArgs)  ReadField2(iprot thrift.TProtocol) error {\n  if v, err := iprot.ReadString(); err != nil {\n  return thrift.PrependError(\"error reading field 2: \", err)\n} else {\n  p.NewName_ = v\n}\n  return nil\n}\n\nfunc (p *UserServiceRenameUserByIdArgs) Write(oprot thrift.TProtocol) error {\n  if err := oprot.WriteStructBegin(\"RenameUserById_args\"); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write struct begin error: \", p), err) }\n  if p != nil {\n    if err := p.writeField1(oprot); err != nil { return err }\n    if err := p.writeField2(oprot); err != nil { return err }\n  }\n  if err := oprot.WriteFieldStop(); err != nil {\n    return thrift.PrependError(\"write field stop error: \", err) }\n  if err := oprot.WriteStructEnd(); err != nil {\n    return thrift.PrependError(\"write struct stop error: \", err) }\n  return nil\n}\n\nfunc (p *UserServiceRenameUserByIdArgs) writeField1(oprot thrift.TProtocol) (err error) {\n  if err := oprot.WriteFieldBegin(\"userId\", thrift.I32, 1); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 1:userId: \", p), err) }\n  if err := oprot.WriteI32(int32(p.UserId)); err != nil {\n  return thrift.PrependError(fmt.Sprintf(\"%T.userId (1) field write error: \", p), err) }\n  if err := oprot.WriteFieldEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field end error 1:userId: \", p), err) }\n  return err\n}\n\nfunc (p *UserServiceRenameUserByIdArgs) writeField2(oprot thrift.TProtocol) (err error) {\n  if err := oprot.WriteFieldBegin(\"NewName\", thrift.STRING, 2); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 2:NewName: \", p), err) }\n  if err := oprot.WriteString(string(p.NewName_)); err != nil {\n  return thrift.PrependError(fmt.Sprintf(\"%T.NewName (2) field write error: \", p), err) }\n  if err := oprot.WriteFieldEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field end error 2:NewName: \", p), err) }\n  return err\n}\n\nfunc (p *UserServiceRenameUserByIdArgs) String() string {\n  if p == nil {\n    return \"<nil>\"\n  }\n  return fmt.Sprintf(\"UserServiceRenameUserByIdArgs(%+v)\", *p)\n}\n\n// Attributes:\n//  - Success\ntype UserServiceRenameUserByIdResult struct {\n  Success *Result_ `thrift:\"success,0\" db:\"success\" json:\"success,omitempty\"`\n}\n\nfunc NewUserServiceRenameUserByIdResult() *UserServiceRenameUserByIdResult {\n  return &UserServiceRenameUserByIdResult{}\n}\n\nvar UserServiceRenameUserByIdResult_Success_DEFAULT *Result_\nfunc (p *UserServiceRenameUserByIdResult) GetSuccess() *Result_ {\n  if !p.IsSetSuccess() {\n    return UserServiceRenameUserByIdResult_Success_DEFAULT\n  }\nreturn p.Success\n}\nfunc (p *UserServiceRenameUserByIdResult) IsSetSuccess() bool {\n  return p.Success != nil\n}\n\nfunc (p *UserServiceRenameUserByIdResult) Read(iprot thrift.TProtocol) error {\n  if _, err := iprot.ReadStructBegin(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T read error: \", p), err)\n  }\n\n\n  for {\n    _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()\n    if err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T field %d read error: \", p, fieldId), err)\n    }\n    if fieldTypeId == thrift.STOP { break; }\n    switch fieldId {\n    case 0:\n      if fieldTypeId == thrift.STRUCT {\n        if err := p.ReadField0(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    default:\n      if err := iprot.Skip(fieldTypeId); err != nil {\n        return err\n      }\n    }\n    if err := iprot.ReadFieldEnd(); err != nil {\n      return err\n    }\n  }\n  if err := iprot.ReadStructEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T read struct end error: \", p), err)\n  }\n  return nil\n}\n\nfunc (p *UserServiceRenameUserByIdResult)  ReadField0(iprot thrift.TProtocol) error {\n  p.Success = &Result_{}\n  if err := p.Success.Read(iprot); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T error reading struct: \", p.Success), err)\n  }\n  return nil\n}\n\nfunc (p *UserServiceRenameUserByIdResult) Write(oprot thrift.TProtocol) error {\n  if err := oprot.WriteStructBegin(\"RenameUserById_result\"); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write struct begin error: \", p), err) }\n  if p != nil {\n    if err := p.writeField0(oprot); err != nil { return err }\n  }\n  if err := oprot.WriteFieldStop(); err != nil {\n    return thrift.PrependError(\"write field stop error: \", err) }\n  if err := oprot.WriteStructEnd(); err != nil {\n    return thrift.PrependError(\"write struct stop error: \", err) }\n  return nil\n}\n\nfunc (p *UserServiceRenameUserByIdResult) writeField0(oprot thrift.TProtocol) (err error) {\n  if p.IsSetSuccess() {\n    if err := oprot.WriteFieldBegin(\"success\", thrift.STRUCT, 0); err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 0:success: \", p), err) }\n    if err := p.Success.Write(oprot); err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T error writing struct: \", p.Success), err)\n    }\n    if err := oprot.WriteFieldEnd(); err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T write field end error 0:success: \", p), err) }\n  }\n  return err\n}\n\nfunc (p *UserServiceRenameUserByIdResult) String() string {\n  if p == nil {\n    return \"<nil>\"\n  }\n  return fmt.Sprintf(\"UserServiceRenameUserByIdResult(%+v)\", *p)\n}\n\n// Attributes:\n//  - MessageType\ntype UserServiceGetMessageArgs struct {\n  MessageType string `thrift:\"messageType,1\" db:\"messageType\" json:\"messageType\"`\n}\n\nfunc NewUserServiceGetMessageArgs() *UserServiceGetMessageArgs {\n  return &UserServiceGetMessageArgs{}\n}\n\n\nfunc (p *UserServiceGetMessageArgs) GetMessageType() string {\n  return p.MessageType\n}\nfunc (p *UserServiceGetMessageArgs) Read(iprot thrift.TProtocol) error {\n  if _, err := iprot.ReadStructBegin(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T read error: \", p), err)\n  }\n\n\n  for {\n    _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()\n    if err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T field %d read error: \", p, fieldId), err)\n    }\n    if fieldTypeId == thrift.STOP { break; }\n    switch fieldId {\n    case 1:\n      if fieldTypeId == thrift.STRING {\n        if err := p.ReadField1(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    default:\n      if err := iprot.Skip(fieldTypeId); err != nil {\n        return err\n      }\n    }\n    if err := iprot.ReadFieldEnd(); err != nil {\n      return err\n    }\n  }\n  if err := iprot.ReadStructEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T read struct end error: \", p), err)\n  }\n  return nil\n}\n\nfunc (p *UserServiceGetMessageArgs)  ReadField1(iprot thrift.TProtocol) error {\n  if v, err := iprot.ReadString(); err != nil {\n  return thrift.PrependError(\"error reading field 1: \", err)\n} else {\n  p.MessageType = v\n}\n  return nil\n}\n\nfunc (p *UserServiceGetMessageArgs) Write(oprot thrift.TProtocol) error {\n  if err := oprot.WriteStructBegin(\"getMessage_args\"); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write struct begin error: \", p), err) }\n  if p != nil {\n    if err := p.writeField1(oprot); err != nil { return err }\n  }\n  if err := oprot.WriteFieldStop(); err != nil {\n    return thrift.PrependError(\"write field stop error: \", err) }\n  if err := oprot.WriteStructEnd(); err != nil {\n    return thrift.PrependError(\"write struct stop error: \", err) }\n  return nil\n}\n\nfunc (p *UserServiceGetMessageArgs) writeField1(oprot thrift.TProtocol) (err error) {\n  if err := oprot.WriteFieldBegin(\"messageType\", thrift.STRING, 1); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 1:messageType: \", p), err) }\n  if err := oprot.WriteString(string(p.MessageType)); err != nil {\n  return thrift.PrependError(fmt.Sprintf(\"%T.messageType (1) field write error: \", p), err) }\n  if err := oprot.WriteFieldEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write field end error 1:messageType: \", p), err) }\n  return err\n}\n\nfunc (p *UserServiceGetMessageArgs) String() string {\n  if p == nil {\n    return \"<nil>\"\n  }\n  return fmt.Sprintf(\"UserServiceGetMessageArgs(%+v)\", *p)\n}\n\n// Attributes:\n//  - Success\ntype UserServiceGetMessageResult struct {\n  Success *string `thrift:\"success,0\" db:\"success\" json:\"success,omitempty\"`\n}\n\nfunc NewUserServiceGetMessageResult() *UserServiceGetMessageResult {\n  return &UserServiceGetMessageResult{}\n}\n\nvar UserServiceGetMessageResult_Success_DEFAULT string\nfunc (p *UserServiceGetMessageResult) GetSuccess() string {\n  if !p.IsSetSuccess() {\n    return UserServiceGetMessageResult_Success_DEFAULT\n  }\nreturn *p.Success\n}\nfunc (p *UserServiceGetMessageResult) IsSetSuccess() bool {\n  return p.Success != nil\n}\n\nfunc (p *UserServiceGetMessageResult) Read(iprot thrift.TProtocol) error {\n  if _, err := iprot.ReadStructBegin(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T read error: \", p), err)\n  }\n\n\n  for {\n    _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()\n    if err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T field %d read error: \", p, fieldId), err)\n    }\n    if fieldTypeId == thrift.STOP { break; }\n    switch fieldId {\n    case 0:\n      if fieldTypeId == thrift.STRING {\n        if err := p.ReadField0(iprot); err != nil {\n          return err\n        }\n      } else {\n        if err := iprot.Skip(fieldTypeId); err != nil {\n          return err\n        }\n      }\n    default:\n      if err := iprot.Skip(fieldTypeId); err != nil {\n        return err\n      }\n    }\n    if err := iprot.ReadFieldEnd(); err != nil {\n      return err\n    }\n  }\n  if err := iprot.ReadStructEnd(); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T read struct end error: \", p), err)\n  }\n  return nil\n}\n\nfunc (p *UserServiceGetMessageResult)  ReadField0(iprot thrift.TProtocol) error {\n  if v, err := iprot.ReadString(); err != nil {\n  return thrift.PrependError(\"error reading field 0: \", err)\n} else {\n  p.Success = &v\n}\n  return nil\n}\n\nfunc (p *UserServiceGetMessageResult) Write(oprot thrift.TProtocol) error {\n  if err := oprot.WriteStructBegin(\"getMessage_result\"); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T write struct begin error: \", p), err) }\n  if p != nil {\n    if err := p.writeField0(oprot); err != nil { return err }\n  }\n  if err := oprot.WriteFieldStop(); err != nil {\n    return thrift.PrependError(\"write field stop error: \", err) }\n  if err := oprot.WriteStructEnd(); err != nil {\n    return thrift.PrependError(\"write struct stop error: \", err) }\n  return nil\n}\n\nfunc (p *UserServiceGetMessageResult) writeField0(oprot thrift.TProtocol) (err error) {\n  if p.IsSetSuccess() {\n    if err := oprot.WriteFieldBegin(\"success\", thrift.STRING, 0); err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T write field begin error 0:success: \", p), err) }\n    if err := oprot.WriteString(string(*p.Success)); err != nil {\n    return thrift.PrependError(fmt.Sprintf(\"%T.success (0) field write error: \", p), err) }\n    if err := oprot.WriteFieldEnd(); err != nil {\n      return thrift.PrependError(fmt.Sprintf(\"%T write field end error 0:success: \", p), err) }\n  }\n  return err\n}\n\nfunc (p *UserServiceGetMessageResult) String() string {\n  if p == nil {\n    return \"<nil>\"\n  }\n  return fmt.Sprintf(\"UserServiceGetMessageResult(%+v)\", *p)\n}\n\n\n"
  },
  {
    "path": "common/api/thrift/gen-go/rpc/user_service-remote/user_service-remote.go",
    "content": "// Autogenerated by Thrift Compiler (0.12.0)\n// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n\npackage main\n\nimport (\n        \"context\"\n        \"flag\"\n        \"fmt\"\n        \"math\"\n        \"net\"\n        \"net/url\"\n        \"os\"\n        \"strconv\"\n        \"strings\"\n        \"github.com/apache/thrift/lib/go/thrift\"\n        \"rpc\"\n)\n\n\nfunc Usage() {\n  fmt.Fprintln(os.Stderr, \"Usage of \", os.Args[0], \" [-h host:port] [-u url] [-f[ramed]] function [arg1 [arg2...]]:\")\n  flag.PrintDefaults()\n  fmt.Fprintln(os.Stderr, \"\\nFunctions:\")\n  fmt.Fprintln(os.Stderr, \"  Result createNewUser(string nickName, string avatarAuto, i64 gold)\")\n  fmt.Fprintln(os.Stderr, \"  Result createQQUser(UserInfo UserInfo)\")\n  fmt.Fprintln(os.Stderr, \"  Result getUserInfoByOpenId(string openId)\")\n  fmt.Fprintln(os.Stderr, \"  Result getUserInfoById(i32 userId)\")\n  fmt.Fprintln(os.Stderr, \"  Result getUserInfoByToken(string token)\")\n  fmt.Fprintln(os.Stderr, \"  Result modifyUserInfoById(string behavior, i32 userId, ModifyPropType propType, i64 incr)\")\n  fmt.Fprintln(os.Stderr, \"  Result RenameUserById(i32 userId, string NewName)\")\n  fmt.Fprintln(os.Stderr, \"  string getMessage(string messageType)\")\n  fmt.Fprintln(os.Stderr)\n  os.Exit(0)\n}\n\ntype httpHeaders map[string]string\n\nfunc (h httpHeaders) String() string {\n  var m map[string]string = h\n  return fmt.Sprintf(\"%s\", m)\n}\n\nfunc (h httpHeaders) Set(value string) error {\n  parts := strings.Split(value, \": \")\n  if len(parts) != 2 {\n    return fmt.Errorf(\"header should be of format 'Key: Value'\")\n  }\n  h[parts[0]] = parts[1]\n  return nil\n}\n\nfunc main() {\n  flag.Usage = Usage\n  var host string\n  var port int\n  var protocol string\n  var urlString string\n  var framed bool\n  var useHttp bool\n  headers := make(httpHeaders)\n  var parsedUrl *url.URL\n  var trans thrift.TTransport\n  _ = strconv.Atoi\n  _ = math.Abs\n  flag.Usage = Usage\n  flag.StringVar(&host, \"h\", \"localhost\", \"Specify host and port\")\n  flag.IntVar(&port, \"p\", 9090, \"Specify port\")\n  flag.StringVar(&protocol, \"P\", \"binary\", \"Specify the protocol (binary, compact, simplejson, json)\")\n  flag.StringVar(&urlString, \"u\", \"\", \"Specify the url\")\n  flag.BoolVar(&framed, \"framed\", false, \"Use framed transport\")\n  flag.BoolVar(&useHttp, \"http\", false, \"Use http\")\n  flag.Var(headers, \"H\", \"Headers to set on the http(s) request (e.g. -H \\\"Key: Value\\\")\")\n  flag.Parse()\n  \n  if len(urlString) > 0 {\n    var err error\n    parsedUrl, err = url.Parse(urlString)\n    if err != nil {\n      fmt.Fprintln(os.Stderr, \"Error parsing URL: \", err)\n      flag.Usage()\n    }\n    host = parsedUrl.Host\n    useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == \"http\" || parsedUrl.Scheme == \"https\"\n  } else if useHttp {\n    _, err := url.Parse(fmt.Sprint(\"http://\", host, \":\", port))\n    if err != nil {\n      fmt.Fprintln(os.Stderr, \"Error parsing URL: \", err)\n      flag.Usage()\n    }\n  }\n  \n  cmd := flag.Arg(0)\n  var err error\n  if useHttp {\n    trans, err = thrift.NewTHttpClient(parsedUrl.String())\n    if len(headers) > 0 {\n      httptrans := trans.(*thrift.THttpClient)\n      for key, value := range headers {\n        httptrans.SetHeader(key, value)\n      }\n    }\n  } else {\n    portStr := fmt.Sprint(port)\n    if strings.Contains(host, \":\") {\n           host, portStr, err = net.SplitHostPort(host)\n           if err != nil {\n                   fmt.Fprintln(os.Stderr, \"error with host:\", err)\n                   os.Exit(1)\n           }\n    }\n    trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))\n    if err != nil {\n      fmt.Fprintln(os.Stderr, \"error resolving address:\", err)\n      os.Exit(1)\n    }\n    if framed {\n      trans = thrift.NewTFramedTransport(trans)\n    }\n  }\n  if err != nil {\n    fmt.Fprintln(os.Stderr, \"Error creating transport\", err)\n    os.Exit(1)\n  }\n  defer trans.Close()\n  var protocolFactory thrift.TProtocolFactory\n  switch protocol {\n  case \"compact\":\n    protocolFactory = thrift.NewTCompactProtocolFactory()\n    break\n  case \"simplejson\":\n    protocolFactory = thrift.NewTSimpleJSONProtocolFactory()\n    break\n  case \"json\":\n    protocolFactory = thrift.NewTJSONProtocolFactory()\n    break\n  case \"binary\", \"\":\n    protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()\n    break\n  default:\n    fmt.Fprintln(os.Stderr, \"Invalid protocol specified: \", protocol)\n    Usage()\n    os.Exit(1)\n  }\n  iprot := protocolFactory.GetProtocol(trans)\n  oprot := protocolFactory.GetProtocol(trans)\n  client := rpc.NewUserServiceClient(thrift.NewTStandardClient(iprot, oprot))\n  if err := trans.Open(); err != nil {\n    fmt.Fprintln(os.Stderr, \"Error opening socket to \", host, \":\", port, \" \", err)\n    os.Exit(1)\n  }\n  \n  switch cmd {\n  case \"createNewUser\":\n    if flag.NArg() - 1 != 3 {\n      fmt.Fprintln(os.Stderr, \"CreateNewUser requires 3 args\")\n      flag.Usage()\n    }\n    argvalue0 := flag.Arg(1)\n    value0 := argvalue0\n    argvalue1 := flag.Arg(2)\n    value1 := argvalue1\n    argvalue2, err20 := (strconv.ParseInt(flag.Arg(3), 10, 64))\n    if err20 != nil {\n      Usage()\n      return\n    }\n    value2 := argvalue2\n    fmt.Print(client.CreateNewUser(context.Background(), value0, value1, value2))\n    fmt.Print(\"\\n\")\n    break\n  case \"createQQUser\":\n    if flag.NArg() - 1 != 1 {\n      fmt.Fprintln(os.Stderr, \"CreateQQUser requires 1 args\")\n      flag.Usage()\n    }\n    arg21 := flag.Arg(1)\n    mbTrans22 := thrift.NewTMemoryBufferLen(len(arg21))\n    defer mbTrans22.Close()\n    _, err23 := mbTrans22.WriteString(arg21)\n    if err23 != nil {\n      Usage()\n      return\n    }\n    factory24 := thrift.NewTJSONProtocolFactory()\n    jsProt25 := factory24.GetProtocol(mbTrans22)\n    argvalue0 := rpc.NewUserInfo()\n    err26 := argvalue0.Read(jsProt25)\n    if err26 != nil {\n      Usage()\n      return\n    }\n    value0 := argvalue0\n    fmt.Print(client.CreateQQUser(context.Background(), value0))\n    fmt.Print(\"\\n\")\n    break\n  case \"getUserInfoByOpenId\":\n    if flag.NArg() - 1 != 1 {\n      fmt.Fprintln(os.Stderr, \"GetUserInfoByOpenId requires 1 args\")\n      flag.Usage()\n    }\n    argvalue0 := flag.Arg(1)\n    value0 := argvalue0\n    fmt.Print(client.GetUserInfoByOpenId(context.Background(), value0))\n    fmt.Print(\"\\n\")\n    break\n  case \"getUserInfoById\":\n    if flag.NArg() - 1 != 1 {\n      fmt.Fprintln(os.Stderr, \"GetUserInfoById requires 1 args\")\n      flag.Usage()\n    }\n    tmp0, err28 := (strconv.Atoi(flag.Arg(1)))\n    if err28 != nil {\n      Usage()\n      return\n    }\n    argvalue0 := int32(tmp0)\n    value0 := argvalue0\n    fmt.Print(client.GetUserInfoById(context.Background(), value0))\n    fmt.Print(\"\\n\")\n    break\n  case \"getUserInfoByToken\":\n    if flag.NArg() - 1 != 1 {\n      fmt.Fprintln(os.Stderr, \"GetUserInfoByToken requires 1 args\")\n      flag.Usage()\n    }\n    argvalue0 := flag.Arg(1)\n    value0 := argvalue0\n    fmt.Print(client.GetUserInfoByToken(context.Background(), value0))\n    fmt.Print(\"\\n\")\n    break\n  case \"modifyUserInfoById\":\n    if flag.NArg() - 1 != 4 {\n      fmt.Fprintln(os.Stderr, \"ModifyUserInfoById requires 4 args\")\n      flag.Usage()\n    }\n    argvalue0 := flag.Arg(1)\n    value0 := argvalue0\n    tmp1, err31 := (strconv.Atoi(flag.Arg(2)))\n    if err31 != nil {\n      Usage()\n      return\n    }\n    argvalue1 := int32(tmp1)\n    value1 := argvalue1\n    tmp2, err := (strconv.Atoi(flag.Arg(3)))\n    if err != nil {\n      Usage()\n     return\n    }\n    argvalue2 := rpc.ModifyPropType(tmp2)\n    value2 := argvalue2\n    argvalue3, err32 := (strconv.ParseInt(flag.Arg(4), 10, 64))\n    if err32 != nil {\n      Usage()\n      return\n    }\n    value3 := argvalue3\n    fmt.Print(client.ModifyUserInfoById(context.Background(), value0, value1, value2, value3))\n    fmt.Print(\"\\n\")\n    break\n  case \"RenameUserById\":\n    if flag.NArg() - 1 != 2 {\n      fmt.Fprintln(os.Stderr, \"RenameUserById requires 2 args\")\n      flag.Usage()\n    }\n    tmp0, err33 := (strconv.Atoi(flag.Arg(1)))\n    if err33 != nil {\n      Usage()\n      return\n    }\n    argvalue0 := int32(tmp0)\n    value0 := argvalue0\n    argvalue1 := flag.Arg(2)\n    value1 := argvalue1\n    fmt.Print(client.RenameUserById(context.Background(), value0, value1))\n    fmt.Print(\"\\n\")\n    break\n  case \"getMessage\":\n    if flag.NArg() - 1 != 1 {\n      fmt.Fprintln(os.Stderr, \"GetMessage requires 1 args\")\n      flag.Usage()\n    }\n    argvalue0 := flag.Arg(1)\n    value0 := argvalue0\n    fmt.Print(client.GetMessage(context.Background(), value0))\n    fmt.Print(\"\\n\")\n    break\n  case \"\":\n    Usage()\n    break\n  default:\n    fmt.Fprintln(os.Stderr, \"Invalid function \", cmd)\n  }\n}\n"
  },
  {
    "path": "common/conf/account.conf",
    "content": "﻿;[dev]\n\naccount_host=127.0.0.1\naccount_port=4000\n\naccount_aes_key=bb6c59d065966e6236fcc635f88f8543\n\n;日志\nlog_path=./logs/account.log\nlog_level=debug\n\n\n;mysql mycat或mysql配置\nmysql_addr=localhost:3306\nmysql_user=root\nmysql_password=root\nmysql_db=fish\n\n;redis cluster 集群配置\nredis_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\nredis_key_prefix=fish_"
  },
  {
    "path": "common/conf/game.conf",
    "content": "﻿;[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",
    "content": "﻿;[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\nversion=20190101\n\napp_id=01673379\napp_key=c18b1b56f2f88ef423bfeadbad9a816c\nredirect_uri=http://fish.blzz.shop/qq/message"
  },
  {
    "path": "common/conf/traces.json",
    "content": "{\n  \"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]]],\n  \"202\": [[[-548, 1158], [1914, -390]], [[-548, 1158], [1914, -312]], [[-548, 1158], [1914, -234]]],\n  \"203\": [[[1914, -390], [-548, 1002]], [[1914, -390], [-548, 1080]], [[1914, -390], [-548, 1158]]],\n  \"204\": [[[1914, -312], [-548, 1002]], [[1914, -312], [-548, 1080]], [[1914, -312], [-548, 1158]]],\n  \"205\": [[[1914, -234], [-548, 1002]], [[1914, -234], [-548, 1080]], [[1914, -234], [-548, 1158]]],\n  \"206\": [[[-548, 362], [1914, 412]], [[-548, 462], [1914, 384]], [[-548, 462], [1914, 306]]],\n  \"207\": [[[-548, 384], [1914, 462]], [[-548, 304], [1914, 384]], [[-548, 384], [1914, 306]]],\n  \"208\": [[[-548, 406], [1914, 462]], [[-548, 326], [1914, 384]], [[-548, 306], [1914, 366]]],\n  \"209\": [[[1914, 462], [-548, 462]], [[1914, 462], [-548, 384]], [[1914, 462], [-548, 306]]],\n  \"210\": [[[1914, 384], [-548, 462]], [[1914, 384], [-548, 384]], [[1914, 384], [-548, 306]]],\n  \"211\": [[[1914, 306], [-548, 462]], [[1914, 306], [-548, 384]], [[1914, 306], [-548, 306]]],\n  \"212\": [[[-548, -390], [1914, 1002]], [[-548, -390], [1914, 1080]], [[-548, -624], [1914, 1158]]],\n  \"213\": [[[-548, -312], [1914, 1002]], [[-548, -312], [1914, 1080]], [[-548, -312], [1914, 1158]]],\n  \"214\": [[[-548, -234], [1914, 1002]], [[-548, -234], [1914, 1080]], [[-548, -234], [1914, 1158]]],\n  \"215\": [[[1914, 1002], [-548, -390]], [[1914, 1002], [-548, -312]], [[1914, 1002], [-548, -234]]],\n  \"216\": [[[1914, 1080], [-548, -390]], [[1914, 1080], [-548, -312]], [[1914, 1080], [-548, -234]]],\n  \"217\": [[[1914, 1158], [-548, -390]], [[1914, 1158], [-548, -312]], [[1914, 1158], [-548, -234]]],\n  \"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]]],\n  \"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]]],\n  \"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]]],\n  \"4\": [[[10, 1268], [0, 0], [2083, -500]], [[30, 1268], [0, 0], [2083, -500]]],\n  \"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]]],\n  \"6\": [[[610, 1268], [0, 0], [1283, -500]], [[710, 1268], [0, 0], [1383, -500]]],\n  \"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]]],\n  \"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]]],\n  \"9\": [[[1060, 1268], [0, 384], [1060, -500]], [[1160, 1268], [0, 384], [1160, -500]], [[1260, 1268], [0, 384], [1260, -500]]],\n  \"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]]],\n  \"101\": [[[-100, 384], [800, 1384], [566, -616], [1466, 384]], [[1466, 384], [566, -616], [800, 1384], [-100, 384]]],\n  \"102\": [[[683, 868], [1866, 284], [-500, 484], [683, -100]], [[683, -100], [-500, 484], [1866, 284], [683, 868]]],\n  \"103\": [[[-68, -38], [0, 1368], [1366, -600], [1434, 806]], [[1434, 806], [1366, -600], [0, 1368], [-68, -38]]],\n  \"104\": [[[-68, -238], [0, 1168], [1366, -800], [1434, 606]], [[1366, 606], [1366, -800], [0, 1168], [-68, -238]]],\n  \"105\": [[[483, 868], [1666, 284], [-700, 484], [483, -100]], [[483, -100], [-700, 484], [1666, 284], [483, 868]]],\n  \"106\": [[[-100, 284], [800, 1284], [566, -716], [1466, 284]], [[1466, 284], [566, -716], [800, 1284], [-100, 284]]],\n  \"107\": [[[-68, 162], [0, 1568], [1366, -400], [1434, 1006]], [[1434, 1006], [1366, -400], [0, 1568], [-68, 162]]],\n  \"108\": [[[883, 868], [2066, 284], [-300, 484], [883, -100]], [[883, -100], [-300, 484], [2066, 284], [883, 868]]],\n  \"109\": [[[-100, 484], [800, 1484], [566, -516], [1466, 484]], [[1466, 484], [566, -516], [800, 1484], [-100, 484]]],\n  \"110\": [[[-68, -38], [1200, 1368], [166, -600], [1434, 806]], [[1434, 851], [166, -600], [1200, 1368], [-68, -38]]]\n}"
  },
  {
    "path": "common/tools/aes.go",
    "content": "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) (aesTool *AesEncrypt,err error) {\n\tif len(appSecret) <16 {\n\t\terr = fmt.Errorf(\"invalid param appsecret of %s\",appSecret)\n\t\treturn\n\t}\n\taesTool = &AesEncrypt{AppSecret:appSecret}\n\treturn\n}\n\ntype AesEncrypt struct {\n\tAppSecret string\n}\n\nfunc (p *AesEncrypt) getKey() []byte {\n\tstrKey := p.AppSecret\n\tkeyLen := len(strKey)\n\tif keyLen < 16 {\n\t\tpanic(\"res key 长度不能小于16\")\n\t}\n\tarrKey := []byte(strKey)\n\tif keyLen >= 32 {\n\t\t//取前32个字节\n\t\treturn arrKey[:32]\n\t}\n\tif keyLen >= 24 {\n\t\t//取前24个字节\n\t\treturn arrKey[:24]\n\t}\n\t//取前16个字节\n\treturn arrKey[:16]\n}\n\n//加密字符串\nfunc (p *AesEncrypt) Encrypt(strMesg string) (string, error) {\n\tkey := p.getKey()\n\tvar iv = []byte(key)[:aes.BlockSize]\n\tencrypted := make([]byte, len(strMesg))\n\taesBlockEncrypter, err := aes.NewCipher(key)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\taesEncrypter := cipher.NewCFBEncrypter(aesBlockEncrypter, iv)\n\taesEncrypter.XORKeyStream(encrypted, []byte(strMesg))\n\tencodeString := fmt.Sprintf(\"%x\",encrypted)\n\t//encodeString := base64.StdEncoding.EncodeToString([]byte(encrypted))\n\treturn encodeString, nil\n}\n\n//解密字符串\nfunc (p *AesEncrypt) Decrypt(aesEncryptString string) (strDesc string, err error) {\n\tsrc, err := hex.DecodeString(aesEncryptString)\n\t//src, err := base64.StdEncoding.DecodeString(aesEncryptString)\n\tif err != nil {\n\t\treturn\n\t}\n\tdefer func() {\n\t\t//错误处理\n\t\tif e := recover(); e != nil {\n\t\t\terr = e.(error)\n\t\t}\n\t}()\n\tkey := p.getKey()\n\tvar iv = []byte(key)[:aes.BlockSize]\n\tdecrypted := make([]byte, len(src))\n\tvar aesBlockDecrypter cipher.Block\n\taesBlockDecrypter, err = aes.NewCipher([]byte(key))\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\taesDecrypter := cipher.NewCFBDecrypter(aesBlockDecrypter, iv)\n\taesDecrypter.XORKeyStream(decrypted, src)\n\treturn string(decrypted), nil\n}"
  },
  {
    "path": "common/tools/call_rpc.go",
    "content": "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\nfunc GetRpcClient(host,port string) (client *rpc.UserServiceClient, closeTransport func() error, err error) {\n\tvar transport thrift.TTransport\n\ttransport, err = thrift.NewTSocket(net.JoinHostPort(host,port))\n\tif err != nil {\n\t\terr = fmt.Errorf(\"NewTSocket failed. err: [%v]\\n\", err)\n\t\treturn\n\t}\n\n\ttransport, err = thrift.NewTBufferedTransportFactory(8192).GetTransport(transport)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"NewTransport failed. err: [%v]\\n\", err)\n\t\treturn\n\t}\n\tcloseTransport = transport.Close\n\n\tif err = transport.Open(); err != nil {\n\t\terr = fmt.Errorf(\"Transport.Open failed. err: [%v]\\n\", err)\n\t\treturn\n\t}\n\tprotocolFactory := thrift.NewTCompactProtocolFactory()\n\tiprot := protocolFactory.GetProtocol(transport)\n\toprot := protocolFactory.GetProtocol(transport)\n\tclient = rpc.NewUserServiceClient(thrift.NewTStandardClient(iprot, oprot))\n\treturn\n}"
  },
  {
    "path": "common/tools/snowFlake.go",
    "content": "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   int64 = -1 ^ (-1 << nodeBits)\n\tstepMax   int64 = -1 ^ (-1 << stepBits)\n\ttimeShift uint8 = nodeBits + stepBits\n\tnodeShift uint8 = stepBits\n)\n\nvar (\n\tEpoch int64 = 1546272000000\n)\n\ntype Node struct {\n\tmu           sync.Mutex\n\ttimestamp    int64\n\tnode         int64\n\tstep         int64\n\tGenerateChan chan int64\n\tstop         chan bool\n}\n\nfunc GenerateUid(nodeNum int64) (err error, generateChan <-chan int64) {\n\tvar node *Node\n\tif node, err = NewNode(nodeNum);err == nil {\n\t\tgenerateChan = node.GenerateChan\n\t\tgo node.run()\n\t\treturn\n\t}\n\n\treturn\n}\n\nfunc (n *Node) run() {\n\tfor {\n\t\tn.GenerateChan <- n.Generate()\n\t}\n}\n\nfunc NewNode(nodeNum int64) (*Node, error) {\n\tif nodeNum < 0 || nodeNum > nodeMax {\n\t\treturn nil, errors.New(\"Node number must be between 0 and 1023\")\n\t}\n\treturn &Node{\n\t\ttimestamp:    0,\n\t\tnode:         nodeNum,\n\t\tstep:         0,\n\t\tGenerateChan: make(chan int64),\n\t\tstop:         make(chan bool),\n\t}, nil\n}\n\nfunc (n *Node) Generate() int64 {\n\tn.mu.Lock()\n\tdefer n.mu.Unlock()\n\tnow := time.Now().UnixNano() / 1e6\n\tif n.timestamp == now {\n\t\tn.step++\n\t\tif n.step > stepMax {\n\t\t\tfor now <= n.timestamp {\n\t\t\t\tnow = time.Now().UnixNano() / 1e6\n\t\t\t}\n\t\t\tn.step = 0\n\t\t}\n\t} else {\n\t\tn.timestamp = now\n\t\tn.step = 0\n\t}\n\treturn (now-Epoch)<<timeShift | n.node<<nodeShift | n.step\n}\n"
  },
  {
    "path": "common/tools/tools.go",
    "content": "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 := md5.New()\n\tio.WriteString(h, \"crazyof.me\")\n\tio.WriteString(h, t.String())\n\tuuid = fmt.Sprintf(\"%x\", h.Sum(nil))\n\treturn\n}"
  },
  {
    "path": "game/common/config.go",
    "content": "package common\n\nvar (\n\tGameConf = &GameServerConf{}\n)\n\ntype GameServerConf struct {\n\tAccountHost string\n\tAccountPort int\n\n\tHallHost   string\n\tHallPort   int\n\tHallSecret string\n\n\tGameHost string\n\tGamePort int\n\tLogPath  string\n\tLogLevel string\n}\n"
  },
  {
    "path": "game/controllers/create_public_room.go",
    "content": "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 CreatePublicRoom(w http.ResponseWriter, r *http.Request) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tlogs.Error(\"CreatePublicRoom panic:%v \", r)\n\t\t}\n\t}()\n\t//logs.Debug(\"new request url:[%s]\",r.URL)\n\tret := make(map[string]interface{})\n\tret[\"time\"] = time.Now().Format(\"2006-01-02 15:04:05\")\n\tdefer func() {\n\t\tdata, err := json.Marshal(ret)\n\t\tif err != nil {\n\t\t\tlogs.Error(\"json marsha1 failed err:%v\", err)\n\t\t\treturn\n\t\t}\n\t\tw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\t\tif _, err := w.Write(data); err != nil {\n\t\t\tlogs.Error(\"CreateRoom err: %v\",err)\n\t\t}\n\t}()\n}\n"
  },
  {
    "path": "game/controllers/create_room.go",
    "content": "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 http.ResponseWriter, r *http.Request) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tlogs.Error(\"CreateRoom panic:%v \", r)\n\t\t}\n\t}()\n\t//logs.Debug(\"new request url:[%s]\",r.URL)\n\tret := make(map[string]interface{})\n\tret[\"time\"] = time.Now().Format(\"2006-01-02 15:04:05\")\n\tdefer func() {\n\t\tdata, err := json.Marshal(ret)\n\t\tif err != nil {\n\t\t\tlogs.Error(\"json marsha1 failed err:%v\", err)\n\t\t\treturn\n\t\t}\n\t\tw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\t\tif _, err := w.Write(data); err != nil {\n\t\t\tlogs.Error(\"CreateRoom err: %v\",err)\n\t\t}\n\t}()\n}\n"
  },
  {
    "path": "game/controllers/enter_public_room.go",
    "content": "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/common/tools\"\n\t\"fish/game/common\"\n\t\"fish/game/service\"\n\t\"fmt\"\n\t\"github.com/astaxie/beego/logs\"\n\t\"net/http\"\n\t\"strconv\"\n\t\"time\"\n)\n\nfunc EnterPublicRoom(w http.ResponseWriter, r *http.Request) {\n\tlogs.Debug(\"new request EnterPublicRoom\")\n\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tlogs.Error(\"EnterPublicRoom panic:%v \", r)\n\t\t}\n\t}()\n\taccount := r.FormValue(\"account\")\n\tif len(account) == 0 {\n\t\treturn\n\t}\n\tbaseParam := r.FormValue(\"baseParam\")\n\tif len(baseParam) == 0 {\n\t\treturn\n\t}\n\tbaseScore, err := strconv.Atoi(baseParam)\n\tif err != nil {\n\t\tlogs.Debug(\"request enterPublicRoom err invalid baseParam %v\", baseParam)\n\t\treturn\n\t}\n\tsign := r.FormValue(\"sign\")\n\tif len(sign) == 0 {\n\t\treturn\n\t}\n\ttoken := r.FormValue(\"token\")\n\tif len(token) == 0 {\n\t\treturn\n\t}\n\tt := r.FormValue(\"t\")\n\tif len(token) == 0 {\n\t\treturn\n\t}\n\tret := map[string]interface{}{\n\t\t\"errcode\": -1,\n\t\t\"errmsg\":  \"enter room failed.\",\n\t}\n\tdefer func() {\n\t\tdata, err := json.Marshal(ret)\n\t\tif err != nil {\n\t\t\tlogs.Error(\"json marsha1 failed err:%v\", err)\n\t\t\treturn\n\t\t}\n\t\tw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\t\tif _, err := w.Write(data); err != nil {\n\t\t\tlogs.Error(\"CreateRoom err: %v\", err)\n\t\t}\n\t}()\n\tif client, closeTransportHandler, err := tools.GetRpcClient(common.GameConf.AccountHost, strconv.Itoa(common.GameConf.AccountPort)); err == nil {\n\t\tdefer func() {\n\t\t\tif err := closeTransportHandler(); err != nil {\n\t\t\t\tlogs.Error(\"close rpc err: %v\", err)\n\t\t\t}\n\t\t}()\n\t\tif res, err := client.GetUserInfoByToken(context.Background(), sign); err == nil {\n\t\t\tif res.Code == rpc.ErrorCode_Success {\n\t\t\t\tuserId := service.UserId(res.UserObj.UserId)\n\t\t\t\tif token == fmt.Sprintf(\"%x\", md5.Sum([]byte(\"t\"+t))) {\n\t\t\t\t\t// todo lock 🔒\n\t\t\t\t\tvar roomId service.RoomId\n\t\t\t\t\tservice.RoomMgr.RoomLock.Lock()\n\t\t\t\t\tlogs.Info(\"EnterPublicRoom get lock...\")\n\t\t\t\t\tdefer service.RoomMgr.RoomLock.Unlock()\n\t\t\t\t\tdefer logs.Info(\"EnterPublicRoom set free lock...\")\n\t\t\t\t\tfor RoomId, RoomInfo := range service.RoomMgr.RoomsInfo {\n\t\t\t\t\t\tfor _, roomUserId := range RoomInfo.UserInfo {\n\t\t\t\t\t\t\tif userId == roomUserId {\n\t\t\t\t\t\t\t\tret = map[string]interface{}{\n\t\t\t\t\t\t\t\t\t\"errcode\": 0,\n\t\t\t\t\t\t\t\t\t\"errmsg\":  \"ok\",\n\t\t\t\t\t\t\t\t\t\"ip\":      common.GameConf.GameHost,\n\t\t\t\t\t\t\t\t\t\"port\":    common.GameConf.GamePort,\n\t\t\t\t\t\t\t\t\t\"roomId\":  RoomId,\n\t\t\t\t\t\t\t\t\t\"sign\":    sign,\n\t\t\t\t\t\t\t\t\t\"time\":    time.Now().Unix() * 1000,\n\t\t\t\t\t\t\t\t\t\"token\":   token,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif roomId == 0 && len(RoomInfo.UserInfo) < 4 && RoomInfo.BaseScore == baseScore {\n\t\t\t\t\t\t\troomId = RoomId\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif roomId == 0 { //房间全满\n\t\t\t\t\t\troomId = service.CreatePublicRoom(&service.RoomConf{\n\t\t\t\t\t\t\tBaseScore:    baseScore,\n\t\t\t\t\t\t\tMinHaveScore: service.MinHaveScore,\n\t\t\t\t\t\t\tMaxHaveScore: service.MaxHaveScore,\n\t\t\t\t\t\t\tTaxRatio:     service.TaxRatio,\n\t\t\t\t\t\t\tCreator:      userId,\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t\tcannonKindVip := map[int]int{\n\t\t\t\t\t\t0: 1,\n\t\t\t\t\t\t1: 4,\n\t\t\t\t\t\t2: 7,\n\t\t\t\t\t\t3: 10,\n\t\t\t\t\t\t4: 13,\n\t\t\t\t\t\t5: 16,\n\t\t\t\t\t\t6: 19,\n\t\t\t\t\t}\n\n\t\t\t\t\tif roomInfo, ok := service.RoomMgr.RoomsInfo[roomId]; ok {\n\t\t\t\t\t\tresChan := make(chan error)\n\t\t\t\t\t\troomInfo.HttpReqChan <- &service.HttpReqData{\n\t\t\t\t\t\t\tUserInfo: service.UserInfo{\n\t\t\t\t\t\t\t\tUserId:     userId,\n\t\t\t\t\t\t\t\tScore:      int(res.UserObj.Gems),\n\t\t\t\t\t\t\t\tName:       res.UserObj.NickName,\n\t\t\t\t\t\t\t\tReady:      false,\n\t\t\t\t\t\t\t\tSeatIndex:  0,\n\t\t\t\t\t\t\t\tVip:        int(res.UserObj.Vip),\n\t\t\t\t\t\t\t\tCannonKind: cannonKindVip[int(res.UserObj.Vip)],\n\t\t\t\t\t\t\t\tPower:      float64(res.UserObj.Power) / 1000,\n\t\t\t\t\t\t\t\tLockFishId: 0,\n\t\t\t\t\t\t\t}, ErrChan: resChan,\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttimeOut := time.After(time.Second)\n\t\t\t\t\t\tselect {\n\t\t\t\t\t\tcase <-timeOut:\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\tcase err := <-resChan:\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\tlogs.Error(\"EnterPublicRoom enter room [%d] err: %v\", roomId, err)\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\texists := false\n\t\t\t\t\t\t\t\tfor _, roomUserId := range service.RoomMgr.RoomsInfo[roomId].UserInfo {\n\t\t\t\t\t\t\t\t\tif roomUserId == userId {\n\t\t\t\t\t\t\t\t\t\texists = true\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif !exists {\n\t\t\t\t\t\t\t\t\troomInfo.UserInfo = append(service.RoomMgr.RoomsInfo[roomId].UserInfo, userId)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tret = map[string]interface{}{\n\t\t\t\t\t\t\t\t\t\"errcode\": 0,\n\t\t\t\t\t\t\t\t\t\"errmsg\":  \"ok\",\n\t\t\t\t\t\t\t\t\t\"ip\":      common.GameConf.GameHost,\n\t\t\t\t\t\t\t\t\t\"port\":    common.GameConf.GamePort,\n\t\t\t\t\t\t\t\t\t\"roomId\":  strconv.Itoa(int(roomId)),\n\t\t\t\t\t\t\t\t\t\"sign\":    sign,\n\t\t\t\t\t\t\t\t\t\"time\":    time.Now().Unix() * 1000,\n\t\t\t\t\t\t\t\t\t\"token\":   token,\n\t\t\t\t\t\t\t\t\t\"mark\":    1,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tlogs.Error(\"EnterPublicRoom check token err\")\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tlogs.Error(\"get UserInfo by token err: %v\", err)\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "game/controllers/enter_room.go",
    "content": "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 http.ResponseWriter, r *http.Request) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tlogs.Error(\"EnterRoom panic:%v \", r)\n\t\t}\n\t}()\n\t//logs.Debug(\"new request url:[%s]\",r.URL)\n\tret := make(map[string]interface{})\n\tret[\"time\"] = time.Now().Format(\"2006-01-02 15:04:05\")\n\tdefer func() {\n\t\tdata, err := json.Marshal(ret)\n\t\tif err != nil {\n\t\t\tlogs.Error(\"json marsha1 failed err:%v\", err)\n\t\t\treturn\n\t\t}\n\t\tw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\t\tif _, err := w.Write(data); err != nil {\n\t\t\tlogs.Error(\"CreateRoom err: %v\",err)\n\t\t}\n\t}()\n}\n"
  },
  {
    "path": "game/controllers/get_server_info.go",
    "content": "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 GetServerInfo(w http.ResponseWriter, r *http.Request) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tlogs.Error(\"GetServerInfo panic:%v \", r)\n\t\t}\n\t}()\n\t//logs.Debug(\"new request url:[%s]\",r.URL)\n\tret := make(map[string]interface{})\n\tret[\"time\"] = time.Now().Format(\"2006-01-02 15:04:05\")\n\tdefer func() {\n\t\tdata, err := json.Marshal(ret)\n\t\tif err != nil {\n\t\t\tlogs.Error(\"json marsha1 failed err:%v\", err)\n\t\t\treturn\n\t\t}\n\t\tw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\t\tif _, err := w.Write(data); err != nil {\n\t\t\tlogs.Error(\"CreateRoom err: %v\",err)\n\t\t}\n\t}()\n}\n"
  },
  {
    "path": "game/controllers/is_room_running.go",
    "content": "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 IsRoomRunning(w http.ResponseWriter, r *http.Request) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tlogs.Error(\"IsRoomRunning panic:%v \", r)\n\t\t}\n\t}()\n\t//logs.Debug(\"new request url:[%s]\",r.URL)\n\tret := make(map[string]interface{})\n\tret[\"time\"] = time.Now().Format(\"2006-01-02 15:04:05\")\n\tdefer func() {\n\t\tdata, err := json.Marshal(ret)\n\t\tif err != nil {\n\t\t\tlogs.Error(\"json marsha1 failed err:%v\", err)\n\t\t\treturn\n\t\t}\n\t\tw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\t\tif _, err := w.Write(data); err != nil {\n\t\t\tlogs.Error(\"CreateRoom err: %v\",err)\n\t\t}\n\t}()\n}\n"
  },
  {
    "path": "game/controllers/ping.go",
    "content": "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.ResponseWriter, r *http.Request) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tlogs.Error(\"Ping panic:%v \", r)\n\t\t}\n\t}()\n\t//logs.Debug(\"new request url:[%s]\",r.URL)\n\tret := make(map[string]interface{})\n\tret[\"time\"] = time.Now().Format(\"2006-01-02 15:04:05\")\n\tdefer func() {\n\t\tdata, err := json.Marshal(ret)\n\t\tif err != nil {\n\t\t\tlogs.Error(\"json marsha1 failed err:%v\", err)\n\t\t\treturn\n\t\t}\n\t\tw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\t\tif _, err := w.Write(data); err != nil {\n\t\t\tlogs.Error(\"CreateRoom err: %v\",err)\n\t\t}\n\t}()\n}\n"
  },
  {
    "path": "game/main/config.go",
    "content": "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\taccountConf, err := config.NewConfig(\"ini\", \"./common/conf/account.conf\")\n\tif err != nil {\n\t\tfmt.Println(\"new account config failed,err:\", err)\n\t\treturn\n\t}\n\tcommon.GameConf.AccountHost = accountConf.String(\"account_host\")\n\tif common.GameConf.AccountHost == \"\" {\n\t\treturn fmt.Errorf(\"conf err: account_host is null\")\n\t}\n\n\tcommon.GameConf.AccountPort, err = accountConf.Int(\"account_port\")\n\tif err != nil {\n\t\treturn\n\t}\n\n\thallConf, err := config.NewConfig(\"ini\", \"./common/conf/hall.conf\")\n\tif err != nil {\n\t\tfmt.Println(\"new account config failed,err:\", err)\n\t\treturn\n\t}\n\tcommon.GameConf.HallHost = hallConf.String(\"hall_host\")\n\tif common.GameConf.HallHost == \"\" {\n\t\treturn fmt.Errorf(\"conf err: account_host is null\")\n\t}\n\n\tcommon.GameConf.HallSecret = hallConf.String(\"hall_secret\")\n\tif common.GameConf.HallSecret == \"\" {\n\t\treturn fmt.Errorf(\"conf err: hall_secret is null\")\n\t}\n\n\tcommon.GameConf.HallPort, err = hallConf.Int(\"hall_port\")\n\tif err != nil {\n\t\treturn\n\t}\n\n\tconf,err := config.NewConfig(\"ini\",\"./common/conf/game.conf\")\n\tif err != nil {\n\t\tfmt.Println(\"new config failed,err:\",err)\n\t\treturn\n\t}\n\n\tcommon.GameConf.GameHost = conf.String(\"game_host\")\n\tif common.GameConf.GameHost == \"\" {\n\t\treturn fmt.Errorf(\"conf err: game_host is null\")\n\t}\n\n\tcommon.GameConf.GamePort,err = conf.Int(\"game_port\")\n\tif err != nil {\n\t\treturn\n\t}\n\n\tcommon.GameConf.LogPath = conf.String(\"log_path\")\n\tif common.GameConf.LogPath == \"\" {\n\t\treturn fmt.Errorf(\"conf err: log_path is null\")\n\t}\n\n\tcommon.GameConf.LogLevel = conf.String(\"log_level\")\n\tif common.GameConf.LogLevel == \"\" {\n\t\treturn fmt.Errorf(\"conf err: log_level is null\")\n\t}\n\treturn\n}"
  },
  {
    "path": "game/main/init.go",
    "content": "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-driver/mysql\"\n)\n\nfunc conversionLogLevel(logLevel string) int {\n\tswitch logLevel {\n\tcase \"debug\":\n\t\treturn logs.LevelDebug\n\tcase \"warn\":\n\t\treturn logs.LevelWarn\n\tcase \"info\":\n\t\treturn logs.LevelInfo\n\tcase \"trace\":\n\t\treturn logs.LevelTrace\n\t}\n\treturn logs.LevelDebug\n}\n\nfunc initLogger() (err error) {\n\tconfig := make(map[string]interface{})\n\tconfig[\"filename\"] = common.GameConf.LogPath\n\tconfig[\"level\"] = conversionLogLevel(common.GameConf.LogLevel)\n\n\tconfigStr, err := json.Marshal(config)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = logs.SetLogger(logs.AdapterFile, string(configStr))\n\treturn\n}\n\nfunc initSec() (err error) {\n\terr = initLogger()\n\tif err != nil {\n\t\treturn\n\t}\n\treturn\n}\n"
  },
  {
    "path": "game/main/main.go",
    "content": "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\"github.com/astaxie/beego/logs\"\n\t\"io/ioutil\"\n\t\"net/http\"\n\t\"net/url\"\n\t\"strconv\"\n\t\"time\"\n)\n\nfunc main() {\n\terr := service.LoadTraceFile(\"./common/conf/traces.json\")\n\tif err != nil {\n\t\tlogs.Error(\"LoadTraceFile err: %v\", err)\n\t\treturn\n\t}\n\tfmt.Println(\"run\")\n\terr = initConf()\n\tif err != nil {\n\t\tlogs.Error(\"init conf err: %v\", err)\n\t\treturn\n\t}\n\tlogs.Debug(\"init config succ\")\n\n\terr = initSec()\n\tif err != nil {\n\t\tlogs.Error(\"init sec err: %v\", err)\n\t\treturn\n\t}\n\tlogs.Debug(\"initSec succ\")\n\n\tvar addr = flag.String(\"addr\", fmt.Sprintf(\":%d\", common.GameConf.GamePort), \"http service address\")\n\n\tlogs.Debug(\"game server listen port %v\", *addr)\n\n\tgo func() {\n\t\theartBeatTicker := time.NewTicker(time.Second * 2)\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-heartBeatTicker.C:\n\t\t\t\tparams := url.Values{}\n\n\t\t\t\tUrl, err := url.Parse(fmt.Sprintf(\"http://%s:%d/register_game_server\", common.GameConf.HallHost, common.GameConf.HallPort))\n\t\t\t\tif err != nil {\n\t\t\t\t\tpanic(err.Error())\n\t\t\t\t}\n\t\t\t\tparams.Set(\"gameHost\", common.GameConf.GameHost)\n\t\t\t\tparams.Set(\"gamePort\", strconv.Itoa(common.GameConf.GamePort))\n\t\t\t\tt := time.Now().Unix()\n\t\t\t\tparams.Set(\"t\", strconv.Itoa(int(t)))\n\t\t\t\tsign := fmt.Sprintf(\"%x\", md5.Sum([]byte(common.GameConf.HallSecret+strconv.Itoa(int(t)))))\n\t\t\t\tparams.Set(\"sign\", sign)\n\n\t\t\t\tservice.RoomMgr.RoomLock.Lock()\n\t\t\t\tparams.Set(\"load\", strconv.Itoa(len(service.RoomMgr.RoomsInfo))) //只传房间数，因为游戏服务器总是优先填满不满员的房间\n\n\t\t\t\tservice.RoomMgr.RoomLock.Unlock()\n\n\t\t\t\tUrl.RawQuery = params.Encode()\n\t\t\t\turlPath := Url.String()\n\t\t\t\tresp, err := http.Get(urlPath)\n\t\t\t\ts, err := ioutil.ReadAll(resp.Body)\n\t\t\t\tif string(s) != \"success\" {\n\t\t\t\t\tlogs.Info(\"register game server response:\", string(s))\n\t\t\t\t}\n\t\t\t\t_ = resp.Body.Close()\n\t\t\t}\n\t\t}\n\t}()\n\terr = http.ListenAndServe(*addr, nil)\n\tif err != nil {\n\t\tlogs.Error(\"ListenAndServe err: %v\", err)\n\t}\n}\n"
  },
  {
    "path": "game/router/router.go",
    "content": "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(\"/get_server_info\", controllers.GetServerInfo)\n\n\thttp.HandleFunc(\"/create_room\", controllers.CreateRoom)\n\thttp.HandleFunc(\"/create_public_room\", controllers.CreatePublicRoom)\n\thttp.HandleFunc(\"/enter_room\", controllers.EnterRoom)\n\thttp.HandleFunc(\"/ping\", controllers.Ping)\n\thttp.HandleFunc(\"/is_room_running\", controllers.IsRoomRunning)\n\thttp.HandleFunc(\"/enter_public_room\", controllers.EnterPublicRoom)\n\thttp.HandleFunc(\"/socket.io/\",service.ServeWs)\n}\n"
  },
  {
    "path": "game/service/client.go",
    "content": "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\"\n\t\"fish/game/common\"\n\t\"fmt\"\n\t\"github.com/astaxie/beego/logs\"\n\t\"github.com/gorilla/websocket\"\n\t\"math/rand\"\n\t\"net/http\"\n\t\"strconv\"\n\t\"strings\"\n\t\"time\"\n)\n\nconst (\n\twriteWait      = 1 * time.Second\n\tpongWait       = 60 * time.Second\n\tpingPeriod     = (pongWait * 9) / 10\n\tmaxMessageSize = 512\n)\n\nvar (\n\tnewline = []byte{'\\n'}\n\tspace   = []byte{' '}\n)\n\nvar upgrader = websocket.Upgrader{\n\tReadBufferSize:  1024,\n\tWriteBufferSize: 1024,\n\tCheckOrigin:     func(r *http.Request) bool { return true }, //不验证origin\n}\n\ntype Client struct {\n\tconn      *websocket.Conn\n\tUserInfo  *UserInfo\n\tRoom      *room\n\tmsgChan   chan []byte\n\tcloseChan chan bool\n}\n\ntype UserId int64\n\ntype UserInfo struct {\n\tUserId          UserId  `json:\"userId\"`\n\tScore           int     `json:\"-\"`\n\tBill            int     `json:\"-\"` //账单\n\tConversionScore float64 `json:\"score\"`\n\tName            string  `json:\"name\"`\n\tReady           bool    `json:\"ready\"`\n\tSeatIndex       int     `json:\"seatIndex\"`\n\tVip             int     `json:\"vip\"`\n\tCannonKind      int     `json:\"cannonKind\"`\n\tPower           float64 `json:\"power\"`\n\tLockFishId      FishId  `json:\"lockFishId\"`\n\tOnline          bool    `json:\"online\"`\n\tclient          *Client `json:\"-\"`\n\tIp              string  `json:\"ip\"`\n}\n\ntype BulletId string\ntype Bullet struct {\n\tUserId     UserId   `json:\"userId\"`\n\tChairId    int      `json:\"chairId\"`\n\tBulletKind int      `json:\"bulletKind\"`\n\tBulletId   BulletId `json:\"bulletId\"`\n\tAngle      float64  `json:\"angle\"`\n\tSign       string   `json:\"sign\"`\n\tLockFishId FishId   `json:\"lockFishId\"`\n}\ntype catchFishReq struct {\n\tBulletId BulletId `json:\"bulletId\"`\n\tFishId   FishId   `json:\"fishId\"`\n}\n\nfunc (c *Client) sendMsg(msg []byte) {\n\tif c.UserInfo != nil {\n\t\t//logs.Debug(\"user [%v] send msg %v\", c.UserInfo.UserId, string(msg))\n\t}\n\tc.msgChan <- msg //为什么此处不担心发送数据到一个已关闭的chan？  因为channel没有手动关闭而是交给gc处理  :)\n}\n\nfunc (c *Client) sendToClient(data []interface{}) {\n\tif dataByte, err := json.Marshal(data); err != nil {\n\t\tlogs.Error(\"broadcast [%v] json marshal err :%v \", data, err)\n\t} else {\n\t\tdataByte = append([]byte{'4', '2'}, dataByte...)\n\t\tc.sendMsg(dataByte)\n\t}\n}\n\nfunc (c *Client) sendToOthers(data []interface{}) {\n\tif dataByte, err := json.Marshal(data); err != nil {\n\t\tlogs.Error(\"broadcast [%v] json marshal err :%v \", data, err)\n\t} else {\n\t\tdataByte = append([]byte{'4', '2'}, dataByte...)\n\t\tfor _, userInfo := range c.Room.Users {\n\t\t\tif userInfo.UserId == c.UserInfo.UserId || userInfo.client == nil {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tuserInfo.client.sendMsg(dataByte)\n\t\t}\n\t}\n}\n\nfunc (c *Client) writePump() {\n\tPingTicker := time.NewTicker(pingPeriod)\n\tdefer func() {\n\t\tPingTicker.Stop()\n\t\t//close(c.closeChan)\n\t\tRoomMgr.RoomLock.Lock()\n\t\tdefer RoomMgr.RoomLock.Unlock()\n\t\tif c.Room != nil { //客户端在房间内\n\t\t\tif _, ok := RoomMgr.RoomsInfo[c.Room.RoomId]; ok { //房间没销毁\n\t\t\t\tc.Room.ClientReqChan <- &clientReqData{c, []string{\"client_exit\"}}\n\t\t\t}\n\t\t}\n\n\t\tif c.UserInfo != nil {\n\t\t\tlogs.Info(\"user %v write goroutine exit...\", c.UserInfo.UserId)\n\t\t}\n\t}()\n\tfor {\n\t\tselect {\n\t\tcase msg := <-c.msgChan:\n\t\t\terr := c.conn.SetWriteDeadline(time.Now().Add(writeWait))\n\t\t\tif err != nil {\n\t\t\t\tlogs.Error(\"sendMsg SetWriteDeadline err, %v\", err)\n\t\t\t}\n\t\t\tw, err := c.conn.NextWriter(websocket.TextMessage)\n\t\t\tif err != nil {\n\t\t\t\tlogs.Error(\"sendMsg NextWriter err, %v\", err)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif _, err = w.Write(msg); err != nil {\n\t\t\t\tlogs.Error(\"sendMsg Write err, %v\", err)\n\t\t\t}\n\t\t\tif err = w.Close(); err != nil {\n\t\t\t\t_ = c.conn.Close()\n\t\t\t}\n\t\tcase <-PingTicker.C:\n\t\t\tc.conn.SetWriteDeadline(time.Now().Add(writeWait))\n\t\t\tif err := c.conn.WriteMessage(websocket.PingMessage, nil); err != nil {\n\t\t\t\tlogs.Debug(\"PingTicker write message err : %v\", err)\n\t\t\t\treturn\n\t\t\t}\n\t\tcase <-c.closeChan:\n\t\t\tif err := c.conn.Close(); err != nil {\n\t\t\t\tif c.UserInfo != nil {\n\t\t\t\t\tlogs.Info(\"user %v client conn close err : %v\", err)\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t}\n}\n\nfunc (c *Client) readPump() {\n\tdefer func() {\n\t\tc.conn.Close()\n\t\t//RoomMgr.RoomLock.Lock()\n\t\t//defer RoomMgr.RoomLock.Unlock()\n\t\t//if c.Room != nil { //客户端在房间内\n\t\t//\tif _, ok := RoomMgr.RoomsInfo[c.Room.RoomId]; ok { //房间没销毁\n\t\t//\t\tc.Room.ClientReqChan <- &clientReqData{c, []string{\"client_exit\"}}\n\t\t//\t}\n\t\t//}\n\t\tif c.UserInfo != nil {\n\t\t\tlogs.Info(\"user %v read goroutine exit...\", c.UserInfo.UserId)\n\t\t}\n\t}()\n\tc.conn.SetReadLimit(maxMessageSize)\n\tc.conn.SetReadDeadline(time.Now().Add(pongWait))\n\tc.conn.SetPongHandler(func(string) error { c.conn.SetReadDeadline(time.Now().Add(pongWait)); return nil })\n\tfor {\n\t\t_, message, err := c.conn.ReadMessage()\n\t\tif err != nil {\n\t\t\tif websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway, websocket.CloseAbnormalClosure) {\n\t\t\t\tif c.UserInfo != nil { //client.userInfo == nil && client.Room != nil 是因为他没有先登录房间\n\t\t\t\t\tlogs.Error(\"websocket userId [%v] UserInfo [%d] unexpected close error: %v\", c.UserInfo.UserId, &c.UserInfo, err)\n\t\t\t\t\t////todo test\n\t\t\t\t\t//if c.Room != nil {\n\t\t\t\t\t//\tlogs.Debug(\"users count %v\", len(c.Room.Users))\n\t\t\t\t\t//\tfor userId, userInfo := range c.Room.Users {\n\t\t\t\t\t//\t\tlogs.Debug(\"user id %v, name %v\", userId, userInfo.Name)\n\t\t\t\t\t//\t}\n\t\t\t\t\t//}\n\t\t\t\t} else {\n\t\t\t\t\tlogs.Error(\"websocket unexpected close error: %v\", err)\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tmessage = bytes.TrimSpace(bytes.Replace(message, newline, space, -1))\n\t\tif err != nil {\n\t\t\tif c.UserInfo != nil {\n\t\t\t\tlogs.Error(\"message unMarsha1 err, user_id[%d] err:%v\", c.UserInfo.UserId, err)\n\t\t\t} else {\n\t\t\t\tlogs.Error(\"message unMarsha1 err:%v\", err)\n\t\t\t}\n\t\t} else {\n\t\t\twsRequest(message, c)\n\t\t}\n\t}\n}\n\nfunc ServeWs(w http.ResponseWriter, r *http.Request) {\n\tconn, err := upgrader.Upgrade(w, r, nil)\n\tif err != nil {\n\t\tlogs.Error(\"upgrader err:%v\", err)\n\t\treturn\n\t}\n\tclient := &Client{conn: conn, msgChan: make(chan []byte, 100), closeChan: make(chan bool, 1), UserInfo: &UserInfo{}}\n\tlogs.Debug(\"new client...\")\n\n\tgo client.readPump()\n\tgo client.writePump()\n\n\tif msg, err := json.Marshal(map[string]interface{}{\n\t\t\"pingInterval\": 25000,\n\t\t\"pingTimeout\":  5000,\n\t\t\"sid\":          \"1JDAUJeOA81mbc00AAAA\",\n\t\t\"upgrades\":     make([]int, 0),\n\t}); err != nil {\n\t\tlogs.Error(\"new client send msg err : %v\", err)\n\t} else {\n\t\tclient.sendMsg(append([]byte{'0'}, msg...))\n\t\tclient.sendMsg(append([]byte{'4', '0'}, ))\n\t}\n}\n\nfunc (c *Client) Fire(bullet *Bullet) {\n\tif bullet.BulletKind == 22 { //激光炮\n\t\t// todo 激光炮\n\t\tc.UserInfo.Power = 0\n\t\tc.sendToOthers([]interface{}{\n\t\t\t\"user_fire_Reply\",\n\t\t\tbullet,\n\t\t})\n\t\treturn\n\t}\n\tc.Room.AliveBullet[bullet.BulletId] = bullet\n\tc.sendToOthers([]interface{}{\"user_fire_Reply\", bullet})\n\n\tc.UserInfo.Score -= c.Room.Conf.BaseScore * GetBulletMulti(bullet.BulletKind)\n\tc.UserInfo.Bill -= c.Room.Conf.BaseScore * GetBulletMulti(bullet.BulletKind)\n\taddPower, _ := strconv.ParseFloat(fmt.Sprintf(\"%.5f\", float64(GetBulletMulti(bullet.BulletKind))/3000), 64)\n\tif c.UserInfo.Power < 1 {\n\t\tc.UserInfo.Power += addPower\n\t}\n}\n\nfunc (c *Client) catchFish(fishId FishId, bulletId BulletId) {\n\tif bullet, ok := c.Room.AliveBullet[bulletId]; ok {\n\t\tif bullet.UserId == c.UserInfo.UserId {\n\t\t\tif fish, ok := c.Room.AliveFish[fishId]; ok {\n\t\t\t\tif IsHit(fish) {\n\t\t\t\t\t//logs.Debug(\"user %v,catchFish %v\", c.UserInfo.UserId, fishId)\n\t\t\t\t\tkilledFishes := []*Fish{fish}\n\t\t\t\t\tif fish.FishKind == FishKind30 { //全屏炸弹\n\t\t\t\t\t\tkilledFishes = append(killedFishes, c.Room.getBombFish()...)\n\t\t\t\t\t} else if fish.FishKind >= FishKind23 && fish.FishKind <= FishKind26 { //一网打尽\n\t\t\t\t\t\tkilledFishes = c.Room.getAllInOne(fish)\n\t\t\t\t\t} else if fish.FishKind >= FishKind31 && fish.FishKind <= FishKind33 {\n\t\t\t\t\t\tkilledFishes = c.Room.getSameFish(fish)\n\t\t\t\t\t}\n\t\t\t\t\t//加钱\n\t\t\t\t\taddScore := 0\n\t\t\t\t\tfor _, fish := range killedFishes {\n\t\t\t\t\t\taddScore += GetFishMulti(fish) * GetBulletMulti(bullet.BulletKind) * c.Room.Conf.BaseScore\n\t\t\t\t\t}\n\t\t\t\t\t//if addScore > c.Room.Conf.BaseScore*200 { //不允许超过200倍\n\t\t\t\t\t//\tlogs.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)\n\t\t\t\t\t//\taddScore = c.Room.Conf.BaseScore * 200\n\t\t\t\t\t//}\n\t\t\t\t\tc.UserInfo.Score += addScore\n\t\t\t\t\tc.UserInfo.Bill += addScore //记账\n\t\t\t\t\t//todo %1的概率获取冰冻道具\n\t\t\t\t\trand.Seed(time.Now().UnixNano())\n\t\t\t\t\titem := \"\"\n\t\t\t\t\tif rand.Intn(100) == 0 {\n\t\t\t\t\t\titem = \"ice\"\n\t\t\t\t\t}\n\t\t\t\t\tfishes := make([]string, 0)\n\t\t\t\t\tfor _, fish := range killedFishes {\n\t\t\t\t\t\tfishes = append(fishes, strconv.Itoa(int(fish.FishId)))\n\t\t\t\t\t}\n\t\t\t\t\tcatchFishAddScore, _ := strconv.ParseFloat(fmt.Sprintf(\"%.5f\", float64(addScore)/1000), 64)\n\t\t\t\t\tcatchResult := []interface{}{\"catch_fish_reply\",\n\t\t\t\t\t\tmap[string]interface{}{\n\t\t\t\t\t\t\t\"userId\":   c.UserInfo.UserId,\n\t\t\t\t\t\t\t\"chairId\":  bullet.ChairId,\n\t\t\t\t\t\t\t\"bulletId\": bullet.BulletId,\n\t\t\t\t\t\t\t\"fishId\":   strings.Join(fishes, \",\"),\n\t\t\t\t\t\t\t\"addScore\": catchFishAddScore,\n\t\t\t\t\t\t\t\"item\":     item,\n\t\t\t\t\t\t}}\n\t\t\t\t\tc.Room.broadcast(catchResult)\n\t\t\t\t\t//logs.Debug(\"catch fish add score %v,catchFishAddScore %v\", addScore, catchFishAddScore)\n\t\t\t\t\tfor _, fish := range killedFishes {\n\t\t\t\t\t\tdelete(c.Room.AliveFish, fish.FishId)\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t//logs.Debug(\"hit fish failed...\")\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tlogs.Debug(\"user [%v] catch fish fishId [%v] not in alive fish array...\", c.UserInfo.UserId, fishId)\n\t\t\t}\n\t\t} else {\n\t\t\tlogs.Debug(\"user [%v] catch fish bullet [%v] belong to user [%v] ...\", c.UserInfo.UserId, bullet.BulletId, bullet.UserId)\n\t\t}\n\t\tdelete(c.Room.AliveBullet, bulletId)\n\t} else {\n\t\t//客户端会多传命中，愚蠢的客户端\n\t\t//logs.Debug(\"user [%v] catch fish bullet [%v] not exists ...\", c.UserInfo.UserId, bulletId)\n\t}\n}\n\nfunc (c *Client) frozenScene(startTime time.Time) { //冰冻屏幕\n\tif c.Room.FrozenEndTime.Unix() > time.Now().Unix() {\n\t\treturn\n\t}\n\tlogs.Debug(\"frozenScene\")\n\tc.Room.Status = GameStatusFrozen\n\tc.Room.Utils.StopBuildFish <- true\n\tc.Room.FrozenEndTime = startTime.Add(time.Second * 10)\n\tcutDown := c.Room.FrozenEndTime.Sub(time.Now())\n\treplyData := []interface{}{\"user_frozen_reply\", map[string]time.Duration{\"cutDownTime\": cutDown / 1e6}}\n\tc.sendToOthers(replyData)\n\tc.Room.frozenEndTimer = time.After(cutDown)\n}\n\nfunc (c *Client) exitRoom() {\n\tdelete(c.Room.Users, c.UserInfo.UserId)\n\t//todo 持久化结算\n}\n\nfunc (c *Client) clearBill() {\n\tgo func(userId UserId, bill int, roomId RoomId, power float64) {\n\t\tif client, closeTransportHandler, err := tools.GetRpcClient(common.GameConf.AccountHost, strconv.Itoa(common.GameConf.AccountPort)); err == nil {\n\t\t\tdefer func() {\n\t\t\t\tif err := closeTransportHandler(); err != nil {\n\t\t\t\t\tlogs.Error(\"close rpc err: %v\", err)\n\t\t\t\t}\n\t\t\t}()\n\t\t\tif res, err := client.ModifyUserInfoById(context.Background(), \"FISH_GAME_MODIFY\", int32(userId), rpc.ModifyPropType_gems, int64(bill)); err == nil {\n\t\t\t\tif res.Code == rpc.ErrorCode_Success {\n\t\t\t\t\tlogs.Debug(\"user [%v] clear bill success :in room [%v] fish game , add score : %v\", userId, roomId, int64(bill))\n\t\t\t\t} else {\n\t\t\t\t\tlogs.Debug(\"user [%v] clear bill failed :in room [%v] fish game , add score : %v,err code = %v\", userId, roomId, int64(bill), res.Code)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tlogs.Error(\"user [%v] clearBill [%v] err: %v\", userId, bill, err)\n\t\t\t}\n\t\t\tif res, err := client.ModifyUserInfoById(context.Background(), \"FISH_GAME_MODIFY\", int32(userId), rpc.ModifyPropType_power, int64(power)); err == nil {\n\t\t\t\tif res.Code == rpc.ErrorCode_Success {\n\t\t\t\t\tlogs.Debug(\"user [%v] clear power success :in room [%v] fish game , add power : %v\", userId, roomId, int64(power))\n\t\t\t\t} else {\n\t\t\t\t\tlogs.Debug(\"user [%v] clear power failed :in room [%v] fish game , add power : %v,err code = %v\", userId, roomId, int64(power), res.Code)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tlogs.Error(\"user [%v] clearBill [%v] err: %v\", userId, bill, err)\n\t\t\t}\n\t\t}\n\t}(c.UserInfo.UserId, c.UserInfo.Bill, c.Room.RoomId, c.UserInfo.Power*1000)\n\t// 不允许其他协程修改client，默认结算成功。如果需要确认，可以在房间加结算消息chan。\n\tc.UserInfo.Bill = 0\n}\n"
  },
  {
    "path": "game/service/define.go",
    "content": "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               3\n 6   5   4\n -------------\n*/\n\nvar (\n\tSwitchSceneTimer = 60 * 5 // 5分钟切一次场景\n\n\t//鱼阵场景\n\tSceneKind1 = 0\n\tSceneKind2 = 1\n\tSceneKind3 = 2\n\tSceneKind4 = 3\n\tSceneKind5 = 4\n\tSceneKind6 = 5\n\tSceneKind7 = 6\n\tSceneKind8 = 7\n\n\t//鱼的种类\n\tFishKind1  = 1\n\tFishKind2  = 2\n\tFishKind3  = 3\n\tFishKind4  = 4\n\tFishKind5  = 5\n\tFishKind6  = 6\n\tFishKind7  = 7\n\tFishKind8  = 8\n\tFishKind9  = 9\n\tFishKind10 = 10\n\tFishKind11 = 11\n\tFishKind12 = 12\n\tFishKind13 = 13\n\tFishKind14 = 14\n\tFishKind15 = 15\n\tFishKind16 = 16\n\tFishKind17 = 17\n\tFishKind18 = 18\n\tFishKind19 = 19\n\tFishKind20 = 20\n\tFishKind21 = 21\n\tFishKind22 = 22\n\tFishKind23 = 23 // 一网打尽\n\tFishKind24 = 24 // 一网打尽\n\tFishKind25 = 25 // 一网打尽\n\tFishKind26 = 26 // 一网打尽\n\tFishKind27 = 27\n\tFishKind28 = 28\n\tFishKind29 = 29\n\tFishKind30 = 30 // 全屏炸弹\n\tFishKind31 = 31 // 同类炸弹\n\tFishKind32 = 32 // 同类炸弹\n\tFishKind33 = 33 // 同类炸弹\n\tFishKind34 = 34\n\tFishKind35 = 35\n\n\tFishMulti = map[int]int{\n\t\t1:  2,\n\t\t2:  2,\n\t\t3:  3,\n\t\t4:  4,\n\t\t5:  5,\n\t\t6:  5,\n\t\t7:  6,\n\t\t8:  7,\n\t\t9:  8,\n\t\t10: 9,\n\t\t11: 10,\n\t\t12: 11,\n\t\t13: 12,\n\t\t14: 18,\n\t\t15: 25,\n\t\t16: 30,\n\t\t17: 35,\n\t\t18: 40,\n\t\t19: 45,\n\t\t20: 50,\n\t\t21: 80,\n\t\t22: 100,\n\t\t23: 45, //45-150, // 一网打尽\n\t\t24: 45, //45-150, // 一网打尽\n\t\t25: 45, //45-150, // 一网打尽\n\t\t26: 45, //45-150, // 一网打尽\n\t\t27: 50,\n\t\t28: 60,\n\t\t29: 70,\n\t\t30: 100, // 全屏炸弹\n\t\t31: 110, // 同类炸弹\n\t\t32: 110, // 同类炸弹\n\t\t33: 110, // 同类炸弹\n\t\t34: 120,\n\t\t35: 200,\n\t}\n\n\tBulletKind = map[string]int{\n\t\t\"bullet_kind_normal_1\": 0,\n\t\t\"bullet_kind_normal_2\": 1,\n\t\t\"bullet_kind_normal_3\": 2,\n\t\t\"bullet_kind_vip1_1\":   3,\n\t\t\"bullet_kind_vip1_2\":   4,\n\t\t\"bullet_kind_vip1_3\":   5,\n\t\t\"bullet_kind_vip2_1\":   6,\n\t\t\"bullet_kind_vip2_2\":   7,\n\t\t\"bullet_kind_vip2_3\":   8,\n\t\t\"bullet_kind_vip3_1\":   9,\n\t\t\"bullet_kind_vip3_2\":   10,\n\t\t\"bullet_kind_vip3_3\":   11,\n\t\t\"bullet_kind_vip4_1\":   12,\n\t\t\"bullet_kind_vip4_2\":   13,\n\t\t\"bullet_kind_vip4_3\":   14,\n\t\t\"bullet_kind_vip5_1\":   15,\n\t\t\"bullet_kind_vip5_2\":   16,\n\t\t\"bullet_kind_vip5_3\":   17,\n\t\t\"bullet_kind_vip6_1\":   19,\n\t\t\"bullet_kind_vip6_2\":   20,\n\t\t\"bullet_kind_vip6_3\":   21,\n\t\t\"bullet_kind_laser\":    22,\n\t}\n\n\tBulletMulti = map[int]int{\n\t\t1:  1,\n\t\t2:  2,\n\t\t3:  3,\n\t\t4:  1,\n\t\t5:  3,\n\t\t6:  5,\n\t\t7:  1,\n\t\t8:  3,\n\t\t9:  5,\n\t\t10: 1,\n\t\t11: 3,\n\t\t12: 5,\n\t\t13: 1,\n\t\t14: 3,\n\t\t15: 5,\n\t\t16: 1,\n\t\t17: 3,\n\t\t18: 5,\n\t\t19: 1,\n\t\t20: 3,\n\t\t21: 5,\n\t\t22: 1, // 激光炮\n\t}\n)\n\nconst (\n\t//SUB_S_GAME_CONFIG             = \"SUB_S_GAME_CONFIG\"\n\t//SUB_S_FISH_TRACE              = \"SUB_S_FISH_TRACE\"\n\t//SUB_S_EXCHANGE_FISHSCORE      = \"SUB_S_FISH_TRACE\"\n\t//SUB_S_USER_FIRE               = \"SUB_S_FISH_TRACE\"\n\t//SUB_S_CATCH_FISH              = \"SUB_S_FISH_TRACE\"\n\t//SUB_S_BULLET_ION_TIMEOUT      = \"SUB_S_BULLET_ION_TIMEOUT\"\n\t//SUB_S_LOCK_TIMEOUT            = \"SUB_S_LOCK_TIMEOUT\"\n\t//SUB_S_CATCH_SWEEP_FISH        = \"SUB_S_CATCH_SWEEP_FISH\"\n\t//SUB_S_CATCH_SWEEP_FISH_RESULT = \"SUB_S_CATCH_SWEEP_FISH_RESULT\"\n\t//SUB_S_HIT_FISH_LK             = \"SUB_S_HIT_FISH_LK\"\n\t//SUB_S_SWITCH_SCENE            = \"SUB_S_SWITCH_SCENE\"\n\t//SUB_S_STOCK_OPERATE_RESULT    = 111 //库存操作\n\t//SUB_S_SCENE_END               = 112 //场景结束\n\t//SUB_S_CATCH_FISHRESULT        = 113 //捉鱼结果\n\t//SUB_S_SETTLE_FISHSCORE        = 114 //解决鱼分数\n\t//SUB_S_SWIM_SCENE              = 115 //游泳场景\n\t//SUB_S_SPECIAL_PRICE1          = 116 //特价1\n\t//SUB_S_ADD_PRICE1_SCORE        = 117 //添加价格分数\n\t//SUB_S_END_SPECIAL1            = 118 //结束特别\n\t//SUB_S_SPECIAL_PRICE2          = 119\n\t//SUB_S_UPDATE_POS              = 120\n\t//SUB_S_END_SPECIAL2            = 121\n\t//SUB_S_SPECIAL_PRICE3          = 122\n\t//SUB_S_END_SPECIAL3            = 123\n\t//SUB_S_LOCK_FISH               = 124 //锁定鱼\n\t//SUB_S_BLACK_LIST              = 125 //黑名单\n\t//SUB_S_WHITE_LIST              = 126 //白名单\n\t//SUB_S_BIGFISH_LIST            = 127 //大鱼名单\n\t//SUB_S_LINE_TRACE              = 128 //线追踪\n\t//SUB_S_SHOAL_TRACE             = 129 //浅追踪\n\n\t//基础分值，底分\n\tGameBaseScore = 1\n\t//最小携带金币\n\tMinHaveScore = 1\n\t//最大携带金币\n\tMaxHaveScore = 100\n\t//抽水比例，千分比，5代表千分之5\n\tTaxRatio = 5\n)\n\nvar pathMap = make(map[string][][][]int)\n\nfunc LoadTraceFile(path string) (err error) {\n\t_, err = os.Stat(path)\n\tif os.IsNotExist(err) {\n\t\treturn fmt.Errorf(\"file %v not exists\", path)\n\t}\n\tfile, err := os.Open(path)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer file.Close()\n\n\tvar jsonStrByte []byte\n\tfor {\n\t\tbuf := make([]byte, 1024)\n\t\treadNum, err := file.Read(buf)\n\t\tif err != nil && err != io.EOF {\n\t\t\tpanic(err)\n\t\t}\n\t\tfor i := 0; i < readNum; i++ {\n\t\t\tjsonStrByte = append(jsonStrByte, buf[i])\n\t\t}\n\t\tif 0 == readNum {\n\t\t\tbreak\n\t\t}\n\t}\n\terr = json.Unmarshal(jsonStrByte, &pathMap)\n\tif err != nil {\n\t\tfmt.Printf(\"json unmarsha1 err:%v \\n\", err)\n\t\treturn\n\t} else {\n\t\tfmt.Println(\"success\")\n\t}\n\treturn\n}\n\nfunc getPathMap(id int) [][][]int {\n\treturn pathMap[strconv.Itoa(id)]\n}\n"
  },
  {
    "path": "game/service/fish_utils.go",
    "content": "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 []*Fish\n\n\t//Lock sync.Mutex\n\tCurrentFishId    FishId\n\tBuildFishChan    chan *Fish\n\tStopBuildFish    chan bool //暂停出鱼\n\tRestartBuildFish chan bool //重新开始出鱼\n\tExit             chan bool //接收信号\n}\ntype FishId int\n\n//普通鱼\ntype Fish struct {\n\tFishKind        int       `json:\"fishKind\"`\n\tTrace           [][]int   `json:\"trace\"`\n\tSpeed           int       `json:\"speed\"`\n\tFishId          FishId    `json:\"fishId\"`\n\tActiveTime      time.Time `json:\"-\"`\n\tFrontActiveTime int64     `json:\"activeTime\"` //给客户端的时间\n}\n\n//组合鱼\ntype ArrayFish struct {\n\tFishKind  int    `json:\"fishKind\"`\n\tTraceKind int    `json:\"traceKind\"`\n\tFishId    FishId `json:\"fishId\"`\n\tSpeed     int    `json:\"speed\"`\n}\n\ntype FishArrayRet struct {\n\tFormationKind int            `json:\"formationKind\"`\n\tFishArray     [][]*ArrayFish `json:\"fishArray\"`\n\tEndTime       time.Time      `json:\"-\"`\n\tEndTimeStamp  int64          `json:\"endTime\"`\n}\n\nfunc (p *FishUtil) GenerateFishId() FishId {\n\tp.CurrentFishId++\n\treturn p.CurrentFishId\n}\n\nfunc (p *FishUtil) BuildFishTrace() {\n\tvar buildTrace = func() int {\n\t\t// 线路随机生成\n\t\tvar traceId = 101\n\t\t//var traceRandom = Math.floor(Math.random() * 1000) + 1\n\t\trand.Seed(time.Now().UnixNano())\n\t\tvar traceKind = rand.Int()\n\t\trandNum := rand.Int()\n\t\tswitch traceKind%3 + 1 {\n\t\tcase 1: // 直线 201-217\n\t\t\ttraceId = randNum%17 + 201\n\t\t\tbreak\n\t\tcase 2: // 二阶曲线 1-10\n\t\t\ttraceId = randNum%10 + 1\n\t\t\tbreak\n\t\tcase 3: // 三阶曲线 101 -110\n\t\t\ttraceId = randNum%10 + 101\n\t\t\tbreak\n\t\t}\n\t\treturn traceId\n\t}\n\n\tc1 := time.NewTicker(time.Second * 2)\n\tc2 := time.NewTicker(time.Second*10 + time.Millisecond*100)\n\tc3 := time.NewTicker(time.Second*30 + time.Millisecond*200)\n\tc4 := time.NewTicker(time.Second * 61)\n\tgo func() {\n\t\tdefer func() {\n\t\t\tlogs.Trace(\"exit utils\")\n\t\t}()\n\t\tdefer func() {\n\t\t\tc1.Stop()\n\t\t\tc2.Stop()\n\t\t\tc3.Stop()\n\t\t\tc4.Stop()\n\t\t\tclose(p.BuildFishChan)\n\t\t\tclose(p.StopBuildFish)\n\t\t\tclose(p.RestartBuildFish)\n\t\t}()\n\t\t//logs.Debug(\"utils start running ...\")\n\t\tvar buildNormalFish = func() {\n\t\t\trand.Seed(time.Now().UnixNano())\n\t\t\ttraceKind := buildTrace()\n\t\t\tfishKind := rand.Intn(15) + 1\n\t\t\ttraces := getPathMap(traceKind)\n\n\t\t\t//logs.Debug(\"add normal fish tick run\")\n\t\t\tfor i := 0; i < len(traces); i++ {\n\t\t\t\tfishId := p.GenerateFishId()\n\t\t\t\tp.AddFish(fishKind, traces[i], fishId)\n\t\t\t}\n\t\t}\n\t\tbuildNormalFish()\n\t\tfor {\n\t\t\t//logs.Error(\"for loop......\")\n\t\t\tselect {\n\t\t\tcase <-c1.C: //随机生成鱼 1-15\n\t\t\t\tbuildNormalFish()\n\t\t\tcase <-c2.C: // 16-20\n\t\t\t\t//logs.Error(\"<-c2.C in\")\n\t\t\t\trand.Seed(time.Now().UnixNano())\n\t\t\t\tfishKind := rand.Intn(5) + 16\n\t\t\t\tfishId := p.GenerateFishId()\n\t\t\t\ttraceKind := buildTrace()\n\t\t\t\ttraces := getPathMap(traceKind)\n\t\t\t\tp.AddFish(fishKind, traces[0], fishId)\n\t\t\tcase <-c3.C: // 21-34\n\t\t\t\t//logs.Error(\"<-c3.C in\")\n\t\t\t\trand.Seed(time.Now().UnixNano())\n\t\t\t\tfishKind := rand.Intn(14) + 21\n\t\t\t\tfishId := p.GenerateFishId()\n\t\t\t\ttraceKind := buildTrace()\n\t\t\t\ttraces := getPathMap(traceKind)\n\t\t\t\tp.AddFish(fishKind, traces[1], fishId)\n\n\t\t\tcase <-c4.C: // 鱼王\n\t\t\t\t//logs.Error(\"<-c4.C in\")\n\t\t\t\tfishKind := 35\n\t\t\t\tfishId := p.GenerateFishId()\n\t\t\t\trand.Seed(time.Now().UnixNano())\n\t\t\t\ttraceKind := rand.Intn(10) + 101\n\t\t\t\ttraces := getPathMap(traceKind)\n\t\t\t\tp.AddFish(fishKind, traces[1], fishId)\n\t\t\tcase <-p.StopBuildFish: //停止出鱼\n\t\t\t\tlogs.Trace(\"build util StopBuildFish...\")\n\t\t\t\tc1.Stop()\n\t\t\t\tc2.Stop()\n\t\t\t\tc3.Stop()\n\t\t\t\tc4.Stop()\n\t\t\t\t//logs.Debug(\"<-p.StopBuildFish\")\n\t\t\tcase <-p.RestartBuildFish:\n\t\t\t\tlogs.Trace(\"build util RestartBuildFish...\")\n\t\t\t\tc1 = time.NewTicker(time.Second * 2)\n\t\t\t\tc2 = time.NewTicker(time.Second*10 + time.Millisecond*100)\n\t\t\t\tc3 = time.NewTicker(time.Second*30 + time.Millisecond*200)\n\t\t\t\tc4 = time.NewTicker(time.Second * 61)\n\t\t\t\t//logs.Debug(\"<-p.RestartBuildFish\")\n\t\t\t\t//return\n\t\t\tcase <-p.Exit:\n\t\t\t\t//logs.Error(\"<-p.Exit\")\n\t\t\t\t//退出关闭资源\n\t\t\t\t//close(p.StopBuildFish)\n\t\t\t\t//close(p.RestartBuildFish)\n\t\t\t\tclose(p.Exit)\n\t\t\t\t//logs.Debug(\"<-p.Exit\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}()\n}\n\nfunc (p *FishUtil) AddFish(fishKind int, trace [][]int, fishId FishId) {\n\n\tvar speed = 6\n\tif fishId >= 35 {\n\t\tspeed = 3\n\t} else if fishId >= 30 {\n\t\tspeed = 4\n\t} else if fishId >= 20 {\n\t\tspeed = 5\n\t}\n\tp.BuildFishChan <- &Fish{\n\t\tFishKind:        fishKind,\n\t\tTrace:           trace,\n\t\tSpeed:           speed,\n\t\tFishId:          fishId,\n\t\tActiveTime:      time.Now(),\n\t\tFrontActiveTime: time.Now().UnixNano() / 1e6,\n\t}\n}\n\n//启动鱼阵\nfunc BuildFishArray() (ret *FishArrayRet) {\n\tvar fishId FishId\n\tvar generateFishId = func() FishId {\n\t\tfishId++\n\t\treturn \tfishId\n\t}\n\tvar fishArray = make([][]*ArrayFish, 0)\n\tvar duration = 0\n\t//直线鱼阵\n\tvar buildFormationLine = func() {\n\t\tduration = 60\n\t\tfishArray = append(fishArray, make([]*ArrayFish, 0))\n\t\tfishArray = append(fishArray, make([]*ArrayFish, 0))\n\t\tvar kind = 14\n\t\tfor i := 0; i < 30; i++ {\n\t\t\tkind = i/3 + 10\n\t\t\tfishArray[0] = append(fishArray[0], &ArrayFish{\n\t\t\t\tFishKind:  kind,\n\t\t\t\tTraceKind: 0,\n\t\t\t\tFishId:    generateFishId(),\n\t\t\t\tSpeed:     0,\n\t\t\t})\n\t\t\tfishArray[1] = append(fishArray[1], &ArrayFish{\n\t\t\t\tFishKind:  kind,\n\t\t\t\tTraceKind: 0,\n\t\t\t\tFishId:    generateFishId(),\n\t\t\t\tSpeed:     0,\n\t\t\t})\n\t\t}\n\t}\n\n\t//环形鱼阵\n\tvar buildCircleGroupFish = func() {\n\t\tduration = 60\n\t\tkind, fishNum := 1, 20\n\t\tfor i := 0; i < 10; i++ {\n\t\t\tkind += 2\n\t\t\tfishArray = append(fishArray, make([]*ArrayFish, 0))\n\t\t\tif i > 20 {\n\t\t\t\tfishNum = 10\n\t\t\t}\n\t\t\tfor j := 0; j < fishNum; j++ {\n\t\t\t\tfishArray[i] = append(fishArray[i], &ArrayFish{\n\t\t\t\t\tFishKind:  kind,\n\t\t\t\t\tTraceKind: 0,\n\t\t\t\t\tFishId:    generateFishId(),\n\t\t\t\t\tSpeed:     0,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n\n\t// 两个螺旋形数组\n\tvar buildSpiralGroupFish = func() {\n\t\tduration = 60\n\t\tfishArray = append(fishArray, make([]*ArrayFish, 0))\n\t\tfishArray = append(fishArray, make([]*ArrayFish, 0))\n\t\tkind := 1\n\t\tfor i := 1; i <= 30; i++ {\n\t\t\tkind = ((i-1)/10 + 1) * 5\n\t\t\tfishArray[0] = append(fishArray[0],&ArrayFish{\n\t\t\t\tFishKind:  kind,\n\t\t\t\tTraceKind: 0,\n\t\t\t\tFishId:    generateFishId(),\n\t\t\t\tSpeed:     0,\n\t\t\t})\n\t\t\tfishArray[1] = append(fishArray[1],&ArrayFish{\n\t\t\t\tFishKind:  kind,\n\t\t\t\tTraceKind: 0,\n\t\t\t\tFishId:    generateFishId(),\n\t\t\t\tSpeed:     0,\n\t\t\t})\n\t\t}\n\t}\n\tret = &FishArrayRet{}\n\tret.FormationKind = rand.Intn(3) + 1\n\t//ret.FormationKind = 1\n\tswitch ret.FormationKind {\n\tcase 1:\n\t\tbuildFormationLine()\n\tcase 2:\n\t\tbuildCircleGroupFish()\n\tcase 3:\n\t\tbuildSpiralGroupFish()\n\t}\n\tret.FishArray = fishArray\n\tret.EndTime = time.Now().Add(time.Second * time.Duration(duration))\n\tret.EndTimeStamp = ret.EndTime.Unix() * 1e3\n\treturn\n}\n\n//是否命中\nfunc IsHit(f *Fish) bool {\n\trand.Seed(time.Now().UnixNano())\n\t// todo 调整概率\n\treturn rand.Intn(GetFishMulti(f)) == 0\n\t//return rand.Intn(GetFishMulti(f)*3/5) == 0\n\t//return true\n}\n\nfunc GetFishMulti(fish *Fish) int {\n\tif multi, ok := FishMulti[fish.FishKind]; ok {\n\t\treturn multi\n\t} else {\n\t\treturn 2\n\t}\n}\n\n// 根据id取得子弹的倍数\nfunc GetBulletMulti(BulletKind int) int {\n\tif multi, ok := BulletMulti[BulletKind]; ok {\n\t\treturn multi\n\t} else {\n\t\treturn 1\n\t}\n}\n"
  },
  {
    "path": "game/service/request.go",
    "content": "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/game/common\"\n\t\"fmt\"\n\t\"github.com/astaxie/beego/logs\"\n\t\"strconv\"\n\t\"strings\"\n\t\"time\"\n)\n\ntype UserLockFishReq struct {\n\tUserId  UserId `json:\"userId\"`\n\tChairId int    `json:\"chairId\"`\n\tFishId  FishId `json:\"fishId\"`\n}\n\ntype LaserCatchReq struct {\n\tUserId  UserId `json:\"userId\"`\n\tChairId int    `json:\"chairId\"`\n\tFishes  string `json:\"fishes\"`\n\tSign    string `json:\"sign\"`\n}\n\ntype UserFireLaserReq struct {\n\tUserId     UserId  `json:\"userId\"`\n\tChairId    int     `json:\"chairId\"`\n\tBulletKind int     `json:\"bulletKind\"`\n\tBulletId   int     `json:\"bulletId\"`\n\tAngle      float64 `json:\"angle\"`\n\tSign       string  `json:\"sign\"`\n\tLockFishId FishId  `json:\"lockFishId\"`\n}\n\nfunc wsRequest(req []byte, client *Client) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tlogs.Error(\"wsRequest panic:%v \", r)\n\t\t}\n\t}()\n\tif req[0] == '4' && req[1] == '2' {\n\t\treqJson := make([]string, 0)\n\t\terr := json.Unmarshal(req[2:], &reqJson)\n\t\tif err != nil {\n\t\t\tlogs.Error(\"wsRequest json unmarshal err :%v\", err)\n\t\t\treturn\n\t\t}\n\t\tif client.Room == nil { //未登录\n\t\t\tlogs.Info(\"未登录 login msg : %v\", reqJson[0])\n\t\t\tif reqJson[0] == \"login\" {\n\t\t\t\tif len(reqJson) < 2 {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\t//if reqByteData, ok := reqJson[1].([]byte); ok {\n\t\t\t\treqData := make(map[string]string)\n\t\t\t\tif err := json.Unmarshal([]byte(reqJson[1]), &reqData); err != nil {\n\t\t\t\t\troomIdStr := reqData[\"roomId\"]\n\t\t\t\t\tif roomIdStr == \"\" { //客户端重连时roomId用的int类型。。。心累\n\t\t\t\t\t\treqDataReconnect := make(map[string]int)\n\t\t\t\t\t\tif err := json.Unmarshal([]byte(reqJson[1]), &reqDataReconnect); err != nil {\n\t\t\t\t\t\t\troomIdInt := reqDataReconnect[\"roomId\"]\n\t\t\t\t\t\t\troomIdStr = strconv.Itoa(roomIdInt)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif roomIdInt, err := strconv.Atoi(roomIdStr); err == nil {\n\t\t\t\t\t\troomId := RoomId(roomIdInt)\n\t\t\t\t\t\tRoomMgr.RoomLock.Lock()\n\t\t\t\t\t\tlogs.Info(\"login get lock...\")\n\t\t\t\t\t\tdefer RoomMgr.RoomLock.Unlock()\n\t\t\t\t\t\tdefer logs.Info(\"login set free lock...\")\n\t\t\t\t\t\tif room, ok := RoomMgr.Rooms[roomId]; ok {\n\t\t\t\t\t\t\t//if room.Status == GameStatusWaitBegin {\n\t\t\t\t\t\t\t//\troom.Status = GameStatusFree\n\t\t\t\t\t\t\t//\troom.Utils.BuildFishTrace()\n\t\t\t\t\t\t\t//}\n\t\t\t\t\t\t\tlogs.Debug(\"send succ\")\n\t\t\t\t\t\t\tclient.Room = room\n\t\t\t\t\t\t\troom.ClientReqChan <- &clientReqData{\n\t\t\t\t\t\t\t\tclient,\n\t\t\t\t\t\t\t\treqJson,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tlogs.Error(\"room %v, not exists\", roomId)\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlogs.Error(\"roomId %v err : %v\", roomIdStr, err)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t//}\n\t\t\t} else {\n\t\t\t\tlogs.Error(\"invalid act %v\", reqJson[0])\n\t\t\t}\n\t\t} else {\n\t\t\t//logs.Debug(\"send req to room [%d] succ 2\", client.Room.RoomId)\n\t\t\tclient.Room.ClientReqChan <- &clientReqData{\n\t\t\t\tclient,\n\t\t\t\treqJson,\n\t\t\t}\n\t\t}\n\t} else {\n\t\tlogs.Error(\"invalid message %v\", req)\n\t}\n}\n\n//todo 弱类型语言写的东西重构简直堪比火葬场\nfunc handleUserRequest(clientReq *clientReqData) {\n\treqJson := clientReq.reqData\n\tclient := clientReq.client\n\tif len(reqJson) > 0 {\n\t\tact := reqJson[0]\n\t\tswitch act {\n\t\tcase \"login\":\n\t\t\t//logs.Debug(\"login\")\n\t\t\tif len(reqJson) < 2 {\n\t\t\t\treturn\n\t\t\t}\n\t\t\treqData := make(map[string]interface{})\n\t\t\tif err := json.Unmarshal([]byte(reqJson[1]), &reqData); err == nil {\n\t\t\t\ttoken := reqData[\"sign\"]\n\t\t\t\tif token, ok := token.(string); ok {\n\t\t\t\t\tlogs.Debug(\"token %v\", token)\n\t\t\t\t\tif rpcClient, closeTransportHandler, err := tools.GetRpcClient(common.GameConf.AccountHost, strconv.Itoa(common.GameConf.AccountPort)); err == nil {\n\t\t\t\t\t\tdefer func() {\n\t\t\t\t\t\t\tif err := closeTransportHandler(); err != nil {\n\t\t\t\t\t\t\t\tlogs.Error(\"close rpc err: %v\", err)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}()\n\t\t\t\t\t\tif res, err := rpcClient.GetUserInfoByToken(context.Background(), token); err == nil {\n\t\t\t\t\t\t\t//logs.Debug(\"rpc res : %v\", res.Code)\n\t\t\t\t\t\t\tif res.Code == rpc.ErrorCode_Success {\n\t\t\t\t\t\t\t\tuserId := UserId(res.UserObj.UserId)\n\t\t\t\t\t\t\t\tfor _, userInfo := range client.Room.Users {\n\t\t\t\t\t\t\t\t\tif userId == userInfo.UserId {\n\t\t\t\t\t\t\t\t\t\tuserInfo.client = client\n\t\t\t\t\t\t\t\t\t\tuserInfo.Online = true\n\t\t\t\t\t\t\t\t\t\tuserInfo.Ip = \"::1\"\n\t\t\t\t\t\t\t\t\t\tclient.UserInfo = userInfo\n\t\t\t\t\t\t\t\t\t\tlogs.Debug(\"client userInfo get data...\")\n\t\t\t\t\t\t\t\t\t\tseats := make([]interface{}, 0)\n\t\t\t\t\t\t\t\t\t\tcannonKindVip := map[int]int{0: 1, 1: 4, 2: 7, 3: 10, 4: 13, 5: 16, 6: 19}\n\t\t\t\t\t\t\t\t\t\t//todo check sign\n\t\t\t\t\t\t\t\t\t\t//score, _ := strconv.ParseFloat(fmt.Sprintf(\"%.3f\", float64(userInfo.Score)/1000), 64)\n\t\t\t\t\t\t\t\t\t\tuserInfo.ConversionScore, _ = strconv.ParseFloat(fmt.Sprintf(\"%.3f\", float64(userInfo.Score)/1000), 64)\n\t\t\t\t\t\t\t\t\t\tfor _, userInfo := range client.Room.Users {\n\t\t\t\t\t\t\t\t\t\t\tseats = append(seats, map[string]interface{}{\n\t\t\t\t\t\t\t\t\t\t\t\t\"userId\":    userInfo.UserId,\n\t\t\t\t\t\t\t\t\t\t\t\t\"ip\":        \"\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"score\":     userInfo.ConversionScore,\n\t\t\t\t\t\t\t\t\t\t\t\t\"name\":      userInfo.Name,\n\t\t\t\t\t\t\t\t\t\t\t\t\"vip\":       userInfo.Vip,\n\t\t\t\t\t\t\t\t\t\t\t\t\"online\":    true,\n\t\t\t\t\t\t\t\t\t\t\t\t\"ready\":     userInfo.Ready,\n\t\t\t\t\t\t\t\t\t\t\t\t\"seatIndex\": userInfo.SeatIndex,\n\n\t\t\t\t\t\t\t\t\t\t\t\t// 正在使用哪种炮 todo 换为真实vip\n\t\t\t\t\t\t\t\t\t\t\t\t\"cannonKind\": cannonKindVip[0],\n\t\t\t\t\t\t\t\t\t\t\t\t// 能量值\n\t\t\t\t\t\t\t\t\t\t\t\t\"power\": 0,\n\t\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tclient.sendToClient([]interface{}{\n\t\t\t\t\t\t\t\t\t\t\t\"login_result\",\n\t\t\t\t\t\t\t\t\t\t\tmap[string]interface{}{\n\t\t\t\t\t\t\t\t\t\t\t\t\"errcode\": 0,\n\t\t\t\t\t\t\t\t\t\t\t\t\"errmsg\":  \"ok\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"data\": map[string]interface{}{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"roomId\":     strconv.Itoa(int(client.Room.RoomId)),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"conf\":       client.Room.Conf,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"numofgames\": 0,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"seats\":      seats,\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t\tclient.sendToOthers([]interface{}{\n\t\t\t\t\t\t\t\t\t\t\t\"new_user_comes_push\",\n\t\t\t\t\t\t\t\t\t\t\tclient.UserInfo,\n\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t\tclient.sendToClient([]interface{}{\n\t\t\t\t\t\t\t\t\t\t\t\"login_finished\",\n\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t//不用断开链接，客户端的问题导致需要保持很多无用链接。。。\n\t\t\t\t\t\t\t\tlogs.Debug(\"user need enter room\")\n\t\t\t\t\t\t\t\tclient.closeChan <- true\n\t\t\t\t\t\t\t\tclose(client.closeChan)\n\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tlogs.Error(\"account server rpc status: %v, err : %v\", res.Code, err)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tlogs.Debug(\"rpc GetUserInfoByToken err : %v\", err)\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlogs.Debug(\"get rpc [%v:%v] client err : %v\", common.GameConf.AccountHost, common.GameConf.AccountPort, err)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tlogs.Error(\"json unmarshal err : %v\", err)\n\t\t\t}\n\t\t\tclient.Room = nil\n\t\tcase \"catch_fish\":\n\t\t\tif len(reqJson) < 2 {\n\t\t\t\treturn\n\t\t\t}\n\t\t\t//42[\"catch_fish\",\"{\\\"userId\\\":101,\\\"chairId\\\":1,\\\"bulletId\\\":\\\"1_324965\\\",\\\"fishId\\\":\\\"10318923\\\",\\\"sign\\\":\\\"8bfef2b82dc7b97e4ad386ec40b83d2b\\\"}\"]\n\t\t\tcatchFishReq := catchFishReq{}\n\t\t\tif err := json.Unmarshal([]byte(reqJson[1]), &catchFishReq); err == nil {\n\t\t\t\tbulletId := catchFishReq.BulletId\n\t\t\t\tclient.catchFish(catchFishReq.FishId, bulletId)\n\t\t\t} else {\n\t\t\t\tlogs.Error(\"catch_fish req err: %v\", err)\n\t\t\t}\n\t\tcase \"ready\":\n\t\t\tif len(reqJson) < 2 {\n\t\t\t\treturn\n\t\t\t}\n\t\t\treqData := make(map[string]int)\n\t\t\tif err := json.Unmarshal([]byte(reqJson[1]), &reqData); err == nil {\n\t\t\t\tuserId := UserId(reqData[\"userId\"])\n\t\t\t\tclient.Room.Users[userId].Ready = true\n\t\t\t\tif client.Room.Status == GameStatusWaitBegin {\n\t\t\t\t\tclient.Room.Status = GameStatusFree\n\t\t\t\t\t//client.Room.begin()\n\t\t\t\t\tclient.Room.Utils.BuildFishTrace()\n\t\t\t\t}\n\t\t\t\tclient.UserInfo.Online = true\n\t\t\t\troomUsers := make([]*UserInfo, 0)\n\t\t\t\tfor i := 0; i < 4; i++ {\n\t\t\t\t\tseatHasPlayer := false\n\t\t\t\t\tfor _, userInfo := range client.Room.Users {\n\t\t\t\t\t\tif userInfo.SeatIndex == i {\n\t\t\t\t\t\t\tuserInfo.ConversionScore, err = strconv.ParseFloat(fmt.Sprintf(\"%.3f\", float64(userInfo.Score)/1000), 64)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\tlogs.Error(\"ParseFloat [%v] err %v\", userInfo.Score, err)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\troomUsers = append(roomUsers, userInfo)\n\t\t\t\t\t\t\tseatHasPlayer = true\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif !seatHasPlayer {\n\t\t\t\t\t\troomUsers = append(roomUsers, &UserInfo{\n\t\t\t\t\t\t\tSeatIndex: i,\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tclient.sendToClient([]interface{}{\n\t\t\t\t\t\"game_sync_push\",\n\t\t\t\t\tmap[string]interface{}{\n\t\t\t\t\t\t\"roomBaseScore\": client.Room.Conf.BaseScore,\n\t\t\t\t\t\t\"seats\":         roomUsers,\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t} else {\n\t\t\t\tlogs.Error(\"user req ready json unmarshal err : %v\", err)\n\t\t\t}\n\t\tcase \"user_fire\":\n\t\t\tif len(reqJson) < 2 {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tbullet := Bullet{}\n\t\t\tif err := json.Unmarshal([]byte(reqJson[1]), &bullet); err == nil {\n\t\t\t\tclient.Fire(&bullet)\n\t\t\t} else {\n\t\t\t\t// todo 没办法 客户端bulletId 传的int :(\n\t\t\t\tuserFireLaserReq := &UserFireLaserReq{}\n\t\t\t\tif err := json.Unmarshal([]byte(reqJson[1]), &userFireLaserReq); err == nil {\n\t\t\t\t\tbullet.UserId = userFireLaserReq.UserId\n\t\t\t\t\tbullet.ChairId = userFireLaserReq.ChairId\n\t\t\t\t\tbullet.BulletKind = userFireLaserReq.BulletKind\n\t\t\t\t\tbullet.BulletId = \"\"\n\t\t\t\t\tbullet.Angle = userFireLaserReq.Angle\n\t\t\t\t\tbullet.Sign = userFireLaserReq.Sign\n\t\t\t\t\tbullet.LockFishId = userFireLaserReq.LockFishId\n\t\t\t\t\tclient.UserInfo.Power = 0\n\t\t\t\t\tclient.sendToOthers([]interface{}{\n\t\t\t\t\t\t\"user_fire_Reply\",\n\t\t\t\t\t\tbullet,\n\t\t\t\t\t})\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tlogs.Error(\"user fire json err: %v\", err)\n\t\t\t}\n\t\tcase \"laser_catch_fish\":\n\t\t\tif len(reqJson) < 2 {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tlaserCatchReq := LaserCatchReq{}\n\t\t\tif err := json.Unmarshal([]byte(reqJson[1]), &laserCatchReq); err == nil {\n\t\t\t\tfishIdStrArr := strings.Split(laserCatchReq.Fishes, \"-\")\n\t\t\t\tif len(fishIdStrArr) == 0 {\n\t\t\t\t\tlogs.Debug(\"user [%v] laser_catch_fish catch zero fish...\")\n\t\t\t\t}\n\t\t\t\tkilledFishes := make([]string, 0)\n\t\t\t\taddScore := 0\n\t\t\t\tfor _, fishStr := range fishIdStrArr {\n\t\t\t\t\tif fishIdInt, err := strconv.Atoi(fishStr); err == nil {\n\t\t\t\t\t\tfishId := FishId(fishIdInt)\n\t\t\t\t\t\tif fish, ok := client.Room.AliveFish[fishId]; ok {\n\t\t\t\t\t\t\tkilledFishes = append(killedFishes, strconv.Itoa(int(fish.FishId)))\n\t\t\t\t\t\t\t//加钱\n\t\t\t\t\t\t\taddScore += GetFishMulti(fish) * GetBulletMulti(BulletKind[\"bullet_kind_laser\"]) * client.Room.Conf.BaseScore\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tlogs.Debug(\"user [%v] laser_catch_fish fishId [%v] not in alive fish array...\", client.UserInfo.UserId, fishId)\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlogs.Error(\"laser_catch_fish err : fishId [%v] err\", fishStr)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t//if addScore > client.Room.Conf.BaseScore*200 { //最大200倍\n\t\t\t\t//\taddScore = client.Room.Conf.BaseScore * 200\n\t\t\t\t//}\n\t\t\t\tclient.UserInfo.Score += addScore\n\t\t\t\tclient.UserInfo.Bill += addScore //记账\n\t\t\t\tcatchFishAddScore, _ := strconv.ParseFloat(fmt.Sprintf(\"%.5f\", float64(addScore)/1000), 64)\n\t\t\t\tclient.Room.broadcast([]interface{}{\n\t\t\t\t\t\"catch_fish_reply\",\n\t\t\t\t\tmap[string]interface{}{\n\t\t\t\t\t\t\"userId\":   laserCatchReq.UserId,\n\t\t\t\t\t\t\"chairId\":  laserCatchReq.ChairId,\n\t\t\t\t\t\t\"fishId\":   strings.Join(killedFishes, \",\"),\n\t\t\t\t\t\t\"addScore\": catchFishAddScore,\n\t\t\t\t\t\t\"isLaser\":  true,\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t} else {\n\t\t\t\tlogs.Error(\"laser_catch_fish err : %v\", err)\n\t\t\t}\n\t\tcase \"user_lock_fish\":\n\t\t\tif len(reqJson) < 2 {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tuserLockFishReq := UserLockFishReq{}\n\t\t\tif err := json.Unmarshal([]byte(reqJson[1]), &userLockFishReq); err == nil {\n\t\t\t\tclient.sendToOthers([]interface{}{\n\t\t\t\t\t\"lock_fish_reply\",\n\t\t\t\t\tuserLockFishReq,\n\t\t\t\t})\n\t\t\t}\n\t\tcase \"user_frozen\":\n\t\t\tif len(reqJson) < 2 {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tclient.frozenScene(time.Now())\n\t\tcase \"user_change_cannon\":\n\t\t\tif len(reqJson) < 2 {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tuserChangeCannonReq := make(map[string]int)\n\t\t\tif err := json.Unmarshal([]byte(reqJson[1]), &userChangeCannonReq); err == nil {\n\t\t\t\tif userChangeCannonReq[\"cannonKind\"] < 1 {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tif userChangeCannonReq[\"cannonKind\"] == BulletKind[\"bullet_kind_laser\"] {\n\t\t\t\t\tif client.UserInfo.Power < 1 {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tclient.UserInfo.CannonKind = userChangeCannonReq[\"cannonKind\"]\n\t\t\t\tclient.sendToOthers([]interface{}{\n\t\t\t\t\t\"user_change_cannon_reply\",\n\t\t\t\t\tuserChangeCannonReq,\n\t\t\t\t})\n\t\t\t}\n\t\tcase \"exit\":\n\t\t\tclient.sendToOthers([]interface{}{\n\t\t\t\t\"exit_notify_push\",\n\t\t\t\tclient.UserInfo.UserId,\n\t\t\t})\n\t\t\tjsonByte, err := json.Marshal([]string{\"exit_result\"})\n\t\t\tif err != nil {\n\t\t\t\tlogs.Error(\"game ping json marshal err,%v\", err)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tclient.sendMsg(append([]byte{'4', '2'}, jsonByte...))\n\t\t\tclient.sendMsg([]byte{'4', '1'})\n\t\t\tclientExit(client, false)\n\n\t\tcase \"dispress\":\n\t\tcase \"disconnect\":\n\t\tcase \"game_ping\":\n\t\t\tjsonByte, err := json.Marshal([]string{\"game_pong\"})\n\t\t\tif err != nil {\n\t\t\t\tlogs.Error(\"game ping json marshal err,%v\", err)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tclient.sendMsg(append([]byte{'4', '2'}, jsonByte...))\n\t\tcase \"client_exit\":\n\t\t\tif client.UserInfo.Online {\n\t\t\t\tclientExit(client, true)\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc clientExit(client *Client, closeClient bool) {\n\tlogs.Debug(\"user %v exit close client: %v ...\", client.UserInfo.UserId, closeClient)\n\tif client.UserInfo.Bill != 0 {\n\t\tclient.clearBill()\n\t}\n\tRoomMgr.RoomLock.Lock()\n\tlogs.Info(\"clientExit get lock...\")\n\tdefer RoomMgr.RoomLock.Unlock()\n\tdefer logs.Info(\"clientExit set free lock...\")\n\tclient.UserInfo.Online = false\n\troomUserIdArr := make([]UserId, 0)\n\tif roomInfo, ok := RoomMgr.RoomsInfo[client.Room.RoomId]; ok {\n\t\tfor _, roomUserId := range roomInfo.UserInfo {\n\t\t\tif roomUserId != client.UserInfo.UserId {\n\t\t\t\troomUserIdArr = append(roomUserIdArr, roomUserId)\n\t\t\t}\n\t\t}\n\t\troomInfo.UserInfo = roomUserIdArr\n\t\tdelete(client.Room.Users, client.UserInfo.UserId)\n\t\tif closeClient {\n\t\t\tclient.closeChan <- true\n\t\t\tclose(client.closeChan) //关闭channel不影响取出关闭前传送的数据，继续取将得到零值  :-)\n\t\t}\n\t\tif len(client.Room.Users) == 0 { //房间无人，消除房间\n\t\t\tdelete(RoomMgr.RoomsInfo, client.Room.RoomId)\n\t\t\tdelete(RoomMgr.Rooms, client.Room.RoomId)\n\t\t\tlogs.Debug(\"room %v is empty now ...\", client.Room.RoomId)\n\t\t\tclient.Room.Exit <- true\n\t\t\tlogs.Debug(\"send exit sign succ ...\")\n\t\t}\n\t\t//close(client.msgChan)\n\t} else {\n\t\tlogs.Error(\"exit client not in room...\")\n\t}\n}\n"
  },
  {
    "path": "game/service/room.go",
    "content": "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)\n\ntype roomMgr struct {\n\tRoomLock   sync.Mutex\n\tRoomsInfo  map[RoomId]*RoomInfo //room暴露出去的信息和channel\n\tRooms      map[RoomId]*room\n\tRoomIdChan <-chan int64\n}\n\ntype RoomInfo struct {\n\tUserInfo    []UserId\n\tHttpReqChan chan *HttpReqData\n\tBaseScore   int //差点忘了请求的房间类型要一致才能进入\n}\n\nvar (\n\tRoomMgr = &roomMgr{\n\t\tRoomLock:   sync.Mutex{},\n\t\tRoomsInfo:  make(map[RoomId]*RoomInfo),\n\t\tRooms:      make(map[RoomId]*room), //只在room的协程里操作\n\t\tRoomIdChan: make(<-chan int64),\n\t}\n)\n\nconst (\n\tGameStatusWaitBegin = iota\n\tGameStatusFree\n\tGameStatusPlay\n\tGameStatusFormation\n\tGameStatusFrozen\n)\n\ntype RoomId int64\n\ntype room struct {\n\tRoomId        RoomId\n\tActiveFish    []*Fish //待激活的鱼\n\tCreateTime    time.Time\n\tUsers         map[UserId]*UserInfo\n\tConf          *RoomConf\n\tFrozenEndTime time.Time\n\t//FormationEndTime  time.Time\n\tStatus            int\n\tAliveFish         map[FishId]*Fish\n\tAliveBullet       map[BulletId]*Bullet\n\tUtils             *FishUtil\n\tfishArrayEndTimer <-chan time.Time\n\tfrozenEndTimer    <-chan time.Time\n\tExit              chan bool\n\tClientReqChan     chan *clientReqData //todo 客户端的请求通过chan传递，省去加锁的写法.包括加入房间\n\tHttpReqChan       chan *HttpReqData\n}\n\ntype clientReqData struct {\n\tclient  *Client\n\treqData []string\n}\n\ntype HttpReqData struct {\n\tUserInfo UserInfo\n\tErrChan  chan error\n}\n\ntype RoomConf struct {\n\tBaseScore    int    `json:\"gamebasescore\"`\n\tMinHaveScore int    `json:\"minhavescore\"`\n\tMaxHaveScore int    `json:\"maxhavescore\"`\n\tTaxRatio     int    `json:\"-\"` //抽水 千分之\n\tCreator      UserId `json:\"creator\"`\n}\n\nfunc init() {\n\tif err := initGenerateUidTool(); err != nil {\n\t\tpanic(err)\n\t}\n}\n\nfunc initGenerateUidTool() (err error) {\n\tif err, RoomMgr.RoomIdChan = tools.GenerateUid(1); err != nil {\n\t\tlogs.Error(\"GenerateUid err: %v\", err)\n\t\treturn\n\t}\n\treturn\n}\n\nfunc CreatePublicRoom(roomConf *RoomConf) (roomId RoomId) {\n\t//方法外获得锁\n\troomId = RoomId(<-RoomMgr.RoomIdChan)\n\tRoomMgr.Rooms[roomId] = &room{\n\t\tRoomId:        roomId,\n\t\tActiveFish:    make([]*Fish, 0),\n\t\tCreateTime:    time.Now(),\n\t\tUsers:         make(map[UserId]*UserInfo, 4),\n\t\tConf:          roomConf,\n\t\tFrozenEndTime: time.Time{},\n\t\t//FormationEndTime: time.Time{},\n\t\tStatus:      GameStatusWaitBegin,\n\t\tAliveFish:   make(map[FishId]*Fish),\n\t\tAliveBullet: make(map[BulletId]*Bullet),\n\t\tUtils: &FishUtil{\n\t\t\t//ActiveFish: make([]*Fish, 0),\n\t\t\t//Lock:       sync.Mutex{},\n\t\t\tBuildFishChan:    make(chan *Fish, 10),\n\t\t\tStopBuildFish:    make(chan bool),    //暂停出鱼\n\t\t\tRestartBuildFish: make(chan bool),    //重新开始出鱼\n\t\t\tExit:             make(chan bool, 1), //接收信号\n\t\t},\n\t\tfishArrayEndTimer: make(<-chan time.Time),\n\t\tfrozenEndTimer:    make(<-chan time.Time),\n\t\tExit:              make(chan bool, 1),\n\t\tClientReqChan:     make(chan *clientReqData),\n\t\tHttpReqChan:       make(chan *HttpReqData),\n\t}\n\tRoomMgr.RoomsInfo[roomId] = &RoomInfo{\n\t\tUserInfo: make([]UserId, 0),\n\t\t//ClientReqChan: make(chan *clientReqData),\n\t\tHttpReqChan: RoomMgr.Rooms[roomId].HttpReqChan,\n\t\tBaseScore:   roomConf.BaseScore,\n\t}\n\n\tRoomMgr.Rooms[roomId].begin()\n\treturn\n}\n\nfunc (room *room) EnterRoom(userInfo *UserInfo) (err error) {\n\tlogs.Debug(\"user %d request enter room %v\", userInfo.UserId, room.RoomId)\n\n\tuserCount := len(room.Users)\n\tif userCount >= 4 {\n\t\tlogs.Error(\"enterRoom err: room [%v] is full\", room.RoomId)\n\t\treturn\n\t}\n\tseatIndex := -1\nout:\n\tfor i := 0; i < 4; i++ {\n\t\tfor _, roomUserInfo := range room.Users {\n\t\t\tif roomUserInfo.SeatIndex == i {\n\t\t\t\tcontinue out\n\t\t\t}\n\t\t}\n\t\tseatIndex = i\n\t\tbreak\n\t}\n\n\tif seatIndex == -1 {\n\t\treturn fmt.Errorf(\"enterRoom  roomId [%v] failed\", room.RoomId)\n\t}\n\tuserInfo.SeatIndex = seatIndex\n\troom.Users[userInfo.UserId] = userInfo\n\treturn\n}\n\nfunc (room *room) begin() {\n\tlogs.Debug(\"room %d begin\", room.RoomId)\n\tbuildNormalFishTicker := time.NewTicker(time.Second * 1)     //普通鱼每秒刷一次\n\tbuildGroupFishTicker := time.NewTicker(time.Second * 5 * 60) //鱼群\n\tflushTimeOutFishTicker := time.NewTicker(time.Second * 5)    //清理过期鱼\n\n\tgo func() {\n\t\tdefer func() {\n\t\t\tlogs.Trace(\"room %v exit...\", room.RoomId)\n\t\t\tbuildNormalFishTicker.Stop()\n\t\t\tbuildGroupFishTicker.Stop()\n\t\t\tflushTimeOutFishTicker.Stop()\n\t\t\troom.Utils.Exit <- true\n\t\t\tgo func() { //启动协程取数据，防止utils阻塞在出鱼阶段导致无法退出 :)\n\t\t\t\tfor range room.Utils.BuildFishChan {\n\t\t\t\t}\n\t\t\t}()\n\t\t\tclose(room.Exit)\n\t\t\tclose(room.HttpReqChan)\n\t\t\tclose(room.ClientReqChan)\n\n\t\t\tRoomMgr.RoomLock.Lock()\n\t\t\tlogs.Info(\"exit room goroutine get lock...\")\n\t\t\tdefer RoomMgr.RoomLock.Unlock()\n\t\t\tdefer logs.Info(\"exit room goroutine set free lock...\")\n\n\t\t\tdelete(RoomMgr.Rooms, room.RoomId)\n\t\t}()\n\t\t//defer room.Wg.Done()\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-buildNormalFishTicker.C:\n\t\t\t\troom.flushFish()\n\t\t\tcase <-buildGroupFishTicker.C:\n\t\t\t\tif room.Status != GameStatusFree {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\troom.Utils.StopBuildFish <- true\n\t\t\t\troom.AliveFish = make(map[FishId]*Fish) //清理鱼\n\t\t\t\troom.buildFormation()\n\t\t\tcase <-flushTimeOutFishTicker.C:\n\t\t\t\tnow := time.Now()\n\t\t\t\tAliveFishCheck := make(map[FishId]*Fish)\n\t\t\t\tfor _, fish := range room.AliveFish {\n\t\t\t\t\tif now.Sub(fish.ActiveTime) < 60*2*time.Second {\n\t\t\t\t\t\tAliveFishCheck[fish.FishId] = fish\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\troom.AliveFish = AliveFishCheck\n\t\t\tcase fish := <-room.Utils.BuildFishChan:\n\t\t\t\troom.ActiveFish = append(room.ActiveFish, fish)\n\t\t\tcase clientReq := <-room.ClientReqChan:\n\t\t\t\t//logs.Debug(\"room [%d] receive client message %v\", room.RoomId, clientReq.reqData)\n\t\t\t\thandleUserRequest(clientReq)\n\t\t\tcase httpReq := <-room.HttpReqChan:\n\t\t\t\thttpReq.ErrChan <- room.EnterRoom(&httpReq.UserInfo)\n\t\t\t\tclose(httpReq.ErrChan)\n\t\t\tcase <-room.Exit:\n\t\t\t\treturn\n\t\t\tcase <-room.fishArrayEndTimer:\n\t\t\t\troom.Status = GameStatusFree\n\t\t\t\t//room.AliveFish = make(map[FishId]*Fish) //清理鱼,因为时间有可能不同步，所以结束也不清理鱼\n\t\t\t\troom.Utils.RestartBuildFish <- true\n\t\t\tcase <-room.frozenEndTimer:\n\t\t\t\troom.Status = GameStatusFree\n\t\t\t\troom.Utils.RestartBuildFish <- true\n\t\t\t}\n\t\t}\n\t}()\n}\n\nfunc (room *room) flushFish() {\n\tif room.Status != GameStatusFree {\n\t\treturn\n\t}\n\tnewFish := make([]*Fish, 0)\n\tfor _, fish := range room.ActiveFish {\n\t\tif _, ok := room.AliveFish[fish.FishId]; ok {\n\t\t\tcontinue\n\t\t}\n\t\t//if len(room.AliveFish) < 30 {\n\t\troom.AliveFish[fish.FishId] = fish\n\t\tnewFish = append(newFish, fish)\n\t\t//} else {\n\t\t//\tbreak\n\t\t//}\n\t}\n\troom.ActiveFish = make([]*Fish, 0)\n\tif len(newFish) > 0 {\n\t\troom.broadcast([]interface{}{\"build_fish_reply\", newFish})\n\t}\n}\n\nfunc (room *room) buildFormation() {\n\tif room.Status != GameStatusFree {\n\t\troom.Utils.RestartBuildFish <- true\n\t\treturn\n\t}\n\troom.Status = GameStatusFormation\n\tfishArrayData := BuildFishArray()\n\tactiveTime := time.Now()\n\tfor _, fishArray := range fishArrayData.FishArray {\n\t\tfor _, arrayFish := range fishArray {\n\t\t\troom.AliveFish[arrayFish.FishId] = &Fish{\n\t\t\t\tFishId:     arrayFish.FishId,\n\t\t\t\tFishKind:   arrayFish.FishKind,\n\t\t\t\tSpeed:      0,\n\t\t\t\tActiveTime: activeTime,\n\t\t\t}\n\t\t}\n\t}\n\troom.fishArrayEndTimer = time.After(fishArrayData.EndTime.Sub(time.Now()))\n\troom.broadcast([]interface{}{\n\t\t\"build_fishArray_reply\",\n\t\tfishArrayData,\n\t})\n}\n\nfunc (room *room) getBombFish() (killedFishes []*Fish) {\n\tfor _, fish := range room.AliveFish {\n\t\tif len(killedFishes) == 20 {\n\t\t\treturn\n\t\t}\n\t\tif fish.FishKind < FishKind11 {\n\t\t\tkilledFishes = append(killedFishes, fish)\n\t\t}\n\t}\n\treturn\n}\n\n//一网打尽\nfunc (room *room) getAllInOne(oneFish *Fish) (killedFishes []*Fish) {\n\tfor _, fish := range room.AliveFish {\n\t\tif fish.FishKind >= FishKind23 && fish.FishKind <= FishKind26 {\n\t\t\tkilledFishes = append(killedFishes, fish)\n\t\t}\n\t}\n\treturn\n}\n\n//同类炸弹\nfunc (room *room) getSameFish(oneFish *Fish) (killedFishes []*Fish) {\n\tswitch oneFish.FishKind {\n\tcase FishKind31:\n\t\tfor _, fish := range room.AliveFish {\n\t\t\tif fish.FishKind == FishKind31 || fish.FishKind == FishKind12 {\n\t\t\t\tkilledFishes = append(killedFishes, fish)\n\t\t\t}\n\t\t}\n\tcase FishKind32:\n\t\tfor _, fish := range room.AliveFish {\n\t\t\tif fish.FishKind == FishKind32 || fish.FishKind == FishKind1 {\n\t\t\t\tkilledFishes = append(killedFishes, fish)\n\t\t\t}\n\t\t}\n\tcase FishKind33:\n\t\tfor _, fish := range room.AliveFish {\n\t\t\tif fish.FishKind == FishKind33 || fish.FishKind == FishKind7 {\n\t\t\t\tkilledFishes = append(killedFishes, fish)\n\t\t\t}\n\t\t}\n\t}\n\treturn\n}\n\nfunc (room *room) broadcast(data []interface{}) {\n\tif dataByte, err := json.Marshal(data); err != nil {\n\t\tlogs.Error(\"broadcast [%v] json marshal err :%v \", data, err)\n\t} else {\n\t\tdataByte = append([]byte{'4', '2'}, dataByte...)\n\t\tfor _, userInfo := range room.Users {\n\t\t\tif userInfo.client != nil {\n\t\t\t\tuserInfo.client.sendMsg(dataByte)\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "go.mod",
    "content": "module fish\n\ngo 1.12\n\nreplace (\n\tgolang.org/x/crypto v0.0.0-20181127143415-eb0de9b17e85 => github.com/golang/crypto v0.0.0-20181127143415-eb0de9b17e85\n\tgolang.org/x/net v0.0.0-20181114220301-adae6a3d119a => github.com/golang/net v0.0.0-20181114220301-adae6a3d119a\n\tgolang.org/x/sys v0.3.0 => github.com/golang/sys v0.3.0\n\tgolang.org/x/text v0.3.0 => github.com/golang/text v0.3.0\n)\n\nrequire (\n\tgit.apache.org/thrift.git v0.12.0\n\tgithub.com/apache/thrift v0.12.0\n\tgithub.com/astaxie/beego v1.11.1\n\tgithub.com/garyburd/redigo v1.6.0\n\tgithub.com/go-redis/redis v6.15.2+incompatible\n\tgithub.com/go-sql-driver/mysql v1.4.1\n\tgithub.com/golang/go v0.0.0-20190523013941-3e9d8e2e1bb9 // indirect\n\tgithub.com/gorilla/websocket v1.4.0\n\tgithub.com/jmoiron/sqlx v1.2.0\n\tgithub.com/orestonce/ChessGame v0.0.0-20190419000812-8e1a70c446b3 // indirect\n\tgolang.org/x/net v0.0.0-20181114220301-adae6a3d119a\n)\n"
  },
  {
    "path": "go.sum",
    "content": "git.apache.org/thrift.git v0.12.0 h1:CMxsZlAmxKs+VAZMlDDL0wXciMblJcutQbEe3A9CYUM=\ngit.apache.org/thrift.git v0.12.0/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg=\ngithub.com/Knetic/govaluate v3.0.0+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=\ngithub.com/apache/thrift v0.12.0 h1:pODnxUFNcjP9UTLZGTdeh+j16A8lJbRvD3rOtrk/7bs=\ngithub.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=\ngithub.com/astaxie/beego v1.11.1 h1:6DESefxW5oMcRLFRKi53/6exzup/IR6N4EzzS1n6CnQ=\ngithub.com/astaxie/beego v1.11.1/go.mod h1:i69hVzgauOPSw5qeyF4GVZhn7Od0yG5bbCGzmhbWxgQ=\ngithub.com/beego/goyaml2 v0.0.0-20130207012346-5545475820dd/go.mod h1:1b+Y/CofkYwXMUU0OhQqGvsY2Bvgr4j6jfT699wyZKQ=\ngithub.com/beego/x2j v0.0.0-20131220205130-a0352aadc542/go.mod h1:kSeGC/p1AbBiEp5kat81+DSQrZenVBZXklMLaELspWU=\ngithub.com/belogik/goes v0.0.0-20151229125003-e54d722c3aff/go.mod h1:PhH1ZhyCzHKt4uAasyx+ljRCgoezetRNf59CUtwUkqY=\ngithub.com/bradfitz/gomemcache v0.0.0-20180710155616-bc664df96737/go.mod h1:PmM6Mmwb0LSuEubjR8N7PtNe1KxZLtOUHtbeikc5h60=\ngithub.com/casbin/casbin v1.7.0/go.mod h1:c67qKN6Oum3UF5Q1+BByfFxkwKvhwW57ITjqwtzR1KE=\ngithub.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58/go.mod h1:EOBUe0h4xcZ5GoxqC5SDxFQ8gwyZPKQoEzownBlhI80=\ngithub.com/couchbase/go-couchbase v0.0.0-20181122212707-3e9b6e1258bb/go.mod h1:TWI8EKQMs5u5jLKW/tsb9VwauIrMIxQG1r5fMsswK5U=\ngithub.com/couchbase/gomemcached v0.0.0-20181122193126-5125a94a666c/go.mod h1:srVSlQLB8iXBVXHgnqemxUXqN6FCvClgCMPCsjBDR7c=\ngithub.com/couchbase/goutils v0.0.0-20180530154633-e865a1461c8a/go.mod h1:BQwMFlJzDjFDG3DJUdU0KORxn88UlsOULuxLExMh3Hs=\ngithub.com/cupcake/rdb v0.0.0-20161107195141-43ba34106c76/go.mod h1:vYwsqCOLxGiisLwp9rITslkFNpZD5rz43tf41QFkTWY=\ngithub.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=\ngithub.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4=\ngithub.com/garyburd/redigo v1.6.0 h1:0VruCpn7yAIIu7pWVClQC8wxCJEcG3nyzpMSHKi1PQc=\ngithub.com/garyburd/redigo v1.6.0/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY=\ngithub.com/go-redis/redis v6.14.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=\ngithub.com/go-redis/redis v6.15.2+incompatible h1:9SpNVG76gr6InJGxoZ6IuuxaCOQwDAhzyXg+Bs+0Sb4=\ngithub.com/go-redis/redis v6.15.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=\ngithub.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=\ngithub.com/go-sql-driver/mysql v1.4.1 h1:g24URVg0OFbNUTx9qqY1IRZ9D9z3iPyi5zKhQZpNwpA=\ngithub.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=\ngithub.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=\ngithub.com/golang/crypto v0.0.0-20181127143415-eb0de9b17e85/go.mod h1:uZvAcrsnNaCxlh1HorK5dUQHGmEKPh2H/Rl1kehswPo=\ngithub.com/golang/go v0.0.0-20190523013941-3e9d8e2e1bb9 h1:wdEw8NbuJZM04QMvzorGVoSx2yGH/OMxNEKan9uCSP0=\ngithub.com/golang/go v0.0.0-20190523013941-3e9d8e2e1bb9/go.mod h1:VnTjtYw+XLkxokOYpCb9NBW3cOTFO8+uqxF7o10XJQk=\ngithub.com/golang/net v0.0.0-20181114220301-adae6a3d119a h1:wxhJMi186V9aI731PnbZnsQ1aE0hEeDc/Gf9tTNIssU=\ngithub.com/golang/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:98y8FxUyMjTdJ5eOj/8vzuiVO14/dkJ98NYhEPG8QGY=\ngithub.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=\ngithub.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4=\ngithub.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q=\ngithub.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=\ngithub.com/jmoiron/sqlx v1.2.0 h1:41Ip0zITnmWNR/vHV+S4m+VoUivnWY5E4OJfLZjCJMA=\ngithub.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks=\ngithub.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=\ngithub.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=\ngithub.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=\ngithub.com/orestonce/ChessGame v0.0.0-20190419000812-8e1a70c446b3 h1:HYSeOb+ue/GSUi+8Tuc0mliUpBG4LgdEACw6ZZdwq0o=\ngithub.com/orestonce/ChessGame v0.0.0-20190419000812-8e1a70c446b3/go.mod h1:DzMpQbwxDX21pjkuZGqrl4AlcKPZIxUFPQ1qHiWYI+M=\ngithub.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=\ngithub.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=\ngithub.com/siddontang/go v0.0.0-20180604090527-bdc77568d726/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw=\ngithub.com/siddontang/ledisdb v0.0.0-20181029004158-becf5f38d373/go.mod h1:mF1DpOSOUiJRMR+FDqaqu3EBqrybQtrDDszLUZ6oxPg=\ngithub.com/siddontang/rdb v0.0.0-20150307021120-fc89ed2e418d/go.mod h1:AMEsy7v5z92TR1JKMkLLoaOQk++LVnOKL3ScbJ8GNGA=\ngithub.com/ssdb/gossdb v0.0.0-20180723034631-88f6b59b84ec/go.mod h1:QBvMkMya+gXctz3kmljlUCu/yB3GZ6oee+dUozsezQE=\ngithub.com/syndtr/goleveldb v0.0.0-20181127023241-353a9fca669c/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=\ngithub.com/wendal/errors v0.0.0-20130201093226-f66c77a7882b/go.mod h1:Q12BUT7DqIlHRmgv3RskH+UCM/4eqVMgI0EMmlSpAXc=\ngopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=\ngopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=\n"
  },
  {
    "path": "hall/common/config.go",
    "content": "package common\n\nvar (\n\tHallConf = &HallServiceConf{}\n)\n\ntype HallServiceConf struct {\n\tAccountHost string\n\tAccountPort int\n\tHallHost    string\n\tHallPort    int\n\tHallSecret  string\n\tLogPath     string\n\tLogLevel    string\n\tVersion     string\n\n\tAppId       int\t\t//qq登录\n\tAppKey      string\n\tRedirectUri string\n}\n"
  },
  {
    "path": "hall/controllers/enter_public_room.go",
    "content": "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\nfunc EnterPublicRoom(w http.ResponseWriter, r *http.Request) {\n\tlock.Lock()\n\tdefer lock.Unlock()\n\tminLoad := 0\n\tgameUrl := \"\"\n\tfor serverUrl,load := range serverInfo{\n\t\tif minLoad == 0 {\n\t\t\t minLoad = load\n\t\t\t gameUrl = serverUrl\n\t\t}else{\n\t\t\tif load <= minLoad {\n\t\t\t\tminLoad = load\n\t\t\t\tgameUrl = serverUrl\n\t\t\t}\n\t\t}\n\t}\n\tif gameUrl == \"\" {\n\t\tlogs.Error(\"no game server running ...\")\n\t\treturn\n\t}\n\ttarget := \"http://\" + gameUrl + r.URL.Path\n\t//target := \"http://127.0.0.1:9001\"  + r.URL.Path\n\ttimeStamp := time.Now().Unix()\n\tdata := []byte(\"t\" + strconv.Itoa(int(timeStamp)))\n\ttoken := fmt.Sprintf(\"%x\", md5.Sum(data))\n\tif len(r.URL.RawQuery) > 0 {\n\t\ttarget += \"?\" + r.URL.RawQuery + \"&token=\" + token + \"&t=\" + strconv.Itoa(int(timeStamp))\n\t} else {\n\t\ttarget += \"?token=\" + token + \"&t=\" + strconv.Itoa(int(timeStamp))\n\t}\n\tw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\thttp.Redirect(w, r, target, http.StatusMovedPermanently)\n}\n"
  },
  {
    "path": "hall/controllers/get_message.go",
    "content": "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/beego/logs\"\n\t\"net/http\"\n\t\"strconv\"\n)\n\nfunc GetMessage(w http.ResponseWriter, r *http.Request) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tlogs.Error(\"GetUserInfo panic:%v \", r)\n\t\t}\n\t}()\n\tmessageType := r.FormValue(\"type\")\n\tif len(messageType) == 0 {\n\t\treturn\n\t}\n\t//logs.Debug(\"new request url:[%s]\",r.URL)\n\tret := map[string]interface{}{\n\t\t\"errcode\": 1,\n\t\t\"errmsg\":  \"get message failed\",\n\t}\n\t//logs.Debug(\"get rpc client %v:%v\", common.HallConf.AccountHost, common.HallConf.AccountPort)\n\tif client, closeTransportHandler, err := tools.GetRpcClient(common.HallConf.AccountHost, strconv.Itoa(common.HallConf.AccountPort)); err == nil {\n\t\tdefer func() {\n\t\t\tif err := closeTransportHandler(); err != nil {\n\t\t\t\tlogs.Error(\"close rpc err: %v\", err)\n\t\t\t}\n\t\t}()\n\t\tif res, err := client.GetMessage(context.Background(), messageType); err == nil {\n\t\t\tret = map[string]interface{}{\n\t\t\t\t\"errcode\": 0,\n\t\t\t\t\"errmsg\":  \"ok\",\n\t\t\t\t\"msg\":     res,\n\t\t\t\t\"version\": common.HallConf.Version,\n\t\t\t}\n\t\t} else {\n\t\t\tlogs.Error(\"call rpc GetMessage err: %v\", err)\n\t\t}\n\t}\n\tdefer func() {\n\t\tdata, err := json.Marshal(ret)\n\t\tif err != nil {\n\t\t\tlogs.Error(\"json marsha1 failed err:%v\", err)\n\t\t\treturn\n\t\t}\n\t\tw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\t\tif _, err := w.Write(data); err != nil {\n\t\t\tlogs.Error(\"CreateRoom err: %v\", err)\n\t\t}\n\t}()\n}\n"
  },
  {
    "path": "hall/controllers/get_server_info.go",
    "content": "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\"strconv\"\n)\n\nfunc GetServerInfo(w http.ResponseWriter, r *http.Request) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tlogs.Error(\"GetUserInfo panic:%v \", r)\n\t\t}\n\t}()\n\t//logs.Debug(\"new request url:[%s]\",r.URL)\n\tret := map[string]interface{}{\n\t\t\"appweb\":  \"please wait\",\n\t\t\"hall\":    common.HallConf.HallHost + \":\" + strconv.Itoa(common.HallConf.HallPort),\n\t\t\"version\": common.HallConf.Version,\n\t}\n\tdefer func() {\n\t\tdata, err := json.Marshal(ret)\n\t\tif err != nil {\n\t\t\tlogs.Error(\"json marsha1 failed err:%v\", err)\n\t\t\treturn\n\t\t}\n\t\tw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\t\tif _, err := w.Write(data); err != nil {\n\t\t\tlogs.Error(\"CreateRoom err: %v\", err)\n\t\t}\n\t}()\n}\n"
  },
  {
    "path": "hall/controllers/get_user_status.go",
    "content": "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\"fish/hall/common\"\n\t\"github.com/astaxie/beego/logs\"\n\t\"net/http\"\n\t\"strconv\"\n)\n\nfunc GetUserStatus(w http.ResponseWriter, r *http.Request) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tlogs.Error(\"GetUserInfo panic:%v \", r)\n\t\t}\n\t}()\n\t//logs.Debug(\"new request url:[%s]\",r.URL)\n\taccount := r.FormValue(\"account\")\n\tif len(account) == 0 {\n\t\treturn\n\t}\n\ttoken := r.FormValue(\"sign\")\n\tif len(token) == 0 {\n\t\treturn\n\t}\n\tret := map[string]interface{}{\n\t\t\"errcode\": 1,\n\t\t\"errmsg\":  \"failed\",\n\t}\n\tif client, closeTransportHandler, err := tools.GetRpcClient(common.HallConf.AccountHost, strconv.Itoa(common.HallConf.AccountPort)); err == nil {\n\t\tdefer func() {\n\t\t\tif err := closeTransportHandler(); err != nil {\n\t\t\t\tlogs.Error(\"close rpc err: %v\", err)\n\t\t\t}\n\t\t}()\n\t\tif res, err := client.GetUserInfoByToken(context.Background(), token); err == nil {\n\t\t\tif res.Code == rpc.ErrorCode_Success {\n\t\t\t\tret = map[string]interface{}{\n\t\t\t\t\t\"errcode\": 0,\n\t\t\t\t\t\"errmsg\":  \"ok\",\n\t\t\t\t\t\"gems\":    res.UserObj.Gems,\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tlogs.Error(\"call rpc GetUserStatus err: %v\", err)\n\t\t}\n\t}\n\tdefer func() {\n\t\tdata, err := json.Marshal(ret)\n\t\tif err != nil {\n\t\t\tlogs.Error(\"json marsha1 failed err:%v\", err)\n\t\t\treturn\n\t\t}\n\t\tw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\t\tif _, err := w.Write(data); err != nil {\n\t\t\tlogs.Error(\"CreateRoom err: %v\", err)\n\t\t}\n\t}()\n}\n"
  },
  {
    "path": "hall/controllers/guest.go",
    "content": "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\"fish/hall/common\"\n\t\"fmt\"\n\t\"github.com/astaxie/beego/logs\"\n\t\"math/rand\"\n\t\"net/http\"\n\t\"strconv\"\n\t\"time\"\n)\n\nfunc Guest(w http.ResponseWriter, r *http.Request) {\n\t//defer func() {\n\t//\tif r := recover(); r != nil {\n\t//\t\tlogs.Error(\"Guest panic:%v \", r)\n\t//\t}\n\t//}()\n\n\tsign := r.FormValue(\"sign\")\n\tif len(sign) == 0 || sign == \"null\" {\n\t\tqqLoginUrl := fmt.Sprintf(\"https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id=%d&redirect_uri=%s&state=1\", appId, redirectUri)\n\t\tret := map[string]interface{}{\n\t\t\t\"errcode\": 1,\n\t\t\t\"qqLoginUrl\": qqLoginUrl,\n\t\t}\n\t\tw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\t\tdata, err := json.Marshal(ret)\n\t\tif err != nil {\n\t\t\tlogs.Error(\"json marsha1 failed err:%v\", err)\n\t\t\treturn\n\t\t}\n\t\tw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\t\tif _, err := w.Write(data); err != nil {\n\t\t\tlogs.Error(\"CreateRoom err: %v\", err)\n\t\t}\n\t} else {\n\t\trand.Seed(time.Now().UnixNano())\n\t\t//account = firstName[rand.Intn(len(firstName)-1)] + secondName[rand.Intn(len(secondName)-1)]\n\t\tif client, closeTransportHandler, err := tools.GetRpcClient(common.HallConf.AccountHost, strconv.Itoa(common.HallConf.AccountPort)); err == nil {\n\t\t\tdefer func() {\n\t\t\t\tif err := closeTransportHandler(); err != nil {\n\t\t\t\t\tlogs.Error(\"close rpc err: %v\", err)\n\t\t\t\t}\n\t\t\t}()\n\t\t\tif r, err := client.GetUserInfoByToken(context.Background(), sign); err == nil {\n\t\t\t\tif r.Code == rpc.ErrorCode_Success {\n\t\t\t\t\tsign = r.UserObj.Token\n\t\t\t\t}\n\t\t\t\tret := map[string]interface{}{\n\t\t\t\t\t\"errcode\": 0,\n\t\t\t\t\t\"errmsg\":  \"ok\",\n\t\t\t\t\t//\"account\":  \"guest_\" + account,\n\t\t\t\t\t\"account\":  r.UserObj.NickName,\n\t\t\t\t\t\"halladdr\": common.HallConf.HallHost + \":\" + strconv.Itoa(common.HallConf.HallPort),\n\t\t\t\t\t\"sign\":     sign,\n\t\t\t\t}\n\t\t\t\tdefer func() {\n\t\t\t\t\tdata, err := json.Marshal(ret)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tlogs.Error(\"json marsha1 failed err:%v\", err)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\t\t\t\t\tif _, err := w.Write(data); err != nil {\n\t\t\t\t\t\tlogs.Error(\"CreateRoom err: %v\", err)\n\t\t\t\t\t}\n\t\t\t\t}()\n\t\t\t} else {\n\t\t\t\tlogs.Error(\"call rpc Guest err: %v\", err)\n\t\t\t}\n\n\t\t} else {\n\t\t\tlogs.Error(\"get rpc client err: %v\", err)\n\t\t}\n\t}\n\n\t/*defer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tlogs.Error(\"Guest panic:%v \", r)\n\t\t}\n\t}()\n\t//logs.Debug(\"new request url:[%s]\",r.URL)\n\taccount := r.FormValue(\"account\")\n\tif len(account) == 0 {\n\t\treturn\n\t}\n\trand.Seed(time.Now().UnixNano())\n\taccount = firstName[rand.Intn(len(firstName)-1)] + secondName[rand.Intn(len(secondName)-1)]\n\tif client, closeTransportHandler, err := tools.GetRpcClient(common.HallConf.AccountHost, strconv.Itoa(common.HallConf.AccountPort)); err == nil {\n\t\tdefer func() {\n\t\t\tif err := closeTransportHandler(); err != nil {\n\t\t\t\tlogs.Error(\"close rpc err: %v\", err)\n\t\t\t}\n\t\t}()\n\t\tsign := \"\"\n\t\tif r, err := client.CreateNewUser(context.Background(), account, \"1\", 1000000); err == nil {\n\t\t\tif r.Code == rpc.ErrorCode_Success {\n\t\t\t\tsign = r.UserObj.Token\n\t\t\t}\n\t\t} else {\n\t\t\tlogs.Error(\"call rpc Guest err: %v\", err)\n\t\t}\n\t\tret := map[string]interface{}{\n\t\t\t\"errcode\": 0,\n\t\t\t\"errmsg\":  \"ok\",\n\t\t\t//\"account\":  \"guest_\" + account,\n\t\t\t\"account\":  account,\n\t\t\t\"halladdr\": common.HallConf.HallHost + \":\" + strconv.Itoa(common.HallConf.HallPort),\n\t\t\t\"sign\":     sign,\n\t\t}\n\t\tdefer func() {\n\t\t\tdata, err := json.Marshal(ret)\n\t\t\tif err != nil {\n\t\t\t\tlogs.Error(\"json marsha1 failed err:%v\", err)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\t\t\tif _, err := w.Write(data); err != nil {\n\t\t\t\tlogs.Error(\"CreateRoom err: %v\", err)\n\t\t\t}\n\t\t}()\n\t} else {\n\t\tlogs.Error(\"get rpc client err: %v\", err)\n\t}*/\n}\n\nvar (\n\tfirstName = []string{\n\t\t\"赵\", \"钱\", \"孙\", \"李\", \"周\", \"吴\", \"郑\", \"王\", \"冯\", \"陈\",\n\t\t\"褚\", \"卫\", \"蒋\", \"沈\", \"韩\", \"杨\", \"朱\", \"秦\", \"尤\", \"许\",\n\t\t\"何\", \"吕\", \"施\", \"张\", \"孔\", \"曹\", \"严\", \"华\", \"金\", \"魏\",\n\t\t\"陶\", \"姜\", \"戚\", \"谢\", \"邹\", \"喻\", \"柏\", \"水\", \"窦\", \"章\",\n\t\t\"云\", \"苏\", \"潘\", \"葛\", \"奚\", \"范\", \"彭\", \"郎\", \"鲁\", \"韦\",\n\t\t\"昌\", \"马\", \"苗\", \"凤\", \"花\", \"方\", \"俞\", \"任\", \"袁\", \"柳\",\n\t\t\"酆\", \"鲍\", \"史\", \"唐\", \"费\", \"廉\", \"岑\", \"薛\", \"雷\", \"贺\",\n\t\t\"倪\", \"汤\", \"滕\", \"殷\", \"罗\", \"毕\", \"郝\", \"邬\", \"安\", \"常\",\n\t\t\"乐\", \"于\", \"时\", \"傅\", \"皮\", \"卞\", \"齐\", \"康\", \"伍\", \"余\",\n\t\t\"元\", \"卜\", \"顾\", \"孟\", \"平\", \"黄\", \"和\", \"穆\", \"萧\", \"尹\",\n\t}\n\tsecondName = []string{\n\t\t\"子璇\", \"淼\", \"国栋\", \"夫子\", \"瑞堂\", \"甜\", \"敏\", \"尚\", \"国贤\", \"贺祥\", \"晨涛\",\n\t\t\"昊轩\", \"易轩\", \"益辰\", \"益帆\", \"益冉\", \"瑾春\", \"瑾昆\", \"春齐\", \"杨\", \"文昊\",\n\t\t\"东东\", \"雄霖\", \"浩晨\", \"熙涵\", \"溶溶\", \"冰枫\", \"欣欣\", \"宜豪\", \"欣慧\", \"建政\",\n\t\t\"美欣\", \"淑慧\", \"文轩\", \"文杰\", \"欣源\", \"忠林\", \"榕润\", \"欣汝\", \"慧嘉\", \"新建\",\n\t\t\"建林\", \"亦菲\", \"林\", \"冰洁\", \"佳欣\", \"涵涵\", \"禹辰\", \"淳美\", \"泽惠\", \"伟洋\",\n\t\t\"涵越\", \"润丽\", \"翔\", \"淑华\", \"晶莹\", \"凌晶\", \"苒溪\", \"雨涵\", \"嘉怡\", \"佳毅\",\n\t\t\"子辰\", \"佳琪\", \"紫轩\", \"瑞辰\", \"昕蕊\", \"萌\", \"明远\", \"欣宜\", \"泽远\", \"欣怡\",\n\t\t\"佳怡\", \"佳惠\", \"晨茜\", \"晨璐\", \"运昊\", \"汝鑫\", \"淑君\", \"晶滢\", \"润莎\", \"榕汕\",\n\t\t\"佳钰\", \"佳玉\", \"晓庆\", \"一鸣\", \"语晨\", \"添池\", \"添昊\", \"雨泽\", \"雅晗\", \"雅涵\",\n\t\t\"清妍\", \"诗悦\", \"嘉乐\", \"晨涵\", \"天赫\", \"玥傲\", \"佳昊\", \"天昊\", \"萌萌\", \"若萌\",\n\t}\n)\n"
  },
  {
    "path": "hall/controllers/login.go",
    "content": "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\"fish/hall/common\"\n\t\"github.com/astaxie/beego/logs\"\n\t\"net/http\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc Login(w http.ResponseWriter, r *http.Request) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tlogs.Error(\"GetUserInfo panic:%v \", r)\n\t\t}\n\t}()\n\t//logs.Debug(\"new request url:[%s]\",r.URL)\n\taccount := r.FormValue(\"account\")\n\tif len(account) == 0 {\n\t\treturn\n\t}\n\ttoken := r.FormValue(\"sign\")\n\tif len(token) == 0 {\n\t\treturn\n\t}\n\tret := map[string]interface{}{\n\t\t\"errcode\": 0,\n\t\t\"errmsg\":  \"ok\",\n\t}\n\tif client, closeTransportHandler, err := tools.GetRpcClient(common.HallConf.AccountHost, strconv.Itoa(common.HallConf.AccountPort)); err == nil {\n\t\tdefer func() {\n\t\t\tif err := closeTransportHandler(); err != nil {\n\t\t\t\tlogs.Error(\"close rpc err: %v\", err)\n\t\t\t}\n\t\t}()\n\t\tip := strings.TrimSpace(strings.Split(r.Header.Get(\"X-Forwarded-For\"), \",\")[0])\n\t\tif res, err := client.GetUserInfoByToken(context.Background(), token); err == nil {\n\t\t\tif res.Code == rpc.ErrorCode_Success {\n\t\t\t\tret = map[string]interface{}{\n\t\t\t\t\t\"errcode\":     0,\n\t\t\t\t\t\"errmsg\":      \"ok\",\n\t\t\t\t\t\"account\":     res.UserObj.NickName,\n\t\t\t\t\t\"userid\":      res.UserObj.UserId,\n\t\t\t\t\t\"name\":        res.UserObj.NickName,\n\t\t\t\t\t\"headimg\":     res.UserObj.HeadImg,\n\t\t\t\t\t\"lv\":          res.UserObj.Lv,\n\t\t\t\t\t\"exp\":         res.UserObj.Exp,\n\t\t\t\t\t\"coins\":       res.UserObj.Gems,\n\t\t\t\t\t\"vip\":         res.UserObj.Vip,\n\t\t\t\t\t\"money\":       res.UserObj.Gems,\n\t\t\t\t\t\"gems\":        res.UserObj.Gems,\n\t\t\t\t\t\"ip\":          ip,\n\t\t\t\t\t\"sex\":         res.UserObj.Sex,\n\t\t\t\t\t\"RenameCount\": res.UserObj.ReNameCount,\n\t\t\t\t\t\"ReHeadCount\": res.UserObj.ReHeadCount,\n\t\t\t\t\t\"item\": map[string]int64{\n\t\t\t\t\t\t\"ice\": res.UserObj.Ice,\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tlogs.Error(\"call rpc Login err: %v\", err)\n\t\t}\n\t}\n\tdefer func() {\n\t\tdata, err := json.Marshal(ret)\n\t\tif err != nil {\n\t\t\tlogs.Error(\"json marsha1 failed err:%v\", err)\n\t\t\treturn\n\t\t}\n\t\tw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\t\tif _, err := w.Write(data); err != nil {\n\t\t\tlogs.Error(\"CreateRoom err: %v\", err)\n\t\t}\n\t}()\n}\n"
  },
  {
    "path": "hall/controllers/qq_callback.go",
    "content": "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\"fish/hall/common\"\n\t\"fmt\"\n\t\"github.com/astaxie/beego/logs\"\n\t\"io/ioutil\"\n\t\"math/rand\"\n\t\"net/http\"\n\t\"net/url\"\n\t\"strconv\"\n\t\"strings\"\n)\n\ntype qqUserInfo struct {\n\tRet                int `json:\"ret\"`\n\tMsg                string `json:\"msg\"`\n\tIsLost            int `json:\"is_lost\"`\n\tNickname           string `json:\"nickname\"`\n\tGender             string `json:\"gender\"`\n\tProvince           string `json:\"province\"`\n\tCity               string `json:\"city\"`\n\tYear               string `json:\"year\"`\n\tConstellation      string `json:\"constellation\"`\n\tFigureUrl          string `json:\"figureurl\"`\n\tFigureUrl1        string `json:\"figureurl_1\"`\n\tFigureUrl2        string `json:\"figureurl_2\"`\n\tFigureUrlQQ1     string `json:\"figureurl_qq_1\"`\n\tFigureUrlQQ2     string `json:\"figureurl_qq_2\"`\n\tFigureUrlQQ       string `json:\"figureurl_qq\"`\n\tFigureUrlType     string `json:\"figureurl_type\"`\n\tIsYellowVip      string `json:\"is_yellow_vip\"`\n\tVip                string `json:\"vip\"`\n\tYellowVipLevel   string `json:\"yellow_vip_level\"`\n\tLevel              string `json:\"level\"`\n\tIsYellowYearVip string `json:\"is_yellow_year_vip\"`\n}\n\nfunc QQCallback(w http.ResponseWriter, r *http.Request) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tlogs.Error(\"QQCallback panic:%v \", r)\n\t\t}\n\t}()\n\tvar sign string\n\tdefer func() {\n\t\tvar script = fmt.Sprintf(`<script>localStorage.setItem(\"sign\",\"%s\");location.href=\"/\"</script>`,sign)\n\t\tw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\t\tif _, err := w.Write([]byte(script)); err != nil {\n\t\t\tlogs.Error(\"QQCallback err: %v\", err)\n\t\t}\n\t}()\n\tr.ParseForm()\n\tcode := r.FormValue(\"code\")\n\tif len(code) == 0 {\n\t\tlogs.Error(\"QQCallback :code is null\")\n\t}\n\tgetTokenUrl := fmt.Sprintf(\"https://graph.qq.com/oauth2.0/token?grant_type=authorization_code&client_id=%d&client_secret=%s&code=%s&redirect_uri=%s\", appId, AppKey, code, redirectUri)\n\tresp, err := http.Get(getTokenUrl)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tdefer resp.Body.Close()\n\tbody, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tm, _ := url.ParseQuery(string(body))\n\tif len(m[\"access_token\"]) > 0 {\n\t\taccessToken := m[\"access_token\"][0]\n\n\t\tgetOpenIdUrl := fmt.Sprintf(\"https://graph.qq.com/oauth2.0/me?access_token=%s\", accessToken)\n\t\tresp, err := http.Get(getOpenIdUrl)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\n\t\tdefer resp.Body.Close()\n\t\tbody, err := ioutil.ReadAll(resp.Body)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tcallback := string(body)\n\t\t//callback( {\"client_id\":\"101673379\",\"openid\":\"EC0F4A930140B2581EDC71A08D824985\"} );\n\t\tstart := strings.Index(callback, \"{\")\n\t\tend := strings.Index(callback, \"}\")\n\t\tretMapStr := callback[start : end+1]\n\t\tretMap := make(map[string]string)\n\t\tif err := json.Unmarshal([]byte(retMapStr), &retMap); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tif len(retMap[\"openid\"]) != 0 {\n\t\t\tgetUserInfoUrl := fmt.Sprintf(\"https://graph.qq.com/user/get_user_info?access_token=%s&oauth_consumer_key=%d&openid=%s\", accessToken, appId, retMap[\"openid\"])\n\t\t\tresp, err := http.Get(getUserInfoUrl)\n\t\t\tif err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\n\t\t\tdefer resp.Body.Close()\n\t\t\tbody, err = ioutil.ReadAll(resp.Body)\n\t\t\tif err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\n\t\t\tqqUserInfo := &qqUserInfo{}\n\t\t\tif err := json.Unmarshal([]byte(body), qqUserInfo); err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\n\t\t\tfmt.Println(string(body))\n\t\t\tfmt.Println(qqUserInfo)\n\t\t\tfmt.Println(qqUserInfo.Nickname)\n\t\t\tif client, closeTransportHandler, err := tools.GetRpcClient(common.HallConf.AccountHost, strconv.Itoa(common.HallConf.AccountPort)); err == nil {\n\t\t\t\tdefer func() {\n\t\t\t\t\tif err := closeTransportHandler(); err != nil {\n\t\t\t\t\t\tlogs.Error(\"close rpc err: %v\", err)\n\t\t\t\t\t}\n\t\t\t\t}()\n\t\t\t\tvar sex int8\n\t\t\t\tif qqUserInfo.Gender != \"男\" {\n\t\t\t\t\tsex = 1\n\t\t\t\t}\n\t\t\t\tif resp, err := client.CreateQQUser(context.Background(), &rpc.UserInfo{\n\t\t\t\t\tUserName: qqUserInfo.Nickname,\n\t\t\t\t\tNickName: qqUserInfo.Nickname,\n\t\t\t\t\tSex:      sex,\n\t\t\t\t\tHeadImg:  \"1\",\n\t\t\t\t\tLv:       int32(rand.Intn(7)),\n\t\t\t\t\tExp:      0,\n\t\t\t\t\tVip:      int8(rand.Intn(7)),\n\t\t\t\t\tGems:     10000,\n\t\t\t\t\tIce:      10,\n\t\t\t\t\tQqInfo: &rpc.QqInfo{\n\t\t\t\t\t\tOpenId:        retMap[\"openid\"],\n\t\t\t\t\t\tFigureUrl:     qqUserInfo.FigureUrlQQ1,\n\t\t\t\t\t\tProvince:      qqUserInfo.Province,\n\t\t\t\t\t\tCity:          qqUserInfo.City,\n\t\t\t\t\t\tTotalSpending: 0,\n\t\t\t\t\t},\n\t\t\t\t}); err == nil {\n\t\t\t\t\tsign = resp.UserObj.Token\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "hall/controllers/qq_login.go",
    "content": "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 = \"c18b1b56f2f88ef423bfeadbad9a816c\"\n\tredirectUri = \"http://fish.blzz.shop/qq/message\"\n)\nfunc QQLogin(w http.ResponseWriter, r *http.Request) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tlogs.Error(\"QQLogin panic:%v \", r)\n\t\t}\n\t}()\n\n\tw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\t//qqLoginUrl := fmt.Sprintf(\"https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id=%d&redirect_uri=%s&state=%d&display=%s\",appId,redirectUri,1,\"mobile\")\n\tqqLoginUrl := fmt.Sprintf(\"https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id=%d&redirect_uri=%s&state=%d&display=%s\",appId,redirectUri,1,\"pc\")\n\thttp.Redirect(w,r,qqLoginUrl,302)\n}\n"
  },
  {
    "path": "hall/controllers/register_game_server.go",
    "content": "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\"strconv\"\n\t\"sync\"\n)\n\nvar lock = sync.Mutex{}\nvar serverInfo = make(map[string]int)\n//todo 优化的空间：可以加个注销服务接口。心跳加入时间，长时间未发送心跳的游戏服务器由大厅发起询问或暂时挂起。懒得做 :(\n\nfunc RegisterGameServer(w http.ResponseWriter, r *http.Request) {\n\tret := \"failed\"\n\tdefer func() {\n\t\tw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\t\tif _, err := w.Write([]byte(ret)); err != nil {\n\t\t\tlogs.Error(\"CreateRoom err: %v\", err)\n\t\t}\n\t}()\n\tgameHost := r.FormValue(\"gameHost\")\n\tif len(gameHost) == 0 {\n\t\tlogs.Error(\"load game server failed,err : invalid param gameHost %v\", gameHost)\n\t\treturn\n\t}\n\tgamePort := r.FormValue(\"gamePort\")\n\tif len(gamePort) == 0 {\n\t\tlogs.Error(\"load game server failed,err : invalid param gamePort %v\", gamePort)\n\t\treturn\n\t}\n\tloadStr := r.FormValue(\"load\")\n\tif len(loadStr) == 0 {\n\t\tlogs.Error(\"load game server failed,err : invalid param load %v \", loadStr)\n\t\treturn\n\t}\n\tt := r.FormValue(\"t\")\n\tif len(t) == 0 {\n\t\tlogs.Error(\"load game server failed,err : invalid param t %v \", t)\n\t\treturn\n\t}\n\tsign := r.FormValue(\"sign\")\n\tif len(sign) == 0 {\n\t\tlogs.Error(\"load game server failed,err : invalid param sign %v \", sign)\n\t\treturn\n\t}\n\tif fmt.Sprintf(\"%x\", md5.Sum([]byte(common.HallConf.HallSecret+t))) != sign {\n\t\tlogs.Error(\"load game server failed,check sign failed  \")\n\t\treturn\n\t}\n\tif loadInt, err := strconv.Atoi(loadStr); err != nil {\n\t\tlogs.Error(\"load game server [%v:%v],err : invalid param load [%v]\", gameHost, gamePort, loadStr)\n\t\treturn\n\t} else {\n\t\tret = \"success\"\n\t\tserverUrl := gameHost + \":\" + gamePort\n\t\tlock.Lock()\n\t\tdefer lock.Unlock()\n\t\tserverInfo[serverUrl] = loadInt\n\t}\n}\n"
  },
  {
    "path": "hall/main/config.go",
    "content": "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\tconf, err := config.NewConfig(\"ini\", \"./common/conf/hall.conf\")\n\tif err != nil {\n\t\tfmt.Println(\"new hall config failed,err:\", err)\n\t\treturn\n\t}\n\n\tcommon.HallConf.HallHost = conf.String(\"hall_host\")\n\tif common.HallConf.HallHost == \"\" {\n\t\treturn fmt.Errorf(\"conf err: hall_host is null\")\n\t}\n\n\tcommon.HallConf.HallPort, err = conf.Int(\"hall_port\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"conf err: hall_port is null\")\n\t}\n\n\tcommon.HallConf.HallSecret = conf.String(\"hall_secret\")\n\tif common.HallConf.HallSecret == \"\" {\n\t\treturn fmt.Errorf(\"conf err: hall_secret is null\")\n\t}\n\n\tcommon.HallConf.LogPath = conf.String(\"log_path\")\n\tif common.HallConf.LogPath == \"\" {\n\t\treturn fmt.Errorf(\"conf err: log_path is null\")\n\t}\n\n\tcommon.HallConf.LogLevel = conf.String(\"log_level\")\n\tif common.HallConf.LogLevel == \"\" {\n\t\treturn fmt.Errorf(\"conf err: log_level is null\")\n\t}\n\n\tcommon.HallConf.Version = conf.String(\"version\")\n\tif common.HallConf.Version == \"\" {\n\t\treturn fmt.Errorf(\"conf err: version is null\")\n\t}\n\n\taccountConf, err := config.NewConfig(\"ini\", \"./common/conf/account.conf\")\n\tif err != nil {\n\t\tfmt.Println(\"new account config failed,err:\", err)\n\t\treturn\n\t}\n\tcommon.HallConf.AccountHost = accountConf.String(\"account_host\")\n\tif common.HallConf.AccountHost == \"\" {\n\t\treturn fmt.Errorf(\"conf err: account_host is null\")\n\t}\n\n\tcommon.HallConf.AccountPort, err = accountConf.Int(\"account_port\")\n\tif err != nil {\n\t\treturn  fmt.Errorf(\"conf err: account_port is null\")\n\t}\n\n\tcommon.HallConf.AppId, err = conf.Int(\"app_id\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"conf err: app_id is null\")\n\t}\n\tcommon.HallConf.AppKey = conf.String(\"app_key\")\n\tif common.HallConf.AppKey == \"\" {\n\t\treturn fmt.Errorf(\"conf err: app_key is null\")\n\t}\n\tcommon.HallConf.RedirectUri = conf.String(\"redirect_uri\")\n\tif common.HallConf.RedirectUri == \"\" {\n\t\treturn fmt.Errorf(\"conf err: redirect_uri is null\")\n\t}\n\n\treturn\n}\n"
  },
  {
    "path": "hall/main/init.go",
    "content": "package main\n\nimport (\n\t\"encoding/json\"\n\t\"fish/hall/common\"\n\t\"github.com/astaxie/beego/logs\"\n)\n\nfunc conversionLogLevel(logLevel string) int {\n\tswitch logLevel {\n\tcase \"debug\":\n\t\treturn logs.LevelDebug\n\tcase \"warn\":\n\t\treturn logs.LevelWarn\n\tcase \"info\":\n\t\treturn logs.LevelInfo\n\tcase \"trace\":\n\t\treturn logs.LevelTrace\n\t}\n\treturn logs.LevelDebug\n}\n\nfunc initLogger() (err error) {\n\tconfig := make(map[string]interface{})\n\tconfig[\"filename\"] = common.HallConf.LogPath\n\tconfig[\"level\"] = conversionLogLevel(common.HallConf.LogLevel)\n\n\tconfigStr, err := json.Marshal(config)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = logs.SetLogger(logs.AdapterFile, string(configStr))\n\treturn\n}\n\nfunc initSec() (err error) {\n\terr = initLogger()\n\tif err != nil {\n\t\treturn\n\t}\n\treturn\n}\n"
  },
  {
    "path": "hall/main/main.go",
    "content": "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/http\"\n)\n\nfunc main() {\n\terr := initConf()\n\tif err != nil {\n\t\tlogs.Error(\"init conf err: %v\", err)\n\t\treturn\n\t}\n\n\terr = initSec()\n\tif err != nil {\n\t\tlogs.Error(\"init sec err: %v\", err)\n\t\treturn\n\t}\n\n\tvar addr = flag.String(\"addr\", fmt.Sprintf(\":%d\", common.HallConf.HallPort), \"http service address\")\n\tlogs.Debug(\"hall server listen port %v\",*addr)\n\terr = http.ListenAndServe(*addr, nil)\n\tif err != nil {\n\t\tlogs.Error(\"ListenAndServe err: %v\", err)\n\t}\n}\n"
  },
  {
    "path": "hall/router/router.go",
    "content": "package router\n\nimport (\n\t\"fish/hall/controllers\"\n\t\"net/http\"\n)\n\nfunc init() {\n\thttp.HandleFunc(\"/get_serverinfo\", controllers.GetServerInfo)\n\thttp.HandleFunc(\"/guest\", controllers.Guest)\n\thttp.HandleFunc(\"/login\", controllers.Login)\n\thttp.HandleFunc(\"/get_user_status\", controllers.GetUserStatus)\n\thttp.HandleFunc(\"/get_message\", controllers.GetMessage)\n\thttp.HandleFunc(\"/enter_public_room\", controllers.EnterPublicRoom)\n\thttp.HandleFunc(\"/register_game_server\", controllers.RegisterGameServer)\n\n\thttp.HandleFunc(\"/qq/login\", controllers.QQLogin)\n\thttp.HandleFunc(\"/qq/message\", controllers.QQCallback)\n}\n"
  },
  {
    "path": "start_account.bat",
    "content": "call account.exe\npause"
  },
  {
    "path": "start_fish.bat",
    "content": "call fish.exe\npause"
  },
  {
    "path": "start_hall.bat",
    "content": "call hall.exe\npause"
  },
  {
    "path": "z-start_all_server.bat",
    "content": "start %~dp0\\start_account.bat\nstart %~dp0\\start_hall.bat\nstart %~dp0\\start_fish.bat"
  }
]