From da78066f4d25210209146a281439271e104592f9 Mon Sep 17 00:00:00 2001 From: HuangZiBo <1278481331@qq.com> Date: Sun, 1 Dec 2024 23:17:54 +0800 Subject: [PATCH] =?UTF-8?q?9.*=E8=9C=97=E7=89=9B=E5=B7=A5=E5=8E=82?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Assets/Scripts/snailFactory.meta | 8 ++ .../Assets/Scripts/snailFactory/bindSlot.cs | 49 +++++++++ .../Scripts/snailFactory/bindSlot.cs.meta | 11 ++ .../Scripts/snailFactory/buyNewFactory.cs | 38 +++++++ .../snailFactory/buyNewFactory.cs.meta | 11 ++ .../Scripts/snailFactory/factoryTest.cs | 34 ++++++ .../Scripts/snailFactory/factoryTest.cs.meta | 11 ++ .../Scripts/snailFactory/queryFactory.cs | 103 ++++++++++++++++++ .../Scripts/snailFactory/queryFactory.cs.meta | 11 ++ .../snailFactory/queryUserSnailCount.cs | 42 +++++++ .../snailFactory/queryUserSnailCount.cs.meta | 11 ++ 11 files changed, 329 insertions(+) create mode 100644 TheStrongestSnail/Assets/Scripts/snailFactory.meta create mode 100644 TheStrongestSnail/Assets/Scripts/snailFactory/bindSlot.cs create mode 100644 TheStrongestSnail/Assets/Scripts/snailFactory/bindSlot.cs.meta create mode 100644 TheStrongestSnail/Assets/Scripts/snailFactory/buyNewFactory.cs create mode 100644 TheStrongestSnail/Assets/Scripts/snailFactory/buyNewFactory.cs.meta create mode 100644 TheStrongestSnail/Assets/Scripts/snailFactory/factoryTest.cs create mode 100644 TheStrongestSnail/Assets/Scripts/snailFactory/factoryTest.cs.meta create mode 100644 TheStrongestSnail/Assets/Scripts/snailFactory/queryFactory.cs create mode 100644 TheStrongestSnail/Assets/Scripts/snailFactory/queryFactory.cs.meta create mode 100644 TheStrongestSnail/Assets/Scripts/snailFactory/queryUserSnailCount.cs create mode 100644 TheStrongestSnail/Assets/Scripts/snailFactory/queryUserSnailCount.cs.meta diff --git a/TheStrongestSnail/Assets/Scripts/snailFactory.meta b/TheStrongestSnail/Assets/Scripts/snailFactory.meta new file mode 100644 index 0000000..f64f770 --- /dev/null +++ b/TheStrongestSnail/Assets/Scripts/snailFactory.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f2df43d9fd05b3041807eb23babf40e2 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/TheStrongestSnail/Assets/Scripts/snailFactory/bindSlot.cs b/TheStrongestSnail/Assets/Scripts/snailFactory/bindSlot.cs new file mode 100644 index 0000000..913ae25 --- /dev/null +++ b/TheStrongestSnail/Assets/Scripts/snailFactory/bindSlot.cs @@ -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 QueryUserSnailCount(long snailId,long slotId) // 9.1 + { + // 准备请求的头部信息,包含授权令牌 + Dictionary head = new Dictionary + { + { "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(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; +} \ No newline at end of file diff --git a/TheStrongestSnail/Assets/Scripts/snailFactory/bindSlot.cs.meta b/TheStrongestSnail/Assets/Scripts/snailFactory/bindSlot.cs.meta new file mode 100644 index 0000000..2ed547a --- /dev/null +++ b/TheStrongestSnail/Assets/Scripts/snailFactory/bindSlot.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 726d1b949e506154b92a6c218ba775ff +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/TheStrongestSnail/Assets/Scripts/snailFactory/buyNewFactory.cs b/TheStrongestSnail/Assets/Scripts/snailFactory/buyNewFactory.cs new file mode 100644 index 0000000..3cbcf08 --- /dev/null +++ b/TheStrongestSnail/Assets/Scripts/snailFactory/buyNewFactory.cs @@ -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 BuyNewFactory() // 9.1 + { + // 准备请求的头部信息,包含授权令牌 + Dictionary head = new Dictionary + { + { "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(response93); + + // 返回解析后的对象 + return buyNewFactoryResponse; + } +} +//=============返回========================================================================== +public class BuyNewFactoryResponse : Response +{ + public string data; +} +//返回参数:code:200,成功 +//        message:成功,提示语 +//        data:null \ No newline at end of file diff --git a/TheStrongestSnail/Assets/Scripts/snailFactory/buyNewFactory.cs.meta b/TheStrongestSnail/Assets/Scripts/snailFactory/buyNewFactory.cs.meta new file mode 100644 index 0000000..5143d66 --- /dev/null +++ b/TheStrongestSnail/Assets/Scripts/snailFactory/buyNewFactory.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d5e3f8f75a0b35942945bb8d9cc51a29 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/TheStrongestSnail/Assets/Scripts/snailFactory/factoryTest.cs b/TheStrongestSnail/Assets/Scripts/snailFactory/factoryTest.cs new file mode 100644 index 0000000..81d2e6f --- /dev/null +++ b/TheStrongestSnail/Assets/Scripts/snailFactory/factoryTest.cs @@ -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,非必传,每页数目 diff --git a/TheStrongestSnail/Assets/Scripts/snailFactory/factoryTest.cs.meta b/TheStrongestSnail/Assets/Scripts/snailFactory/factoryTest.cs.meta new file mode 100644 index 0000000..fb01c55 --- /dev/null +++ b/TheStrongestSnail/Assets/Scripts/snailFactory/factoryTest.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1a7688c2b1b5754469336cab8fb3e4e3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/TheStrongestSnail/Assets/Scripts/snailFactory/queryFactory.cs b/TheStrongestSnail/Assets/Scripts/snailFactory/queryFactory.cs new file mode 100644 index 0000000..848b0bf --- /dev/null +++ b/TheStrongestSnail/Assets/Scripts/snailFactory/queryFactory.cs @@ -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 QueryFactoryList() // 9.1 + { + // 准备请求的头部信息,包含授权令牌 + Dictionary head91 = new Dictionary + { + { "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(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 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 \ No newline at end of file diff --git a/TheStrongestSnail/Assets/Scripts/snailFactory/queryFactory.cs.meta b/TheStrongestSnail/Assets/Scripts/snailFactory/queryFactory.cs.meta new file mode 100644 index 0000000..46b781d --- /dev/null +++ b/TheStrongestSnail/Assets/Scripts/snailFactory/queryFactory.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2769c2977a9680c4fbc1c659ccd3c603 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/TheStrongestSnail/Assets/Scripts/snailFactory/queryUserSnailCount.cs b/TheStrongestSnail/Assets/Scripts/snailFactory/queryUserSnailCount.cs new file mode 100644 index 0000000..4244830 --- /dev/null +++ b/TheStrongestSnail/Assets/Scripts/snailFactory/queryUserSnailCount.cs @@ -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 QueryUserSnailCount() // 9.1 + { + // 准备请求的头部信息,包含授权令牌 + Dictionary head = new Dictionary + { + { "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(response92); + + // 返回解析后的对象 + return userSnail; + } +} +//==========返回===================================================================== +//返回参数:code:200,成功 +//        message:成功,提示语 +//        data:空闲蜗牛的数组,这里取数组的长度即可,最大渲染10只蜗牛 +//            id:Long,蜗牛的id  +public class UserSnail : Response +{ + public List data; +} +public class UserSnailData +{ + public long snailId; +} \ No newline at end of file diff --git a/TheStrongestSnail/Assets/Scripts/snailFactory/queryUserSnailCount.cs.meta b/TheStrongestSnail/Assets/Scripts/snailFactory/queryUserSnailCount.cs.meta new file mode 100644 index 0000000..ce42f3b --- /dev/null +++ b/TheStrongestSnail/Assets/Scripts/snailFactory/queryUserSnailCount.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 28be15502251a794e98b4f9a6276e674 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: