In Mindflow interface renamed all methods that work with Post into *Post().
This commit is contained in:
parent
a8a7e6427d
commit
16e2ff6ebc
@ -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)
|
InternalError(err.Error(), "Title: "+r.FormValue("title")+" | Body: "+r.FormValue("body"), w)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -288,7 +288,7 @@ func (h *MindflowApiHandlers) Edit(w http.ResponseWriter, r *http.Request) {
|
|||||||
post.ID, _ = strconv.ParseInt(GetURLParam(r, "id"), 10, 64)
|
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)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
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) {
|
func (h *MindflowApiHandlers) Delete(w http.ResponseWriter, r *http.Request) {
|
||||||
id, _ := strconv.ParseInt(GetURLParam(r, "id"), 10, 64)
|
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)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ func dsn(filePath string) string {
|
|||||||
return fmt.Sprintf("file:%s?_journal=WAL&_mutex=full", filePath)
|
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()
|
tx, err := s.db.Begin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -145,7 +145,7 @@ func (s *SQLiteMindflow) New(post *mindflow.Post) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SQLiteMindflow) Edit(post *mindflow.Post) error {
|
func (s *SQLiteMindflow) EditPost(post *mindflow.Post) error {
|
||||||
tx, err := s.db.Begin()
|
tx, err := s.db.Begin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -162,7 +162,7 @@ func (s *SQLiteMindflow) Edit(post *mindflow.Post) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SQLiteMindflow) Delete(id int64) error {
|
func (s *SQLiteMindflow) DeletePost(id int64) error {
|
||||||
tx, err := s.db.Begin()
|
tx, err := s.db.Begin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -38,14 +38,14 @@ func (p *Post) PostID() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Mindflow interface {
|
type Mindflow interface {
|
||||||
New(post *Post) error
|
NewPost(post *Post) error
|
||||||
Edit(post *Post) error
|
EditPost(post *Post) error
|
||||||
Delete(id int64) error
|
DeletePost(id int64) error
|
||||||
Posts() ([]Post, error)
|
Posts() ([]Post, error)
|
||||||
Categories() ([]Category, error)
|
|
||||||
NewCategory(name string) (int64, error)
|
NewCategory(name string) (int64, error)
|
||||||
EditCategory(category *Category) error
|
EditCategory(category *Category) error
|
||||||
DeleteCategory(id int64) error
|
DeleteCategory(id int64) error
|
||||||
DeleteUnusedCategories() error
|
DeleteUnusedCategories() error
|
||||||
|
Categories() ([]Category, error)
|
||||||
Close() error
|
Close() error
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user