mirror of https://gitee.com/answerdev/answer.git
feat(plugin): update search condition
This commit is contained in:
parent
5a03fef6ec
commit
bf50c8971c
|
@ -381,7 +381,7 @@ func (ar *answerRepo) updateSearch(ctx context.Context, answerID string) (err er
|
|||
Type: constant.AnswerObjectType,
|
||||
Content: answer.ParsedText,
|
||||
Answers: 0,
|
||||
Status: int64(answer.Status),
|
||||
Status: plugin.SearchContentStatus(answer.Status),
|
||||
Tags: tags,
|
||||
QuestionID: answer.QuestionID,
|
||||
UserID: answer.UserID,
|
||||
|
|
|
@ -457,7 +457,7 @@ func (qr *questionRepo) updateSearch(ctx context.Context, questionID string) (er
|
|||
Type: constant.QuestionObjectType,
|
||||
Content: question.ParsedText,
|
||||
Answers: int64(question.AnswerCount),
|
||||
Status: int64(question.Status),
|
||||
Status: plugin.SearchContentStatus(question.Status),
|
||||
Tags: tags,
|
||||
QuestionID: questionID,
|
||||
UserID: question.UserID,
|
||||
|
|
|
@ -59,7 +59,7 @@ func (s *SearchCondition) Convert2PluginSearchCond(page, pageSize int, order str
|
|||
Words: s.Words,
|
||||
TagIDs: s.Tags,
|
||||
UserID: s.UserID,
|
||||
Order: order,
|
||||
Order: plugin.SearchOrderCond(order),
|
||||
QuestionID: s.QuestionID,
|
||||
VoteAmount: s.VoteAmount,
|
||||
ViewAmount: s.Views,
|
||||
|
|
|
@ -17,7 +17,7 @@ type SearchContent struct {
|
|||
Type string `json:"type"`
|
||||
Content string `json:"content"`
|
||||
Answers int64 `json:"answers"`
|
||||
Status int64 `json:"status"`
|
||||
Status SearchContentStatus `json:"status"`
|
||||
Tags []string `json:"tags"`
|
||||
QuestionID string `json:"questionID"`
|
||||
UserID string `json:"userID"`
|
||||
|
@ -41,12 +41,12 @@ type SearchBasicCond struct {
|
|||
// The object's owner user ID.
|
||||
UserID string
|
||||
// The order of the search result.
|
||||
Order string
|
||||
Order SearchOrderCond
|
||||
|
||||
// Weathers the question is accepted or not. Only support search question.
|
||||
QuestionAccepted AcceptedCond
|
||||
QuestionAccepted SearchAcceptedCond
|
||||
// Weathers the answer is accepted or not. Only support search answer.
|
||||
AnswerAccepted AcceptedCond
|
||||
AnswerAccepted SearchAcceptedCond
|
||||
|
||||
// Only support search answer.
|
||||
QuestionID string
|
||||
|
@ -59,14 +59,28 @@ type SearchBasicCond struct {
|
|||
AnswerAmount int
|
||||
}
|
||||
|
||||
type AcceptedCond int
|
||||
type SearchAcceptedCond int
|
||||
type SearchContentStatus int
|
||||
type SearchOrderCond string
|
||||
|
||||
const (
|
||||
AcceptedCondAll AcceptedCond = iota
|
||||
AcceptedCondAll SearchAcceptedCond = iota
|
||||
AcceptedCondTrue
|
||||
AcceptedCondFalse
|
||||
)
|
||||
|
||||
const (
|
||||
SearchContentStatusAvailable = 1
|
||||
SearchContentStatusDeleted = 10
|
||||
)
|
||||
|
||||
const (
|
||||
SearchNewestOrder SearchOrderCond = "newest"
|
||||
SearchActiveOrder SearchOrderCond = "active"
|
||||
SearchScoreOrder SearchOrderCond = "score"
|
||||
SearchRelevanceOrder SearchOrderCond = "relevance"
|
||||
)
|
||||
|
||||
type Search interface {
|
||||
Base
|
||||
SearchContents(ctx context.Context, cond *SearchBasicCond) (res []SearchResult, total int64, err error)
|
||||
|
|
Loading…
Reference in New Issue