饭太稀
This commit is contained in:
31
Hotfix/HTTPHandler/HelloController.cs
Normal file
31
Hotfix/HTTPHandler/HelloController.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System.Threading;
|
||||
using Fantasy.Async;
|
||||
using Fantasy.Entitas;
|
||||
using Fantasy.Network.HTTP;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Fantasy;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
[ServiceFilter(typeof(SceneContextFilter))]
|
||||
public class HelloController : ControllerBase
|
||||
{
|
||||
private readonly Scene _scene;
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数依赖注入
|
||||
/// </summary>
|
||||
/// <param name="scene"></param>
|
||||
public HelloController(Scene scene)
|
||||
{
|
||||
_scene = scene;
|
||||
}
|
||||
|
||||
[HttpGet("greet")]
|
||||
public async FTask<IActionResult> Greet()
|
||||
{
|
||||
Log.Debug($"HelloController Thread.CurrentThread.ManagedThreadId:{Thread.CurrentThread.ManagedThreadId}");
|
||||
return Ok($"Hello from the Fantasy controller! _scene.SceneType:{_scene.SceneType} _scene.SceneType:{_scene.SceneConfigId}");
|
||||
}
|
||||
}
|
||||
21
Hotfix/HTTPHandler/ProductsController.cs
Normal file
21
Hotfix/HTTPHandler/ProductsController.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Fantasy;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class ProductsController : ControllerBase
|
||||
{
|
||||
[HttpPost]
|
||||
public IActionResult MiniGame ([FromBody] Product product)
|
||||
{
|
||||
// 假设已经保存产品数据
|
||||
return Ok("Product created successfully");
|
||||
}
|
||||
}
|
||||
|
||||
public class Product
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
45
Hotfix/HTTPHandler/UsersController.cs
Normal file
45
Hotfix/HTTPHandler/UsersController.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System.Threading;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Fantasy;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class UsersController : ControllerBase
|
||||
{
|
||||
private readonly Scene _scene;
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数依赖注入
|
||||
/// </summary>
|
||||
/// <param name="scene"></param>
|
||||
public UsersController(Scene scene)
|
||||
{
|
||||
_scene = scene;
|
||||
}
|
||||
|
||||
[HttpGet("{userId}")]
|
||||
public IActionResult GetUser(int userId)
|
||||
{
|
||||
return Ok($"User ID: {userId}");
|
||||
}
|
||||
|
||||
[HttpPost("register")]
|
||||
public IActionResult RegisterUser([FromBody] User user)
|
||||
{
|
||||
return Ok("User registered successfully");
|
||||
}
|
||||
|
||||
[HttpGet("greet")]
|
||||
public IActionResult Greet()
|
||||
{
|
||||
Log.Debug($"HelloController Thread.CurrentThread.ManagedThreadId:{Thread.CurrentThread.ManagedThreadId}");
|
||||
return Ok($"Hello from the Fantasy controller! _scene.SceneType:{_scene.SceneType} _scene.SceneType:{_scene.SceneConfigId}");
|
||||
}
|
||||
}
|
||||
|
||||
public class User
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user