玩家列表接口

This commit is contained in:
HuangZiBo 2024-12-11 11:01:36 +08:00
parent 158082ec63
commit 5cece435ae
2 changed files with 62 additions and 0 deletions

View File

@ -0,0 +1,57 @@
using Newtonsoft.Json;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
//获取房间玩家列表
public class getPlayerList : MonoBehaviour
{
private void Start()
{
GetPlayerList();
}
// 创建请求头,使用最新的 token
public Dictionary<string, string> CreateHeaders()
{
return new Dictionary<string, string>
{
{ "Authorization","Bearer "+GlobalData.ServerData.data.access_token },
{"clientId", "e5cd7e4891bf95d1d19206ce24a7b32e" }
};
}
//
public async Task<PlayerListResponse> GetPlayerList()
{
string response = await web.SendRequest(web.URL + "/admin/companyUser/player/list", "GET", "{}", CreateHeaders());
Debug.Log("获取演练账号列表" + response);
// 解析服务器返回的数据
PlayerListResponse playerListResponse = JsonConvert.DeserializeObject<PlayerListResponse>(response);
Debug.Log(playerListResponse.data[0].UserName);
return playerListResponse;
}
}
//=====================================================================================================================
public class PlayerListResponse : Response
{
public List<PlayerListData> data { get; set; }
}
public class PlayerListData
{
public string UserName { get; set; }
public string Id { get; set; }
public string CompanyId { get; set; }
public string UserId { get; set; }
public string IsAdmin { get; set; }
public string Status { get; set; }
public string Remark { get; set; } // 可以为null通常使用string类型
public string DepartmentName { get; set; }
public string PostName { get; set; }
public string NickName { get; set; }
public string CreateTime { get; set; }
}

View File

@ -64,6 +64,11 @@ public class loginData
public int expire_in;//toling剩余时间 public int expire_in;//toling剩余时间
public string isCreater;//是否是模板创建者Y是则跳蓝湖预定演练01页面开始创建模板N否则跳蓝狐回放1页面 public string isCreater;//是否是模板创建者Y是则跳蓝湖预定演练01页面开始创建模板N否则跳蓝狐回放1页面
} }
public static class GlobalData
{
// 静态变量用于存储登录响应数据
public static loginResponse ServerData;
}
//==================================================== //====================================================
//public class TemplateListData: Response //public class TemplateListData: Response
//{ //{