Exemple #1
0
        //Post api/Player?token={token}&name={name}&pid={pid}&sid={sid}&type={type}&value={value}
        /// <summary>玩家详细信息</summary>
        /// <param name="token">令牌</param>
        /// <param name="name">用户名称</param>
        /// <param name="pid">平台pid</param>
        /// <param name="sid">服务器sid</param>
        /// <param name="type">查询类型</param>
        /// <param name="value">查询值</param>
        public PlayerDetailed PostDetailed(String token, String name, Int32 pid, Int32 sid, Int32 type, String value)
        {
            if (!IsToken(token))
            {
                return new PlayerDetailed()
                       {
                           result = -1, message = "令牌不存在"
                       }
            }
            ;

            tgm_platform.SetDbConnName(tgm_connection);
            var platform = tgm_platform.FindByid(pid);

            if (platform == null)
            {
                return new PlayerDetailed()
                       {
                           result = -1, message = "平台信息不存在"
                       }
            }
            ;

            tgm_server.SetDbConnName(tgm_connection);
            var server = tgm_server.FindByid(sid);

            if (server == null || server.pid != pid)
            {
                return new PlayerDetailed()
                       {
                           result = -1, message = " 服务器信息不存在"
                       }
            }
            ;

            tgm_role.SetDbConnName(tgm_connection);
            var user = tgm_role.GetFindEntity(name);

            if (user.role != 10000)
            {
                if (user.pid != pid)
                {
                    return new PlayerDetailed()
                           {
                               result = -1, message = "没有权限操作该平台信息"
                           }
                }
                ;
            }

            SN = server.name;
            tg_user.SetDbConnName(db_connection);
            var player = type == 1 ? tg_user.GetEntityByCode(value) : tg_user.GetEntityByName(value);

            if (player == null)
            {
                return new PlayerDetailed()
                       {
                           result = -1, message = "玩家信息不存在"
                       }
            }
            ;

            tg_role.SetDbConnName(db_connection);
            var role = tg_role.GetRoleByUserId(player.id);

            if (role == null)
            {
                return new PlayerDetailed()
                       {
                           result = -1, message = "玩家主角信息不存在"
                       }
            }
            ;

            tg_user_vip.SetDbConnName(db_connection);
            var vip = tg_user_vip.GetByUserId(player.id);

            if (vip == null)
            {
                return new PlayerDetailed()
                       {
                           result = -1, message = "玩家VIP信息不存在"
                       }
            }
            ;

            tg_car.SetDbConnName(db_connection);
            var cars = tg_car.GetCarCount(player.id);

            tg_user_login_log.SetDbConnName(db_connection);
            var log = tg_user_login_log.GetLoginLog(player.id);

            if (log == null)
            {
                return new PlayerDetailed()
                       {
                           result = -1, message = "登陆日志信息不存在"
                       }
            }
            ;

            var areas    = GetAreaName(player.id);
            var vocation = GetVocation(role.role_id, player.player_vocation);
            var identity = GetIdentity(role.role_identity);
            var office   = GetOffice(player.office);
            var data     = ToEntity.ToPlayerDetailed(player, role, areas, log.login_state, cars, vip.vip_level, identity, vocation, office);

            data     = BuildData(data, player.id);
            data.sid = server.id;
            return(data);
        }