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,
|
Type: constant.AnswerObjectType,
|
||||||
Content: answer.ParsedText,
|
Content: answer.ParsedText,
|
||||||
Answers: 0,
|
Answers: 0,
|
||||||
Status: int64(answer.Status),
|
Status: plugin.SearchContentStatus(answer.Status),
|
||||||
Tags: tags,
|
Tags: tags,
|
||||||
QuestionID: answer.QuestionID,
|
QuestionID: answer.QuestionID,
|
||||||
UserID: answer.UserID,
|
UserID: answer.UserID,
|
||||||
|
|
|
@ -457,7 +457,7 @@ func (qr *questionRepo) updateSearch(ctx context.Context, questionID string) (er
|
||||||
Type: constant.QuestionObjectType,
|
Type: constant.QuestionObjectType,
|
||||||
Content: question.ParsedText,
|
Content: question.ParsedText,
|
||||||
Answers: int64(question.AnswerCount),
|
Answers: int64(question.AnswerCount),
|
||||||
Status: int64(question.Status),
|
Status: plugin.SearchContentStatus(question.Status),
|
||||||
Tags: tags,
|
Tags: tags,
|
||||||
QuestionID: questionID,
|
QuestionID: questionID,
|
||||||
UserID: question.UserID,
|
UserID: question.UserID,
|
||||||
|
|
|
@ -59,7 +59,7 @@ func (s *SearchCondition) Convert2PluginSearchCond(page, pageSize int, order str
|
||||||
Words: s.Words,
|
Words: s.Words,
|
||||||
TagIDs: s.Tags,
|
TagIDs: s.Tags,
|
||||||
UserID: s.UserID,
|
UserID: s.UserID,
|
||||||
Order: order,
|
Order: plugin.SearchOrderCond(order),
|
||||||
QuestionID: s.QuestionID,
|
QuestionID: s.QuestionID,
|
||||||
VoteAmount: s.VoteAmount,
|
VoteAmount: s.VoteAmount,
|
||||||
ViewAmount: s.Views,
|
ViewAmount: s.Views,
|
||||||
|
|
|
@ -12,20 +12,20 @@ type SearchResult struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type SearchContent struct {
|
type SearchContent struct {
|
||||||
ObjectID string `json:"objectID"`
|
ObjectID string `json:"objectID"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
Content string `json:"content"`
|
Content string `json:"content"`
|
||||||
Answers int64 `json:"answers"`
|
Answers int64 `json:"answers"`
|
||||||
Status int64 `json:"status"`
|
Status SearchContentStatus `json:"status"`
|
||||||
Tags []string `json:"tags"`
|
Tags []string `json:"tags"`
|
||||||
QuestionID string `json:"questionID"`
|
QuestionID string `json:"questionID"`
|
||||||
UserID string `json:"userID"`
|
UserID string `json:"userID"`
|
||||||
Views int64 `json:"views"`
|
Views int64 `json:"views"`
|
||||||
Created int64 `json:"created"`
|
Created int64 `json:"created"`
|
||||||
Active int64 `json:"active"`
|
Active int64 `json:"active"`
|
||||||
Score int64 `json:"score"`
|
Score int64 `json:"score"`
|
||||||
HasAccepted bool `json:"hasAccepted"`
|
HasAccepted bool `json:"hasAccepted"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SearchBasicCond struct {
|
type SearchBasicCond struct {
|
||||||
|
@ -41,12 +41,12 @@ type SearchBasicCond struct {
|
||||||
// The object's owner user ID.
|
// The object's owner user ID.
|
||||||
UserID string
|
UserID string
|
||||||
// The order of the search result.
|
// The order of the search result.
|
||||||
Order string
|
Order SearchOrderCond
|
||||||
|
|
||||||
// Weathers the question is accepted or not. Only support search question.
|
// 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.
|
// Weathers the answer is accepted or not. Only support search answer.
|
||||||
AnswerAccepted AcceptedCond
|
AnswerAccepted SearchAcceptedCond
|
||||||
|
|
||||||
// Only support search answer.
|
// Only support search answer.
|
||||||
QuestionID string
|
QuestionID string
|
||||||
|
@ -59,14 +59,28 @@ type SearchBasicCond struct {
|
||||||
AnswerAmount int
|
AnswerAmount int
|
||||||
}
|
}
|
||||||
|
|
||||||
type AcceptedCond int
|
type SearchAcceptedCond int
|
||||||
|
type SearchContentStatus int
|
||||||
|
type SearchOrderCond string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
AcceptedCondAll AcceptedCond = iota
|
AcceptedCondAll SearchAcceptedCond = iota
|
||||||
AcceptedCondTrue
|
AcceptedCondTrue
|
||||||
AcceptedCondFalse
|
AcceptedCondFalse
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
SearchContentStatusAvailable = 1
|
||||||
|
SearchContentStatusDeleted = 10
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
SearchNewestOrder SearchOrderCond = "newest"
|
||||||
|
SearchActiveOrder SearchOrderCond = "active"
|
||||||
|
SearchScoreOrder SearchOrderCond = "score"
|
||||||
|
SearchRelevanceOrder SearchOrderCond = "relevance"
|
||||||
|
)
|
||||||
|
|
||||||
type Search interface {
|
type Search interface {
|
||||||
Base
|
Base
|
||||||
SearchContents(ctx context.Context, cond *SearchBasicCond) (res []SearchResult, total int64, err error)
|
SearchContents(ctx context.Context, cond *SearchBasicCond) (res []SearchResult, total int64, err error)
|
||||||
|
|
Loading…
Reference in New Issue