37 lines
1.3 KiB
Go
37 lines
1.3 KiB
Go
package mapper
|
|
|
|
import (
|
|
"github.com/google/uuid"
|
|
"netidhub-saas-be/app/database/entity"
|
|
res "netidhub-saas-be/app/module/article_comments/response"
|
|
usersRepository "netidhub-saas-be/app/module/users/repository"
|
|
)
|
|
|
|
func ArticleCommentsResponseMapper(clientId *uuid.UUID, articleCommentsReq *entity.ArticleComments, usersRepo usersRepository.UsersRepository) (articleCommentsRes *res.ArticleCommentsResponse) {
|
|
if articleCommentsReq != nil {
|
|
|
|
commentFromName := ""
|
|
if articleCommentsReq.CommentFrom != nil {
|
|
findUser, _ := usersRepo.FindOne(clientId, *articleCommentsReq.CommentFrom)
|
|
if findUser != nil {
|
|
commentFromName = findUser.Fullname
|
|
}
|
|
}
|
|
|
|
articleCommentsRes = &res.ArticleCommentsResponse{
|
|
ID: articleCommentsReq.ID,
|
|
Message: articleCommentsReq.Message,
|
|
ArticleId: articleCommentsReq.ArticleId,
|
|
CommentFromId: articleCommentsReq.CommentFrom,
|
|
CommentFromName: &commentFromName,
|
|
ParentId: articleCommentsReq.ParentId,
|
|
IsPublic: articleCommentsReq.IsPublic,
|
|
StatusId: articleCommentsReq.StatusId,
|
|
IsActive: articleCommentsReq.IsActive,
|
|
CreatedAt: articleCommentsReq.CreatedAt,
|
|
UpdatedAt: articleCommentsReq.UpdatedAt,
|
|
}
|
|
}
|
|
return articleCommentsRes
|
|
}
|