|
|
@@ -55,7 +55,7 @@ func (r *PlaceRepo) GetByID(ctx context.Context, id string) (*models.Place, erro
|
|
|
ST_Y(coordinates::geometry), ST_X(coordinates::geometry),
|
|
|
cover_image, access_info, status, moderation_comment,
|
|
|
rating, reviews_count, hourly_rate, currency, min_hours, booking_url,
|
|
|
- created_at, updated_at, published_at, deleted_at
|
|
|
+ version, created_at, updated_at, published_at, deleted_at
|
|
|
FROM places WHERE id = $1 AND deleted_at IS NULL`, id)
|
|
|
return scanPlace(row)
|
|
|
}
|
|
|
@@ -66,7 +66,7 @@ func (r *PlaceRepo) GetByIDWithDetails(ctx context.Context, id string) (*models.
|
|
|
ST_Y(p.coordinates::geometry), ST_X(p.coordinates::geometry),
|
|
|
p.cover_image, p.access_info, p.status, p.moderation_comment,
|
|
|
p.rating, p.reviews_count, p.hourly_rate, p.currency, p.min_hours, p.booking_url,
|
|
|
- p.created_at, p.updated_at, p.published_at, p.deleted_at,
|
|
|
+ p.version, p.created_at, p.updated_at, p.published_at, p.deleted_at,
|
|
|
COALESCE(json_agg(DISTINCT jsonb_build_object('id', t.id, 'name', t.name, 'category', t.category))
|
|
|
FILTER (WHERE t.id IS NOT NULL), '[]'::json) as tags,
|
|
|
COALESCE(json_agg(DISTINCT jsonb_build_object('id', f.id, 'name', f.name, 'category', f.category, 'icon', f.icon))
|
|
|
@@ -88,6 +88,7 @@ func (r *PlaceRepo) GetByIDWithDetails(ctx context.Context, id string) (*models.
|
|
|
&p.Lat, &p.Lng,
|
|
|
&p.CoverImage, &p.AccessInfo, &p.Status, &p.ModerationComment,
|
|
|
&p.Rating, &p.ReviewsCount, &p.HourlyRate, &p.Currency, &p.MinHours, &p.BookingURL,
|
|
|
+ &p.Version,
|
|
|
&p.CreatedAt, &p.UpdatedAt, &p.PublishedAt, &p.DeletedAt,
|
|
|
&tagsJSON, &featuresJSON,
|
|
|
)
|
|
|
@@ -113,7 +114,7 @@ func (r *PlaceRepo) List(ctx context.Context, filter models.PlaceFilter) ([]*mod
|
|
|
ST_Y(p.coordinates::geometry), ST_X(p.coordinates::geometry),
|
|
|
p.cover_image, p.access_info, p.status, p.moderation_comment,
|
|
|
p.rating, p.reviews_count, p.hourly_rate, p.currency, p.min_hours, p.booking_url,
|
|
|
- p.created_at, p.updated_at, p.published_at, p.deleted_at
|
|
|
+ p.version, p.created_at, p.updated_at, p.published_at, p.deleted_at
|
|
|
FROM places p`
|
|
|
args := pgx.NamedArgs{}
|
|
|
joins := ""
|
|
|
@@ -197,7 +198,7 @@ func (r *PlaceRepo) Update(ctx context.Context, p *models.Place) error {
|
|
|
`UPDATE places SET title=$1, description=$2, address=$3,
|
|
|
coordinates=ST_SetSRID(ST_MakePoint($4, $5), 4326),
|
|
|
cover_image=$6, access_info=$7, status=$8, hourly_rate=$9, currency=$10, min_hours=$11,
|
|
|
- booking_url=$12, updated_at=now()
|
|
|
+ booking_url=$12, updated_at=now(), version=version+1
|
|
|
WHERE id=$13 AND deleted_at IS NULL`,
|
|
|
p.Title, p.Description, p.Address,
|
|
|
p.Lng, p.Lat,
|
|
|
@@ -240,7 +241,7 @@ func (r *PlaceRepo) GetByIDRaw(ctx context.Context, id string) (*models.Place, e
|
|
|
ST_Y(coordinates::geometry), ST_X(coordinates::geometry),
|
|
|
cover_image, access_info, status, moderation_comment,
|
|
|
rating, reviews_count, hourly_rate, currency, min_hours, booking_url,
|
|
|
- created_at, updated_at, published_at, deleted_at
|
|
|
+ version, created_at, updated_at, published_at, deleted_at
|
|
|
FROM places WHERE id = $1`, id)
|
|
|
return scanPlace(row)
|
|
|
}
|
|
|
@@ -412,6 +413,7 @@ func scanPlace(row interface{ Scan(dest ...any) error }) (*models.Place, error)
|
|
|
&p.Lat, &p.Lng,
|
|
|
&p.CoverImage, &p.AccessInfo, &p.Status, &p.ModerationComment,
|
|
|
&p.Rating, &p.ReviewsCount, &p.HourlyRate, &p.Currency, &p.MinHours, &p.BookingURL,
|
|
|
+ &p.Version,
|
|
|
&p.CreatedAt, &p.UpdatedAt, &p.PublishedAt, &p.DeletedAt,
|
|
|
)
|
|
|
if err != nil {
|