Skip to content

Commit

Permalink
feat: 集成WebApiClientCore
Browse files Browse the repository at this point in the history
  • Loading branch information
WangJunZzz committed Sep 14, 2024
1 parent 158feac commit fc4c5bd
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 1 deletion.
2 changes: 1 addition & 1 deletion aspnet-core/Directory.Build.Microsoft.targets
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<ItemGroup>
<PackageReference Update="Microsoft.Extensions.DependencyModel" Version="8.0.0"/>
<PackageReference Update="Microsoft.Extensions.Diagnostics.HealthChecks" Version="8.0.0"/>
<PackageReference Update="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.0"/>
<PackageReference Update="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.4"/>
<PackageReference Update="Microsoft.EntityFrameworkCore.Tools" Version="8.0.0"/>
<PackageReference Update="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="8.0.0"/>
<PackageReference Update="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.0"/>
Expand Down
2 changes: 2 additions & 0 deletions aspnet-core/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,7 @@

<!-- NEST ElasticSearch-->
<PackageReference Update="NEST" Version="7.17.5"/>

<PackageReference Update="WebApiClientCore" Version="2.1.4" />
</ItemGroup>
</Project>
7 changes: 7 additions & 0 deletions aspnet-core/Lion.AbpPro.sln
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lion.AbpPro.ElasticSearch.T
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lion.AbpPro.Starter", "frameworks\src\Lion.AbpPro.Starter\Lion.AbpPro.Starter.csproj", "{A70659A2-91F4-4FE7-80D0-DA12430543FD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lion.AbpPro.HttpClient", "frameworks\src\Lion.AbpPro.HttpClient\Lion.AbpPro.HttpClient.csproj", "{9C88C5AE-21A1-4A62-9FA3-173806CD9EE3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -638,6 +640,10 @@ Global
{A70659A2-91F4-4FE7-80D0-DA12430543FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A70659A2-91F4-4FE7-80D0-DA12430543FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A70659A2-91F4-4FE7-80D0-DA12430543FD}.Release|Any CPU.Build.0 = Release|Any CPU
{9C88C5AE-21A1-4A62-9FA3-173806CD9EE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9C88C5AE-21A1-4A62-9FA3-173806CD9EE3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9C88C5AE-21A1-4A62-9FA3-173806CD9EE3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9C88C5AE-21A1-4A62-9FA3-173806CD9EE3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -761,6 +767,7 @@ Global
{CCC3BE80-5D36-4833-B629-9F4230396EC3} = {7BE85EBC-99AD-4CDE-957E-4BDD087FC4E3}
{2B2110E1-4C29-41AF-ADB5-C1B5F3C3C1D0} = {EFC415F8-872F-4C7E-8645-31A51481BCFC}
{A70659A2-91F4-4FE7-80D0-DA12430543FD} = {7BE85EBC-99AD-4CDE-957E-4BDD087FC4E3}
{9C88C5AE-21A1-4A62-9FA3-173806CD9EE3} = {7BE85EBC-99AD-4CDE-957E-4BDD087FC4E3}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {28315BFD-90E7-4E14-A2EA-F3D23AF4126F}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<AssemblyName>Lion.AbpPro.HttpClient</AssemblyName>
<RootNamespace />
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Volo.Abp.Autofac" />
<PackageReference Include="WebApiClientCore"/>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using WebApiClientCore;
using WebApiClientCore.Attributes;

namespace Lion.AbpPro.HttpClient;

/// <summary>
/// Demo
/// </summary>
public interface IDemoHttpClient : IHttpApi
{
/// <summary>
/// 获取天气信息
/// </summary>
[HttpGet("api/WeatherForecast/Get")]
Task<IEnumerable<WeatherForecast>> GetAsync(CancellationToken token = default);


[HttpPost("api/WeatherForecast/Demo1")]
Task<IEnumerable<WeatherForecast>> PostAsync([JsonContent] WeatherForecast weatherForecasts, CancellationToken token = default);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Autofac;
using Volo.Abp.Modularity;

namespace Lion.AbpPro.HttpClient;

[DependsOn(typeof(AbpAutofacModule))]
public class SevenHttpClientModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
// 示例项目
context.Services.AddHttpApi<IDemoHttpClient>().ConfigureHttpApi(options => { options.HttpHost = new Uri("http://localhost:5048/"); });
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Lion.AbpPro.HttpClient;

public class WeatherForecast
{
public DateTime Date { get; set; }

public int TemperatureC { get; set; }

public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);

public string? Summary { get; set; }

Check warning on line 11 in aspnet-core/frameworks/src/Lion.AbpPro.HttpClient/Lion/AbpPro/HttpClient/WeatherForecast.cs

View workflow job for this annotation

GitHub Actions / Push-Nuget

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 11 in aspnet-core/frameworks/src/Lion.AbpPro.HttpClient/Lion/AbpPro/HttpClient/WeatherForecast.cs

View workflow job for this annotation

GitHub Actions / Push-Nuget

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 11 in aspnet-core/frameworks/src/Lion.AbpPro.HttpClient/Lion/AbpPro/HttpClient/WeatherForecast.cs

View workflow job for this annotation

GitHub Actions / Push-Nuget

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
}

0 comments on commit fc4c5bd

Please sign in to comment.