添加项目文件。
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
using MessageService.Domain.Entities;
|
||||
using MessageService.Domain.IReposities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace MessageService.Infrastructure.Reposities
|
||||
{
|
||||
public class ConversationReposity : IConversationReposity
|
||||
{
|
||||
private readonly MessageDbContext db;
|
||||
|
||||
public ConversationReposity(MessageDbContext db)
|
||||
{
|
||||
this.db = db;
|
||||
}
|
||||
|
||||
public void Create(Conversation conversation)
|
||||
{
|
||||
db.Conversations.Add(conversation);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<string>> FindAllStreamKeyAsync(Guid userId)
|
||||
{
|
||||
return await db.Conversations.Where(x => x.UserId == userId)
|
||||
.Select(s => s.StreamKey)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<Conversation?> FindByIdAsync(Guid id)
|
||||
{
|
||||
return await db.Conversations.FirstOrDefaultAsync(x => x.Id == id);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Conversation>> FindByStreamKeyAsync(string streamKey)
|
||||
{
|
||||
return await db.Conversations.Where(x => x.StreamKey == streamKey).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Conversation>> FindByTargetIdAsync(Guid targetId)
|
||||
{
|
||||
return await db.Conversations.Where(x => x.TargetId == targetId).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Conversation>> FindByUserIdAsync(Guid userId)
|
||||
{
|
||||
return await db.Conversations.Where(x => x.UserId == userId).ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user