fix: update fixing bookmarks
This commit is contained in:
parent
ee61a0411c
commit
2a61cf9987
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"netidhub-saas-be/app/module/bookmarks/response"
|
"netidhub-saas-be/app/module/bookmarks/response"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ToBookmarksResponse(bookmark *entity.Bookmarks) *response.BookmarksResponse {
|
func ToBookmarksResponse(domain string, bookmark *entity.Bookmarks) *response.BookmarksResponse {
|
||||||
return &response.BookmarksResponse{
|
return &response.BookmarksResponse{
|
||||||
ID: bookmark.ID,
|
ID: bookmark.ID,
|
||||||
UserId: bookmark.UserId,
|
UserId: bookmark.UserId,
|
||||||
|
|
@ -22,7 +22,7 @@ func ToBookmarksResponse(bookmark *entity.Bookmarks) *response.BookmarksResponse
|
||||||
CategoryId: bookmark.Article.CategoryId,
|
CategoryId: bookmark.Article.CategoryId,
|
||||||
TypeId: bookmark.Article.TypeId,
|
TypeId: bookmark.Article.TypeId,
|
||||||
Tags: bookmark.Article.Tags,
|
Tags: bookmark.Article.Tags,
|
||||||
ThumbnailUrl: getThumbnailUrl(bookmark.Article.ThumbnailPath),
|
ThumbnailUrl: getThumbnailUrl(domain, bookmark.Article.ThumbnailName),
|
||||||
PageUrl: bookmark.Article.PageUrl,
|
PageUrl: bookmark.Article.PageUrl,
|
||||||
CreatedById: bookmark.Article.CreatedById,
|
CreatedById: bookmark.Article.CreatedById,
|
||||||
ShareCount: bookmark.Article.ShareCount,
|
ShareCount: bookmark.Article.ShareCount,
|
||||||
|
|
@ -39,17 +39,17 @@ func ToBookmarksResponse(bookmark *entity.Bookmarks) *response.BookmarksResponse
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ToBookmarksResponseList(bookmarks []entity.Bookmarks) []*response.BookmarksResponse {
|
func ToBookmarksResponseList(domain string, bookmarks []entity.Bookmarks) []*response.BookmarksResponse {
|
||||||
var responses []*response.BookmarksResponse
|
var responses []*response.BookmarksResponse
|
||||||
for _, bookmark := range bookmarks {
|
for _, bookmark := range bookmarks {
|
||||||
responses = append(responses, ToBookmarksResponse(&bookmark))
|
responses = append(responses, ToBookmarksResponse(domain, &bookmark))
|
||||||
}
|
}
|
||||||
return responses
|
return responses
|
||||||
}
|
}
|
||||||
|
|
||||||
func getThumbnailUrl(thumbnailPath *string) string {
|
func getThumbnailUrl(domain string, thumbnailName *string) string {
|
||||||
if thumbnailPath != nil && *thumbnailPath != "" {
|
if thumbnailName != nil && *thumbnailName != "" {
|
||||||
return *thumbnailPath
|
return domain + "/articles/thumbnail/viewer/" + *thumbnailName
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"netidhub-saas-be/app/module/bookmarks/request"
|
"netidhub-saas-be/app/module/bookmarks/request"
|
||||||
"netidhub-saas-be/app/module/bookmarks/response"
|
"netidhub-saas-be/app/module/bookmarks/response"
|
||||||
usersRepository "netidhub-saas-be/app/module/users/repository"
|
usersRepository "netidhub-saas-be/app/module/users/repository"
|
||||||
|
"netidhub-saas-be/config/config"
|
||||||
"netidhub-saas-be/utils/paginator"
|
"netidhub-saas-be/utils/paginator"
|
||||||
utilSvc "netidhub-saas-be/utils/service"
|
utilSvc "netidhub-saas-be/utils/service"
|
||||||
|
|
||||||
|
|
@ -22,6 +23,7 @@ type bookmarksService struct {
|
||||||
ArticlesRepo articlesRepository.ArticlesRepository
|
ArticlesRepo articlesRepository.ArticlesRepository
|
||||||
UsersRepo usersRepository.UsersRepository
|
UsersRepo usersRepository.UsersRepository
|
||||||
Log zerolog.Logger
|
Log zerolog.Logger
|
||||||
|
Cfg *config.Config
|
||||||
}
|
}
|
||||||
|
|
||||||
// BookmarksService define interface of IBookmarksService
|
// BookmarksService define interface of IBookmarksService
|
||||||
|
|
@ -41,6 +43,7 @@ func NewBookmarksService(
|
||||||
repo repository.BookmarksRepository,
|
repo repository.BookmarksRepository,
|
||||||
articlesRepo articlesRepository.ArticlesRepository,
|
articlesRepo articlesRepository.ArticlesRepository,
|
||||||
usersRepo usersRepository.UsersRepository,
|
usersRepo usersRepository.UsersRepository,
|
||||||
|
cfg *config.Config,
|
||||||
log zerolog.Logger,
|
log zerolog.Logger,
|
||||||
) BookmarksService {
|
) BookmarksService {
|
||||||
return &bookmarksService{
|
return &bookmarksService{
|
||||||
|
|
@ -48,6 +51,7 @@ func NewBookmarksService(
|
||||||
ArticlesRepo: articlesRepo,
|
ArticlesRepo: articlesRepo,
|
||||||
UsersRepo: usersRepo,
|
UsersRepo: usersRepo,
|
||||||
Log: log,
|
Log: log,
|
||||||
|
Cfg: cfg,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -75,7 +79,9 @@ func (_i *bookmarksService) All(authToken string, req request.BookmarksQueryRequ
|
||||||
for _, b := range bookmarksEntity {
|
for _, b := range bookmarksEntity {
|
||||||
bookmarksSlice = append(bookmarksSlice, *b)
|
bookmarksSlice = append(bookmarksSlice, *b)
|
||||||
}
|
}
|
||||||
bookmarks = mapper.ToBookmarksResponseList(bookmarksSlice)
|
|
||||||
|
domain := _i.Cfg.App.Domain
|
||||||
|
bookmarks = mapper.ToBookmarksResponseList(domain, bookmarksSlice)
|
||||||
return bookmarks, paging, nil
|
return bookmarks, paging, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -96,7 +102,8 @@ func (_i *bookmarksService) Show(authToken string, id uint) (bookmark *response.
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
bookmark = mapper.ToBookmarksResponse(bookmarkEntity)
|
domain := _i.Cfg.App.Domain
|
||||||
|
bookmark = mapper.ToBookmarksResponse(domain, bookmarkEntity)
|
||||||
return bookmark, nil
|
return bookmark, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -192,7 +199,9 @@ func (_i *bookmarksService) GetByUserId(authToken string, req request.BookmarksQ
|
||||||
for _, b := range bookmarksEntity {
|
for _, b := range bookmarksEntity {
|
||||||
bookmarksSlice = append(bookmarksSlice, *b)
|
bookmarksSlice = append(bookmarksSlice, *b)
|
||||||
}
|
}
|
||||||
bookmarks = mapper.ToBookmarksResponseList(bookmarksSlice)
|
|
||||||
|
domain := _i.Cfg.App.Domain
|
||||||
|
bookmarks = mapper.ToBookmarksResponseList(domain, bookmarksSlice)
|
||||||
return bookmarks, paging, nil
|
return bookmarks, paging, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -293,7 +302,9 @@ func (_i *bookmarksService) GetBookmarkSummary(authToken string) (summary *respo
|
||||||
for _, b := range recentBookmarksEntity {
|
for _, b := range recentBookmarksEntity {
|
||||||
bookmarksSlice = append(bookmarksSlice, *b)
|
bookmarksSlice = append(bookmarksSlice, *b)
|
||||||
}
|
}
|
||||||
recentBookmarks := mapper.ToBookmarksResponseList(bookmarksSlice)
|
|
||||||
|
domain := _i.Cfg.App.Domain
|
||||||
|
recentBookmarks := mapper.ToBookmarksResponseList(domain, bookmarksSlice)
|
||||||
|
|
||||||
summary = &response.BookmarksSummaryResponse{
|
summary = &response.BookmarksSummaryResponse{
|
||||||
TotalBookmarks: int(totalCount),
|
TotalBookmarks: int(totalCount),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue