9.*蜗牛工厂接口

This commit is contained in:
HuangZiBo 2024-12-01 23:17:54 +08:00
parent 5fd716a4da
commit da78066f4d
11 changed files with 329 additions and 0 deletions

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f2df43d9fd05b3041807eb23babf40e2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,49 @@
using Newtonsoft.Json;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
//9.4,蜗牛绑定卡槽
public class bindSlot : MonoBehaviour
{
public async Task<BindSlot> QueryUserSnailCount(long snailId,long slotId) // 9.1
{
// 准备请求的头部信息,包含授权令牌
Dictionary<string, string> head = new Dictionary<string, string>
{
{ "Authorization", Global.global.serverResponse.data.token }
};
BindSlotBody body = new BindSlotBody();
body.snailId=snailId;
body.slotId=slotId;
Debug.Log(JsonConvert.SerializeObject(body) + "========入参==========");
// 异步发送请求以获取最新的蜗牛骑士信息
string response94 = await web.SendRequest(web.URL + "/snail/factory/bindSlot", "POST", JsonConvert.SerializeObject(body), head);
// 调试输出接收到的响应
Debug.Log("9.4,蜗牛绑定卡槽" + response94);
// 将响应反序列化为对象
BindSlot bindSlot = JsonConvert.DeserializeObject<BindSlot>(response94);
Debug.Log(bindSlot.code);
// 返回解析后的对象
return bindSlot;
}
}
//==========请求体========================================
//请求参数headerAuthorization1.2接口返回的token
//         bodysnailIdLong蜗牛id
//               slotIdLong卡槽id
//返回参数code200成功
//        message成功提示语
//        datanull
public class BindSlotBody
{
public long snailId;
public long slotId;
}
public class BindSlot : Response
{
public string data;
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 726d1b949e506154b92a6c218ba775ff
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,38 @@
using Newtonsoft.Json;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
//9.39.3,开启新的工厂卡槽
public class buyNewFactory : MonoBehaviour
{
public async Task<BuyNewFactoryResponse> BuyNewFactory() // 9.1
{
// 准备请求的头部信息,包含授权令牌
Dictionary<string, string> head = new Dictionary<string, string>
{
{ "Authorization", Global.global.serverResponse.data.token }
};
// 异步发送请求以获取最新的蜗牛骑士信息
string response93 = await web.SendRequest(web.URL + "/snail/factory/openSlot", "POST", "{}", head);
// 调试输出接收到的响应
Debug.Log("9.3,开启新的工厂卡槽" + response93);
// 将响应反序列化为对象
BuyNewFactoryResponse buyNewFactoryResponse = JsonConvert.DeserializeObject<BuyNewFactoryResponse>(response93);
// 返回解析后的对象
return buyNewFactoryResponse;
}
}
//=============返回==========================================================================
public class BuyNewFactoryResponse : Response
{
public string data;
}
//返回参数code200成功
//        message成功提示语
//        datanull

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d5e3f8f75a0b35942945bb8d9cc51a29
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,34 @@
using Newtonsoft.Json;
using Spine;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using Unity.VisualScripting;
using UnityEngine;
public class factoryTest : MonoBehaviour
{
//9.1
queryFactory queryFactory = new queryFactory();
FactoryList factoryList = new FactoryList();
//9.2
queryUserSnailCount queryUserSnailCount = new queryUserSnailCount();
//9.3
buyNewFactory buyNewFactory = new buyNewFactory();
//9.4
bindSlot bindSlot = new bindSlot();
async void Start()
{
factoryList =await queryFactory.QueryFactoryList();
Debug.Log(factoryList.data.pageNo + "=======" + factoryList.data.dataList[0].useType+"==============================");
//queryUserSnailCount.QueryUserSnailCount();
//BuyNewFactoryResponse buyNewFactoryResponse = await buyNewFactory.BuyNewFactory();
bindSlot.QueryUserSnailCount(0,1);
}
}
//请求体===================================================================
//bodyuserIdLong用户的userId必传
//              pageNoInteger默认1非必传起始页
//              pageSizeInteger默认20非必传每页数目

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1a7688c2b1b5754469336cab8fb3e4e3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,103 @@
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;
}
}
//请求体===================================================================
//bodyuserIdLong用户的userId必传
//              pageNoInteger默认1非必传起始页
//              pageSizeInteger默认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; }
}
//返回参数code200成功
//        message成功提示语
//        data用户信息
//             pageNo起始页
//             pageSize每页展示
//             totalCount总记录数
//             dataList列表
//                 idLong卡槽id
//                 userIdLong用户id
//                 snailIdLong蜗牛id
//                 contractIdLong合同id
//                 bindTimeString绑定到期时间
//                 statusInteger1绑定中其他未绑定
//                 settleInteger绑定中的进度取100-settle*2.5

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2769c2977a9680c4fbc1c659ccd3c603
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,42 @@
using Newtonsoft.Json;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
//9.2,查询我的工厂未绑定的蜗牛数:
public class queryUserSnailCount : MonoBehaviour
{
public async Task<UserSnail> QueryUserSnailCount() // 9.1
{
// 准备请求的头部信息,包含授权令牌
Dictionary<string, string> head = new Dictionary<string, string>
{
{ "Authorization", Global.global.serverResponse.data.token }
};
// 异步发送请求以获取最新的蜗牛骑士信息
string response92 = await web.SendRequest(web.URL + "/snail/factory/queryUserSnailCount", "POST", "{}", head);
// 调试输出接收到的响应
Debug.Log("9.2查询我的工厂未绑定的蜗牛数" + response92);
// 将响应反序列化为对象
UserSnail userSnail = JsonConvert.DeserializeObject<UserSnail>(response92);
// 返回解析后的对象
return userSnail;
}
}
//==========返回=====================================================================
//返回参数code200成功
//        message成功提示语
//        data空闲蜗牛的数组这里取数组的长度即可最大渲染10只蜗牛
//            idLong蜗牛的id 
public class UserSnail : Response
{
public List<UserSnailData> data;
}
public class UserSnailData
{
public long snailId;
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 28be15502251a794e98b4f9a6276e674
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: