1
This commit is contained in:
70
IDIS_Server-SIM/Controllers/IDISController.cs
Normal file
70
IDIS_Server-SIM/Controllers/IDISController.cs
Normal 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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user