A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.
question/page
aichy126caf1fb446623
diff --git a/internal/controller/template_controller.go b/internal/controller/template_controller.goindex 295b1f03..a0349a25 100644--- a/internal/controller/template_controller.go+++ b/internal/controller/template_controller.go@@ -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),})}diff --git a/internal/controller/template_render/tags.go b/internal/controller/template_render/tags.goindex c7443be6..f62539b4 100644--- a/internal/controller/template_render/tags.go+++ b/internal/controller/template_render/tags.go@@ -3,15 +3,30 @@ package templaterenderimport ("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}diff --git a/internal/schema/tag_schema.go b/internal/schema/tag_schema.goindex 8e1b6da0..48f335c2 100644--- a/internal/schema/tag_schema.go+++ b/internal/schema/tag_schema.go@@ -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)