Resolved conflicts
This commit is contained in:
@@ -2,32 +2,19 @@ package blogs
|
||||
|
||||
import (
|
||||
"context"
|
||||
<<<<<<< HEAD
|
||||
"fmt"
|
||||
=======
|
||||
>>>>>>> dev/cedric
|
||||
"net/http"
|
||||
|
||||
core "fr.latosa-escrima/core"
|
||||
"fr.latosa-escrima/core/models"
|
||||
)
|
||||
|
||||
<<<<<<< HEAD
|
||||
func HandleGetBlogs(w http.ResponseWriter, r *http.Request) {
|
||||
var blog []models.Blog
|
||||
count, err := core.DB.NewSelect().
|
||||
Model(&blog).
|
||||
=======
|
||||
func HandleBlog(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
blog_uuid := r.PathValue("uuid")
|
||||
|
||||
var blog models.Blog
|
||||
_, err := core.DB.NewSelect().
|
||||
Model(&blog).
|
||||
Where("blog_id = ?", blog_uuid).
|
||||
>>>>>>> dev/cedric
|
||||
Relation("Author").
|
||||
ScanAndCount(context.Background())
|
||||
if err != nil {
|
||||
@@ -40,40 +27,8 @@ func HandleBlog(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
core.JSONSuccess{
|
||||
Status: core.Success,
|
||||
<<<<<<< HEAD
|
||||
Message: fmt.Sprintf("%d blogs objects sent", count),
|
||||
=======
|
||||
Message: "Status OK",
|
||||
>>>>>>> dev/cedric
|
||||
Message: "Blog retrieved.",
|
||||
Data: blog,
|
||||
}.Respond(w, http.StatusOK)
|
||||
return
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
<<<<<<<< HEAD:backend/api/blogs/blog.go
|
||||
|
||||
func HandleBlogs(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
|
||||
}
|
||||
========
|
||||
>>>>>>>> dev/cedric:backend/api/blogs/blogs.go
|
||||
=======
|
||||
>>>>>>> dev/cedric
|
||||
|
||||
32
backend/api/blogs/blogs.go
Normal file
32
backend/api/blogs/blogs.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package blogs
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
core "fr.latosa-escrima/core"
|
||||
"fr.latosa-escrima/core/models"
|
||||
)
|
||||
|
||||
func HandleGetBlogs(w http.ResponseWriter, r *http.Request) {
|
||||
var blog []models.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.Sprintf("%d blogs objects sent", count),
|
||||
Data: blog,
|
||||
}.Respond(w, http.StatusOK)
|
||||
return
|
||||
}
|
||||
@@ -6,12 +6,13 @@ import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"fr.latosa-escrima/api/core"
|
||||
"fr.latosa-escrima/core"
|
||||
"fr.latosa-escrima/core/models"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
func HandleUpdate(w http.ResponseWriter, r *http.Request) {
|
||||
var blog core.Blog
|
||||
var blog models.Blog
|
||||
err := json.NewDecoder(r.Body).Decode(&blog)
|
||||
if err != nil {
|
||||
core.JSONError{
|
||||
|
||||
Reference in New Issue
Block a user