Skip to content

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.

feat(review): add url title for review page

LinkinStars3bce8e3418ef
diff --git a/internal/schema/revision_schema.go b/internal/schema/revision_schema.go
index 04b3439f..f1b11688 100644
--- a/internal/schema/revision_schema.go
+++ b/internal/schema/revision_schema.go
@@ -90,23 +90,15 @@ type GetUnreviewedRevisionResp struct {
// GetRevisionResp get revision response
type GetRevisionResp struct {
- // id
- ID string `json:"id"`
- // user id
- UserID string `json:"use_id"`
- // object id
- ObjectID string `json:"object_id"`
- // object type
- ObjectType int `json:"-"`
- // title
- Title string `json:"title"`
- // content
- Content string `json:"-"`
- // content parsed
- ContentParsed interface{} `json:"content"`
- // revision status(normal: 1; delete 2)
- Status int `json:"status"`
- // create time
+ ID string `json:"id"`
+ UserID string `json:"use_id"`
+ ObjectID string `json:"object_id"`
+ ObjectType int `json:"-"`
+ Title string `json:"title"`
+ UrlTitle string `json:"url_title"`
+ Content string `json:"-"`
+ ContentParsed interface{} `json:"content"`
+ Status int `json:"status"`
CreatedAt time.Time `json:"-"`
CreatedAtParsed int64 `json:"create_at"`
UserInfo UserBasicInfo `json:"user_info"`
diff --git a/internal/schema/simple_obj_info_schema.go b/internal/schema/simple_obj_info_schema.go
index 9dbf0d79..7c4fa9af 100644
--- a/internal/schema/simple_obj_info_schema.go
+++ b/internal/schema/simple_obj_info_schema.go
@@ -42,6 +42,7 @@ type UnreviewedRevisionInfoInfo struct {
ObjectType string `json:"object_type"`
ObjectCreatorUserID string `json:"object_creator_user_id"`
Title string `json:"title"`
+ UrlTitle string `json:"url_title"`
Content string `json:"content"`
Html string `json:"html"`
AnswerCount int `json:"answer_count"`
diff --git a/internal/service/content/revision_service.go b/internal/service/content/revision_service.go
index efea1ce1..715d30cc 100644
--- a/internal/service/content/revision_service.go
+++ b/internal/service/content/revision_service.go
@@ -43,6 +43,7 @@ import (
tagcommon "github.com/apache/incubator-answer/internal/service/tag_common"
usercommon "github.com/apache/incubator-answer/internal/service/user_common"
"github.com/apache/incubator-answer/pkg/converter"
+ "github.com/apache/incubator-answer/pkg/htmltext"
"github.com/apache/incubator-answer/pkg/obj"
"github.com/apache/incubator-answer/pkg/uid"
"github.com/jinzhu/copier"
@@ -344,6 +345,8 @@ func (rs *RevisionService) GetUnreviewedRevisionPage(ctx context.Context, req *s
_ = copier.Copy(&uinfo, userInfo)
item.UnreviewedInfo.UserInfo = uinfo
}
+ item.Info.UrlTitle = htmltext.UrlTitle(item.Info.Title)
+ item.UnreviewedInfo.UrlTitle = htmltext.UrlTitle(item.UnreviewedInfo.Title)
revisionResp = append(revisionResp, item)
}
return pager.NewPageModel(total, revisionResp), nil