43 lines
1.5 KiB
C#
43 lines
1.5 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Milimoe.FunGame.Core.Api.Transmittal;
|
|
using Milimoe.FunGame.Core.Library.Exception;
|
|
using Milimoe.FunGame.WebAPI.Constant;
|
|
|
|
namespace Milimoe.FunGame.WebAPI.Controllers
|
|
{
|
|
[Authorize(AuthenticationSchemes = "CustomBearer")]
|
|
[ApiController]
|
|
[Route("[controller]")]
|
|
public class APIController : ControllerBase
|
|
{
|
|
[HttpGet("getuser")]
|
|
public async Task<IActionResult> GetUser(long id)
|
|
{
|
|
if (Statics.RunningPlugin != null)
|
|
{
|
|
try
|
|
{
|
|
SQLHelper? sql = Statics.RunningPlugin.Controller.SQLHelper;
|
|
if (sql != null)
|
|
{
|
|
sql.Script = "select * from users where id = @id";
|
|
sql.Parameters.Add("id", id);
|
|
await sql.ExecuteDataSetAsync();
|
|
if (sql.Success)
|
|
{
|
|
return Ok(sql.DataSet);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Statics.RunningPlugin.Controller.Error(e);
|
|
return NotFound("无法调用此接口。原因:\r\n" + e.GetErrorInfo());
|
|
}
|
|
}
|
|
return StatusCode(500, "无法调用此接口。原因:与 SQL 服务器通信失败。");
|
|
}
|
|
}
|
|
}
|