feat: cut off answer html description

This commit is contained in:
LinkinStar 2022-11-09 16:24:25 +08:00
parent 865bf95b37
commit 5bce99208c
1 changed files with 2 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import (
"github.com/answerdev/answer/internal/entity" "github.com/answerdev/answer/internal/entity"
"github.com/answerdev/answer/internal/schema" "github.com/answerdev/answer/internal/schema"
"github.com/answerdev/answer/pkg/htmltext"
) )
type AnswerRepo interface { type AnswerRepo interface {
@ -75,11 +76,11 @@ func (as *AnswerCommon) AdminShowFormat(ctx context.Context, data *entity.Answer
info := schema.AdminAnswerInfo{} info := schema.AdminAnswerInfo{}
info.ID = data.ID info.ID = data.ID
info.QuestionID = data.QuestionID info.QuestionID = data.QuestionID
info.Description = data.ParsedText
info.Adopted = data.Adopted info.Adopted = data.Adopted
info.VoteCount = data.VoteCount info.VoteCount = data.VoteCount
info.CreateTime = data.CreatedAt.Unix() info.CreateTime = data.CreatedAt.Unix()
info.UpdateTime = data.UpdatedAt.Unix() info.UpdateTime = data.UpdatedAt.Unix()
info.UserID = data.UserID info.UserID = data.UserID
info.Description = htmltext.FetchExcerpt(data.ParsedText, "...", 240)
return &info return &info
} }