medol-be/app/module/articles/mapper/articles.mapper.go

38 lines
1.2 KiB
Go
Raw Normal View History

2024-03-05 19:15:53 +00:00
package mapper
import (
"go-humas-be/app/database/entity"
res "go-humas-be/app/module/articles/response"
)
func ArticlesResponseMapper(articlesReq *entity.Articles) (articlesRes *res.ArticlesResponse) {
thumbnailUrl := "/articles/thumbnail/viewer/"
if articlesReq.ThumbnailName != nil {
thumbnailUrl += *articlesReq.ThumbnailName
}
2024-03-05 19:15:53 +00:00
if articlesReq != nil {
articlesRes = &res.ArticlesResponse{
ID: articlesReq.ID,
Title: articlesReq.Title,
Slug: articlesReq.Slug,
Description: articlesReq.Description,
HtmlDescription: articlesReq.HtmlDescription,
TypeId: articlesReq.TypeId,
Tags: articlesReq.Tags,
ThumbnailUrl: thumbnailUrl,
PageUrl: articlesReq.PageUrl,
CreatedById: articlesReq.CreatedById,
ShareCount: articlesReq.ShareCount,
ViewCount: articlesReq.ViewCount,
DownloadCount: articlesReq.DownloadCount,
StatusId: articlesReq.StatusId,
IsPublish: articlesReq.IsPublish,
PublishedAt: articlesReq.PublishedAt,
IsActive: articlesReq.IsActive,
CreatedAt: articlesReq.CreatedAt,
UpdatedAt: articlesReq.UpdatedAt,
2024-03-05 19:15:53 +00:00
}
}
return articlesRes
}