作者 yangfu

Merge branch 'dev' into test

... ... @@ -65,7 +65,7 @@ func (l *MiniArticleBackupSearchLogic) MiniArticleBackupSearch(req *types.MiniAr
Id: backupList[i].Id,
Title: "",
Content: "",
Images: []string{},
Images: backupList[i].GetImages(),
Videos: []types.Video{},
CreatedAt: backupList[i].CreatedAt,
Location: types.Location{
... ...
... ... @@ -52,14 +52,10 @@ func (l *MiniArticleSearchMeLogic) MiniArticleSearchMe(req *types.MiniArticleSea
}
func NewArticle(article *domain.Article) types.ArticleSearchMe {
images := []string{}
for _, val2 := range article.Images {
images = append(images, val2.Url)
}
articleSearchMe := types.ArticleSearchMe{
Id: article.Id,
Title: article.Title,
Images: images,
Images: article.GetImages(),
CreatedAt: article.CreatedAt,
CountLove: article.CountLove,
CountComment: article.CountComment,
... ...
... ... @@ -71,7 +71,7 @@ func (l *MiniSearchArticleDraftMeLogic) MiniSearchArticleDraftMe(req *types.Mini
Template: draftList[i].Template,
//Section: draftList[i].Content,
Title: draftList[i].Title,
Images: images,
Images: draftList[i].GetImages(),
CreatedAt: draftList[i].CreatedAt,
MatchUrl: draftList[i].MatchUrl,
Paragraphs: paragraphs,
... ...
... ... @@ -73,7 +73,7 @@ func (l *MiniSearchArticlePageLogic) MiniSearchArticlePage(req *types.MiniSearch
AuthorId: val.AuthorId,
Author: author.Name,
Avatar: author.Avatar,
Images: []string{},
Images: val.GetImages(),
CreatedAt: val.CreatedAt,
MeReadFlag: 0,
Cover: val.GetCover(),
... ... @@ -82,9 +82,6 @@ func (l *MiniSearchArticlePageLogic) MiniSearchArticlePage(req *types.MiniSearch
if _, ok := readFlag[val.Id]; ok {
item.MeReadFlag = 1
}
for _, img := range val.Images {
item.Images = append(item.Images, img.Url)
}
resp.List[i] = item
}
... ...
... ... @@ -67,7 +67,7 @@ func (l *SystemSearchArticleDraftLogic) SystemSearchArticleDraft(req *types.Syst
resp.List = append(resp.List, types.SystemArticleDraftSearch{
Id: item.Id,
Title: item.Title,
Images: images,
Images: item.GetImages(),
Operator: item.Operator.Name,
AuthorId: item.AuthorId,
Author: author,
... ...
... ... @@ -54,11 +54,6 @@ func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleS
//获取标签
_, tags, _ := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, req.CompanyId, domain.NewQueryOptions())
lo.ForEach(articles, func(item *domain.Article, index int) {
//图片
images := make([]string, 0)
lo.ForEach(item.Images, func(img domain.Image, n int) {
images = append(images, img.Url)
})
//发布人
author := item.Author.Name
for _, user := range users {
... ... @@ -80,7 +75,7 @@ func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleS
Title: item.Title,
AuthorId: item.AuthorId,
Author: author,
Images: images,
Images: item.GetImages(),
CreatedAt: item.CreatedAt,
UpdatedAt: item.UpdatedAt,
CountLove: item.CountLove,
... ...
... ... @@ -62,7 +62,7 @@ func (l *MiniUserNewsLogic) MiniUserNews(req *types.MiniUserNewsRequest) (resp *
Title: item.Title,
Summary: item.Summary,
Time: item.CreatedAt,
Images: make([]string, 0),
Images: item.GetImages(),
ReadFlag: false,
Cover: item.GetCover(),
}
... ... @@ -73,9 +73,6 @@ func (l *MiniUserNewsLogic) MiniUserNews(req *types.MiniUserNewsRequest) (resp *
Avatar: lo.ToPtr(author.Avatar),
}
}
for _, img := range item.Images {
newsItem.Images = append(newsItem.Images, img.Url)
}
if _, ok := readArticlesMap[item.Id]; ok {
newsItem.ReadFlag = true
}
... ...
... ... @@ -186,6 +186,18 @@ func (m *Article) GetCover() string {
return ""
}
func (m *Article) GetImages() []string {
cover := m.GetCover()
var result = make([]string, 0)
for _, img := range m.Images {
result = append(result, img.Url)
}
if len(result) == 0 && len(cover) > 0 {
result = append(result, cover)
}
return result
}
func (m *Article) GetCoverWithSections(list []*ArticleSection) string {
if len(m.Cover) > 0 {
return m.Cover
... ...
... ... @@ -212,3 +212,15 @@ func (m *ArticleBackup) GetCover() string {
}
return ""
}
func (m *ArticleBackup) GetImages() []string {
cover := m.GetCover()
var result = make([]string, 0)
for _, img := range m.Images {
result = append(result, img.Url)
}
if len(result) == 0 && len(cover) > 0 {
result = append(result, cover)
}
return result
}
... ...
... ... @@ -47,3 +47,15 @@ func (m *ArticleDraft) GetCover() string {
}
return ""
}
func (m *ArticleDraft) GetImages() []string {
cover := m.GetCover()
var result = make([]string, 0)
for _, img := range m.Images {
result = append(result, img.Url)
}
if len(result) == 0 && len(cover) > 0 {
result = append(result, cover)
}
return result
}
... ...
... ... @@ -46,6 +46,18 @@ func (m *ArticleDraftOperation) Identify() interface{} {
return m.Id
}
func (m *ArticleDraftOperation) GetImages() []string {
cover := m.GetCover()
var result = make([]string, 0)
for _, img := range m.Images {
result = append(result, img.Url)
}
if len(result) == 0 && len(cover) > 0 {
result = append(result, cover)
}
return result
}
func (m *ArticleDraftOperation) GetCover() string {
if len(m.Images) > 0 {
return m.Images[0].Url
... ...