This commit is contained in:
CortexCore
2024-04-28 15:45:17 +08:00
commit 5ca9a8ee1b
6 changed files with 764 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
using BITKit;
using IDIS.Models;
using IDIS.Services;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
namespace IDIS_Server_SIM.Controllers;
[ApiController]
[Route("api")]
public class IDISController:Controller
{
private readonly IDIS_Service _service;
public IDISController(IDIS_Service service)
{
_service = service;
}
[HttpGet]
[Route("info")]
public IActionResult Info()
{
return new ContentResult
{
Content = Environment.MachineName
};
}
[HttpGet]
[Route("query")]
public async Task<IActionResult> Query(string key)
{
try
{
return Ok(await _service.QueryAsync(key));
}
catch (Exception e)
{
return BadRequest(ContextModel.Error(e.ToString()));
}
}
[HttpGet]
[Route("isExist")]
public async Task<bool> IsExist(string key)
{
return await _service.IsExistAsync(key);
}
[HttpGet]
[Route("register")]
public string Register([FromBody] string json)
{
return "err:0";
}
[HttpGet]
[Route("update")]
public string Update([FromBody] string json)
{
return "err:0";
}
[HttpGet]
[Route("delete")]
public async Task<bool> Delete (string handle)
{
await _service.DeleteAsync(handle);
return true;
}
}