feat: update article & category host for url
This commit is contained in:
parent
e79ad4bcd8
commit
5894b81549
|
|
@ -5,8 +5,8 @@ import (
|
||||||
res "go-humas-be/app/module/article_files/response"
|
res "go-humas-be/app/module/article_files/response"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ArticleFilesResponseMapper(articleFilesReq *entity.ArticleFiles) (articleFilesRes *res.ArticleFilesResponse) {
|
func ArticleFilesResponseMapper(articleFilesReq *entity.ArticleFiles, host string) (articleFilesRes *res.ArticleFilesResponse) {
|
||||||
fileUrl := "/article-files/viewer/"
|
fileUrl := host + "/article-files/viewer/"
|
||||||
if articleFilesReq.FileName != nil {
|
if articleFilesReq.FileName != nil {
|
||||||
fileUrl += *articleFilesReq.FileName
|
fileUrl += *articleFilesReq.FileName
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"go-humas-be/app/module/article_files/repository"
|
"go-humas-be/app/module/article_files/repository"
|
||||||
"go-humas-be/app/module/article_files/request"
|
"go-humas-be/app/module/article_files/request"
|
||||||
"go-humas-be/app/module/article_files/response"
|
"go-humas-be/app/module/article_files/response"
|
||||||
|
config "go-humas-be/config/config"
|
||||||
minioStorage "go-humas-be/config/config"
|
minioStorage "go-humas-be/config/config"
|
||||||
"go-humas-be/utils/paginator"
|
"go-humas-be/utils/paginator"
|
||||||
"io"
|
"io"
|
||||||
|
|
@ -29,6 +30,7 @@ import (
|
||||||
type articleFilesService struct {
|
type articleFilesService struct {
|
||||||
Repo repository.ArticleFilesRepository
|
Repo repository.ArticleFilesRepository
|
||||||
Log zerolog.Logger
|
Log zerolog.Logger
|
||||||
|
Cfg *config.Config
|
||||||
MinioStorage *minioStorage.MinioStorage
|
MinioStorage *minioStorage.MinioStorage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -45,11 +47,12 @@ type ArticleFilesService interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewArticleFilesService init ArticleFilesService
|
// NewArticleFilesService init ArticleFilesService
|
||||||
func NewArticleFilesService(repo repository.ArticleFilesRepository, log zerolog.Logger, minioStorage *minioStorage.MinioStorage) ArticleFilesService {
|
func NewArticleFilesService(repo repository.ArticleFilesRepository, log zerolog.Logger, cfg *config.Config, minioStorage *minioStorage.MinioStorage) ArticleFilesService {
|
||||||
|
|
||||||
return &articleFilesService{
|
return &articleFilesService{
|
||||||
Repo: repo,
|
Repo: repo,
|
||||||
Log: log,
|
Log: log,
|
||||||
|
Cfg: cfg,
|
||||||
MinioStorage: minioStorage,
|
MinioStorage: minioStorage,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -72,8 +75,10 @@ func (_i *articleFilesService) All(req request.ArticleFilesQueryRequest) (articl
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
host := _i.Cfg.App.Domain
|
||||||
|
|
||||||
for _, result := range results {
|
for _, result := range results {
|
||||||
articleFiless = append(articleFiless, mapper.ArticleFilesResponseMapper(result))
|
articleFiless = append(articleFiless, mapper.ArticleFilesResponseMapper(result, host))
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
@ -85,7 +90,9 @@ func (_i *articleFilesService) Show(id uint) (articleFiles *response.ArticleFile
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return mapper.ArticleFilesResponseMapper(result), nil
|
host := _i.Cfg.App.Domain
|
||||||
|
|
||||||
|
return mapper.ArticleFilesResponseMapper(result, host), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_i *articleFilesService) SaveAsync(c *fiber.Ctx, id uint) (err error) {
|
func (_i *articleFilesService) SaveAsync(c *fiber.Ctx, id uint) (err error) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue