Started styling the app and have got editing posts working.
This commit is contained in:
parent
7ef6725bdb
commit
bf5d6cbe52
20 changed files with 511 additions and 41 deletions
|
|
@ -18,6 +18,15 @@ func (db *DB) ListPostsOfSite(ctx context.Context, siteID int64) ([]models.Post,
|
|||
return moslice.Map(res, dbPostToPost), nil
|
||||
}
|
||||
|
||||
func (db *DB) GetPost(ctx context.Context, postID int64) (models.Post, error) {
|
||||
res, err := db.q.GetPostWithID(ctx, postID)
|
||||
if err != nil {
|
||||
return models.Post{}, err
|
||||
}
|
||||
|
||||
return dbPostToPost(res), nil
|
||||
}
|
||||
|
||||
func (db *DB) ListPublishablePosts(ctx context.Context, fromID, siteID int64, now time.Time) ([]models.Post, error) {
|
||||
res, err := db.q.ListPublishablePosts(ctx, dbq.ListPublishablePostsParams{
|
||||
ID: fromID,
|
||||
|
|
@ -49,6 +58,19 @@ func (db *DB) InsertPost(ctx context.Context, p *models.Post) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (db *DB) UpdatePost(ctx context.Context, p *models.Post) error {
|
||||
return db.q.UpdatePost(ctx, dbq.UpdatePostParams{
|
||||
ID: p.ID,
|
||||
SiteID: p.SiteID,
|
||||
Title: pgtype.Text{String: p.Title, Valid: p.Title != ""},
|
||||
Body: p.Body,
|
||||
State: dbq.PostState(p.State),
|
||||
Props: []byte(`{}`),
|
||||
PostDate: pgtype.Timestamptz{Time: p.PostDate, Valid: !p.PostDate.IsZero()},
|
||||
//CreatedAt: pgtype.Timestamp{Time: p.CreatedAt, Valid: !p.CreatedAt.IsZero()},
|
||||
})
|
||||
}
|
||||
|
||||
func dbPostToPost(p dbq.Post) models.Post {
|
||||
return models.Post{
|
||||
ID: p.ID,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue