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.

fix by code review

sy-records9dc0d566cc47
diff --git a/internal/repo/search_common/search_repo.go b/internal/repo/search_common/search_repo.go
index 3745a645..de3c03eb 100644
--- a/internal/repo/search_common/search_repo.go
+++ b/internal/repo/search_common/search_repo.go
@@ -486,8 +486,8 @@ func (sr *searchRepo) parseResult(ctx context.Context, res []map[string][]byte)
userIDs = append(userIDs, string(r["user_id"]))
tp, _ := time.ParseInLocation("2006-01-02 15:04:05", string(r["created_at"]), time.Local)
- ID := string(r["id"])
- QuestionID := string(r["question_id"])
+ var ID = string(r["id"])
+ var QuestionID = string(r["question_id"])
if handler.GetEnableShortID(ctx) {
ID = uid.EnShortID(ID)
QuestionID = uid.EnShortID(QuestionID)
diff --git a/internal/schema/answer_schema.go b/internal/schema/answer_schema.go
index dde1cb1d..2cd45947 100644
--- a/internal/schema/answer_schema.go
+++ b/internal/schema/answer_schema.go
@@ -98,12 +98,12 @@ type AnswerListReq struct {
}
type AnswerInfo struct {
- ID string `json:"id" xorm:"id"`
- QuestionID string `json:"question_id" xorm:"question_id"`
- Content string `json:"content" xorm:"content"`
- HTML string `json:"html" xorm:"html"`
- CreateTime int64 `json:"create_time" xorm:"created"`
- UpdateTime int64 `json:"update_time" xorm:"updated"`
+ ID string `json:"id"`
+ QuestionID string `json:"question_id"`
+ Content string `json:"content"`
+ HTML string `json:"html"`
+ CreateTime int64 `json:"create_time"`
+ UpdateTime int64 `json:"update_time"`
Accepted int `json:"accepted"`
UserID string `json:"-"`
UpdateUserID string `json:"-"`
diff --git a/internal/schema/question_schema.go b/internal/schema/question_schema.go
index 7c079c25..bb409e6d 100644
--- a/internal/schema/question_schema.go
+++ b/internal/schema/question_schema.go
@@ -204,43 +204,43 @@ func (req *QuestionUpdate) Check() (errFields []*validator.FormErrorField, err e
type QuestionBaseInfo struct {
ID string `json:"id" `
- Title string `json:"title" xorm:"title"` // title
- UrlTitle string `json:"url_title" xorm:"url_title"` // title
- ViewCount int `json:"view_count" xorm:"view_count"` // view count
- AnswerCount int `json:"answer_count" xorm:"answer_count"` // answer count
- CollectionCount int `json:"collection_count" xorm:"collection_count"` // collection count
- FollowCount int `json:"follow_count" xorm:"follow_count"` // follow count
+ Title string `json:"title"`
+ UrlTitle string `json:"url_title"`
+ ViewCount int `json:"view_count"`
+ AnswerCount int `json:"answer_count"`
+ CollectionCount int `json:"collection_count"`
+ FollowCount int `json:"follow_count"`
Status string `json:"status"`
AcceptedAnswer bool `json:"accepted_answer"`
}
type QuestionInfo struct {
ID string `json:"id" `
- Title string `json:"title" xorm:"title"` // title
- UrlTitle string `json:"url_title" xorm:"url_title"` // title
- Content string `json:"content" xorm:"content"` // content
- HTML string `json:"html" xorm:"html"` // html
- Description string `json:"description"` //description
- Tags []*TagResp `json:"tags" ` // tags
- ViewCount int `json:"view_count" xorm:"view_count"` // view_count
- UniqueViewCount int `json:"unique_view_count" xorm:"unique_view_count"` // unique_view_count
- VoteCount int `json:"vote_count" xorm:"vote_count"` // vote_count
- AnswerCount int `json:"answer_count" xorm:"answer_count"` // answer count
- CollectionCount int `json:"collection_count" xorm:"collection_count"` // collection count
- FollowCount int `json:"follow_count" xorm:"follow_count"` // follow count
- AcceptedAnswerID string `json:"accepted_answer_id" ` // accepted_answer_id
- LastAnswerID string `json:"last_answer_id" ` // last_answer_id
- CreateTime int64 `json:"create_time" ` // create_time
- UpdateTime int64 `json:"-"` // update_time
+ Title string `json:"title"`
+ UrlTitle string `json:"url_title"`
+ Content string `json:"content"`
+ HTML string `json:"html"`
+ Description string `json:"description"`
+ Tags []*TagResp `json:"tags"`
+ ViewCount int `json:"view_count"`
+ UniqueViewCount int `json:"unique_view_count"`
+ VoteCount int `json:"vote_count"`
+ AnswerCount int `json:"answer_count"`
+ CollectionCount int `json:"collection_count"`
+ FollowCount int `json:"follow_count"`
+ AcceptedAnswerID string `json:"accepted_answer_id"`
+ LastAnswerID string `json:"last_answer_id"`
+ CreateTime int64 `json:"create_time"`
+ UpdateTime int64 `json:"-"`
PostUpdateTime int64 `json:"update_time"`
QuestionUpdateTime int64 `json:"edit_time"`
- Pin int `json:"pin"` // 1: unpin, 2: pin
- Show int `json:"show"` // 0: show, 1: hide
+ Pin int `json:"pin"`
+ Show int `json:"show"`
Status int `json:"status"`
Operation *Operation `json:"operation,omitempty"`
- UserID string `json:"-" `
- LastEditUserID string `json:"-" `
- LastAnsweredUserID string `json:"-" `
+ UserID string `json:"-"`
+ LastEditUserID string `json:"-"`
+ LastAnsweredUserID string `json:"-"`
UserInfo *UserBasicInfo `json:"user_info"`
UpdateUserInfo *UserBasicInfo `json:"update_user_info,omitempty"`
LastAnsweredUserInfo *UserBasicInfo `json:"last_answered_user_info,omitempty"`
diff --git a/internal/service/question_common/question.go b/internal/service/question_common/question.go
index 136788cd..007e4831 100644
--- a/internal/service/question_common/question.go
+++ b/internal/service/question_common/question.go
@@ -591,7 +591,7 @@ func (qs *QuestionCommon) ShowListFormat(ctx context.Context, data *entity.Quest
}
func (qs *QuestionCommon) ShowFormat(ctx context.Context, data *entity.Question) *schema.QuestionInfo {
- ID := data.ID
+ var ID = data.ID
if handler.GetEnableShortID(ctx) {
ID = uid.EnShortID(data.ID)
}