_xiaofang/xiaofang/Assets/Script/DirllInterface/querySenceList.cs

105 lines
3.3 KiB
C#
Raw Normal View History

2024-11-29 17:27:21 +08:00
using Newtonsoft.Json;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
public class querySenceList : MonoBehaviour
{
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD> token
public Dictionary<string, string> CreateHeaders()
{
2024-12-04 15:26:46 +08:00
if (string.IsNullOrEmpty(MyGlobal.global.loginResponse.data.access_token))
2024-11-29 17:27:21 +08:00
{
Debug.LogWarning("<22><><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷʱ<CDB7><CAB1>token δ<><CEB4><EFBFBD>á<EFBFBD>");
return new Dictionary<string, string>();
}
return new Dictionary<string, string>
{
2024-12-04 15:26:46 +08:00
{ "Authorization","Bearer "+MyGlobal.global.loginResponse.data.access_token },
2024-11-29 17:27:21 +08:00
{"clientId", "e5cd7e4891bf95d1d19206ce24a7b32e" }
};
}
//<2F><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>б<EFBFBD>
public async Task<QuerySceneData> QueryScene()
{
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>󲢻<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
string response = await web.SendRequest(web.URL + "/game/scene/list", "GET", "", CreateHeaders());
Debug.Log("<22><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>б<EFBFBD>" + response);
// ʹ<><CAB9>Newtonsoft.Json<6F><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD>JSON<4F><4E><EFBFBD>ݵ<EFBFBD>QuerySceneData<74><61><EFBFBD><EFBFBD>
QuerySceneData senceData = JsonConvert.DeserializeObject<QuerySceneData>(response);
// <20><>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD>ݵ<EFBFBD>ijЩ<C4B3><D0A9><EFBFBD><EFBFBD>
if (senceData != null && senceData.data != null)
{
foreach (var scene in senceData.data)
{
Debug.Log("<22><><EFBFBD><EFBFBD>ID: " + scene.id);
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: " + scene.name);
Debug.Log("<22><><EFBFBD><EFBFBD>: " + scene.description);
Debug.Log("<22>۸<EFBFBD>: " + scene.price);
Debug.Log("<22><>ҵ: " + scene.industryName);
if (scene.fileList != null)
{
foreach (var file in scene.fileList)
{
Debug.Log("<22>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>: " + file.name);
Debug.Log("<22>ļ<EFBFBD>URL: " + file.url);
}
}
}
}
else
{
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>");
}
return senceData;
}
}
//============================================================================
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public class QuerySceneData
{
public int code { get; set; }
public string msg { get; set; }
public List<Scene> data { get; set; }
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>
public class Scene
{
public string id { get; set; }
public string name { get; set; }//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public string type { get; set; }//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public string description { get; set; }//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public int suitIndustry { get; set; }//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҵ
public string price { get; set; }//<2F>۸<EFBFBD> <20><>
public int companyId { get; set; }//<2F><>λ<EFBFBD><CEBB>**Сѧ֮<D1A7>
public string status { get; set; }//<2F><><EFBFBD><EFBFBD>״̬<D7B4><CCAC>0<EFBFBD><30><EFBFBD>ã<EFBFBD><31>ã<EFBFBD>
public string delFlag { get; set; }
public string remark { get; set; }
public string gameName { get; set; }
public string gameType { get; set; }
public string ossId { get; set; }
public List<File> fileList { get; set; }
public string gameStoreroom { get; set; }
public string industryName { get; set; }
public string companyName { get; set; }
}
// <20>ļ<EFBFBD><C4BC><EFBFBD>Ϣ<EFBFBD><CFA2>
public class File
{
public string ossId { get; set; }
public string name { get; set; }
public string url { get; set; }
public string originalName { get; set; }
public string fileSuffix { get; set; }
}