Skip to content

Commit c032d02

Browse files
committed
Update story params and views
1 parent f324297 commit c032d02

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

params/stories/create.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ type Create struct {
66
AuthorID uint `json:"authorId"`
77
Title string `json:"title"`
88
Content string `json:"content"`
9+
PinOrder *int `json:"pinOrder"`
910
}
1011

1112
// TODO: Add some validation
@@ -18,5 +19,6 @@ func (params *Create) ToModel() *model.Story {
1819
AuthorID: params.AuthorID,
1920
Title: params.Title,
2021
Content: params.Content,
22+
PinOrder: params.PinOrder,
2123
}
2224
}

view/stories/list.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ type ListView struct {
66
AuthorID uint `json:"authorId"`
77
Title string `json:"title"`
88
Content string `json:"content"`
9+
Pinned bool `json:"isPinned"`
910
}
1011

1112
func ListFrom(stories []model.Story) []ListView {
@@ -15,6 +16,7 @@ func ListFrom(stories []model.Story) []ListView {
1516
AuthorID: story.AuthorID,
1617
Title: story.Title,
1718
Content: story.Content,
19+
Pinned: story.PinOrder != nil,
1820
}
1921
}
2022
return storiesListView

view/stories/view.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ type View struct {
77
AuthorID uint `json:"authorId"`
88
Title string `json:"title"`
99
Content string `json:"content"`
10+
Pinned bool `json:"isPinned"`
1011
}
1112

1213
func SingleFrom(story model.Story) View {
@@ -15,6 +16,7 @@ func SingleFrom(story model.Story) View {
1516
AuthorID: story.AuthorID,
1617
Title: story.Title,
1718
Content: story.Content,
19+
Pinned: story.PinOrder != nil,
1820
}
1921
return storyView
2022
}

0 commit comments

Comments
 (0)