mirror of
https://github.com/wgh136/nysoure.git
synced 2025-12-15 07:31:14 +00:00
Search charaters
This commit is contained in:
@@ -13,20 +13,36 @@ import (
|
||||
)
|
||||
|
||||
type ResourceParams struct {
|
||||
Id uint
|
||||
Title string
|
||||
Subtitles []string
|
||||
Time time.Time
|
||||
Id uint
|
||||
Title string
|
||||
Subtitles []string
|
||||
Time time.Time
|
||||
Characters []ResourceCharacter
|
||||
}
|
||||
|
||||
type ResourceCharacter struct {
|
||||
Name string
|
||||
Alias []string
|
||||
CV string
|
||||
}
|
||||
|
||||
var index bleve.Index
|
||||
|
||||
func AddResourceToIndex(r model.Resource) error {
|
||||
cs := make([]ResourceCharacter, 0, len(r.Characters))
|
||||
for _, c := range r.Characters {
|
||||
cs = append(cs, ResourceCharacter{
|
||||
Name: c.Name,
|
||||
Alias: c.Alias,
|
||||
CV: c.CV,
|
||||
})
|
||||
}
|
||||
return index.Index(fmt.Sprintf("%d", r.ID), ResourceParams{
|
||||
Id: r.ID,
|
||||
Title: r.Title,
|
||||
Subtitles: r.AlternativeTitles,
|
||||
Time: r.CreatedAt,
|
||||
Id: r.ID,
|
||||
Title: r.Title,
|
||||
Subtitles: r.AlternativeTitles,
|
||||
Time: r.CreatedAt,
|
||||
Characters: cs,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user