|
|
@ -8,7 +8,9 @@ import ( |
|
|
|
"time" |
|
|
|
|
|
|
|
"git.aiterp.net/rpdata/api/internal/store" |
|
|
|
"git.aiterp.net/rpdata/api/model/story" |
|
|
|
"git.aiterp.net/rpdata/api/models" |
|
|
|
"git.aiterp.net/rpdata/api/models/chapters" |
|
|
|
"git.aiterp.net/rpdata/api/models/stories" |
|
|
|
_ "github.com/go-sql-driver/mysql" |
|
|
|
"github.com/jmoiron/sqlx" |
|
|
|
) |
|
|
@ -71,14 +73,20 @@ func main() { |
|
|
|
log.Fatalln(err) |
|
|
|
} |
|
|
|
|
|
|
|
tags := make([]story.Tag, 0, 8) |
|
|
|
tags := make([]models.Tag, 0, 8) |
|
|
|
for _, tagResult := range tagResults { |
|
|
|
if tagResult.PageID == result.ID { |
|
|
|
tags = append(tags, story.Tag{Kind: tagResult.Type, Name: tagResult.Name}) |
|
|
|
tags = append(tags, models.Tag{Kind: models.TagKind(tagResult.Type), Name: tagResult.Name}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
story, err := story.New(result.Name, result.Author[5:], result.Category, false, false, tags, publishDate, fictionalDate) |
|
|
|
category := models.StoryCategory(result.Category) |
|
|
|
if category.IsValid() { |
|
|
|
log.Println(result.Name, "does not have a valid category:", result.Category) |
|
|
|
continue |
|
|
|
} |
|
|
|
|
|
|
|
story, err := stories.Add(result.Name, result.Author[5:], category, true, false, tags, publishDate, fictionalDate) |
|
|
|
if err != nil { |
|
|
|
log.Fatalln(err) |
|
|
|
} |
|
|
@ -96,19 +104,11 @@ func main() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
chapter, err := story.AddChapter(title, result.Author[5:], result.Source, publishDate, fictionalDate) |
|
|
|
chapter, err := chapters.Add(story, title, result.Author[5:], result.Source, publishDate, &fictionalDate) |
|
|
|
if err != nil { |
|
|
|
log.Fatalln(err) |
|
|
|
} |
|
|
|
|
|
|
|
if !result.Unlisted { |
|
|
|
listed := true |
|
|
|
err := story.Edit(nil, nil, &listed, nil, nil) |
|
|
|
if err != nil { |
|
|
|
log.Fatalln(err) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
fmt.Println(result.ID, "->", story.ID, chapter.ID) |
|
|
|
} |
|
|
|
} |
|
|
|