地址系统8.*接口

This commit is contained in:
HuangZiBo 2024-11-27 15:54:29 +08:00
parent e89891e582
commit 57ac99fc81
10 changed files with 322 additions and 0 deletions

View File

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

View File

@ -0,0 +1,56 @@
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
public class AdressList83 : MonoBehaviour
{
public AdressResponse adressResponse;
public async Task<AdressResponse> AdressList()
{
// 准备请求的头部信息,包含授权令牌
Dictionary<string, string> head83 = new Dictionary<string, string>
{
{ "Authorization", Global.global.serverResponse.data.token }
};
// 异步发送请求
string response83 = await web.SendRequest(web.URL + "/snail/area/list", "POST", "{}", head83);
// 调试输出接收到的响应
Debug.Log("8.3地址列表: " + response83);
// 将响应反序列化为 AdressResponse 对象
try
{
adressResponse = JsonConvert.DeserializeObject<AdressResponse>(response83);
Debug.Log(adressResponse.data + "=======================================");
// 遍历 data 列表中的每个地址
if (adressResponse.data != null)
{
foreach (var address in adressResponse.data)
{
Debug.Log($"地址ID: {address.id}");
Debug.Log($"收件人: {address.receiveName}");
Debug.Log($"电话号码: {address.receivePhone}");
Debug.Log($"区域: {address.area}");
Debug.Log($"详细地址: {address.address}");
Debug.Log($"状态: {address.status}");
Debug.Log($"创建时间: {address.createTime}");
}
}
}
catch (Exception ex)
{
Debug.LogError("反序列化响应失败: " + ex.Message);
}
// 返回解析后的对象
return adressResponse;
}
}

View File

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

View File

@ -0,0 +1,41 @@
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
//8.4查看地址详情
public class areaInfo84 : MonoBehaviour
{
public AdressInfoResponse adressInfoResponse;
public async Task<AdressInfoResponse> AdressInfo(int areaId)
{
// 准备请求的头部信息,包含授权令牌
Dictionary<string, string> head84 = new Dictionary<string, string>
{
{ "Authorization", Global.global.serverResponse.data.token }
};
// 异步发送请求
string response84 = await web.SendRequest(web.URL + "/snail/area/queryInfo?areaId=" + areaId, "GET", "{}", head84);
// 调试输出接收到的响应
Debug.Log("8.4地址详情====================: " + response84);
// 将响应反序列化为 AdressInfoResponse 对象
try
{
adressInfoResponse = JsonConvert.DeserializeObject<AdressInfoResponse>(response84);
}
catch (Exception ex)
{
Debug.LogError("反序列化响应失败: " + ex.Message);
}
// 返回解析后的对象
return adressInfoResponse;
}
}

View File

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

View File

@ -0,0 +1,54 @@
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
public class newAddress81 : MonoBehaviour
{
//返回的(解析后)
public newAddressResponse newAddressResponse;
//public async Task<KnightBetResult> queryKnightBetResult(int KnightId) // 5.2.2//需传入KightId
public async Task<newAddressResponse> newAddress(string receiveName, string receivePhone,string area, string address)
{
// 准备请求的头部信息,包含授权令牌
Dictionary<string, string> head81 = new Dictionary<string, string>
{
{ "Authorization", Global.global.serverResponse.data.token }
};
// 请求体
newAddressBody newAddressBody = new newAddressBody
{
receivePhone = receivePhone,
area = area,
address = address,
receiveName = receiveName,
};
//Debug.Log("8.1=====入参======"+ JsonConvert.SerializeObject(newAddressBody));
// 异步发送请求
//string response525 = await web.SendRequest(web.URL + "/snail/gameKnight/queryUserBetResult", "POST", JsonUtility.ToJson(queryKnightRoomListBody), head525);
string response81 = await web.SendRequest(web.URL + "/snail/area/save", "POST", JsonConvert.SerializeObject(newAddressBody), head81);
// 调试输出接收到的响应
Debug.Log("8.1新增地址:======== " + response81);
//将响应反序列化为 KnightRoomList 对象
try
{
newAddressResponse = JsonConvert.DeserializeObject<newAddressResponse>(response81);
//Debug.Log(newAddressResponse.data+"");
}
catch (Exception ex)
{
Debug.LogError("反序列化响应失败: " + ex.Message);
}
// 返回解析后的 对象
return newAddressResponse;
}
}

View File

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

View File

@ -0,0 +1,55 @@
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
public class updateAddress82 : MonoBehaviour
{
//返回的(解析后)
public updateAddressResponse updateAddressResponse;
//public async Task<KnightBetResult> queryKnightBetResult(int KnightId) // 5.2.2//需传入KightId
public async Task<updateAddressResponse> updateAddress(int id,string receiveName, string receivePhone, string area, string address)
{
// 准备请求的头部信息,包含授权令牌
Dictionary<string, string> head81 = new Dictionary<string, string>
{
{ "Authorization", Global.global.serverResponse.data.token }
};
// 请求体
updateAddressBody updateAddressBody = new updateAddressBody
{
id = id,
receivePhone = receivePhone,
area = area,
address = address,
receiveName = receiveName,
};
Debug.Log("8.2=====入参======" + JsonConvert.SerializeObject(updateAddressBody));
// 异步发送请求
//string response525 = await web.SendRequest(web.URL + "/snail/gameKnight/queryUserBetResult", "POST", JsonUtility.ToJson(queryKnightRoomListBody), head525);
string response82 = await web.SendRequest(web.URL + "/snail/area/update", "POST", JsonConvert.SerializeObject(updateAddressBody), head81);
// 调试输出接收到的响应
Debug.Log("8.2修改地址:+++++++++++++ " + response82);
//将响应反序列化为 KnightRoomList 对象
try
{
updateAddressResponse = JsonConvert.DeserializeObject<updateAddressResponse>(response82);
Debug.Log(updateAddressResponse.data + "=======================================");
}
catch (Exception ex)
{
Debug.LogError("反序列化响应失败: " + ex.Message);
}
// 返回解析后的 对象
return updateAddressResponse;
}
}

View File

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

View File

@ -765,4 +765,68 @@ public class InviteUserInfo
public string memberTime { get; set; }
public bool? isMember { get; set; }
public string unionId { get; set; }
}
//=========81==========================================
//添加地址请求体
public class newAddressBody
{
public string receiveName { get; set; }
public string receivePhone { get; set; }
public string area { get; set; }
public string address { get; set; }
}
public class newAddressResponse : Response
{
public string data;
}
//======8.2================================================
//请求体
public class updateAddressBody
{
public int id { get; set; }
public string receiveName { get; set; }
public string receivePhone { get; set; }
public string area { get; set; }
public string address { get; set; }
}
//返回
public class updateAddressResponse : Response
{
public string data;
}
//=========8.3=================================================
[Serializable]
public class Address
{
public int id;
public int userId;
public string receiveName;
public string receivePhone;
public string area;
public string address;
public int status;
public string createTime;
}
[Serializable]
public class AdressResponse : Response
{
public List<Address> data; // 包含多个地址的列表
}
//8.4===================================================================
public class AdressInfoResponse : Response
{
public AddressInfoData data { get; set; }
}
public class AddressInfoData
{
public int id { get; set; }
public int userId { get; set; }
public string receiveName { get; set; }
public string receivePhone { get; set; }
public string area { get; set; }
public string address { get; set; }
public int status { get; set; }
public string createTime { get; set; }
}