Major database refactor (again)

This commit is contained in:
Ske
2020-08-29 13:46:27 +02:00
parent 3996cd48c7
commit c7612df37e
55 changed files with 1014 additions and 1100 deletions

View File

@@ -13,18 +13,20 @@ namespace PluralKit.API
[Route( "v{version:apiVersion}/a" )]
public class AccountController: ControllerBase
{
private IDataStore _data;
public AccountController(IDataStore data)
private readonly IDatabase _db;
private readonly ModelRepository _repo;
public AccountController(IDatabase db, ModelRepository repo)
{
_data = data;
_db = db;
_repo = repo;
}
[HttpGet("{aid}")]
public async Task<ActionResult<JObject>> GetSystemByAccount(ulong aid)
{
var system = await _data.GetSystemByAccount(aid);
if (system == null) return NotFound("Account not found.");
var system = await _db.Execute(c => _repo.GetSystemByAccount(c, aid));
if (system == null)
return NotFound("Account not found.");
return Ok(system.ToJson(User.ContextFor(system)));
}