-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Made skeleton of chat microservice architecture, made creating chats …
…when creating group, new Migration
- Loading branch information
Showing
16 changed files
with
918 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using Backend.Auth.Dto; | ||
using Backend.Chat.Dto; | ||
using Backend.Chat.Logic; | ||
|
||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace Backend.Chat.Api; | ||
|
||
|
||
[ApiController] | ||
[Route(template: "/api/v1/chat")] | ||
public class ChatController(ChatService chatService) | ||
{ | ||
private readonly ChatService _chatService = chatService; | ||
|
||
[HttpGet] | ||
public async Task<ChatGetAllChatsDto> GetAllChats([FromHeader] UserAuthInfo authInfo) | ||
{ | ||
return await _chatService.GetAllChatsAsync(authInfo); | ||
} | ||
|
||
[HttpGet] | ||
[Route("{chatId}/message")] | ||
public async Task<ChatGetAllMessagesDto> GetAllMessages([FromHeader] UserAuthInfo authInfo, [FromRoute] int chatId) | ||
{ | ||
return await _chatService.GetAllMessagesAsync(authInfo, chatId); | ||
} | ||
|
||
[HttpGet] | ||
[Route("message/{messageId}")] | ||
public async Task<ChatGetOneMessageDto> GetOneMessage([FromRoute] int messageId) | ||
{ | ||
return await _chatService.GetMessageAsync(messageId); | ||
} | ||
|
||
[HttpPost] | ||
[Route("{chatId}/message")] | ||
public async Task<IResult> SendMessage([FromHeader] UserAuthInfo authInfo, [FromRoute] int chatId, [FromBody] ChatSendMessageDto messageDto) | ||
{ | ||
await _chatService.SendMessageAsync(authInfo, chatId, messageDto); | ||
return Results.Ok(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Backend.Base.Dal; | ||
using Backend.Base.Dal.Interfaces; | ||
using Backend.Chat.Dal.Interfaces; | ||
using Backend.Chat.Dal.Models; | ||
|
||
namespace Backend.Chat.Dal; | ||
|
||
public class ChatRepo : BaseRepo<ChatModel>, IChatRepo | ||
{ | ||
public ChatRepo(AppDatabase database) : base(database) | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using Backend.Base.Dal.Interfaces; | ||
using Backend.Chat.Dal.Models; | ||
|
||
namespace Backend.Chat.Dal.Interfaces; | ||
|
||
public interface IChatRepo : IBaseRepo<ChatModel> | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using Backend.Base.Dal.Interfaces; | ||
using Backend.Chat.Dal.Models; | ||
|
||
namespace Backend.Chat.Dal.Interfaces; | ||
|
||
public interface IMessageRepo : IBaseRepo<MessageModel> | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Backend.Base.Dal; | ||
using Backend.Chat.Dal.Interfaces; | ||
using Backend.Chat.Dal.Models; | ||
|
||
namespace Backend.Chat.Dal; | ||
|
||
public class MessageRepo : BaseRepo<MessageModel>, IMessageRepo | ||
{ | ||
public MessageRepo(AppDatabase database) : base(database) | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using Backend.Base.Dal.Models; | ||
|
||
namespace Backend.Chat.Dal.Models; | ||
|
||
public class ChatModel : BaseModel | ||
{ | ||
public int User1Id { get; set; } | ||
public int User2Id { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Backend.Base.Dal.Models; | ||
|
||
namespace Backend.Chat.Dal.Models; | ||
|
||
public class MessageModel : BaseModel | ||
{ | ||
public int ChatId { get; set; } | ||
public int UserId { get; set; } | ||
public string MessageText { get; set; } | ||
public bool IsRead { get; set; } | ||
public long CreatedAt { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using Backend.Base.Dto; | ||
|
||
namespace Backend.Chat.Dto; | ||
|
||
public class ChatGetAllChatsDto : BaseDto | ||
{ | ||
public class ChatDto | ||
{ | ||
public int ChatId { get; set; } | ||
public string UserPhoto { get; set; } | ||
public string UserName { get; set; } | ||
public string UserSurname { get; set; } | ||
public string UserPatronymic { get; set; } | ||
public string LastMessageId { get; set; } | ||
} | ||
|
||
public List<ChatDto> Chats { get; set; } | ||
} | ||
|
||
public class MessageDto : BaseDto | ||
{ | ||
public int SenderId { get; set; } | ||
public int ReceiverId { get; set; } | ||
public int MessageId { get; set; } | ||
public string MessageText { get; set; } | ||
public bool IsRead { get; set; } | ||
public long CreatedAt { get; set; } | ||
} | ||
|
||
public class ChatGetAllMessagesDto : BaseDto | ||
{ | ||
public List<MessageDto> Messages { get; set; } | ||
} | ||
|
||
public class ChatGetOneMessageDto : BaseDto | ||
{ | ||
public MessageDto Message { get; set; } | ||
} | ||
|
||
public class ChatSendMessageDto : BaseDto | ||
{ | ||
public int UserId { get; set; } | ||
public string Text { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Backend.Auth.Dto; | ||
using Backend.Chat.Dto; | ||
|
||
namespace Backend.Chat.Logic; | ||
|
||
public class ChatService | ||
{ | ||
public ChatService() | ||
{ | ||
|
||
} | ||
|
||
public async Task<ChatGetAllChatsDto> GetAllChatsAsync(UserAuthInfo authInfo) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public async Task<ChatGetAllMessagesDto> GetAllMessagesAsync(UserAuthInfo authInfo, int chatId) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public async Task<ChatGetOneMessageDto> GetMessageAsync(int messageId) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public async Task SendMessageAsync(UserAuthInfo authInfo, int chatId, ChatSendMessageDto chatSendMessageDto) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.