feat: implement core backend architecture and project management services for the History API
Build and Release / release (push) Successful in 1m33s
Build and Release / release (push) Successful in 1m33s
This commit is contained in:
@@ -3,13 +3,13 @@ package controllers
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"history-api/internal/dtos/request"
|
||||
"history-api/internal/dtos/response"
|
||||
"history-api/internal/models"
|
||||
"history-api/internal/services"
|
||||
"history-api/pkg/config"
|
||||
"history-api/pkg/constants"
|
||||
json "history-api/pkg/jsonx"
|
||||
"history-api/pkg/validator"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -111,9 +111,6 @@ func (h *EntityController) IsExistEntitySlug(c fiber.Ctx) error {
|
||||
// @Failure 500 {object} response.CommonResponse
|
||||
// @Router /entities [get]
|
||||
func (h *EntityController) SearchEntities(c fiber.Ctx) error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
dto := &request.SearchEntityDto{}
|
||||
if err := validator.ValidateQueryDto(c, dto); err != nil {
|
||||
return c.Status(fiber.StatusBadRequest).JSON(response.CommonResponse{
|
||||
@@ -122,7 +119,7 @@ func (h *EntityController) SearchEntities(c fiber.Ctx) error {
|
||||
})
|
||||
}
|
||||
|
||||
res, err := h.service.SearchEntities(ctx, dto)
|
||||
res, err := h.service.SearchEntities(c.Context(), dto)
|
||||
if err != nil {
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
@@ -172,4 +169,3 @@ func (h *EntityController) GetEntitiesByGeometryIDs(c fiber.Ctx) error {
|
||||
Data: res,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -57,9 +57,6 @@ func (h *GeometryController) GetGeometryById(c fiber.Ctx) error {
|
||||
// @Failure 500 {object} response.CommonResponse
|
||||
// @Router /geometries [get]
|
||||
func (h *GeometryController) SearchGeometries(c fiber.Ctx) error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
dto := &request.SearchGeometryDto{}
|
||||
if err := validator.ValidateQueryDto(c, dto); err != nil {
|
||||
return c.Status(fiber.StatusBadRequest).JSON(response.CommonResponse{
|
||||
@@ -68,7 +65,7 @@ func (h *GeometryController) SearchGeometries(c fiber.Ctx) error {
|
||||
})
|
||||
}
|
||||
|
||||
res, err := h.service.SearchGeometries(ctx, dto)
|
||||
res, err := h.service.SearchGeometries(c.Context(), dto)
|
||||
if err != nil {
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
|
||||
@@ -63,8 +63,9 @@ func (ctrl *goongController) Proxy(c fiber.Ctx) error {
|
||||
}
|
||||
}
|
||||
|
||||
headers := make(map[string]string)
|
||||
for k, v := range c.GetReqHeaders() {
|
||||
reqHeaders := c.GetReqHeaders()
|
||||
headers := make(map[string]string, len(reqHeaders))
|
||||
for k, v := range reqHeaders {
|
||||
if len(v) > 0 {
|
||||
headers[k] = v[0]
|
||||
}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"history-api/internal/dtos/response"
|
||||
"history-api/internal/services"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
@@ -29,10 +27,7 @@ func NewRasterTileController(svc services.RasterTileService) *RasterTileControll
|
||||
// @Failure 500 {object} response.CommonResponse
|
||||
// @Router /raster-tiles/metadata [get]
|
||||
func (h *RasterTileController) GetMetadata(c fiber.Ctx) error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
res, err := h.service.GetMetadata(ctx)
|
||||
res, err := h.service.GetMetadata(c.Context())
|
||||
if err != nil {
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
@@ -59,9 +54,6 @@ func (h *RasterTileController) GetMetadata(c fiber.Ctx) error {
|
||||
// @Failure 500 {object} response.CommonResponse
|
||||
// @Router /raster-tiles/{z}/{x}/{y} [get]
|
||||
func (h *RasterTileController) GetTile(c fiber.Ctx) error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
z, x, y, pErr := h.parseTileParams(c)
|
||||
if pErr != nil {
|
||||
return c.Status(fiber.StatusBadRequest).JSON(response.CommonResponse{
|
||||
@@ -70,7 +62,7 @@ func (h *RasterTileController) GetTile(c fiber.Ctx) error {
|
||||
})
|
||||
}
|
||||
|
||||
data, headers, err := h.service.GetTile(ctx, z, x, y)
|
||||
tile, err := h.service.GetTile(c.Context(), z, x, y)
|
||||
if err != nil {
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
@@ -78,11 +70,14 @@ func (h *RasterTileController) GetTile(c fiber.Ctx) error {
|
||||
})
|
||||
}
|
||||
|
||||
for k, v := range headers {
|
||||
c.Set(k, v)
|
||||
if tile.ContentType != "" {
|
||||
c.Set(fiber.HeaderContentType, tile.ContentType)
|
||||
}
|
||||
if tile.CacheControl != "" {
|
||||
c.Set(fiber.HeaderCacheControl, tile.CacheControl)
|
||||
}
|
||||
|
||||
return c.Status(fiber.StatusOK).Send(data)
|
||||
return c.Status(fiber.StatusOK).Send(tile.Data)
|
||||
}
|
||||
|
||||
func (h *RasterTileController) parseTileParams(c fiber.Ctx) (int, int, int, error) {
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"history-api/internal/dtos/response"
|
||||
"history-api/internal/services"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
@@ -29,10 +27,7 @@ func NewTileController(svc services.TileService) *TileController {
|
||||
// @Failure 500 {object} response.CommonResponse
|
||||
// @Router /tiles/metadata [get]
|
||||
func (h *TileController) GetMetadata(c fiber.Ctx) error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
res, err := h.service.GetMetadata(ctx)
|
||||
res, err := h.service.GetMetadata(c.Context())
|
||||
if err != nil {
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
@@ -59,9 +54,6 @@ func (h *TileController) GetMetadata(c fiber.Ctx) error {
|
||||
// @Failure 500 {object} response.CommonResponse
|
||||
// @Router /tiles/{z}/{x}/{y} [get]
|
||||
func (h *TileController) GetTile(c fiber.Ctx) error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
z, x, y, pErr := h.parseTileParams(c)
|
||||
if pErr != nil {
|
||||
return c.Status(fiber.StatusBadRequest).JSON(response.CommonResponse{
|
||||
@@ -70,7 +62,7 @@ func (h *TileController) GetTile(c fiber.Ctx) error {
|
||||
})
|
||||
}
|
||||
|
||||
data, headers, err := h.service.GetTile(ctx, z, x, y)
|
||||
tile, err := h.service.GetTile(c.Context(), z, x, y)
|
||||
if err != nil {
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
@@ -78,11 +70,17 @@ func (h *TileController) GetTile(c fiber.Ctx) error {
|
||||
})
|
||||
}
|
||||
|
||||
for k, v := range headers {
|
||||
c.Set(k, v)
|
||||
if tile.ContentType != "" {
|
||||
c.Set(fiber.HeaderContentType, tile.ContentType)
|
||||
}
|
||||
if tile.ContentEncoding != "" {
|
||||
c.Set(fiber.HeaderContentEncoding, tile.ContentEncoding)
|
||||
}
|
||||
if tile.CacheControl != "" {
|
||||
c.Set(fiber.HeaderCacheControl, tile.CacheControl)
|
||||
}
|
||||
|
||||
return c.Status(fiber.StatusOK).Send(data)
|
||||
return c.Status(fiber.StatusOK).Send(tile.Data)
|
||||
}
|
||||
|
||||
func (h *TileController) parseTileParams(c fiber.Ctx) (int, int, int, error) {
|
||||
|
||||
@@ -111,9 +111,6 @@ func (h *WikiController) IsExistWikiSlug(c fiber.Ctx) error {
|
||||
// @Failure 500 {object} response.CommonResponse
|
||||
// @Router /wikis [get]
|
||||
func (h *WikiController) SearchWikis(c fiber.Ctx) error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
dto := &request.SearchWikiDto{}
|
||||
if err := validator.ValidateQueryDto(c, dto); err != nil {
|
||||
return c.Status(fiber.StatusBadRequest).JSON(response.CommonResponse{
|
||||
@@ -122,7 +119,7 @@ func (h *WikiController) SearchWikis(c fiber.Ctx) error {
|
||||
})
|
||||
}
|
||||
|
||||
res, err := h.service.SearchWikis(ctx, dto)
|
||||
res, err := h.service.SearchWikis(c.Context(), dto)
|
||||
if err != nil {
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
|
||||
Reference in New Issue
Block a user