添加项目文件。
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
using AutoMapper;
|
||||
using IM.Commons;
|
||||
using MessageService.Domain.IReposities;
|
||||
using MessageService.WebApi.Application.Dtos;
|
||||
|
||||
namespace MessageService.WebApi.Application.Conversation
|
||||
{
|
||||
public class ConversationService
|
||||
{
|
||||
private readonly IConversationReposity reposity;
|
||||
private readonly IMapper mapper;
|
||||
|
||||
public ConversationService(IConversationReposity reposity, IMapper mapper)
|
||||
{
|
||||
this.reposity = reposity;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
public async Task<Result<List<ConversationResponse>>> GetByOwnerIdAsync(Guid userId)
|
||||
{
|
||||
var list = await reposity.FindByUserIdAsync(userId);
|
||||
return Result.Success(mapper.Map<List<ConversationResponse>>(list.ToList()));
|
||||
}
|
||||
|
||||
public async Task<Result<ConversationResponse>> GetByIdAsync(Guid id, Guid userId)
|
||||
{
|
||||
var conversation = await reposity.FindByIdAsync(id);
|
||||
|
||||
if (conversation is null || conversation.UserId != userId)
|
||||
{
|
||||
return Result.Fail<ConversationResponse>(ResultCode.CONVERSATION_NOT_FOUND);
|
||||
}
|
||||
|
||||
return Result.Success(mapper.Map<ConversationResponse>(conversation));
|
||||
}
|
||||
|
||||
public async Task<Result<List<string>>> GetStreamkeysAsync(Guid userId)
|
||||
{
|
||||
var list = await reposity.FindAllStreamKeyAsync(userId);
|
||||
return Result.Success(list.ToList());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user