103 lines
3.7 KiB
C#
103 lines
3.7 KiB
C#
using Newtonsoft.Json;
|
||
using System;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using System.Threading.Tasks;
|
||
using UnityEngine;
|
||
//9.1查询工会分页列表
|
||
public class queryFactory : MonoBehaviour
|
||
{
|
||
public async Task<FactoryList> QueryFactoryList() // 9.1
|
||
{
|
||
// 准备请求的头部信息,包含授权令牌
|
||
Dictionary<string, string> head91 = new Dictionary<string, string>
|
||
{
|
||
{ "Authorization", Global.global.serverResponse.data.token }
|
||
};
|
||
|
||
queryPlayerInfo queryPlayerInfo = new queryPlayerInfo();
|
||
RealPlayerInfo realPlayerInfo = new RealPlayerInfo();
|
||
realPlayerInfo = await queryPlayerInfo.QueryPlayerInfoPro();
|
||
|
||
queryFactoryBody queryFactoryBody = new queryFactoryBody();
|
||
queryFactoryBody.userId = realPlayerInfo.data.userId;
|
||
|
||
Debug.Log("===入参====" + JsonUtility.ToJson(queryFactoryBody));
|
||
|
||
// 异步发送请求以获取最新的蜗牛骑士信息
|
||
string response91 = await web.SendRequest(web.URL + "/snail/factory/queryFactorySlot", "POST", JsonUtility.ToJson(queryFactoryBody), head91);
|
||
|
||
// 调试输出接收到的响应
|
||
Debug.Log("9.1查询工厂列表" + response91);
|
||
|
||
// 将响应反序列化为对象
|
||
FactoryList factoryList = JsonConvert.DeserializeObject<FactoryList>(response91);
|
||
|
||
// 访问并使用返回的数据
|
||
if (factoryList.code == 200 && factoryList.data != null)
|
||
{
|
||
// 访问第一页的数据列表
|
||
foreach (var factoryItem in factoryList.data.dataList)
|
||
{
|
||
Debug.Log($"工厂ID: {factoryItem.id}, 用户ID: {factoryItem.userId}, 状态: {factoryItem.status}, 使用类型: {factoryItem.useType}");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
Debug.LogError("请求失败或没有数据");
|
||
}
|
||
|
||
// 返回解析后的对象
|
||
return factoryList;
|
||
}
|
||
}
|
||
//请求体===================================================================
|
||
//body:userId:Long,用户的userId,必传
|
||
// pageNo:Integer,默认1,非必传,起始页
|
||
// pageSize:Integer,默认20,非必传,每页数目
|
||
public class queryFactoryBody
|
||
{
|
||
public long userId;
|
||
public int pageNo;
|
||
public int pageSize;
|
||
}
|
||
//======================================================
|
||
public class FactoryList:Response
|
||
{
|
||
public FactoryData data { get; set; }
|
||
}
|
||
|
||
public class FactoryData
|
||
{
|
||
public int pageNo { get; set; }
|
||
public int pageSize { get; set; }
|
||
public int totalCount { get; set; }
|
||
public List<FactoryItem> dataList { get; set; }
|
||
}
|
||
|
||
public class FactoryItem
|
||
{
|
||
public long id { get; set; }
|
||
public long userId { get; set; }
|
||
public long snailId { get; set; }
|
||
public long contractId { get; set; }
|
||
public string bindTime { get; set; }
|
||
public int source { get; set; }
|
||
public int useType { get; set; }
|
||
public int status { get; set; }
|
||
public int settle { get; set; }
|
||
}
|
||
//返回参数:code:200,成功
|
||
// message:成功,提示语
|
||
// data:用户信息
|
||
// pageNo:起始页
|
||
// pageSize:每页展示
|
||
// totalCount:总记录数
|
||
// dataList:列表
|
||
// id:Long,卡槽id
|
||
// userId:Long,用户id
|
||
// snailId:Long,蜗牛id
|
||
// contractId:Long,合同id
|
||
// bindTime:String,绑定到期时间
|
||
// status:Integer,1绑定中,其他未绑定
|
||
// settle:Integer,绑定中的进度,取100-settle*2.5 |