begin new and last rework

This commit is contained in:
2024-07-18 14:44:29 +02:00
parent abfc997ac1
commit 1a976fc9ef
26 changed files with 444 additions and 101 deletions

View File

@@ -0,0 +1,34 @@
namespace OwnChar.ServerNew.Api.Endpoint.Implementations;
internal class CharactersApi(IServer server) : IApiEndpoint
{
public void Initialize(IApiBuilder builder)
{
throw new NotImplementedException();
}
private IResult GetCharacter(long characterId)
{
}
private IResult CreateGroupCharacter(string name, long groupId)
{
}
private IResult CreateUserCharacter(string name, long userId)
{
}
private IResult UpdateCharacter(long characterId)
{
}
private IResult DeleteCharacter(long characterId)
{
}
}

View File

@@ -0,0 +1,48 @@
namespace OwnChar.ServerNew.Api.Endpoint.Implementations;
internal class GroupsApi(IServer server) : IApiEndpoint
{
public void Initialize(IApiBuilder builder)
{
}
private IResult GetGroups()
{
}
private IResult GetGroups(long characterId)
{
}
private IResult GetGroup(long groupId)
{
}
private IResult CreateGroup(string name)
{
}
private IResult UpdateGroup(int groupId, string name)
{
}
private IResult DeleteGroup(int groupId)
{
}
private IResult AddMember(int groupId, long memberId)
{
}
private IResult RemoveMember(int groupId, long memberId)
{
}
}

View File

@@ -0,0 +1,31 @@
using Microsoft.AspNetCore.Mvc;
using OwnChar.Api.Responses;
using OwnChar.Model;
namespace OwnChar.ServerNew.Api.Endpoint.Implementations;
internal class LoginApi(ServerContext server) : IApiEndpoint
{
public void Initialize(IApiBuilder builder)
{
builder.Map("/auth/login/{username}", Login);
builder.Map("/auth/logout/{secret}", Logout);
}
private IResult Login(string username, [FromHeader(Name = "X-USER-PASSWORD")] string password)
{
if (server.Data != null && server.Data.GetAll<UserAccount>()?.FirstOrDefault(n => n.Username == username && n.Password == password) is UserAccount account)
return TypedResults.Ok(new LoginResponse
{
Secret = server.Login(account),
UserAccount = account,
});
return TypedResults.Unauthorized();
}
private IResult Logout([FromHeader(Name = "X-AUTH-SECRET")] string secret)
{
server.Logout(secret);
return TypedResults.Ok();
}
}

View File

@@ -0,0 +1,44 @@
namespace OwnChar.ServerNew.Api.Endpoint.Implementations;
internal class UsersApi(IServer server) : IApiEndpoint
{
public void Initialize(IApiBuilder builder)
{
throw new NotImplementedException();
}
private IResult GetUsers()
{
}
private IResult GetUser(long userId)
{
}
private IResult GetUserProfile(long userId)
{
}
private IResult CreateUser(string username, string password)
{
}
private IResult DeleteUser(long userId)
{
}
private IResult UpdateUserPassword(long userId, string username, string password)
{
}
private IResult UpdateUserProfile(long profileId, string displayName)
{
}
}