mirror of https://gitee.com/answerdev/answer.git
question/page
This commit is contained in:
parent
0a46a9b002
commit
caf1fb4466
|
@ -139,9 +139,9 @@ func (tc *TemplateController) TagList(ctx *gin.Context) {
|
|||
func (tc *TemplateController) TagInfo(ctx *gin.Context) {
|
||||
tag := ctx.Param("tag")
|
||||
|
||||
req := &schema.GetTagInfoReq{}
|
||||
req := &schema.GetTamplateTagInfoReq{}
|
||||
req.Name = tag
|
||||
taginifo, err := tc.templateRenderController.TagInfo(ctx, req)
|
||||
taginifo, questionList, questionCount, err := tc.templateRenderController.TagInfo(ctx, req)
|
||||
if err != nil {
|
||||
ctx.HTML(http.StatusOK, "404.html", gin.H{
|
||||
"scriptPath": tc.scriptPath,
|
||||
|
@ -152,10 +152,12 @@ func (tc *TemplateController) TagInfo(ctx *gin.Context) {
|
|||
return
|
||||
}
|
||||
ctx.HTML(http.StatusOK, "tag-detail.html", gin.H{
|
||||
"tag": taginifo,
|
||||
"scriptPath": tc.scriptPath,
|
||||
"cssPath": tc.cssPath,
|
||||
"siteinfo": tc.SiteInfo(ctx),
|
||||
"tag": taginifo,
|
||||
"questionList": questionList,
|
||||
"questionCount": questionCount,
|
||||
"scriptPath": tc.scriptPath,
|
||||
"cssPath": tc.cssPath,
|
||||
"siteinfo": tc.SiteInfo(ctx),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -3,15 +3,30 @@ package templaterender
|
|||
import (
|
||||
"github.com/answerdev/answer/internal/base/pager"
|
||||
"github.com/answerdev/answer/internal/schema"
|
||||
"github.com/jinzhu/copier"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func (q *TemplateRenderController) TagList(ctx context.Context, req *schema.GetTagWithPageReq) (resp *pager.PageModel, err error) {
|
||||
resp, err = q.tagService.GetTagWithPage(ctx, req)
|
||||
return resp, err
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (q *TemplateRenderController) TagInfo(ctx context.Context, req *schema.GetTagInfoReq) (resp *schema.GetTagResp, err error) {
|
||||
resp, err = q.tagService.GetTagInfo(ctx, req)
|
||||
return resp, err
|
||||
func (q *TemplateRenderController) TagInfo(ctx context.Context, req *schema.GetTamplateTagInfoReq) (resp *schema.GetTagResp, questionList []*schema.QuestionInfo, questionCount int64, err error) {
|
||||
dto := &schema.GetTagInfoReq{}
|
||||
_ = copier.Copy(dto, req)
|
||||
resp, err = q.tagService.GetTagInfo(ctx, dto)
|
||||
searchQuestion := &schema.QuestionSearch{}
|
||||
searchQuestion.Page = req.Page
|
||||
searchQuestion.PageSize = req.PageSize
|
||||
searchQuestion.Order = "news"
|
||||
searchQuestion.Tag = req.Name
|
||||
questionList, questionCount, err = q.questionService.SearchList(ctx, searchQuestion, "")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return resp, questionList, questionCount, err
|
||||
}
|
||||
|
|
|
@ -25,6 +25,17 @@ type GetTagInfoReq struct {
|
|||
UserID string `json:"-"`
|
||||
}
|
||||
|
||||
type GetTamplateTagInfoReq struct {
|
||||
// tag id
|
||||
ID string `validate:"omitempty" form:"id"`
|
||||
// tag slug name
|
||||
Name string `validate:"omitempty,gt=0,lte=35" form:"name"`
|
||||
// user id
|
||||
UserID string `json:"-"`
|
||||
Page int `validate:"omitempty,min=1" form:"page"`
|
||||
PageSize int `validate:"omitempty,min=1" form:"page_size"`
|
||||
}
|
||||
|
||||
func (r *GetTagInfoReq) Check() (errFields []*validator.FormErrorField, err error) {
|
||||
if len(r.ID) == 0 && len(r.Name) == 0 {
|
||||
return nil, errors.BadRequest(reason.RequestFormatError)
|
||||
|
|
Loading…
Reference in New Issue