Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: filter private journal #247

Merged
merged 1 commit into from
May 19, 2023
Merged

fix: filter private journal #247

merged 1 commit into from
May 19, 2023

Conversation

golangboy
Copy link
Contributor

过滤私密日志

@golangboy
Copy link
Contributor Author

@1379

@1379
Copy link
Contributor

1379 commented May 19, 2023

是不是在上层调用JournalService的ListJournal的方法更好些

@golangboy
Copy link
Contributor Author

是不是在上层调用JournalService的ListJournal的方法更好些

但是通过http://127.0.0.1:8080/journals访问的话,是不会调用到service\impl\journal里的ListJournal函数

@golangboy
Copy link
Contributor Author

handler/router.go:408

contentRouter.GET(journalPath, s.wrapHTMLHandler(s.ContentJournalHandler.Journals))

handler/content/journal.go:38

func (p *JournalHandler) Journals(ctx *gin.Context, model template.Model) (string, error) {
	return p.JournalModel.Journals(ctx, model, 0)
}

handler/content/model/journal.go:30

func (p *JournalModel) Journals(ctx context.Context, model template.Model, page int) (string, error) {
	pageSize := p.OptionService.GetOrByDefault(ctx, property.JournalPageSize).(int)
	journals, total, err := p.JournalService.Page(ctx,
		param.Page{
			PageNum:  page,
			PageSize: pageSize,
		},
		&param.Sort{
			Fields: []string{"createTime,desc"},
		})
	if err != nil {
		return "", err
	}
	journalDTOs, err := p.JournalService.ConvertToWithCommentDTOList(ctx, journals)
	if err != nil {
		return "", err
	}
	journalPage := dto.NewPage(journalDTOs, total, param.Page{PageNum: page, PageSize: pageSize})
	model["is_journals"] = true
	model["journals"] = journalPage
	model["meta_keywords"] = p.OptionService.GetOrByDefault(ctx, property.SeoKeywords)
	model["meta_description"] = p.OptionService.GetOrByDefault(ctx, property.SeoDescription)
	return p.ThemeService.Render(ctx, "journals")
}

@1379
Copy link
Contributor

1379 commented May 19, 2023

是的,我明白你的意思,但是如果Page和ListJournal方法都能实现,并且ListJournal方法功能更多,我们是不是可以考虑不调用Page方法了

@golangboy
Copy link
Contributor Author

是的,我明白你的意思,但是如果Page和ListJournal方法都能实现,并且ListJournal方法功能更多,我们是不是可以考虑不调用Page方法了

你说的对,我按你说的进行了修改,确实可以,如此一来,Page函数似乎可以移除了,因为ListJournal功能已经覆盖了Page函数了

@1379 1379 merged commit 7bec1f6 into go-sonic:master May 19, 2023
@1379
Copy link
Contributor

1379 commented May 19, 2023

Everything is ok!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants