@@ -72,9 +72,9 @@ func (g GenreSchema) Init(genre models.Genre) GenreSchema {
7272}
7373
7474type ChapterListSchema struct {
75- Title string `json:"title"`
76- Slug string `json:"slug"`
77- IsLast bool `json:"is_last"`
75+ Title string `json:"title"`
76+ Slug string `json:"slug"`
77+ IsLast bool `json:"is_last"`
7878}
7979
8080func (c ChapterListSchema ) Init (chapter models.Chapter ) ChapterListSchema {
@@ -114,8 +114,7 @@ type BookSchema struct {
114114 Blurb string `json:"blurb"`
115115 AgeDiscretion choices.AgeType `json:"age_discretion"`
116116 Genre GenreWithoutTagSchema `json:"genre"`
117- Section * SectionSchema `json:"section"`
118- SubSection * SubSectionSchema `json:"sub_section"`
117+ SubSections []SubSectionSchema `json:"sub_sections"`
119118 Tags []TagSchema `json:"tags"`
120119 ChaptersCount int `json:"chapters_count"`
121120 PartialViewChapter * ChapterListSchema `json:"partial_view_chapter"`
@@ -147,15 +146,13 @@ func (b BookSchema) Init(book models.Book) BookSchema {
147146 b .Title = book .Title
148147 b .Slug = book .Slug
149148 b .Genre = b .Genre .Init (book .Genre )
150- if book .SubSection != nil {
151- section := SectionSchema {}.Init (book .SubSection .Section )
152- subsection := SubSectionSchema {}.Init (book .SubSection )
153- b .Section = & section
154- b .SubSection = & subsection
155- } else {
156- b .Section = nil
157- b .SubSection = nil
149+
150+ subsections := book .SubSections
151+ subsectionsToAdd := make ([]SubSectionSchema , 0 )
152+ for _ , subsection := range subsections {
153+ subsectionsToAdd = append (subsectionsToAdd , SubSectionSchema {}.Init (& subsection ))
158154 }
155+ b .SubSections = subsectionsToAdd
159156 b .ChaptersCount = book .ChaptersCount ()
160157 b .Votes = book .VotesCount ()
161158 b .Reads = book .ReadsCount ()
0 commit comments