Skip to content

Commit 8037d3a

Browse files
update post summary response
1 parent b1fd373 commit 8037d3a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

internal/models/post.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ type ClubSummary struct {
124124
type PostSummary struct {
125125
ID uint `json:"id" gorm:"column:id"`
126126
Title string `json:"title" gorm:"column:title"`
127+
Content string `json:"content" gorm:"column:content"`
127128
Type string `json:"type" gorm:"column:type"`
129+
TypeData PostTypeData `json:"type_data,omitempty" gorm:"type:jsonb"`
128130
IsPinned bool `json:"is_pinned" gorm:"column:is_pinned"`
129131
LikesCount int `json:"likes_count" gorm:"column:likes_count"`
130132
CommentsCount int `json:"comments_count" gorm:"column:comments_count"`

internal/repository/post.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ func (r *postRepository) ListPostSummaries(clubID uint, limit, offset int) ([]mo
8585
type row struct {
8686
ID uint `gorm:"column:id"`
8787
Title string `gorm:"column:title"`
88+
Content string `gorm:"column:content"`
8889
Type string `gorm:"column:type"`
90+
TypeData string `gorm:"column:type_data"`
8991
IsPinned bool `gorm:"column:is_pinned"`
9092
LikesCount int `gorm:"column:likes_count"`
9193
CommentsCount int `gorm:"column:comments_count"`
@@ -106,7 +108,7 @@ func (r *postRepository) ListPostSummaries(clubID uint, limit, offset int) ([]mo
106108
var rows []row
107109

108110
err := r.db.Table("posts").
109-
Select(`posts.id, posts.title, posts.type, posts.is_pinned, posts.likes_count, posts.comments_count, posts.views_count,
111+
Select(`posts.id, posts.title, posts.content, posts.type, posts.type_data, posts.is_pinned, posts.likes_count, posts.comments_count, posts.views_count,
110112
posts.user_id as post_user_id, posts.club_id as post_club_id, posts.created_at, posts.updated_at,
111113
users.id as user_id, users.username as user_username, users.avatar_url as user_avatar_url,
112114
clubs.id as club_id, clubs.name as club_name`).
@@ -126,7 +128,9 @@ func (r *postRepository) ListPostSummaries(clubID uint, limit, offset int) ([]mo
126128
ps := models.PostSummary{
127129
ID: rrow.ID,
128130
Title: rrow.Title,
131+
Content: rrow.Content,
129132
Type: rrow.Type,
133+
TypeData: []byte(rrow.TypeData),
130134
IsPinned: rrow.IsPinned,
131135
LikesCount: rrow.LikesCount,
132136
CommentsCount: rrow.CommentsCount,

0 commit comments

Comments
 (0)