geo_type: store numeric code and return int16
All checks were successful
Build and Release / release (push) Successful in 1m27s
All checks were successful
Build and Release / release (push) Successful in 1m27s
This commit is contained in:
@@ -14,7 +14,7 @@ type Bbox struct {
|
|||||||
|
|
||||||
type GeometryResponse struct {
|
type GeometryResponse struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
GeoType string `json:"geo_type"`
|
GeoType int16 `json:"geo_type"`
|
||||||
DrawGeometry json.RawMessage `json:"draw_geometry"`
|
DrawGeometry json.RawMessage `json:"draw_geometry"`
|
||||||
Binding json.RawMessage `json:"binding,omitempty"`
|
Binding json.RawMessage `json:"binding,omitempty"`
|
||||||
TimeStart int32 `json:"time_start,omitempty"`
|
TimeStart int32 `json:"time_start,omitempty"`
|
||||||
|
|||||||
@@ -3,13 +3,12 @@ package models
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"history-api/internal/dtos/response"
|
"history-api/internal/dtos/response"
|
||||||
"history-api/pkg/constants"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GeometryEntity struct {
|
type GeometryEntity struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
GeoType constants.GeoType `json:"geo_type"`
|
GeoType int16 `json:"geo_type"`
|
||||||
DrawGeometry json.RawMessage `json:"draw_geometry"`
|
DrawGeometry json.RawMessage `json:"draw_geometry"`
|
||||||
Binding json.RawMessage `json:"binding"`
|
Binding json.RawMessage `json:"binding"`
|
||||||
TimeStart int32 `json:"time_start"`
|
TimeStart int32 `json:"time_start"`
|
||||||
@@ -27,7 +26,7 @@ func (g *GeometryEntity) ToResponse() *response.GeometryResponse {
|
|||||||
}
|
}
|
||||||
return &response.GeometryResponse{
|
return &response.GeometryResponse{
|
||||||
ID: g.ID,
|
ID: g.ID,
|
||||||
GeoType: g.GeoType.String(),
|
GeoType: g.GeoType,
|
||||||
DrawGeometry: g.DrawGeometry,
|
DrawGeometry: g.DrawGeometry,
|
||||||
Binding: g.Binding,
|
Binding: g.Binding,
|
||||||
TimeStart: g.TimeStart,
|
TimeStart: g.TimeStart,
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ func (r *geometryRepository) getByIDsWithFallback(ctx context.Context, ids []str
|
|||||||
for _, row := range dbRows {
|
for _, row := range dbRows {
|
||||||
item := models.GeometryEntity{
|
item := models.GeometryEntity{
|
||||||
ID: convert.UUIDToString(row.ID),
|
ID: convert.UUIDToString(row.ID),
|
||||||
GeoType: constants.ParseGeoType(row.GeoType),
|
GeoType: row.GeoType,
|
||||||
DrawGeometry: row.DrawGeometry,
|
DrawGeometry: row.DrawGeometry,
|
||||||
Binding: row.Binding,
|
Binding: row.Binding,
|
||||||
TimeStart: convert.Int4ToInt32(row.TimeStart),
|
TimeStart: convert.Int4ToInt32(row.TimeStart),
|
||||||
@@ -152,7 +152,7 @@ func (r *geometryRepository) GetByID(ctx context.Context, id pgtype.UUID) (*mode
|
|||||||
|
|
||||||
geometry = models.GeometryEntity{
|
geometry = models.GeometryEntity{
|
||||||
ID: convert.UUIDToString(row.ID),
|
ID: convert.UUIDToString(row.ID),
|
||||||
GeoType: constants.ParseGeoType(row.GeoType),
|
GeoType: row.GeoType,
|
||||||
DrawGeometry: row.DrawGeometry,
|
DrawGeometry: row.DrawGeometry,
|
||||||
Binding: row.Binding,
|
Binding: row.Binding,
|
||||||
TimeStart: convert.Int4ToInt32(row.TimeStart),
|
TimeStart: convert.Int4ToInt32(row.TimeStart),
|
||||||
@@ -191,7 +191,7 @@ func (r *geometryRepository) Search(ctx context.Context, params sqlc.SearchGeome
|
|||||||
for _, row := range rows {
|
for _, row := range rows {
|
||||||
geometry := &models.GeometryEntity{
|
geometry := &models.GeometryEntity{
|
||||||
ID: convert.UUIDToString(row.ID),
|
ID: convert.UUIDToString(row.ID),
|
||||||
GeoType: constants.ParseGeoType(row.GeoType),
|
GeoType: row.GeoType,
|
||||||
DrawGeometry: row.DrawGeometry,
|
DrawGeometry: row.DrawGeometry,
|
||||||
Binding: row.Binding,
|
Binding: row.Binding,
|
||||||
TimeStart: convert.Int4ToInt32(row.TimeStart),
|
TimeStart: convert.Int4ToInt32(row.TimeStart),
|
||||||
@@ -230,7 +230,7 @@ func (r *geometryRepository) Create(ctx context.Context, params sqlc.CreateGeome
|
|||||||
|
|
||||||
geometry := models.GeometryEntity{
|
geometry := models.GeometryEntity{
|
||||||
ID: convert.UUIDToString(row.ID),
|
ID: convert.UUIDToString(row.ID),
|
||||||
GeoType: constants.ParseGeoType(row.GeoType),
|
GeoType: row.GeoType,
|
||||||
DrawGeometry: row.DrawGeometry,
|
DrawGeometry: row.DrawGeometry,
|
||||||
Binding: row.Binding,
|
Binding: row.Binding,
|
||||||
TimeStart: convert.Int4ToInt32(row.TimeStart),
|
TimeStart: convert.Int4ToInt32(row.TimeStart),
|
||||||
@@ -257,7 +257,7 @@ func (r *geometryRepository) Update(ctx context.Context, params sqlc.UpdateGeome
|
|||||||
}
|
}
|
||||||
geometry := models.GeometryEntity{
|
geometry := models.GeometryEntity{
|
||||||
ID: convert.UUIDToString(row.ID),
|
ID: convert.UUIDToString(row.ID),
|
||||||
GeoType: constants.ParseGeoType(row.GeoType),
|
GeoType: row.GeoType,
|
||||||
DrawGeometry: row.DrawGeometry,
|
DrawGeometry: row.DrawGeometry,
|
||||||
Binding: row.Binding,
|
Binding: row.Binding,
|
||||||
TimeStart: convert.Int4ToInt32(row.TimeStart),
|
TimeStart: convert.Int4ToInt32(row.TimeStart),
|
||||||
@@ -321,7 +321,7 @@ func (r *geometryRepository) GetByProjectID(ctx context.Context, projectID pgtyp
|
|||||||
for _, row := range rows {
|
for _, row := range rows {
|
||||||
geometry := &models.GeometryEntity{
|
geometry := &models.GeometryEntity{
|
||||||
ID: convert.UUIDToString(row.ID),
|
ID: convert.UUIDToString(row.ID),
|
||||||
GeoType: constants.ParseGeoType(row.GeoType),
|
GeoType: row.GeoType,
|
||||||
DrawGeometry: row.DrawGeometry,
|
DrawGeometry: row.DrawGeometry,
|
||||||
Binding: row.Binding,
|
Binding: row.Binding,
|
||||||
TimeStart: convert.Int4ToInt32(row.TimeStart),
|
TimeStart: convert.Int4ToInt32(row.TimeStart),
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import (
|
|||||||
"history-api/pkg/cache"
|
"history-api/pkg/cache"
|
||||||
"history-api/pkg/constants"
|
"history-api/pkg/constants"
|
||||||
"history-api/pkg/convert"
|
"history-api/pkg/convert"
|
||||||
|
"strconv"
|
||||||
"slices"
|
"slices"
|
||||||
|
|
||||||
"github.com/gofiber/fiber/v3"
|
"github.com/gofiber/fiber/v3"
|
||||||
@@ -399,11 +400,17 @@ func (s *submissionService) UpdateSubmissionStatus(ctx context.Context, reviewer
|
|||||||
}
|
}
|
||||||
|
|
||||||
binding, _ := json.Marshal(geo.Binding)
|
binding, _ := json.Marshal(geo.Binding)
|
||||||
|
geoTypeCode := int16(0)
|
||||||
|
if geo.Type != "" {
|
||||||
|
if n, err := strconv.ParseInt(geo.Type, 10, 16); err == nil {
|
||||||
|
geoTypeCode = int16(n)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if _, ok := persistCurrentItemIDs[geo.ID]; ok {
|
if _, ok := persistCurrentItemIDs[geo.ID]; ok {
|
||||||
params := sqlc.UpdateGeometryParams{
|
params := sqlc.UpdateGeometryParams{
|
||||||
ID: geometryUUID,
|
ID: geometryUUID,
|
||||||
GeoType: pgtype.Int2{Int16: constants.ParseGeoTypeText(geo.Type).Int16(), Valid: true},
|
GeoType: pgtype.Int2{Int16: geoTypeCode, Valid: true},
|
||||||
DrawGeometry: geo.DrawGeometry,
|
DrawGeometry: geo.DrawGeometry,
|
||||||
Binding: binding,
|
Binding: binding,
|
||||||
TimeStart: convert.PtrFloat64ToInt4(geo.TimeStart),
|
TimeStart: convert.PtrFloat64ToInt4(geo.TimeStart),
|
||||||
@@ -428,7 +435,7 @@ func (s *submissionService) UpdateSubmissionStatus(ctx context.Context, reviewer
|
|||||||
} else if geo.Source == "inline" {
|
} else if geo.Source == "inline" {
|
||||||
params := sqlc.CreateGeometryParams{
|
params := sqlc.CreateGeometryParams{
|
||||||
ID: geometryUUID,
|
ID: geometryUUID,
|
||||||
GeoType: constants.ParseGeoTypeText(geo.Type).Int16(),
|
GeoType: geoTypeCode,
|
||||||
DrawGeometry: geo.DrawGeometry,
|
DrawGeometry: geo.DrawGeometry,
|
||||||
Binding: binding,
|
Binding: binding,
|
||||||
TimeStart: convert.PtrFloat64ToInt4(geo.TimeStart),
|
TimeStart: convert.PtrFloat64ToInt4(geo.TimeStart),
|
||||||
|
|||||||
Reference in New Issue
Block a user