Skip to content

Commit

Permalink
Merge pull request #49 from go-park-mail-ru/add_photos
Browse files Browse the repository at this point in the history
Add photos
  • Loading branch information
mevain authored Nov 27, 2024
2 parents a07f96e + 71c36d6 commit 4539932
Show file tree
Hide file tree
Showing 14 changed files with 1,103 additions and 482 deletions.
2 changes: 2 additions & 0 deletions cmd/gateway/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ func main() {
trips.Handle("/{id}", middleware.MiddlewareAuth(jwtHandler, http.HandlerFunc(tripsHandler.DeleteTripHandler), logger)).Methods(http.MethodDelete)
trips.Handle("/{id}", middleware.MiddlewareAuth(jwtHandler, http.HandlerFunc(tripsHandler.AddPlaceToTripHandler), logger)).Methods(http.MethodPost)
user.Handle("/trips", middleware.MiddlewareAuth(jwtHandler, http.HandlerFunc(tripsHandler.GetTripsByUserIDHandler), logger)).Methods(http.MethodGet)
trips.Handle("/{id}/photos", middleware.MiddlewareAuth(jwtHandler, http.HandlerFunc(tripsHandler.AddPhotosToTripHandler), logger)).Methods(http.MethodPut)
trips.Handle("/{id}/photos", middleware.MiddlewareAuth(jwtHandler, http.HandlerFunc(tripsHandler.DeletePhotoHandler), logger)).Methods(http.MethodDelete)

surveyHandler := httpSurvey.NewSurveyHandler(surveyClient, logger)
survey := r.PathPrefix("/survey").Subrouter()
Expand Down
6 changes: 6 additions & 0 deletions db/migrations/01_up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ CREATE TABLE IF NOT EXISTS trip_place ( --таблица для сопостав
CONSTRAINT uq_trip_place UNIQUE (trip_id, place_id)
);

CREATE TABLE trip_photo (
id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
trip_id INT REFERENCES trip(id) ON DELETE CASCADE,
photo_path TEXT NOT NULL
);

CREATE TABLE IF NOT EXISTS survey (
id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
survey_text TEXT DEFAULT '',
Expand Down
7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ services:
- LOG_LEVEL=Debug
volumes:
- ./assets/avatars:/assets/avatars
- ./assets/photos:/assets/photos
ports:
- 8080:8080
depends_on:
Expand All @@ -27,6 +28,8 @@ services:
- LOG_LEVEL=Debug
volumes:
- ./assets/avatars:/assets/avatars
- ./assets/photos:/assets/photos

ports:
- 8081:8081
depends_on:
Expand All @@ -40,8 +43,10 @@ services:
- .env
environment:
- LOG_LEVEL=Debug
- PHOTO_STORAGE_PATH=/assets/photos
volumes:
- ./assets/avatars:/assets/avatars
- ./assets/photos:/assets/photos
ports:
- 50053:50053
depends_on:
Expand All @@ -58,6 +63,7 @@ services:
- LOG_LEVEL=Debug
volumes:
- ./assets/avatars:/assets/avatars
- ./assets/photos:/assets/photos
ports:
- 50052:50052
depends_on:
Expand All @@ -74,6 +80,7 @@ services:
- LOG_LEVEL=Debug
volumes:
- ./assets/avatars:/assets/avatars
- ./assets/photos:/assets/photos
ports:
- 50054:50054
depends_on:
Expand Down
1 change: 1 addition & 0 deletions internal/models/trip.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type Trip struct {
StartDate string `json:"start_date"`
EndDate string `json:"end_date"`
Private bool `json:"private_trip"`
Photos []string `json:"photos"`
CreatedAt time.Time `json:"created_at"`
}

Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/reviews/delivery/http/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func ErrorCheck(err error, action string, logger *slog.Logger, ctx context.Conte
return response, http.StatusNotFound
}
logContext := log.AppendCtx(ctx, slog.String("action", action))
logger.ErrorContext(logContext, fmt.Sprintf("Failed to %s cities", action), slog.Any("error", err.Error()))
logger.ErrorContext(logContext, fmt.Sprintf("Failed to %s reviews", action), slog.Any("error", err.Error()))
response := httpresponse.ErrorResponse{
Message: fmt.Sprintf("Failed to %s review", action),
}
Expand Down
Loading

0 comments on commit 4539932

Please sign in to comment.