Merge
This commit is contained in:
@@ -2,7 +2,6 @@ package blogs
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
core "fr.latosa-escrima/api/core"
|
||||
@@ -34,25 +33,3 @@ func HandleBlog(w http.ResponseWriter, r *http.Request) {
|
||||
}.Respond(w, http.StatusOK)
|
||||
return
|
||||
}
|
||||
|
||||
func HandleGetBlogs(w http.ResponseWriter, r *http.Request) {
|
||||
var blog []core.Blog
|
||||
count, err := core.DB.NewSelect().
|
||||
Model(&blog).
|
||||
Relation("Author").
|
||||
ScanAndCount(context.Background())
|
||||
if err != nil {
|
||||
core.JSONError{
|
||||
Status: core.Error,
|
||||
Message: err.Error(),
|
||||
}.Respond(w, http.StatusNotAcceptable)
|
||||
return
|
||||
}
|
||||
|
||||
core.JSONSuccess{
|
||||
Status: core.Success,
|
||||
Message: fmt.Sprint("%d blogs objects sent", count),
|
||||
Data: blog,
|
||||
}.Respond(w, http.StatusOK)
|
||||
return
|
||||
}
|
||||
@@ -8,15 +8,10 @@ import (
|
||||
core "fr.latosa-escrima/api/core"
|
||||
)
|
||||
|
||||
func HandleBlog(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
blog_uuid := r.PathValue("uuid")
|
||||
|
||||
var blog core.Blog
|
||||
_, err := core.DB.NewSelect().
|
||||
func HandleGetBlogs(w http.ResponseWriter, r *http.Request) {
|
||||
var blog []core.Blog
|
||||
count, err := core.DB.NewSelect().
|
||||
Model(&blog).
|
||||
Where("blog_id = ?", blog_uuid).
|
||||
Relation("Author").
|
||||
ScanAndCount(context.Background())
|
||||
if err != nil {
|
||||
@@ -29,30 +24,8 @@ func HandleBlog(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
core.JSONSuccess{
|
||||
Status: core.Success,
|
||||
Message: "Status OK",
|
||||
Message: fmt.Sprintf("%d blogs objects sent", count),
|
||||
Data: blog,
|
||||
}.Respond(w, http.StatusOK)
|
||||
return
|
||||
}
|
||||
|
||||
func HandleGetBlogs(w http.ResponseWriter, r *http.Request) {
|
||||
var blog []core.Blog
|
||||
count, err := core.DB.NewSelect().
|
||||
Model(&blog).
|
||||
Relation("Author").
|
||||
ScanAndCount(context.Background())
|
||||
if err != nil {
|
||||
core.JSONError{
|
||||
Status: core.Error,
|
||||
Message: err.Error(),
|
||||
}.Respond(w, http.StatusNotAcceptable)
|
||||
return
|
||||
}
|
||||
|
||||
core.JSONSuccess{
|
||||
Status: core.Success,
|
||||
Message: fmt.Sprint("%d blogs objects sent", count),
|
||||
Data: blog,
|
||||
}.Respond(w, http.StatusOK)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
package blogs
|
||||
|
||||
Reference in New Issue
Block a user