feat: define commit snapshot DTOs and implement submission service submission creation logic
Build and Release / release (push) Successful in 1m39s

This commit is contained in:
2026-05-26 14:32:29 +07:00
parent cc92e07d92
commit 0a416d40e9
2 changed files with 73 additions and 61 deletions
+4 -11
View File
@@ -2,8 +2,8 @@ package services
import (
"context"
"errors"
"encoding/json"
"errors"
"fmt"
"history-api/internal/dtos/request"
"history-api/internal/dtos/response"
@@ -995,6 +995,9 @@ func (s *submissionService) applySnapshot(ctx context.Context, tx pgx.Tx, projec
if len(snapshotData.GeometryEntity) > 0 {
geomLinks := make(map[string][]pgtype.UUID)
for _, link := range snapshotData.GeometryEntity {
if link.Operation == "delete" {
continue
}
if !validEntities[link.EntityID] || !validGeometries[link.GeometryID] {
continue
}
@@ -1041,16 +1044,6 @@ func (s *submissionService) applySnapshot(ctx context.Context, tx pgx.Tx, projec
}
}
newSnapshot, err := json.Marshal(snapshotData)
if err != nil {
return fiber.NewError(fiber.StatusInternalServerError, "Failed to marshal snapshot")
}
commitRepo := s.commitRepo.WithTx(tx)
_, err = commitRepo.UpdateSnapshot(ctx, commitUUID, newSnapshot)
if err != nil {
return fiber.NewError(fiber.StatusInternalServerError, "Failed to update snapshot: "+err.Error())
}
wikiDeleteIDs := make([]string, 0)
entityDeleteIDs := make([]string, 0)