mirror of https://gitee.com/answerdev/answer.git
Merge branch 'fix/report' into 'main'
Fix/report See merge request opensource/answer!29
This commit is contained in:
commit
0a317c5ec3
|
@ -50,6 +50,7 @@ func (sr *searchRepo) SearchContents(ctx context.Context, words []string, tagID,
|
|||
"`vote_count`",
|
||||
"`answer_count`",
|
||||
"0 as `accepted`",
|
||||
"`question`.`status` as `status`",
|
||||
).From("`question`")
|
||||
ub = builder.Select(
|
||||
"`answer`.`id` as `id`",
|
||||
|
@ -61,6 +62,7 @@ func (sr *searchRepo) SearchContents(ctx context.Context, words []string, tagID,
|
|||
"`answer`.`vote_count` as `vote_count`",
|
||||
"0 as `answer_count`",
|
||||
"`adopted` as `accepted`",
|
||||
"`answer`.`status` as `status`",
|
||||
).From("`answer`").
|
||||
LeftJoin("`question`", "`question`.id = `answer`.question_id")
|
||||
|
||||
|
@ -127,6 +129,7 @@ func (sr *searchRepo) SearchQuestions(ctx context.Context, words []string, limit
|
|||
"`vote_count`",
|
||||
"`answer_count`",
|
||||
"0 as `accepted`",
|
||||
"`status`",
|
||||
).From("question")
|
||||
|
||||
for i, word := range words {
|
||||
|
@ -176,6 +179,7 @@ func (sr *searchRepo) SearchAnswers(ctx context.Context, words []string, limitAc
|
|||
"`answer`.`vote_count` as `vote_count`",
|
||||
"0 as `answer_count`",
|
||||
"`adopted` as `accepted`",
|
||||
"`answer`.`status` as `status`",
|
||||
).From("`answer`").
|
||||
LeftJoin("`question`", "`question`.id = `answer`.question_id")
|
||||
|
||||
|
@ -213,7 +217,9 @@ func (sr *searchRepo) SearchAnswers(ctx context.Context, words []string, limitAc
|
|||
func (sr *searchRepo) parseResult(ctx context.Context, res []map[string][]byte) (resp []schema.SearchResp, err error) {
|
||||
for _, r := range res {
|
||||
var (
|
||||
objectKey string
|
||||
objectKey,
|
||||
status string
|
||||
|
||||
tags []schema.TagResp
|
||||
tagsEntity []entity.Tag
|
||||
object schema.SearchObject
|
||||
|
@ -246,6 +252,22 @@ func (sr *searchRepo) parseResult(ctx context.Context, res []map[string][]byte)
|
|||
return
|
||||
}
|
||||
_ = copier.Copy(&tags, tagsEntity)
|
||||
switch objectKey {
|
||||
case "question":
|
||||
for k, v := range entity.CmsQuestionSearchStatus {
|
||||
if v == converter.StringToInt(string(r["status"])) {
|
||||
status = k
|
||||
break
|
||||
}
|
||||
}
|
||||
case "answer":
|
||||
for k, v := range entity.CmsAnswerSearchStatus {
|
||||
if v == converter.StringToInt(string(r["status"])) {
|
||||
status = k
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object = schema.SearchObject{
|
||||
ID: string(r["id"]),
|
||||
|
@ -257,6 +279,7 @@ func (sr *searchRepo) parseResult(ctx context.Context, res []map[string][]byte)
|
|||
VoteCount: converter.StringToInt(string(r["vote_count"])),
|
||||
Accepted: string(r["accepted"]) == "2",
|
||||
AnswerCount: converter.StringToInt(string(r["answer_count"])),
|
||||
StatusStr: status,
|
||||
}
|
||||
resp = append(resp, schema.SearchResp{
|
||||
ObjectType: objectKey,
|
||||
|
|
|
@ -21,6 +21,8 @@ type SearchObject struct {
|
|||
UserInfo *UserBasicInfo `json:"user_info"`
|
||||
// tags
|
||||
Tags []TagResp `json:"tags"`
|
||||
// Status
|
||||
StatusStr string `json:"status"`
|
||||
}
|
||||
|
||||
type TagResp struct {
|
||||
|
|
Loading…
Reference in New Issue