-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #166 from SaintAngeLs/posts_service
Posts service update
- Loading branch information
Showing
25 changed files
with
382 additions
and
5 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
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
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
11 changes: 11 additions & 0 deletions
11
MiniSpace.Services.Posts/src/MiniSpace.Services.Posts.Application/Commands/SearchPosts.cs
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,11 @@ | ||
using Convey.CQRS.Commands; | ||
using MiniSpace.Services.Posts.Application.Dto; | ||
|
||
namespace MiniSpace.Services.Posts.Application.Commands | ||
{ | ||
public class SearchPosts : ICommand | ||
{ | ||
public Guid StudentId { get; set; } | ||
public PageableDto Pageable { get; set; } | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
MiniSpace.Services.Posts/src/MiniSpace.Services.Posts.Application/Dto/PageableDto.cs
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 @@ | ||
namespace MiniSpace.Services.Posts.Application.Dto | ||
{ | ||
public class PageableDto | ||
{ | ||
public int Page { get; set; } | ||
public int Size { get; set; } | ||
public SortDto Sort { 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
8 changes: 8 additions & 0 deletions
8
MiniSpace.Services.Posts/src/MiniSpace.Services.Posts.Application/Dto/SortDto.cs
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,8 @@ | ||
namespace MiniSpace.Services.Posts.Application.Dto | ||
{ | ||
public class SortDto | ||
{ | ||
public IEnumerable<string> SortBy { get; set; } | ||
public string Direction { get; set; } | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
MiniSpace.Services.Posts/src/MiniSpace.Services.Posts.Application/Dto/StudentEventsDto.cs
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 @@ | ||
namespace MiniSpace.Services.Posts.Application.Dto | ||
{ | ||
public class StudentEventsDto | ||
{ | ||
public Guid StudentId { get; set; } | ||
public IEnumerable<Guid> InterestedInEvents { get; set; } | ||
public IEnumerable<Guid> SignedUpEvents { get; set; } | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...ts/src/MiniSpace.Services.Posts.Application/Exceptions/UnauthorizedPostSearchException.cs
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,15 @@ | ||
namespace MiniSpace.Services.Posts.Application.Exceptions | ||
{ | ||
public class UnauthorizedPostSearchException : AppException | ||
{ | ||
public override string Code { get; } = "unauthorized_post_search"; | ||
public Guid StudentId { get; } | ||
public Guid IdentityId { get; } | ||
|
||
public UnauthorizedPostSearchException(Guid studentId, Guid identityId) : base("Unauthorized post search.") | ||
{ | ||
StudentId = studentId; | ||
IdentityId = identityId; | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...Posts/src/MiniSpace.Services.Posts.Application/Services/Clients/IStudentsServiceClient.cs
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 MiniSpace.Services.Posts.Application.Dto; | ||
|
||
namespace MiniSpace.Services.Posts.Application.Services.Clients | ||
{ | ||
public interface IStudentsServiceClient | ||
{ | ||
Task<StudentEventsDto> GetAsync(Guid id); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
MiniSpace.Services.Posts/src/MiniSpace.Services.Posts.Application/Services/IPostsService.cs
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,11 @@ | ||
using MiniSpace.Services.Posts.Application.Commands; | ||
using MiniSpace.Services.Posts.Application.Dto; | ||
using MiniSpace.Services.Posts.Core.Wrappers; | ||
|
||
namespace MiniSpace.Services.Posts.Application.Services | ||
{ | ||
public interface IPostsService | ||
{ | ||
Task<PagedResponse<IEnumerable<PostDto>>> BrowsePostsAsync(SearchPosts command); | ||
} | ||
} |
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
14 changes: 14 additions & 0 deletions
14
.../MiniSpace.Services.Posts.Core/Exceptions/InvalidStudentServiceClientResponseException.cs
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 @@ | ||
namespace MiniSpace.Services.Posts.Core.Exceptions | ||
{ | ||
public class InvalidStudentServiceClientResponseException : DomainException | ||
{ | ||
public override string Code { get; } = "invalid_student_service_client_response"; | ||
public Guid StudentId { get; } | ||
|
||
public InvalidStudentServiceClientResponseException(Guid studentId) | ||
: base($"Invalid student service client response for student with ID: '{studentId}'.") | ||
{ | ||
StudentId = studentId; | ||
} | ||
} | ||
} |
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
28 changes: 28 additions & 0 deletions
28
MiniSpace.Services.Posts/src/MiniSpace.Services.Posts.Core/Wrappers/PagedResponse.cs
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,28 @@ | ||
namespace MiniSpace.Services.Posts.Core.Wrappers | ||
{ | ||
public class PagedResponse<T> : Response<T> | ||
{ | ||
public int TotalPages { get; } | ||
public int TotalElements { get; } | ||
public int Size { get; } | ||
public int Number { get; } | ||
public bool First { get; } | ||
public bool Last { get; } | ||
public bool Empty { get; } | ||
|
||
public PagedResponse(T content, int pageNumber, int pageSize, int totalPages, int totalElements) | ||
{ | ||
Content = content; | ||
TotalPages = totalPages; | ||
TotalElements = totalElements; | ||
Size = pageSize; | ||
Number = pageNumber; | ||
First = pageNumber == 0; | ||
Last = pageNumber == totalPages - 1; | ||
Empty = totalElements == 0; | ||
Succeeded = true; | ||
Errors = null; | ||
Message = null; | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
MiniSpace.Services.Posts/src/MiniSpace.Services.Posts.Core/Wrappers/Response.cs
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,10 @@ | ||
namespace MiniSpace.Services.Posts.Core.Wrappers | ||
{ | ||
public class Response<T> | ||
{ | ||
public T Content { get; set; } | ||
public bool Succeeded { get; set; } | ||
public string[] Errors { get; set; } | ||
public string Message { 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
Oops, something went wrong.