Files
History_Api/internal/models/geometry.go
AzenKain bcc2e192c1
All checks were successful
Build and Release / release (push) Successful in 1m14s
UPDATE: Submission module
2026-05-04 09:55:17 +07:00

56 lines
1.4 KiB
Go

package models
import (
"encoding/json"
"history-api/internal/dtos/response"
"history-api/pkg/constants"
"time"
)
type GeometryEntity struct {
ID string `json:"id"`
GeoType constants.GeoType `json:"geo_type"`
DrawGeometry json.RawMessage `json:"draw_geometry"`
Binding json.RawMessage `json:"binding"`
TimeStart int32 `json:"time_start"`
TimeEnd int32 `json:"time_end"`
Bbox *response.Bbox `json:"bbox"`
ProjectID string `json:"project_id"`
IsDeleted bool `json:"is_deleted"`
CreatedAt *time.Time `json:"created_at"`
UpdatedAt *time.Time `json:"updated_at"`
}
func (g *GeometryEntity) ToResponse() *response.GeometryResponse {
if g == nil {
return nil
}
return &response.GeometryResponse{
ID: g.ID,
GeoType: g.GeoType.String(),
DrawGeometry: g.DrawGeometry,
Binding: g.Binding,
TimeStart: g.TimeStart,
TimeEnd: g.TimeEnd,
Bbox: g.Bbox,
ProjectID: g.ProjectID,
IsDeleted: g.IsDeleted,
CreatedAt: g.CreatedAt,
UpdatedAt: g.UpdatedAt,
}
}
func GeometriesEntityToResponse(gs []*GeometryEntity) []*response.GeometryResponse {
out := make([]*response.GeometryResponse, 0)
if gs == nil {
return out
}
for _, g := range gs {
if g == nil {
continue
}
out = append(out, g.ToResponse())
}
return out
}