9.*蜗牛工厂接口
This commit is contained in:
parent
5fd716a4da
commit
da78066f4d
8
TheStrongestSnail/Assets/Scripts/snailFactory.meta
Normal file
8
TheStrongestSnail/Assets/Scripts/snailFactory.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f2df43d9fd05b3041807eb23babf40e2
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
49
TheStrongestSnail/Assets/Scripts/snailFactory/bindSlot.cs
Normal file
49
TheStrongestSnail/Assets/Scripts/snailFactory/bindSlot.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//==========请求体========================================
|
||||||
|
//请求参数:header:Authorization:1.2接口返回的token
|
||||||
|
// body:snailId:Long,蜗牛id
|
||||||
|
// slotId:Long,卡槽id
|
||||||
|
//返回参数:code:200,成功
|
||||||
|
// message:成功,提示语
|
||||||
|
// data:null
|
||||||
|
public class BindSlotBody
|
||||||
|
{
|
||||||
|
public long snailId;
|
||||||
|
public long slotId;
|
||||||
|
}
|
||||||
|
public class BindSlot : Response
|
||||||
|
{
|
||||||
|
public string data;
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 726d1b949e506154b92a6c218ba775ff
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -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;
|
||||||
|
}
|
||||||
|
//返回参数:code:200,成功
|
||||||
|
// message:成功,提示语
|
||||||
|
// data:null
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d5e3f8f75a0b35942945bb8d9cc51a29
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
34
TheStrongestSnail/Assets/Scripts/snailFactory/factoryTest.cs
Normal file
34
TheStrongestSnail/Assets/Scripts/snailFactory/factoryTest.cs
Normal 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
//请求体===================================================================
|
||||||
|
//body:userId:Long,用户的userId,必传
|
||||||
|
// pageNo:Integer,默认1,非必传,起始页
|
||||||
|
// pageSize:Integer,默认20,非必传,每页数目
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1a7688c2b1b5754469336cab8fb3e4e3
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
103
TheStrongestSnail/Assets/Scripts/snailFactory/queryFactory.cs
Normal file
103
TheStrongestSnail/Assets/Scripts/snailFactory/queryFactory.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//请求体===================================================================
|
||||||
|
//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
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2769c2977a9680c4fbc1c659ccd3c603
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//==========返回=====================================================================
|
||||||
|
//返回参数:code:200,成功
|
||||||
|
// message:成功,提示语
|
||||||
|
// data:空闲蜗牛的数组,这里取数组的长度即可,最大渲染10只蜗牛
|
||||||
|
// id:Long,蜗牛的id
|
||||||
|
public class UserSnail : Response
|
||||||
|
{
|
||||||
|
public List<UserSnailData> data;
|
||||||
|
}
|
||||||
|
public class UserSnailData
|
||||||
|
{
|
||||||
|
public long snailId;
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 28be15502251a794e98b4f9a6276e674
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
Reference in New Issue
Block a user