From ca6d8fb5a8dc4460786f95b595da9117542c81e1 Mon Sep 17 00:00:00 2001 From: aichy126 <16996097+aichy126@users.noreply.github.com> Date: Mon, 13 Mar 2023 11:01:32 +0800 Subject: [PATCH 1/4] update question --- internal/service/question_service.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/service/question_service.go b/internal/service/question_service.go index 0971a9d5..532c441e 100644 --- a/internal/service/question_service.go +++ b/internal/service/question_service.go @@ -770,13 +770,13 @@ func (qs *QuestionService) SearchUserCollectionList(ctx context.Context, page, p return list, count, err } for _, id := range questionIDs { - _, ok := questionMaps[id] + _, ok := questionMaps[uid.EnShortID(id)] if ok { - questionMaps[id].LastAnsweredUserInfo = nil - questionMaps[id].UpdateUserInfo = nil - questionMaps[id].Content = "" - questionMaps[id].HTML = "" - list = append(list, questionMaps[id]) + questionMaps[uid.EnShortID(id)].LastAnsweredUserInfo = nil + questionMaps[uid.EnShortID(id)].UpdateUserInfo = nil + questionMaps[uid.EnShortID(id)].Content = "" + questionMaps[uid.EnShortID(id)].HTML = "" + list = append(list, questionMaps[uid.EnShortID(id)]) } } From 1a814da53b9472f5b83f2f29a2ede3561e0e2f66 Mon Sep 17 00:00:00 2001 From: aichy126 <16996097+aichy126@users.noreply.github.com> Date: Mon, 13 Mar 2023 11:12:31 +0800 Subject: [PATCH 2/4] update question --- internal/schema/question_schema.go | 6 ++++-- internal/service/question_service.go | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/schema/question_schema.go b/internal/schema/question_schema.go index b0101141..c743577b 100644 --- a/internal/schema/question_schema.go +++ b/internal/schema/question_schema.go @@ -215,14 +215,16 @@ type UserAnswerInfo struct { CreateTime int `json:"create_time"` UpdateTime int `json:"update_time"` QuestionInfo struct { - Title string `json:"title"` - Tags []interface{} `json:"tags"` + Title string `json:"title"` + UrlTitle string `json:"url_title"` + Tags []interface{} `json:"tags"` } `json:"question_info"` } type UserQuestionInfo struct { ID string `json:"question_id"` Title string `json:"title"` + UrlTitle string `json:"url_title"` VoteCount int `json:"vote_count"` Tags []interface{} `json:"tags"` ViewCount int `json:"view_count"` diff --git a/internal/service/question_service.go b/internal/service/question_service.go index 532c441e..3f293e39 100644 --- a/internal/service/question_service.go +++ b/internal/service/question_service.go @@ -834,6 +834,7 @@ func (qs *QuestionService) SearchUserTopList(ctx context.Context, userName strin for _, item := range questionlist { info := &schema.UserQuestionInfo{} _ = copier.Copy(info, item) + info.UrlTitle = htmltext.UrlTitle(info.Title) userQuestionlist = append(userQuestionlist, info) } @@ -842,6 +843,7 @@ func (qs *QuestionService) SearchUserTopList(ctx context.Context, userName strin _ = copier.Copy(info, item) info.AnswerID = item.ID info.QuestionID = item.QuestionID + info.QuestionInfo.UrlTitle = htmltext.UrlTitle(info.QuestionInfo.Title) userAnswerlist = append(userAnswerlist, info) } From 2d87c8d49491e04aeb929395653e8d9a6808f4c5 Mon Sep 17 00:00:00 2001 From: aichy126 <16996097+aichy126@users.noreply.github.com> Date: Mon, 13 Mar 2023 11:28:35 +0800 Subject: [PATCH 3/4] update question --- docs/docs.go | 12 ++++++++++++ docs/swagger.json | 12 ++++++++++++ docs/swagger.yaml | 9 +++++++++ internal/schema/comment_schema.go | 2 ++ internal/schema/rank_schema.go | 2 ++ internal/schema/vote_schema.go | 2 ++ internal/service/comment/comment_service.go | 4 ++++ internal/service/rank/rank_service.go | 2 ++ internal/service/vote_service.go | 2 ++ 9 files changed, 47 insertions(+) diff --git a/docs/docs.go b/docs/docs.go index b28986b7..f7ca566e 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -5778,6 +5778,10 @@ const docTemplate = `{ "title": { "description": "title", "type": "string" + }, + "url_title": { + "description": "url title", + "type": "string" } } }, @@ -6033,6 +6037,10 @@ const docTemplate = `{ "title": { "description": "title", "type": "string" + }, + "url_title": { + "description": "url title", + "type": "string" } } }, @@ -6612,6 +6620,10 @@ const docTemplate = `{ "description": "title", "type": "string" }, + "url_title": { + "description": "url title", + "type": "string" + }, "vote_type": { "description": "vote type", "type": "string" diff --git a/docs/swagger.json b/docs/swagger.json index 21be9a5c..f9cc9422 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -5766,6 +5766,10 @@ "title": { "description": "title", "type": "string" + }, + "url_title": { + "description": "url title", + "type": "string" } } }, @@ -6021,6 +6025,10 @@ "title": { "description": "title", "type": "string" + }, + "url_title": { + "description": "url title", + "type": "string" } } }, @@ -6600,6 +6608,10 @@ "description": "title", "type": "string" }, + "url_title": { + "description": "url title", + "type": "string" + }, "vote_type": { "description": "vote type", "type": "string" diff --git a/docs/swagger.yaml b/docs/swagger.yaml index c57892fa..01fec9cd 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -337,6 +337,9 @@ definitions: title: description: title type: string + url_title: + description: url title + type: string type: object schema.GetCommentResp: properties: @@ -525,6 +528,9 @@ definitions: title: description: title type: string + url_title: + description: url title + type: string type: object schema.GetReportTypeResp: properties: @@ -943,6 +949,9 @@ definitions: title: description: title type: string + url_title: + description: url title + type: string vote_type: description: vote type type: string diff --git a/internal/schema/comment_schema.go b/internal/schema/comment_schema.go index 5b045a07..4d64cf01 100644 --- a/internal/schema/comment_schema.go +++ b/internal/schema/comment_schema.go @@ -198,6 +198,8 @@ type GetCommentPersonalWithPageResp struct { ObjectType string `json:"object_type" enums:"question,answer,tag,comment"` // title Title string `json:"title"` + // url title + UrlTitle string `json:"url_title"` // content Content string `json:"content"` } diff --git a/internal/schema/rank_schema.go b/internal/schema/rank_schema.go index 81505c82..b09eb66b 100644 --- a/internal/schema/rank_schema.go +++ b/internal/schema/rank_schema.go @@ -26,6 +26,8 @@ type GetRankPersonalWithPageResp struct { ObjectType string `json:"object_type" enums:"question,answer,tag,comment"` // title Title string `json:"title"` + // url title + UrlTitle string `json:"url_title"` // content Content string `json:"content"` // reputation diff --git a/internal/schema/vote_schema.go b/internal/schema/vote_schema.go index 8a17666f..4cb86c66 100644 --- a/internal/schema/vote_schema.go +++ b/internal/schema/vote_schema.go @@ -60,6 +60,8 @@ type GetVoteWithPageResp struct { ObjectType string `json:"object_type" enums:"question,answer,tag,comment"` // title Title string `json:"title"` + // url title + UrlTitle string `json:"url_title"` // content Content string `json:"content"` // vote type diff --git a/internal/service/comment/comment_service.go b/internal/service/comment/comment_service.go index 30527cb5..38595229 100644 --- a/internal/service/comment/comment_service.go +++ b/internal/service/comment/comment_service.go @@ -18,7 +18,9 @@ import ( "github.com/answerdev/answer/internal/service/permission" usercommon "github.com/answerdev/answer/internal/service/user_common" "github.com/answerdev/answer/pkg/encryption" + "github.com/answerdev/answer/pkg/htmltext" "github.com/answerdev/answer/pkg/uid" + "github.com/davecgh/go-spew/spew" "github.com/jinzhu/copier" "github.com/segmentfault/pacman/errors" "github.com/segmentfault/pacman/log" @@ -446,8 +448,10 @@ func (cs *CommentService) GetCommentPersonalWithPage(ctx context.Context, req *s if err != nil { log.Error(err) } else { + spew.Dump("==", objInfo) commentResp.ObjectType = objInfo.ObjectType commentResp.Title = objInfo.Title + commentResp.UrlTitle = htmltext.UrlTitle(objInfo.Title) commentResp.QuestionID = objInfo.QuestionID commentResp.AnswerID = objInfo.AnswerID } diff --git a/internal/service/rank/rank_service.go b/internal/service/rank/rank_service.go index 111924e9..dac7df20 100644 --- a/internal/service/rank/rank_service.go +++ b/internal/service/rank/rank_service.go @@ -14,6 +14,7 @@ import ( "github.com/answerdev/answer/internal/service/permission" "github.com/answerdev/answer/internal/service/role" usercommon "github.com/answerdev/answer/internal/service/user_common" + "github.com/answerdev/answer/pkg/htmltext" "github.com/segmentfault/pacman/errors" "github.com/segmentfault/pacman/log" "xorm.io/xorm" @@ -260,6 +261,7 @@ func (rs *RankService) GetRankPersonalWithPage(ctx context.Context, req *schema. commentResp.RankType = activity_type.Format(userRankInfo.ActivityType) commentResp.ObjectType = objInfo.ObjectType commentResp.Title = objInfo.Title + commentResp.UrlTitle = htmltext.UrlTitle(objInfo.Title) commentResp.Content = objInfo.Content commentResp.QuestionID = objInfo.QuestionID commentResp.AnswerID = objInfo.AnswerID diff --git a/internal/service/vote_service.go b/internal/service/vote_service.go index ae555bf0..62c20b64 100644 --- a/internal/service/vote_service.go +++ b/internal/service/vote_service.go @@ -9,6 +9,7 @@ import ( "github.com/answerdev/answer/internal/service/comment_common" "github.com/answerdev/answer/internal/service/config" "github.com/answerdev/answer/internal/service/object_info" + "github.com/answerdev/answer/pkg/htmltext" "github.com/answerdev/answer/pkg/obj" "github.com/segmentfault/pacman/log" @@ -190,6 +191,7 @@ func (vs *VoteService) ListUserVotes(ctx context.Context, req schema.GetVoteWith AnswerID: objInfo.AnswerID, ObjectType: objInfo.ObjectType, Title: objInfo.Title, + UrlTitle: htmltext.UrlTitle(objInfo.Title), Content: objInfo.Content, VoteType: activity_type.Format(voteInfo.ActivityType), } From 8070bcdcf480046de3be42fb57e89b9a44b2b10e Mon Sep 17 00:00:00 2001 From: aichy126 <16996097+aichy126@users.noreply.github.com> Date: Mon, 13 Mar 2023 11:31:29 +0800 Subject: [PATCH 4/4] update short id --- docs/docs.go | 4 ++-- docs/swagger.json | 4 ++-- docs/swagger.yaml | 4 ++-- internal/schema/siteinfo_schema.go | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/docs.go b/docs/docs.go index f7ca566e..3c065c45 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -7287,7 +7287,7 @@ const docTemplate = `{ "properties": { "permalink": { "type": "integer", - "maximum": 3, + "maximum": 4, "minimum": 0 }, "robots": { @@ -7304,7 +7304,7 @@ const docTemplate = `{ "properties": { "permalink": { "type": "integer", - "maximum": 3, + "maximum": 4, "minimum": 0 }, "robots": { diff --git a/docs/swagger.json b/docs/swagger.json index f9cc9422..000624b4 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -7275,7 +7275,7 @@ "properties": { "permalink": { "type": "integer", - "maximum": 3, + "maximum": 4, "minimum": 0 }, "robots": { @@ -7292,7 +7292,7 @@ "properties": { "permalink": { "type": "integer", - "maximum": 3, + "maximum": 4, "minimum": 0 }, "robots": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 01fec9cd..b01b8555 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -1408,7 +1408,7 @@ definitions: schema.SiteSeoReq: properties: permalink: - maximum: 3 + maximum: 4 minimum: 0 type: integer robots: @@ -1420,7 +1420,7 @@ definitions: schema.SiteSeoResp: properties: permalink: - maximum: 3 + maximum: 4 minimum: 0 type: integer robots: diff --git a/internal/schema/siteinfo_schema.go b/internal/schema/siteinfo_schema.go index b420813f..dd66fa4f 100644 --- a/internal/schema/siteinfo_schema.go +++ b/internal/schema/siteinfo_schema.go @@ -28,7 +28,7 @@ type SiteGeneralReq struct { } type SiteSeoReq struct { - PermaLink int `validate:"required,lte=3,gte=0" form:"permalink" json:"permalink"` + PermaLink int `validate:"required,lte=4,gte=0" form:"permalink" json:"permalink"` Robots string `validate:"required" form:"robots" json:"robots"` }