70 lines
1.2 KiB
C#
70 lines
1.2 KiB
C#
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;
|
|
}
|
|
} |