UPDATE: Entity, Geo, Wiki
Some checks failed
Build and Release / release (push) Failing after 1m7s

This commit is contained in:
2026-04-22 17:45:09 +07:00
parent f127e2f029
commit adb65d8292
50 changed files with 3354 additions and 119 deletions

45
internal/models/entity.go Normal file
View File

@@ -0,0 +1,45 @@
package models
import (
"history-api/internal/dtos/response"
"time"
)
type EntityEntity struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
ThumbnailUrl string `json:"thumbnail_url"`
IsDeleted bool `json:"is_deleted"`
CreatedAt *time.Time `json:"created_at"`
UpdatedAt *time.Time `json:"updated_at"`
}
func (e *EntityEntity) ToResponse() *response.EntityResponse {
if e == nil {
return nil
}
return &response.EntityResponse{
ID: e.ID,
Name: e.Name,
Description: e.Description,
ThumbnailUrl: e.ThumbnailUrl,
IsDeleted: e.IsDeleted,
CreatedAt: e.CreatedAt,
UpdatedAt: e.UpdatedAt,
}
}
func EntitiesEntityToResponse(es []*EntityEntity) []*response.EntityResponse {
out := make([]*response.EntityResponse, 0)
if es == nil {
return out
}
for _, e := range es {
if e == nil {
continue
}
out = append(out, e.ToResponse())
}
return out
}

View File

@@ -0,0 +1,52 @@
package models
import (
"encoding/json"
"history-api/internal/dtos/response"
"time"
)
type GeometryEntity struct {
ID string `json:"id"`
GeoType string `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"`
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,
DrawGeometry: g.DrawGeometry,
Binding: g.Binding,
TimeStart: g.TimeStart,
TimeEnd: g.TimeEnd,
Bbox: g.Bbox,
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
}

43
internal/models/wiki.go Normal file
View File

@@ -0,0 +1,43 @@
package models
import (
"history-api/internal/dtos/response"
"time"
)
type WikiEntity struct {
ID string `json:"id"`
Title string `json:"title"`
Content string `json:"content"`
IsDeleted bool `json:"is_deleted"`
CreatedAt *time.Time `json:"created_at"`
UpdatedAt *time.Time `json:"updated_at"`
}
func (w *WikiEntity) ToResponse() *response.WikiResponse {
if w == nil {
return nil
}
return &response.WikiResponse{
ID: w.ID,
Title: w.Title,
Content: w.Content,
IsDeleted: w.IsDeleted,
CreatedAt: w.CreatedAt,
UpdatedAt: w.UpdatedAt,
}
}
func WikisEntityToResponse(ws []*WikiEntity) []*response.WikiResponse {
out := make([]*response.WikiResponse, 0)
if ws == nil {
return out
}
for _, w := range ws {
if w == nil {
continue
}
out = append(out, w.ToResponse())
}
return out
}