添加项目文件。
This commit is contained in:
20
Atomx.WebAPI/Atomx.WebAPI.csproj
Normal file
20
Atomx.WebAPI/Atomx.WebAPI.csproj
Normal file
@@ -0,0 +1,20 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.0" />
|
||||
<PackageReference Include="Microsoft.Orleans.Server" Version="9.2.1" />
|
||||
<PackageReference Include="TickerQ" Version="10.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Atomx.Common\Atomx.Common.csproj" />
|
||||
<ProjectReference Include="..\Atomx.Data\Atomx.Data.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
6
Atomx.WebAPI/Atomx.WebAPI.http
Normal file
6
Atomx.WebAPI/Atomx.WebAPI.http
Normal file
@@ -0,0 +1,6 @@
|
||||
@Atomx.WebAPI_HostAddress = http://localhost:5241
|
||||
|
||||
GET {{Atomx.WebAPI_HostAddress}}/weatherforecast/
|
||||
Accept: application/json
|
||||
|
||||
###
|
||||
25
Atomx.WebAPI/Controllers/AreaController.cs
Normal file
25
Atomx.WebAPI/Controllers/AreaController.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Atomx.WebAPI.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 国家地区省份API
|
||||
/// </summary>
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class AreaController : ControllerBase
|
||||
{
|
||||
public AreaController() { }
|
||||
|
||||
/// <summary>
|
||||
/// 获取国家列表信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("country")]
|
||||
public IActionResult GetCountry()
|
||||
{
|
||||
return new ContentResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
33
Atomx.WebAPI/Controllers/SignController.cs
Normal file
33
Atomx.WebAPI/Controllers/SignController.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Atomx.WebAPI.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 登录注册API
|
||||
/// </summary>
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class SignController : ControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 登录
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost("sign/in")]
|
||||
public IActionResult SignIn()
|
||||
{
|
||||
return new ContentResult();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 注册
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost("sign/up")]
|
||||
public IActionResult SignUp()
|
||||
{
|
||||
return new ContentResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
26
Atomx.WebAPI/Controllers/WeatherForecastController.cs
Normal file
26
Atomx.WebAPI/Controllers/WeatherForecastController.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Atomx.WebAPI.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class WeatherForecastController : ControllerBase
|
||||
{
|
||||
private static readonly string[] Summaries =
|
||||
[
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
];
|
||||
|
||||
[HttpGet(Name = "GetWeatherForecast")]
|
||||
public IEnumerable<WeatherForecast> Get()
|
||||
{
|
||||
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||
{
|
||||
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
||||
TemperatureC = Random.Shared.Next(-20, 55),
|
||||
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
|
||||
})
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
27
Atomx.WebAPI/Grains/UserGrain.cs
Normal file
27
Atomx.WebAPI/Grains/UserGrain.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using Atomx.Common.Entities;
|
||||
using Atomx.Data;
|
||||
|
||||
namespace Atomx.WebAPI.Grains
|
||||
{
|
||||
public interface IUserGrain : IGrainWithIntegerKey
|
||||
{
|
||||
Task<User> GetUserByName(string name);
|
||||
}
|
||||
|
||||
public class UserGrain : Grain, IUserGrain
|
||||
{
|
||||
private readonly ILogger<UserGrain> _logger;
|
||||
private readonly DataContext _dbContext;
|
||||
|
||||
public UserGrain(ILogger<UserGrain> logger, DataContext dbContext)
|
||||
{
|
||||
_logger = logger;
|
||||
_dbContext = dbContext;
|
||||
}
|
||||
|
||||
public Task<User> GetUserByName(string name)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
21
Atomx.WebAPI/Program.cs
Normal file
21
Atomx.WebAPI/Program.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
|
||||
builder.Services.AddControllers();
|
||||
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
|
||||
builder.Services.AddOpenApi();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.MapOpenApi();
|
||||
}
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
14
Atomx.WebAPI/Properties/launchSettings.json
Normal file
14
Atomx.WebAPI/Properties/launchSettings.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": false,
|
||||
"applicationUrl": "http://localhost:5241",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Atomx.WebAPI/WeatherForecast.cs
Normal file
13
Atomx.WebAPI/WeatherForecast.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
namespace Atomx.WebAPI
|
||||
{
|
||||
public class WeatherForecast
|
||||
{
|
||||
public DateOnly Date { get; set; }
|
||||
|
||||
public int TemperatureC { get; set; }
|
||||
|
||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||
|
||||
public string? Summary { get; set; }
|
||||
}
|
||||
}
|
||||
8
Atomx.WebAPI/appsettings.Development.json
Normal file
8
Atomx.WebAPI/appsettings.Development.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
||||
9
Atomx.WebAPI/appsettings.json
Normal file
9
Atomx.WebAPI/appsettings.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
Reference in New Issue
Block a user