mirror of
https://github.com/wgh136/nysoure.git
synced 2025-12-15 23:41:16 +00:00
Search charaters
This commit is contained in:
@@ -13,20 +13,36 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type ResourceParams struct {
|
type ResourceParams struct {
|
||||||
Id uint
|
Id uint
|
||||||
Title string
|
Title string
|
||||||
Subtitles []string
|
Subtitles []string
|
||||||
Time time.Time
|
Time time.Time
|
||||||
|
Characters []ResourceCharacter
|
||||||
|
}
|
||||||
|
|
||||||
|
type ResourceCharacter struct {
|
||||||
|
Name string
|
||||||
|
Alias []string
|
||||||
|
CV string
|
||||||
}
|
}
|
||||||
|
|
||||||
var index bleve.Index
|
var index bleve.Index
|
||||||
|
|
||||||
func AddResourceToIndex(r model.Resource) error {
|
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{
|
return index.Index(fmt.Sprintf("%d", r.ID), ResourceParams{
|
||||||
Id: r.ID,
|
Id: r.ID,
|
||||||
Title: r.Title,
|
Title: r.Title,
|
||||||
Subtitles: r.AlternativeTitles,
|
Subtitles: r.AlternativeTitles,
|
||||||
Time: r.CreatedAt,
|
Time: r.CreatedAt,
|
||||||
|
Characters: cs,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user