diff --git a/internal/http/api_handlers.go b/internal/http/api_handlers.go index 1d49bc6..ef93634 100644 --- a/internal/http/api_handlers.go +++ b/internal/http/api_handlers.go @@ -244,7 +244,7 @@ func (h *MindflowApiHandlers) New(w http.ResponseWriter, r *http.Request) { } } - if err = h.db.New(post); err != nil { + if err = h.db.NewPost(post); err != nil { InternalError(err.Error(), "Title: "+r.FormValue("title")+" | Body: "+r.FormValue("body"), w) return } @@ -288,7 +288,7 @@ func (h *MindflowApiHandlers) Edit(w http.ResponseWriter, r *http.Request) { post.ID, _ = strconv.ParseInt(GetURLParam(r, "id"), 10, 64) } - if err = h.db.Edit(post); err != nil { + if err = h.db.EditPost(post); err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } @@ -296,7 +296,7 @@ func (h *MindflowApiHandlers) Edit(w http.ResponseWriter, r *http.Request) { func (h *MindflowApiHandlers) Delete(w http.ResponseWriter, r *http.Request) { id, _ := strconv.ParseInt(GetURLParam(r, "id"), 10, 64) - if err := h.db.Delete(id); err != nil { + if err := h.db.DeletePost(id); err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } diff --git a/pkg/mindflow/database/sqlite/db.go b/pkg/mindflow/database/sqlite/db.go index 189ea71..33540b3 100644 --- a/pkg/mindflow/database/sqlite/db.go +++ b/pkg/mindflow/database/sqlite/db.go @@ -123,7 +123,7 @@ func dsn(filePath string) string { return fmt.Sprintf("file:%s?_journal=WAL&_mutex=full", filePath) } -func (s *SQLiteMindflow) New(post *mindflow.Post) error { +func (s *SQLiteMindflow) NewPost(post *mindflow.Post) error { tx, err := s.db.Begin() if err != nil { return err @@ -145,7 +145,7 @@ func (s *SQLiteMindflow) New(post *mindflow.Post) error { return nil } -func (s *SQLiteMindflow) Edit(post *mindflow.Post) error { +func (s *SQLiteMindflow) EditPost(post *mindflow.Post) error { tx, err := s.db.Begin() if err != nil { return err @@ -162,7 +162,7 @@ func (s *SQLiteMindflow) Edit(post *mindflow.Post) error { return nil } -func (s *SQLiteMindflow) Delete(id int64) error { +func (s *SQLiteMindflow) DeletePost(id int64) error { tx, err := s.db.Begin() if err != nil { return err diff --git a/pkg/mindflow/mindflow.go b/pkg/mindflow/mindflow.go index 7ad0b7a..0664444 100644 --- a/pkg/mindflow/mindflow.go +++ b/pkg/mindflow/mindflow.go @@ -38,14 +38,14 @@ func (p *Post) PostID() string { } type Mindflow interface { - New(post *Post) error - Edit(post *Post) error - Delete(id int64) error + NewPost(post *Post) error + EditPost(post *Post) error + DeletePost(id int64) error Posts() ([]Post, error) - Categories() ([]Category, error) NewCategory(name string) (int64, error) EditCategory(category *Category) error DeleteCategory(id int64) error DeleteUnusedCategories() error + Categories() ([]Category, error) Close() error }