Files
juipnet/Infrastructure/ServiceClient/BaseInfoClient/Response/Room/QueryAllHouseholderRoomsByOwnerIdResponse.cs
“wanyongkang” ed3b2c653e 接口文件
2024-04-10 13:55:27 +08:00

54 lines
1.7 KiB
C#

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Etor.Infrastructure.Common;
using Etor.Infrastructure.Data;
using Etor.Infrastructure.Serializer;
using Etor.Infrastructure.WebApi;
using Newtonsoft.Json;
using ServiceClient;
using ServiceClient.Response.Room;
namespace ServiceClient.Response.Room
{
public class QueryAllHouseholderRoomsByOwnerIdResponse
{
[JsonProperty("userToRoomData")]
public List<UserRoomItem> UserRoomItems { get; set; } = new List<UserRoomItem>();
}
}
namespace BaseInfoClient.Extension
{
public static class QueryAllHouseholderRoomsByOwnerIdResponseExtension
{
public static async Task<List<UserRoomItem>> QueryAllHouseholderRoomsByOwnerId(this BaseInfoHttpClient client
, int ownerId, bool throwException = false)
{
try
{
var response = await client.CreateHttpClient().GetAsync(
$"{client.BaseUrl}/api/baseinfo/v1/BaseData/GetAllBasePerson?Data.IsGetUserToRoom=true&OwnerID={ownerId}");
var content = await response.Content.ReadAsStringAsync();
return content.FromJsonTo<ApiResult<QueryAllHouseholderRoomsByOwnerIdResponse>>().Data.UserRoomItems;
}
catch (Exception e)
{
LogHelper.Error("根据UserId获取用户房间信息", e);
if (throwException)
{
BusinessException.Throw("获取用户房间信息失败");
}
else
{
return new List<UserRoomItem>();
}
}
return new List<UserRoomItem>();
}
}
}