Add AutoMapper and message response models

Introduced AutoMapper to the API project and registered it in the DI container. Added mapping profiles for core models to DTOs and response objects. Refactored controllers to use AutoMapper for mapping entities to response DTOs. Implemented new response models for messages, media attachments, reactions, and views. Updated MessagesLoader to load messages with related data. Added a migration to support ChatGroupId in messages. Updated dependencies and fixed minor issues in related files.
This commit is contained in:
Artemy
2025-07-12 16:39:06 +07:00
parent c7de2318fc
commit 96587b491d
22 changed files with 972 additions and 98 deletions
@@ -65,6 +65,9 @@ public static class ConfigurationProgramExtensions
services.AddScoped<IVerifyFriendship, VerifyFriendship>();
services.AddScoped<IUserGroupsService, UserGroupsService>();
services.AddScoped<IMessagesLoader, MessagesLoader>();
// Auto Mapper
services.AddAutoMapper(typeof(MappingProfile));
}
public static void AddRepositories(this IServiceCollection services)
+22
View File
@@ -0,0 +1,22 @@
using AutoMapper;
using Govor.Contracts.DTOs;
using Govor.Contracts.Responses;
using Govor.Core.Models;
using Govor.Core.Models.Messages;
using Govor.Core.Models.Users;
namespace Govor.API.Extensions;
public class MappingProfile : Profile
{
public MappingProfile()
{
CreateMap<Message, MessageResponse>();
CreateMap<MediaAttachments, MediaAttachmentResponse>();
CreateMap<MessageReaction, MessageReactionResponse>();
CreateMap<MessageView, MessageViewResponse>();
CreateMap<User, UserDto>();
CreateMap<Friendship, FriendshipDto>();
}
}