Compare commits
2 Commits
554719f566
...
98f069c94e
Author | SHA1 | Date | |
---|---|---|---|
98f069c94e | |||
b9fc8c84d3 |
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
DB "log101/konulu-konum-backend/db"
|
DB "log101/konulu-konum-backend/db"
|
||||||
|
@ -21,6 +22,11 @@ func KonuluKonumCreate(c *fiber.Ctx) error {
|
||||||
// Get form values
|
// Get form values
|
||||||
author := form.Value["author"][0]
|
author := form.Value["author"][0]
|
||||||
description := form.Value["description"][0]
|
description := form.Value["description"][0]
|
||||||
|
radius := form.Value["geolocation-radius"][0]
|
||||||
|
radiusInt, err := strconv.Atoi(radius)
|
||||||
|
if err != nil {
|
||||||
|
radiusInt = 50
|
||||||
|
}
|
||||||
|
|
||||||
// Geolocation is stored as JSON array string
|
// Geolocation is stored as JSON array string
|
||||||
geolocation := fmt.Sprintf("[%s]", form.Value["geolocation"][0])
|
geolocation := fmt.Sprintf("[%s]", form.Value["geolocation"][0])
|
||||||
|
@ -61,7 +67,7 @@ func KonuluKonumCreate(c *fiber.Ctx) error {
|
||||||
|
|
||||||
// Write to DB
|
// Write to DB
|
||||||
db := DB.GetDB()
|
db := DB.GetDB()
|
||||||
db.Create(&models.KonuluKonum{URI: imageUri, ImageURL: imageURL, Coordinates: geolocation, AuthorName: author, Description: description, UnlockedCounter: 0})
|
db.Create(&models.KonuluKonum{URI: imageUri, ImageURL: imageURL, Coordinates: geolocation, AuthorName: author, Description: description, UnlockedCounter: 0, Radius: radiusInt})
|
||||||
|
|
||||||
// Return URL
|
// Return URL
|
||||||
redirectURL := fmt.Sprintf("%s/x?id=%s", clientURL, imageUri)
|
redirectURL := fmt.Sprintf("%s/x?id=%s", clientURL, imageUri)
|
||||||
|
@ -91,6 +97,7 @@ func KonuluKonumGet(c *fiber.Ctx) error {
|
||||||
"loc": konuluKonum.Coordinates,
|
"loc": konuluKonum.Coordinates,
|
||||||
"author": konuluKonum.AuthorName,
|
"author": konuluKonum.AuthorName,
|
||||||
"description": konuluKonum.Description,
|
"description": konuluKonum.Description,
|
||||||
|
"radius": konuluKonum.Radius,
|
||||||
"unlocked_counter": konuluKonum.UnlockedCounter,
|
"unlocked_counter": konuluKonum.UnlockedCounter,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,5 +11,6 @@ type KonuluKonum struct {
|
||||||
Coordinates string
|
Coordinates string
|
||||||
AuthorName string
|
AuthorName string
|
||||||
Description string
|
Description string
|
||||||
|
Radius int
|
||||||
UnlockedCounter int
|
UnlockedCounter int
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user