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