Add relationships feature and EF migration
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
using AutoMapper;
|
||||
using RecNet.Application.Profiles;
|
||||
using RecNet.Application.Profiles.Avatar;
|
||||
using RecNet.Application.Profiles.Relationships;
|
||||
using RecNet.Application.Profiles.Settings;
|
||||
|
||||
namespace RecNet.Application.Common.Mapping;
|
||||
|
||||
@@ -9,6 +12,7 @@ public class ApplicationMappingProfile : Profile
|
||||
{
|
||||
CreateMap<Domain.Profiles.Profile, ProfileDTO>();
|
||||
CreateMap<Domain.Profiles.Avatar, AvatarDTO>();
|
||||
CreateMap<Domain.Profiles.Relationship, RelationshipDTO>();
|
||||
CreateMap<Domain.Profiles.PlayerSetting, PlayerSettingDTO>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using RecNet.Application.Neutrino;
|
||||
using RecNet.Application.Profiles;
|
||||
using RecNet.Application.Profiles.Login;
|
||||
using RecNet.Application.Profiles.Relationships;
|
||||
|
||||
namespace RecNet.Application;
|
||||
|
||||
@@ -13,6 +15,7 @@ public static class DependencyInjection
|
||||
services.AddScoped<NameGenerator>();
|
||||
|
||||
services.AddScoped<IProfileService, ProfileService>();
|
||||
services.AddScoped<IRelationshipService, RelationshipService>();
|
||||
services.AddScoped<INeutrinoAuthorizationService, NeutrinoAuthorizationService>();
|
||||
|
||||
return services;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RecNet.Application.Profiles;
|
||||
namespace RecNet.Application.Profiles.Avatar;
|
||||
|
||||
public class AvatarDTO
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace RecNet.Application.Profiles;
|
||||
namespace RecNet.Application.Profiles.Avatar;
|
||||
|
||||
public sealed record UpdateAvatarCommand(
|
||||
string? OutfitSelections,
|
||||
@@ -1,4 +1,8 @@
|
||||
|
||||
using RecNet.Application.Profiles.Avatar;
|
||||
using RecNet.Application.Profiles.Login;
|
||||
using RecNet.Application.Profiles.Settings;
|
||||
|
||||
namespace RecNet.Application.Profiles;
|
||||
|
||||
public interface IProfileService
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using RecNet.Domain.Common;
|
||||
|
||||
namespace RecNet.Application.Profiles;
|
||||
namespace RecNet.Application.Profiles.Login;
|
||||
|
||||
public sealed record LoginProfileCommand(
|
||||
string AppVersion,
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace RecNet.Application.Profiles;
|
||||
namespace RecNet.Application.Profiles.Login;
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using RecNet.Application.Common.Interfaces;
|
||||
using RecNet.Domain.Profiles.Names;
|
||||
|
||||
namespace RecNet.Application.Profiles;
|
||||
namespace RecNet.Application.Profiles.Login;
|
||||
|
||||
public class NameGenerator(IConfigService configService)
|
||||
{
|
||||
@@ -1,10 +1,14 @@
|
||||
using AutoMapper;
|
||||
using RecNet.Application.Common.Interfaces;
|
||||
using RecNet.Application.Common.Security;
|
||||
using RecNet.Application.Profiles.Avatar;
|
||||
using RecNet.Application.Profiles.Login;
|
||||
using RecNet.Application.Profiles.Settings;
|
||||
using RecNet.Domain.Common;
|
||||
using RecNet.Domain.GameVersions;
|
||||
using RecNet.Domain.Profiles;
|
||||
using ProfileEntity = RecNet.Domain.Profiles.Profile;
|
||||
using AvatarEntity = RecNet.Domain.Profiles.Avatar;
|
||||
|
||||
namespace RecNet.Application.Profiles;
|
||||
|
||||
@@ -45,7 +49,7 @@ public class ProfileService(
|
||||
return null;
|
||||
|
||||
profile.SetAvatar(
|
||||
Avatar.Create(
|
||||
AvatarEntity.Create(
|
||||
command.OutfitSelections,
|
||||
command.SkinColor,
|
||||
command.HairColor
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace RecNet.Application.Profiles.Relationships;
|
||||
|
||||
public interface IRelationshipService
|
||||
{
|
||||
Task<IReadOnlyList<RelationshipDTO>> GetRelationshipsAsync(Guid profileId, CancellationToken ct = default);
|
||||
Task<RelationshipDTO> UpdateRelationshipAsync(Guid profileId, UpdateRelationshipCommand command, CancellationToken ct = default);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RecNet.Application.Profiles.Relationships;
|
||||
|
||||
public class RelationshipDTO
|
||||
{
|
||||
[JsonPropertyName("ProfileId")]
|
||||
public Guid ProfileId { get; set; }
|
||||
|
||||
[JsonPropertyName("Muted")]
|
||||
public bool Muted { get; set; }
|
||||
|
||||
[JsonPropertyName("Ignored")]
|
||||
public bool Ignored { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using AutoMapper;
|
||||
using RecNet.Domain.Profiles;
|
||||
|
||||
namespace RecNet.Application.Profiles.Relationships;
|
||||
|
||||
public class RelationshipService(IRelationshipRepository repository, IMapper mapper) : IRelationshipService
|
||||
{
|
||||
public async Task<IReadOnlyList<RelationshipDTO>> GetRelationshipsAsync(
|
||||
Guid profileId,
|
||||
CancellationToken ct = default)
|
||||
{
|
||||
var relationships = await repository.GetAllOwnedRelationships(profileId, ct);
|
||||
|
||||
return mapper.Map<List<RelationshipDTO>>(relationships);
|
||||
}
|
||||
|
||||
public async Task<RelationshipDTO> UpdateRelationshipAsync(Guid profileId, UpdateRelationshipCommand command, CancellationToken ct = default)
|
||||
{
|
||||
var relationship = await repository.GetAsync(profileId, command.ProfileId, ct);
|
||||
if (relationship == null)
|
||||
{
|
||||
|
||||
relationship = Relationship.Create(profileId, command.ProfileId);
|
||||
await repository.AddAsync(relationship, ct);
|
||||
}
|
||||
|
||||
relationship.Mutate(command.Muted, command.Ignored);
|
||||
|
||||
await repository.SaveChangesAsync(ct);
|
||||
|
||||
return mapper.Map<RelationshipDTO>(relationship);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace RecNet.Application.Profiles.Relationships;
|
||||
|
||||
public record UpdateRelationshipCommand(
|
||||
Guid ProfileId,
|
||||
bool Muted,
|
||||
bool Ignored);
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RecNet.Application.Profiles;
|
||||
namespace RecNet.Application.Profiles.Settings;
|
||||
|
||||
public class PlayerSettingDTO
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace RecNet.Application.Profiles;
|
||||
namespace RecNet.Application.Profiles.Settings;
|
||||
|
||||
public sealed record UpdatePlayerSettingCommand(
|
||||
string Key,
|
||||
Reference in New Issue
Block a user