answer/internal/schema/search_schema.go

49 lines
1.6 KiB
Go
Raw Normal View History

2022-09-27 17:59:05 +08:00
package schema
type SearchDTO struct {
2022-10-25 11:45:45 +08:00
UserID string // UserID current login user ID
Query string `validate:"required,gte=1,lte=60" json:"q" form:"q"` // Query the query string
Page int `validate:"omitempty,min=1" form:"page,default=1" json:"page"` //Query number of pages
Size int `validate:"omitempty,min=1,max=50" form:"size,default=30" json:"size"` //Search page size
Order string `validate:"required,oneof=newest active score relevance" form:"order,default=relevance" json:"order" enums:"newest,active,score,relevance"`
2022-09-27 17:59:05 +08:00
}
type SearchObject struct {
ID string `json:"id"`
Title string `json:"title"`
Excerpt string `json:"excerpt"`
CreatedAtParsed int64 `json:"created_at"`
VoteCount int `json:"vote_count"`
Accepted bool `json:"accepted"`
AnswerCount int `json:"answer_count"`
// user info
UserInfo *UserBasicInfo `json:"user_info"`
// tags
Tags []TagResp `json:"tags"`
2022-09-30 10:28:38 +08:00
// Status
StatusStr string `json:"status"`
2022-09-27 17:59:05 +08:00
}
type TagResp struct {
2022-10-11 10:18:26 +08:00
SlugName string `json:"slug_name"`
DisplayName string `json:"display_name"`
2022-09-27 17:59:05 +08:00
// if main tag slug name is not empty, this tag is synonymous with the main tag
MainTagSlugName string `json:"main_tag_slug_name"`
2022-11-14 16:44:48 +08:00
Recommend bool `json:"recommend"`
2022-09-27 17:59:05 +08:00
}
type SearchResp struct {
// object_type
ObjectType string `json:"object_type"`
// this object
Object SearchObject `json:"object"`
}
type SearchListResp struct {
Total int64 `json:"count"`
// search response
SearchResp []SearchResp `json:"list"`
// extra fields
Extra interface{} `json:"extra"`
}