feat: reimplement geometry module with database schema, repository, service layer, and API documentation
All checks were successful
Build and Release / release (push) Successful in 1m36s
All checks were successful
Build and Release / release (push) Successful in 1m36s
This commit is contained in:
@@ -9,6 +9,7 @@ type SearchGeometryDto struct {
|
||||
TimeRange *int32 `json:"time_range" query:"time_range" validate:"omitempty,number"`
|
||||
EntityID *string `json:"entity_id" query:"entity_id" validate:"omitempty,uuid"`
|
||||
ProjectID *string `json:"project_id" query:"project_id" validate:"omitempty,uuid"`
|
||||
HasBound *bool `json:"has_bound" query:"has_bound" validate:"omitempty"`
|
||||
}
|
||||
|
||||
type SearchGeometriesByEntityNameDto struct {
|
||||
|
||||
@@ -36,7 +36,7 @@ type FeatureProperties struct {
|
||||
GeometryPreset string `json:"geometry_preset,omitempty"`
|
||||
TimeStart *float64 `json:"time_start,omitempty"`
|
||||
TimeEnd *float64 `json:"time_end,omitempty"`
|
||||
Binding []string `json:"binding,omitempty"`
|
||||
BoundWith *string `json:"bound_with,omitempty"`
|
||||
EntityID string `json:"entity_id,omitempty" validate:"omitempty,uuidv7"`
|
||||
EntityIDs []string `json:"entity_ids,omitempty" validate:"omitempty,dive,uuidv7"`
|
||||
EntityName string `json:"entity_name,omitempty"`
|
||||
@@ -64,7 +64,7 @@ type GeometrySnapshot struct {
|
||||
Operation string `json:"operation,omitempty" validate:"omitempty,oneof=create update delete reference"`
|
||||
Type string `json:"type,omitempty" validate:"omitempty"`
|
||||
DrawGeometry json.RawMessage `json:"draw_geometry,omitempty"`
|
||||
Binding []string `json:"binding,omitempty"`
|
||||
BoundWith *string `json:"bound_with,omitempty"`
|
||||
TimeStart *float64 `json:"time_start,omitempty"`
|
||||
TimeEnd *float64 `json:"time_end,omitempty"`
|
||||
BBox *BBox `json:"bbox,omitempty" validate:"omitempty"`
|
||||
|
||||
@@ -16,7 +16,7 @@ type GeometryResponse struct {
|
||||
ID string `json:"id"`
|
||||
GeoType int16 `json:"geo_type"`
|
||||
DrawGeometry json.RawMessage `json:"draw_geometry"`
|
||||
Binding json.RawMessage `json:"binding,omitempty"`
|
||||
BoundWith *string `json:"bound_with,omitempty"`
|
||||
TimeStart int32 `json:"time_start,omitempty"`
|
||||
TimeEnd int32 `json:"time_end,omitempty"`
|
||||
Bbox *Bbox `json:"bbox,omitempty"`
|
||||
|
||||
@@ -2,24 +2,23 @@ package response
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
|
||||
type SearchGeometriesByEntityNameResponse struct {
|
||||
Items []*EntityGeometriesSearchItem `json:"items"`
|
||||
NextCursor string `json:"next_cursor,omitempty"`
|
||||
NextCursor string `json:"next_cursor,omitempty"`
|
||||
}
|
||||
|
||||
type EntityGeometriesSearchItem struct {
|
||||
EntityID string `json:"entity_id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
EntityID string `json:"entity_id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Geometries []*EntityGeometrySearchGeo `json:"geometries"`
|
||||
}
|
||||
|
||||
type EntityGeometrySearchGeo struct {
|
||||
ID string `json:"id"`
|
||||
GeoType int16 `json:"geo_type"`
|
||||
ID string `json:"id"`
|
||||
GeoType int16 `json:"geo_type"`
|
||||
DrawGeometry json.RawMessage `json:"draw_geometry"`
|
||||
Binding json.RawMessage `json:"binding,omitempty"`
|
||||
TimeStart *int32 `json:"time_start,omitempty"`
|
||||
TimeEnd *int32 `json:"time_end,omitempty"`
|
||||
BoundWith *string `json:"bound_with,omitempty"`
|
||||
TimeStart *int32 `json:"time_start,omitempty"`
|
||||
TimeEnd *int32 `json:"time_end,omitempty"`
|
||||
}
|
||||
|
||||
@@ -69,11 +69,11 @@ func (q *Queries) CreateEntityGeometries(ctx context.Context, arg CreateEntityGe
|
||||
|
||||
const createGeometry = `-- name: CreateGeometry :one
|
||||
INSERT INTO geometries (
|
||||
id, geo_type, draw_geometry, binding, time_start, time_end, bbox, project_id
|
||||
id, geo_type, draw_geometry, bound_with, time_start, time_end, bbox, project_id
|
||||
) VALUES (
|
||||
COALESCE($7::uuid, uuidv7()), $1, $2, $3, $4, $5, ST_MakeEnvelope($8::float8, $9::float8, $10::float8, $11::float8, 4326), $6
|
||||
)
|
||||
RETURNING id, geo_type, draw_geometry, binding, time_start, time_end, project_id,
|
||||
RETURNING id, geo_type, draw_geometry, bound_with, time_start, time_end, project_id,
|
||||
ST_XMin(bbox)::float8 as min_lng, ST_YMin(bbox)::float8 as min_lat, ST_XMax(bbox)::float8 as max_lng, ST_YMax(bbox)::float8 as max_lat,
|
||||
is_deleted, created_at, updated_at
|
||||
`
|
||||
@@ -81,7 +81,7 @@ RETURNING id, geo_type, draw_geometry, binding, time_start, time_end, project_id
|
||||
type CreateGeometryParams struct {
|
||||
GeoType int16 `json:"geo_type"`
|
||||
DrawGeometry json.RawMessage `json:"draw_geometry"`
|
||||
Binding []byte `json:"binding"`
|
||||
BoundWith pgtype.UUID `json:"bound_with"`
|
||||
TimeStart pgtype.Int4 `json:"time_start"`
|
||||
TimeEnd pgtype.Int4 `json:"time_end"`
|
||||
ProjectID pgtype.UUID `json:"project_id"`
|
||||
@@ -96,7 +96,7 @@ type CreateGeometryRow struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
GeoType int16 `json:"geo_type"`
|
||||
DrawGeometry json.RawMessage `json:"draw_geometry"`
|
||||
Binding []byte `json:"binding"`
|
||||
BoundWith pgtype.UUID `json:"bound_with"`
|
||||
TimeStart pgtype.Int4 `json:"time_start"`
|
||||
TimeEnd pgtype.Int4 `json:"time_end"`
|
||||
ProjectID pgtype.UUID `json:"project_id"`
|
||||
@@ -113,7 +113,7 @@ func (q *Queries) CreateGeometry(ctx context.Context, arg CreateGeometryParams)
|
||||
row := q.db.QueryRow(ctx, createGeometry,
|
||||
arg.GeoType,
|
||||
arg.DrawGeometry,
|
||||
arg.Binding,
|
||||
arg.BoundWith,
|
||||
arg.TimeStart,
|
||||
arg.TimeEnd,
|
||||
arg.ProjectID,
|
||||
@@ -128,7 +128,7 @@ func (q *Queries) CreateGeometry(ctx context.Context, arg CreateGeometryParams)
|
||||
&i.ID,
|
||||
&i.GeoType,
|
||||
&i.DrawGeometry,
|
||||
&i.Binding,
|
||||
&i.BoundWith,
|
||||
&i.TimeStart,
|
||||
&i.TimeEnd,
|
||||
&i.ProjectID,
|
||||
@@ -199,7 +199,7 @@ SELECT
|
||||
g.id AS geometry_id,
|
||||
g.geo_type,
|
||||
g.draw_geometry,
|
||||
g.binding,
|
||||
g.bound_with,
|
||||
g.time_start,
|
||||
g.time_end
|
||||
FROM (
|
||||
@@ -224,7 +224,7 @@ type GetEntityGeometriesByPairsRow struct {
|
||||
GeometryID pgtype.UUID `json:"geometry_id"`
|
||||
GeoType int16 `json:"geo_type"`
|
||||
DrawGeometry json.RawMessage `json:"draw_geometry"`
|
||||
Binding []byte `json:"binding"`
|
||||
BoundWith pgtype.UUID `json:"bound_with"`
|
||||
TimeStart pgtype.Int4 `json:"time_start"`
|
||||
TimeEnd pgtype.Int4 `json:"time_end"`
|
||||
}
|
||||
@@ -245,7 +245,7 @@ func (q *Queries) GetEntityGeometriesByPairs(ctx context.Context, arg GetEntityG
|
||||
&i.GeometryID,
|
||||
&i.GeoType,
|
||||
&i.DrawGeometry,
|
||||
&i.Binding,
|
||||
&i.BoundWith,
|
||||
&i.TimeStart,
|
||||
&i.TimeEnd,
|
||||
); err != nil {
|
||||
@@ -261,7 +261,7 @@ func (q *Queries) GetEntityGeometriesByPairs(ctx context.Context, arg GetEntityG
|
||||
|
||||
const getGeometriesByIDs = `-- name: GetGeometriesByIDs :many
|
||||
SELECT
|
||||
id, geo_type, draw_geometry, binding, time_start, time_end, project_id,
|
||||
id, geo_type, draw_geometry, bound_with, time_start, time_end, project_id,
|
||||
ST_XMin(bbox)::float8 as min_lng,
|
||||
ST_YMin(bbox)::float8 as min_lat,
|
||||
ST_XMax(bbox)::float8 as max_lng,
|
||||
@@ -275,7 +275,7 @@ type GetGeometriesByIDsRow struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
GeoType int16 `json:"geo_type"`
|
||||
DrawGeometry json.RawMessage `json:"draw_geometry"`
|
||||
Binding []byte `json:"binding"`
|
||||
BoundWith pgtype.UUID `json:"bound_with"`
|
||||
TimeStart pgtype.Int4 `json:"time_start"`
|
||||
TimeEnd pgtype.Int4 `json:"time_end"`
|
||||
ProjectID pgtype.UUID `json:"project_id"`
|
||||
@@ -301,7 +301,7 @@ func (q *Queries) GetGeometriesByIDs(ctx context.Context, dollar_1 []pgtype.UUID
|
||||
&i.ID,
|
||||
&i.GeoType,
|
||||
&i.DrawGeometry,
|
||||
&i.Binding,
|
||||
&i.BoundWith,
|
||||
&i.TimeStart,
|
||||
&i.TimeEnd,
|
||||
&i.ProjectID,
|
||||
@@ -325,7 +325,7 @@ func (q *Queries) GetGeometriesByIDs(ctx context.Context, dollar_1 []pgtype.UUID
|
||||
|
||||
const getGeometriesByProjectId = `-- name: GetGeometriesByProjectId :many
|
||||
SELECT
|
||||
id, geo_type, draw_geometry, binding, time_start, time_end, project_id,
|
||||
id, geo_type, draw_geometry, bound_with, time_start, time_end, project_id,
|
||||
ST_XMin(bbox)::float8 as min_lng,
|
||||
ST_YMin(bbox)::float8 as min_lat,
|
||||
ST_XMax(bbox)::float8 as max_lng,
|
||||
@@ -339,7 +339,7 @@ type GetGeometriesByProjectIdRow struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
GeoType int16 `json:"geo_type"`
|
||||
DrawGeometry json.RawMessage `json:"draw_geometry"`
|
||||
Binding []byte `json:"binding"`
|
||||
BoundWith pgtype.UUID `json:"bound_with"`
|
||||
TimeStart pgtype.Int4 `json:"time_start"`
|
||||
TimeEnd pgtype.Int4 `json:"time_end"`
|
||||
ProjectID pgtype.UUID `json:"project_id"`
|
||||
@@ -365,7 +365,7 @@ func (q *Queries) GetGeometriesByProjectId(ctx context.Context, projectID pgtype
|
||||
&i.ID,
|
||||
&i.GeoType,
|
||||
&i.DrawGeometry,
|
||||
&i.Binding,
|
||||
&i.BoundWith,
|
||||
&i.TimeStart,
|
||||
&i.TimeEnd,
|
||||
&i.ProjectID,
|
||||
@@ -388,7 +388,7 @@ func (q *Queries) GetGeometriesByProjectId(ctx context.Context, projectID pgtype
|
||||
}
|
||||
|
||||
const getGeometryById = `-- name: GetGeometryById :one
|
||||
SELECT id, geo_type, draw_geometry, binding, time_start, time_end, project_id,
|
||||
SELECT id, geo_type, draw_geometry, bound_with, time_start, time_end, project_id,
|
||||
ST_XMin(bbox)::float8 as min_lng, ST_YMin(bbox)::float8 as min_lat, ST_XMax(bbox)::float8 as max_lng, ST_YMax(bbox)::float8 as max_lat,
|
||||
is_deleted, created_at, updated_at
|
||||
FROM geometries
|
||||
@@ -399,7 +399,7 @@ type GetGeometryByIdRow struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
GeoType int16 `json:"geo_type"`
|
||||
DrawGeometry json.RawMessage `json:"draw_geometry"`
|
||||
Binding []byte `json:"binding"`
|
||||
BoundWith pgtype.UUID `json:"bound_with"`
|
||||
TimeStart pgtype.Int4 `json:"time_start"`
|
||||
TimeEnd pgtype.Int4 `json:"time_end"`
|
||||
ProjectID pgtype.UUID `json:"project_id"`
|
||||
@@ -419,7 +419,7 @@ func (q *Queries) GetGeometryById(ctx context.Context, id pgtype.UUID) (GetGeome
|
||||
&i.ID,
|
||||
&i.GeoType,
|
||||
&i.DrawGeometry,
|
||||
&i.Binding,
|
||||
&i.BoundWith,
|
||||
&i.TimeStart,
|
||||
&i.TimeEnd,
|
||||
&i.ProjectID,
|
||||
@@ -436,7 +436,7 @@ func (q *Queries) GetGeometryById(ctx context.Context, id pgtype.UUID) (GetGeome
|
||||
|
||||
const searchGeometries = `-- name: SearchGeometries :many
|
||||
SELECT
|
||||
g.id, g.geo_type, g.draw_geometry, g.binding, g.time_start, g.time_end, g.project_id,
|
||||
g.id, g.geo_type, g.draw_geometry, g.bound_with, g.time_start, g.time_end, g.project_id,
|
||||
ST_XMin(g.bbox)::float8 as min_lng,
|
||||
ST_YMin(g.bbox)::float8 as min_lat,
|
||||
ST_XMax(g.bbox)::float8 as max_lng,
|
||||
@@ -475,6 +475,11 @@ WHERE g.is_deleted = false
|
||||
AND eg.entity_id = $8::uuid
|
||||
)
|
||||
)
|
||||
AND (
|
||||
$9::boolean IS NULL OR
|
||||
$9::boolean = true OR
|
||||
g.bound_with IS NULL
|
||||
)
|
||||
ORDER BY g.id DESC
|
||||
`
|
||||
|
||||
@@ -487,13 +492,14 @@ type SearchGeometriesParams struct {
|
||||
TimePoint pgtype.Int4 `json:"time_point"`
|
||||
TimeRange pgtype.Int4 `json:"time_range"`
|
||||
EntityID pgtype.UUID `json:"entity_id"`
|
||||
HasBound pgtype.Bool `json:"has_bound"`
|
||||
}
|
||||
|
||||
type SearchGeometriesRow struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
GeoType int16 `json:"geo_type"`
|
||||
DrawGeometry json.RawMessage `json:"draw_geometry"`
|
||||
Binding []byte `json:"binding"`
|
||||
BoundWith pgtype.UUID `json:"bound_with"`
|
||||
TimeStart pgtype.Int4 `json:"time_start"`
|
||||
TimeEnd pgtype.Int4 `json:"time_end"`
|
||||
ProjectID pgtype.UUID `json:"project_id"`
|
||||
@@ -516,6 +522,7 @@ func (q *Queries) SearchGeometries(ctx context.Context, arg SearchGeometriesPara
|
||||
arg.TimePoint,
|
||||
arg.TimeRange,
|
||||
arg.EntityID,
|
||||
arg.HasBound,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -528,7 +535,7 @@ func (q *Queries) SearchGeometries(ctx context.Context, arg SearchGeometriesPara
|
||||
&i.ID,
|
||||
&i.GeoType,
|
||||
&i.DrawGeometry,
|
||||
&i.Binding,
|
||||
&i.BoundWith,
|
||||
&i.TimeStart,
|
||||
&i.TimeEnd,
|
||||
&i.ProjectID,
|
||||
@@ -570,7 +577,7 @@ SELECT
|
||||
g.id AS geometry_id,
|
||||
g.geo_type,
|
||||
g.draw_geometry,
|
||||
g.binding,
|
||||
g.bound_with,
|
||||
g.time_start,
|
||||
g.time_end
|
||||
FROM matched_entities me
|
||||
@@ -595,7 +602,7 @@ type SearchGeometriesByEntityNameRow struct {
|
||||
GeometryID pgtype.UUID `json:"geometry_id"`
|
||||
GeoType pgtype.Int2 `json:"geo_type"`
|
||||
DrawGeometry []byte `json:"draw_geometry"`
|
||||
Binding []byte `json:"binding"`
|
||||
BoundWith pgtype.UUID `json:"bound_with"`
|
||||
TimeStart pgtype.Int4 `json:"time_start"`
|
||||
TimeEnd pgtype.Int4 `json:"time_end"`
|
||||
}
|
||||
@@ -616,7 +623,7 @@ func (q *Queries) SearchGeometriesByEntityName(ctx context.Context, arg SearchGe
|
||||
&i.GeometryID,
|
||||
&i.GeoType,
|
||||
&i.DrawGeometry,
|
||||
&i.Binding,
|
||||
&i.BoundWith,
|
||||
&i.TimeStart,
|
||||
&i.TimeEnd,
|
||||
); err != nil {
|
||||
@@ -635,7 +642,7 @@ UPDATE geometries
|
||||
SET
|
||||
geo_type = COALESCE($1, geo_type),
|
||||
draw_geometry = COALESCE($2, draw_geometry),
|
||||
binding = COALESCE($3, binding),
|
||||
bound_with = COALESCE($3, bound_with),
|
||||
time_start = COALESCE($4, time_start),
|
||||
time_end = COALESCE($5, time_end),
|
||||
project_id = COALESCE($6, project_id),
|
||||
@@ -646,7 +653,7 @@ SET
|
||||
END,
|
||||
updated_at = now()
|
||||
WHERE id = $12 AND is_deleted = false
|
||||
RETURNING id, geo_type, draw_geometry, binding, time_start, time_end, project_id,
|
||||
RETURNING id, geo_type, draw_geometry, bound_with, time_start, time_end, project_id,
|
||||
ST_XMin(bbox)::float8 as min_lng, ST_YMin(bbox)::float8 as min_lat, ST_XMax(bbox)::float8 as max_lng, ST_YMax(bbox)::float8 as max_lat,
|
||||
is_deleted, created_at, updated_at
|
||||
`
|
||||
@@ -654,7 +661,7 @@ RETURNING id, geo_type, draw_geometry, binding, time_start, time_end, project_id
|
||||
type UpdateGeometryParams struct {
|
||||
GeoType pgtype.Int2 `json:"geo_type"`
|
||||
DrawGeometry []byte `json:"draw_geometry"`
|
||||
Binding []byte `json:"binding"`
|
||||
BoundWith pgtype.UUID `json:"bound_with"`
|
||||
TimeStart pgtype.Int4 `json:"time_start"`
|
||||
TimeEnd pgtype.Int4 `json:"time_end"`
|
||||
ProjectID pgtype.UUID `json:"project_id"`
|
||||
@@ -670,7 +677,7 @@ type UpdateGeometryRow struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
GeoType int16 `json:"geo_type"`
|
||||
DrawGeometry json.RawMessage `json:"draw_geometry"`
|
||||
Binding []byte `json:"binding"`
|
||||
BoundWith pgtype.UUID `json:"bound_with"`
|
||||
TimeStart pgtype.Int4 `json:"time_start"`
|
||||
TimeEnd pgtype.Int4 `json:"time_end"`
|
||||
ProjectID pgtype.UUID `json:"project_id"`
|
||||
@@ -687,7 +694,7 @@ func (q *Queries) UpdateGeometry(ctx context.Context, arg UpdateGeometryParams)
|
||||
row := q.db.QueryRow(ctx, updateGeometry,
|
||||
arg.GeoType,
|
||||
arg.DrawGeometry,
|
||||
arg.Binding,
|
||||
arg.BoundWith,
|
||||
arg.TimeStart,
|
||||
arg.TimeEnd,
|
||||
arg.ProjectID,
|
||||
@@ -703,7 +710,7 @@ func (q *Queries) UpdateGeometry(ctx context.Context, arg UpdateGeometryParams)
|
||||
&i.ID,
|
||||
&i.GeoType,
|
||||
&i.DrawGeometry,
|
||||
&i.Binding,
|
||||
&i.BoundWith,
|
||||
&i.TimeStart,
|
||||
&i.TimeEnd,
|
||||
&i.ProjectID,
|
||||
|
||||
@@ -81,7 +81,7 @@ type Geometry struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
GeoType int16 `json:"geo_type"`
|
||||
DrawGeometry json.RawMessage `json:"draw_geometry"`
|
||||
Binding []byte `json:"binding"`
|
||||
BoundWith pgtype.UUID `json:"bound_with"`
|
||||
TimeStart pgtype.Int4 `json:"time_start"`
|
||||
TimeEnd pgtype.Int4 `json:"time_end"`
|
||||
Bbox interface{} `json:"bbox"`
|
||||
|
||||
@@ -10,7 +10,7 @@ type GeometryEntity struct {
|
||||
ID string `json:"id"`
|
||||
GeoType int16 `json:"geo_type"`
|
||||
DrawGeometry json.RawMessage `json:"draw_geometry"`
|
||||
Binding json.RawMessage `json:"binding"`
|
||||
BoundWith *string `json:"bound_with"`
|
||||
TimeStart int32 `json:"time_start"`
|
||||
TimeEnd int32 `json:"time_end"`
|
||||
Bbox *response.Bbox `json:"bbox"`
|
||||
@@ -27,7 +27,7 @@ type EntityGeometriesSearchEntity struct {
|
||||
GeometryID string `json:"id"`
|
||||
GeoType int16 `json:"geo_type"`
|
||||
DrawGeometry json.RawMessage `json:"draw_geometry"`
|
||||
Binding json.RawMessage `json:"binding,omitempty"`
|
||||
BoundWith *string `json:"bound_with,omitempty"`
|
||||
TimeStart *int32 `json:"time_start,omitempty"`
|
||||
TimeEnd *int32 `json:"time_end,omitempty"`
|
||||
}
|
||||
@@ -40,7 +40,7 @@ func (g *GeometryEntity) ToResponse() *response.GeometryResponse {
|
||||
ID: g.ID,
|
||||
GeoType: g.GeoType,
|
||||
DrawGeometry: g.DrawGeometry,
|
||||
Binding: g.Binding,
|
||||
BoundWith: g.BoundWith,
|
||||
TimeStart: g.TimeStart,
|
||||
TimeEnd: g.TimeEnd,
|
||||
Bbox: g.Bbox,
|
||||
|
||||
@@ -97,7 +97,7 @@ func (r *geometryRepository) getByIDsWithFallback(ctx context.Context, ids []str
|
||||
ID: convert.UUIDToString(row.ID),
|
||||
GeoType: row.GeoType,
|
||||
DrawGeometry: row.DrawGeometry,
|
||||
Binding: row.Binding,
|
||||
BoundWith: convert.UUIDToStringPtr(row.BoundWith),
|
||||
TimeStart: convert.Int4ToInt32(row.TimeStart),
|
||||
TimeEnd: convert.Int4ToInt32(row.TimeEnd),
|
||||
Bbox: &response.Bbox{
|
||||
@@ -159,7 +159,7 @@ func (r *geometryRepository) GetByID(ctx context.Context, id pgtype.UUID) (*mode
|
||||
ID: convert.UUIDToString(row.ID),
|
||||
GeoType: row.GeoType,
|
||||
DrawGeometry: row.DrawGeometry,
|
||||
Binding: row.Binding,
|
||||
BoundWith: convert.UUIDToStringPtr(row.BoundWith),
|
||||
TimeStart: convert.Int4ToInt32(row.TimeStart),
|
||||
TimeEnd: convert.Int4ToInt32(row.TimeEnd),
|
||||
Bbox: &response.Bbox{
|
||||
@@ -198,7 +198,7 @@ func (r *geometryRepository) Search(ctx context.Context, params sqlc.SearchGeome
|
||||
ID: convert.UUIDToString(row.ID),
|
||||
GeoType: row.GeoType,
|
||||
DrawGeometry: row.DrawGeometry,
|
||||
Binding: row.Binding,
|
||||
BoundWith: convert.UUIDToStringPtr(row.BoundWith),
|
||||
TimeStart: convert.Int4ToInt32(row.TimeStart),
|
||||
TimeEnd: convert.Int4ToInt32(row.TimeEnd),
|
||||
Bbox: &response.Bbox{
|
||||
@@ -237,7 +237,7 @@ func (r *geometryRepository) Create(ctx context.Context, params sqlc.CreateGeome
|
||||
ID: convert.UUIDToString(row.ID),
|
||||
GeoType: row.GeoType,
|
||||
DrawGeometry: row.DrawGeometry,
|
||||
Binding: row.Binding,
|
||||
BoundWith: convert.UUIDToStringPtr(row.BoundWith),
|
||||
TimeStart: convert.Int4ToInt32(row.TimeStart),
|
||||
TimeEnd: convert.Int4ToInt32(row.TimeEnd),
|
||||
Bbox: &response.Bbox{
|
||||
@@ -264,7 +264,7 @@ func (r *geometryRepository) Update(ctx context.Context, params sqlc.UpdateGeome
|
||||
ID: convert.UUIDToString(row.ID),
|
||||
GeoType: row.GeoType,
|
||||
DrawGeometry: row.DrawGeometry,
|
||||
Binding: row.Binding,
|
||||
BoundWith: convert.UUIDToStringPtr(row.BoundWith),
|
||||
TimeStart: convert.Int4ToInt32(row.TimeStart),
|
||||
TimeEnd: convert.Int4ToInt32(row.TimeEnd),
|
||||
Bbox: &response.Bbox{
|
||||
@@ -328,7 +328,7 @@ func (r *geometryRepository) GetByProjectID(ctx context.Context, projectID pgtyp
|
||||
ID: convert.UUIDToString(row.ID),
|
||||
GeoType: row.GeoType,
|
||||
DrawGeometry: row.DrawGeometry,
|
||||
Binding: row.Binding,
|
||||
BoundWith: convert.UUIDToStringPtr(row.BoundWith),
|
||||
TimeStart: convert.Int4ToInt32(row.TimeStart),
|
||||
TimeEnd: convert.Int4ToInt32(row.TimeEnd),
|
||||
Bbox: &response.Bbox{
|
||||
@@ -430,7 +430,7 @@ func (r *geometryRepository) getSearchByIDsWithFallback(ctx context.Context, pai
|
||||
GeometryID: convert.UUIDToString(row.GeometryID),
|
||||
GeoType: row.GeoType,
|
||||
DrawGeometry: row.DrawGeometry,
|
||||
Binding: row.Binding,
|
||||
BoundWith: convert.UUIDToStringPtr(row.BoundWith),
|
||||
TimeStart: convert.Int4ToPtr(row.TimeStart),
|
||||
TimeEnd: convert.Int4ToPtr(row.TimeEnd),
|
||||
}
|
||||
@@ -485,7 +485,7 @@ func (r *geometryRepository) SearchByEntityName(ctx context.Context, params sqlc
|
||||
GeometryID: convert.UUIDToString(row.GeometryID),
|
||||
GeoType: convert.Int2ToInt16(row.GeoType),
|
||||
DrawGeometry: row.DrawGeometry,
|
||||
Binding: row.Binding,
|
||||
BoundWith: convert.UUIDToStringPtr(row.BoundWith),
|
||||
TimeStart: convert.Int4ToPtr(row.TimeStart),
|
||||
TimeEnd: convert.Int4ToPtr(row.TimeEnd),
|
||||
}
|
||||
|
||||
@@ -73,6 +73,18 @@ func (s *geometryService) SearchGeometries(ctx context.Context, req *request.Sea
|
||||
params.EntityID = entityId
|
||||
}
|
||||
|
||||
if req.ProjectID != nil {
|
||||
projectId, err := convert.StringToUUID(*req.ProjectID)
|
||||
if err != nil {
|
||||
return nil, fiber.NewError(fiber.StatusBadRequest, "Invalid project ID format")
|
||||
}
|
||||
params.ProjectID = projectId
|
||||
}
|
||||
|
||||
if req.HasBound != nil {
|
||||
params.HasBound = pgtype.Bool{Bool: *req.HasBound, Valid: true}
|
||||
}
|
||||
|
||||
geometries, err := s.geometryRepo.Search(ctx, params)
|
||||
if err != nil {
|
||||
return nil, fiber.NewError(fiber.StatusInternalServerError, "Failed to search geometries")
|
||||
@@ -132,7 +144,7 @@ func (s *geometryService) SearchGeometriesByEntityName(
|
||||
ID: row.GeometryID,
|
||||
GeoType: row.GeoType,
|
||||
DrawGeometry: row.DrawGeometry,
|
||||
Binding: row.Binding,
|
||||
BoundWith: row.BoundWith,
|
||||
TimeStart: row.TimeStart,
|
||||
TimeEnd: row.TimeEnd,
|
||||
})
|
||||
|
||||
@@ -716,7 +716,15 @@ func (s *submissionService) applySnapshot(ctx context.Context, tx pgx.Tx, projec
|
||||
return fiber.NewError(fiber.StatusInternalServerError, "Invalid geometry ID")
|
||||
}
|
||||
|
||||
binding, _ := json.Marshal(geo.Binding)
|
||||
var boundWith pgtype.UUID
|
||||
if geo.BoundWith != nil && *geo.BoundWith != "" {
|
||||
var err error
|
||||
boundWith, err = convert.StringToUUID(*geo.BoundWith)
|
||||
if err != nil {
|
||||
return fiber.NewError(fiber.StatusBadRequest, "Invalid bound_with geometry ID")
|
||||
}
|
||||
}
|
||||
|
||||
geoTypeCode := int16(0)
|
||||
if geo.Type != "" {
|
||||
if n, err := strconv.ParseInt(geo.Type, 10, 16); err == nil {
|
||||
@@ -729,7 +737,7 @@ func (s *submissionService) applySnapshot(ctx context.Context, tx pgx.Tx, projec
|
||||
ID: geometryUUID,
|
||||
GeoType: pgtype.Int2{Int16: geoTypeCode, Valid: true},
|
||||
DrawGeometry: geo.DrawGeometry,
|
||||
Binding: binding,
|
||||
BoundWith: boundWith,
|
||||
TimeStart: convert.PtrFloat64ToInt4(geo.TimeStart),
|
||||
TimeEnd: convert.PtrFloat64ToInt4(geo.TimeEnd),
|
||||
ProjectID: projectUUID,
|
||||
@@ -754,7 +762,7 @@ func (s *submissionService) applySnapshot(ctx context.Context, tx pgx.Tx, projec
|
||||
ID: geometryUUID,
|
||||
GeoType: geoTypeCode,
|
||||
DrawGeometry: geo.DrawGeometry,
|
||||
Binding: binding,
|
||||
BoundWith: boundWith,
|
||||
TimeStart: convert.PtrFloat64ToInt4(geo.TimeStart),
|
||||
TimeEnd: convert.PtrFloat64ToInt4(geo.TimeEnd),
|
||||
ProjectID: projectUUID,
|
||||
|
||||
Reference in New Issue
Block a user