@@ -12,7 +12,7 @@ import (
1212type (
1313 PostService interface {
1414 CreatePost (ctx context.Context , userId string , req dto.PostCreateRequest ) (dto.PostResponse , error )
15- GetPostById (ctx context.Context , postId uint64 ) (dto.PostRepliesResponse , error )
15+ GetPostById (ctx context.Context , postId uint64 ) (dto.PostRepliesPaginationResponse , error )
1616 DeletePostById (ctx context.Context , postId uint64 ) error
1717 UpdatePostById (ctx context.Context , userId string , postId uint64 , req dto.PostUpdateRequest ) (dto.PostResponse , error )
1818 GetAllPosts (ctx context.Context , req dto.PaginationRequest ) (dto.PostPaginationResponse , error )
@@ -71,15 +71,15 @@ func (s *postService) CreatePost(ctx context.Context, userId string, req dto.Pos
7171 }, nil
7272}
7373
74- func (s * postService ) GetPostById (ctx context.Context , postId uint64 ) (dto.PostRepliesResponse , error ) {
74+ func (s * postService ) GetPostById (ctx context.Context , postId uint64 ) (dto.PostRepliesPaginationResponse , error ) {
7575 post , err := s .postRepo .GetPostById (ctx , nil , postId )
7676 if err != nil {
77- return dto.PostRepliesResponse {}, dto .ErrGetPostById
77+ return dto.PostRepliesPaginationResponse {}, dto .ErrGetPostById
7878 }
7979
8080 replies , err := s .postRepo .GetAllPostRepliesWithPagination (ctx , nil , postId , dto.PaginationRequest {})
8181 if err != nil {
82- return dto.PostRepliesResponse {}, dto .ErrGetPostReplies
82+ return dto.PostRepliesPaginationResponse {}, dto .ErrGetPostReplies
8383 }
8484
8585 var data []dto.PostResponse
@@ -100,28 +100,27 @@ func (s *postService) GetPostById(ctx context.Context, postId uint64) (dto.PostR
100100 data = append (data , datum )
101101 }
102102
103- return dto.PostRepliesResponse {
104- PostResponse : dto.PostResponse {
105- ID : post .ID ,
106- Text : post .Text ,
107- ParentID : post .ParentID ,
108- User : dto.UserResponse {
109- ID : post .UserID .String (),
110- Name : post .User .Name ,
111- Bio : post .User .Bio ,
112- UserName : post .User .Username ,
113- ImageUrl : post .User .ImageUrl ,
114- },
103+ return dto.PostRepliesPaginationResponse {
104+ Data : dto.PostResponse {
105+ ID : post .ID ,
106+ Text : post .Text ,
107+ ParentID : post .ParentID ,
108+ User : dto.UserResponse {
109+ ID : post .UserID .String (),
110+ Name : post .User .Name ,
111+ Bio : post .User .Bio ,
112+ UserName : post .User .Username ,
113+ ImageUrl : post .User .ImageUrl ,
115114 },
116115 Replies : data ,
117- PaginationResponse : dto.PaginationResponse {
118- Page : replies .Page ,
119- PerPage : replies .PerPage ,
120- MaxPage : replies .MaxPage ,
121- Count : replies .Count ,
122- },
123116 },
124- nil
117+ PaginationResponse : dto.PaginationResponse {
118+ Page : replies .Page ,
119+ PerPage : replies .PerPage ,
120+ MaxPage : replies .MaxPage ,
121+ Count : replies .Count ,
122+ },
123+ }, nil
125124}
126125
127126func (s * postService ) DeletePostById (ctx context.Context , postId uint64 ) error {
0 commit comments