mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 19:54:55 +00:00
Refactor: migrate Core -> Domain and reorganize projects
Large refactor that renames/moves core types into a new Govor.Domain surface and reorganizes the Application layer. Models, configurations, migrations and many files moved from Govor.Core/Govor.Data to Govor.Domain; numerous Application services, interfaces and implementations were relocated or added (authentication, friends, messages, medias, push notifications, user sessions, storage, synching, private chats, etc.). Tests updated to use Govor.Domain namespaces and adjusted project references (removed Govor.Data reference from API tests). Also updated API, Hub and mapping code and project files to reflect the new structure and naming. This is primarily a codebase-wide namespace and module reorganization to establish a Domain project and restructure application services.
This commit is contained in:
@@ -1,8 +1,3 @@
|
||||
using Govor.Contracts.DTOs;
|
||||
using Govor.Core.Models;
|
||||
using Govor.Core.Models.Users;
|
||||
using Govor.Core.Repositories.Friendships;
|
||||
using Govor.Data.Repositories.Exceptions;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
@@ -14,14 +9,8 @@ namespace Govor.API.Controllers.AdminStuff;
|
||||
public class FriendshipsController : Controller
|
||||
{
|
||||
private readonly ILogger<FriendshipsController> _logger;
|
||||
private readonly IFriendshipsRepository _friendshipsRepository;
|
||||
|
||||
public FriendshipsController(ILogger<FriendshipsController> logger, IFriendshipsRepository friendshipsRepository)
|
||||
{
|
||||
_logger = logger;
|
||||
_friendshipsRepository = friendshipsRepository;
|
||||
}
|
||||
|
||||
/*
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> Get()
|
||||
{
|
||||
@@ -88,5 +77,5 @@ public class FriendshipsController : Controller
|
||||
_logger.LogError(ex, ex.Message);
|
||||
return StatusCode(500, new { error = "Internal server error." });
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
using Govor.Application.Interfaces;
|
||||
using Govor.Application.Infrastructure.AdminsStuff;
|
||||
using Govor.Contracts.DTOs;
|
||||
using Govor.Contracts.Requests;
|
||||
using Govor.Core.Repositories.Invaites;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Govor.API.Controllers.AdminStuff;
|
||||
@@ -12,17 +10,17 @@ namespace Govor.API.Controllers.AdminStuff;
|
||||
//[Authorize(Roles = "Admin")]
|
||||
public class InviteUserController : Controller
|
||||
{
|
||||
private readonly IInvitesRepository _repository;
|
||||
private readonly IInvitationGetter _invitationGetter;
|
||||
private readonly IInvitationGenerator _invitationGenerator;
|
||||
private readonly ILogger<InviteUserController> _logger;
|
||||
|
||||
public InviteUserController(IInvitationGenerator invitationGenerator,
|
||||
IInvitesRepository repository,
|
||||
IInvitationGetter invitationGetter,
|
||||
ILogger<InviteUserController> logger)
|
||||
{
|
||||
_invitationGenerator = invitationGenerator;
|
||||
_logger = logger;
|
||||
_repository = repository;
|
||||
_invitationGetter = invitationGetter;
|
||||
}
|
||||
|
||||
[HttpPost("[action]")]
|
||||
@@ -51,7 +49,7 @@ public class InviteUserController : Controller
|
||||
{
|
||||
_logger.LogInformation("Getting all active invitations by administrator");
|
||||
|
||||
var read = await _repository.GetAllAsync();
|
||||
var read = await _invitationGetter.GetAllAsync();
|
||||
var result = read.Where(x => x.IsActive).ToList();
|
||||
|
||||
List<InvitationResponses> dtos = new List<InvitationResponses>();
|
||||
@@ -86,7 +84,7 @@ public class InviteUserController : Controller
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Getting all invitations by administrator");
|
||||
var read = await _repository.GetAllAsync();
|
||||
var read = await _invitationGetter.GetAllAsync();
|
||||
|
||||
List<InvitationResponses> dtos = new List<InvitationResponses>();
|
||||
|
||||
@@ -120,18 +118,22 @@ public class InviteUserController : Controller
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Getting invitations {id} by administrator");
|
||||
var read = await _repository.FindByIdAsync(id);
|
||||
var read = await _invitationGetter.FindByIdAsync(id);
|
||||
|
||||
if(read.IsFailure)
|
||||
return NotFound(read.Error);
|
||||
var dto = read.Value;
|
||||
|
||||
var response = new InvitationResponses(){
|
||||
Id = read.Id,
|
||||
Description = read.Description,
|
||||
IsAdmin = read.IsAdmin,
|
||||
MaxParticipants = read.MaxParticipants,
|
||||
Code = read.Code,
|
||||
CreatedAt = read.DateCreated,
|
||||
EndAt = read.EndDate,
|
||||
IsActive = read.IsActive,
|
||||
ParticipantCount = read.Users.Count,
|
||||
Id = dto.Id,
|
||||
Description = dto.Description,
|
||||
IsAdmin = dto.IsAdmin,
|
||||
MaxParticipants = dto.MaxParticipants,
|
||||
Code = dto.Code,
|
||||
CreatedAt = dto.DateCreated,
|
||||
EndAt = dto.EndDate,
|
||||
IsActive = dto.IsActive,
|
||||
ParticipantCount = dto.Users.Count,
|
||||
};
|
||||
|
||||
return Ok(response);
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
using Govor.Application.Interfaces;
|
||||
using Govor.Application.Infrastructure.AdminsStuff;
|
||||
using Govor.Contracts.Responses.Admins;
|
||||
using Govor.Core.Infrastructure.Extensions;
|
||||
using Govor.Core.Models.Users;
|
||||
using Govor.Data.Repositories.Exceptions;
|
||||
using Govor.Domain.Models.Users;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Govor.API.Controllers.AdminStuff;
|
||||
@@ -54,11 +51,6 @@ public class UsersController : Controller
|
||||
var read = await _users.GetUserById(id);
|
||||
return Ok(BuildUserDtos([read]).First());
|
||||
}
|
||||
catch (NotFoundByKeyException<Guid> ex)
|
||||
{
|
||||
_logger.LogWarning(ex, ex.Message);
|
||||
return NotFound(ex.Message);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError(e, e.Message);
|
||||
|
||||
Reference in New Issue
Block a user