mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 11:44:56 +00:00
MediaAttachments first init
This commit is contained in:
@@ -6,10 +6,10 @@ public class MediaAttachments
|
|||||||
public Guid MessageId { get; set; }
|
public Guid MessageId { get; set; }
|
||||||
|
|
||||||
public MediaType Type { get; set; }
|
public MediaType Type { get; set; }
|
||||||
public string FilePath { get; set; } = string.Empty; // путь к файлу (локальный или URL)
|
public string FilePath { get; set; } = string.Empty; // local path in filesystem
|
||||||
public string MimeType { get; set; } = string.Empty;
|
public string MimeType { get; set; } = string.Empty;
|
||||||
|
|
||||||
public string? EncryptedKey { get; set; } // если используется отдельное шифрование
|
public string? EncryptedKey { get; set; }
|
||||||
public Message Message { get; set; } = null!;
|
public Message Message { get; set; } = null!;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using Govor.Core.Models;
|
||||||
|
|
||||||
|
namespace Govor.Core.Repositories.MediasAttachments;
|
||||||
|
|
||||||
|
public interface IMediaAttachmentsExist
|
||||||
|
{
|
||||||
|
bool Exists(Guid id);
|
||||||
|
bool Exists(MediaAttachments attachments);
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using Govor.Core.Models;
|
||||||
|
|
||||||
|
namespace Govor.Core.Repositories.MediasAttachments;
|
||||||
|
|
||||||
|
public interface IMediaAttachmentsReader
|
||||||
|
{
|
||||||
|
Task<List<MediaAttachments>> GetAllAsync();
|
||||||
|
Task<List<MediaAttachments>> GetAllByMessageId(Guid messageId);
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace Govor.Core.Repositories.MediasAttachments;
|
||||||
|
|
||||||
|
public interface IMediaAttachmentsRepository : IMediaAttachmentsReader, IMediaAttachmentsWriter, IMediaAttachmentsExist
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
using Govor.Core.Models;
|
||||||
|
|
||||||
|
namespace Govor.Core.Repositories.MediasAttachments;
|
||||||
|
|
||||||
|
public interface IMediaAttachmentsWriter
|
||||||
|
{
|
||||||
|
Task AddAsync(MediaAttachments mediaAttachments);
|
||||||
|
Task UpdateAsync(MediaAttachments mediaAttachments);
|
||||||
|
Task RemoveAsync(Guid Id);
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
using Govor.Core.Infrastructure.Extensions;
|
||||||
|
using Govor.Core.Infrastructure.Validators;
|
||||||
|
using Govor.Core.Models;
|
||||||
|
using Govor.Core.Repositories.MediasAttachments;
|
||||||
|
using Govor.Data.Repositories.Exceptions;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace Govor.Data.Repositories;
|
||||||
|
|
||||||
|
public class MediaAttachmentsRepository : IMediaAttachmentsRepository
|
||||||
|
{
|
||||||
|
public IObjectValidator<MediaAttachments> _validator;
|
||||||
|
public GovorDbContext _context;
|
||||||
|
|
||||||
|
public MediaAttachmentsRepository(GovorDbContext context, IObjectValidator<MediaAttachments> validator)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
_validator = validator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<MediaAttachments>> GetAllAsync()
|
||||||
|
{
|
||||||
|
return await _context.MediaAttachments
|
||||||
|
.AsNoTracking()
|
||||||
|
.Include(ma => ma.Message)
|
||||||
|
.ToListOrThrowIfEmpty(new NotFoundException("No media attachments found."));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<List<MediaAttachments>> GetAllByMessageId(Guid messageId)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task AddAsync(MediaAttachments mediaAttachments)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task UpdateAsync(MediaAttachments mediaAttachments)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task RemoveAsync(Guid Id)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Exists(Guid id)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Exists(MediaAttachments attachments)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user