edit added
All checks were successful
Deploy to NAS / deploy (push) Successful in 1m51s

This commit is contained in:
Christoph K.
2026-04-09 22:25:31 +02:00
parent fa76787d7b
commit b73d91ccaa
6 changed files with 201 additions and 1 deletions

View File

@@ -45,6 +45,33 @@ func (s *JournalStore) InsertImage(ctx context.Context, img domain.JournalImage)
return img, err
}
// GetEntry returns a single entry by ID, verifying ownership.
func (s *JournalStore) GetEntry(ctx context.Context, entryID, userID string) (domain.JournalEntry, error) {
var e domain.JournalEntry
err := s.pool.QueryRow(ctx,
`SELECT entry_id, user_id, entry_date::text, entry_time::text, title, description, lat, lon, visibility, hashtags, created_at
FROM journal_entries WHERE entry_id = $1 AND user_id = $2`,
entryID, userID,
).Scan(&e.EntryID, &e.UserID, &e.EntryDate, &e.EntryTime,
&e.Title, &e.Description, &e.Lat, &e.Lon, &e.Visibility, &e.Hashtags, &e.CreatedAt)
return e, err
}
// UpdateEntry updates mutable fields of an existing entry.
func (s *JournalStore) UpdateEntry(ctx context.Context, e domain.JournalEntry) error {
if e.Hashtags == nil {
e.Hashtags = []string{}
}
_, err := s.pool.Exec(ctx,
`UPDATE journal_entries
SET entry_time = $1, title = $2, description = $3, lat = $4, lon = $5, visibility = $6, hashtags = $7
WHERE entry_id = $8 AND user_id = $9`,
e.EntryTime, e.Title, e.Description, e.Lat, e.Lon, e.Visibility, e.Hashtags,
e.EntryID, e.UserID,
)
return err
}
// ListByDate returns all journal entries for a given date (YYYY-MM-DD), including their images.
func (s *JournalStore) ListByDate(ctx context.Context, userID, date string) ([]domain.JournalEntry, error) {
rows, err := s.pool.Query(ctx,