Initial commit
Go CI / build (push) Failing after 2m42s

feat: create basic server to manage google oauth, account, sessions, places, attributes and ratings.
This commit is contained in:
2025-09-19 02:43:04 -07:00
commit f1909da1ad
26 changed files with 2619 additions and 0 deletions
+49
View File
@@ -0,0 +1,49 @@
package store
import "git.pengzhan.dev/noteplace-server/internal/models"
// CreatePlace adds a new place to the store and saves it.
func (s *Store) CreatePlace(place models.Place) error {
s.Mu.Lock()
defer s.Mu.Unlock()
s.Data.Places[place.ID] = place
return s.save() // Use an unexported save for internal consistency
}
// GetPlaceByID finds a place by its ID.
func (s *Store) GetPlaceByID(id string) (models.Place, bool) {
s.Mu.RLock()
defer s.Mu.RUnlock()
p, ok := s.Data.Places[id]
return p, ok
}
// GetRatingsByPlaceID finds all ratings for a given place ID.
func (s *Store) GetRatingsByPlaceID(placeID string) []models.Rating {
s.Mu.RLock()
defer s.Mu.RUnlock()
var results []models.Rating
for _, r := range s.Data.Ratings {
if r.PlaceID == placeID {
results = append(results, r)
}
}
return results
}
// GetAttributesByPlace finds all relevant attributes for a given place.
func (s *Store) GetAttributesByPlace(place models.Place) []models.Attribute {
s.Mu.RLock()
defer s.Mu.RUnlock()
var results []models.Attribute
for _, val := range s.Data.Attributes {
if val.Scope == models.CATEGORY && place.Category == val.OwnerID {
results = append(results, val)
}
if val.Scope == models.PLACE && place.ID == val.OwnerID {
results = append(results, val)
}
}
return results
}