Demo app (web/):
- Collections: select, rename, remove (x button per row), delete
- Features: add point (lon/lat validation), remove, list in selected collection
- QR codes for pk (private) and pb (public) keys
- Restore public key from private key
- 409 Conflict handled for already-registered login
- Title: Momswap Geo Backend Use-Cases Test
Backend:
- PATCH /v1/collections/{id} for rename
- DELETE /v1/collections/{id}
- Clearer lon/lat validation errors (-180..180, -90..90)
Client:
- updateCollection, deleteCollection, derivePublicKey
Docs:
- docs/frontend-development.md (demo app, local dev)
- README links to all docs
Made-with: Cursor
This commit is contained in:
@@ -16,6 +16,7 @@ type Store interface {
|
||||
SaveCollection(c Collection)
|
||||
ListCollectionsByOwner(owner string) []Collection
|
||||
GetCollection(id string) (Collection, error)
|
||||
DeleteCollection(id string) error
|
||||
SaveFeature(f Feature)
|
||||
ListFeaturesByCollection(collectionID string) []Feature
|
||||
GetFeature(featureID string) (Feature, error)
|
||||
|
||||
@@ -157,6 +157,21 @@ func (s *MemoryStore) GetCollection(id string) (Collection, error) {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
func (s *MemoryStore) DeleteCollection(id string) error {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
if _, ok := s.collections[id]; !ok {
|
||||
return ErrNotFound
|
||||
}
|
||||
for fid, f := range s.features {
|
||||
if f.CollectionID == id {
|
||||
delete(s.features, fid)
|
||||
}
|
||||
}
|
||||
delete(s.collections, id)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *MemoryStore) SaveFeature(f Feature) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
@@ -204,6 +204,18 @@ func (s *PostgresStore) GetCollection(id string) (Collection, error) {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
func (s *PostgresStore) DeleteCollection(id string) error {
|
||||
res, err := s.db.Exec(`DELETE FROM collections WHERE id = $1`, id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
n, _ := res.RowsAffected()
|
||||
if n == 0 {
|
||||
return ErrNotFound
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *PostgresStore) SaveFeature(f Feature) {
|
||||
geom, _ := json.Marshal(f.Geometry)
|
||||
props, _ := json.Marshal(f.Properties)
|
||||
|
||||
Reference in New Issue
Block a user