generated from yandex-praktikum/java-filmorate
-
Notifications
You must be signed in to change notification settings - Fork 0
Develop #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Ilusha92
wants to merge
38
commits into
main
Choose a base branch
from
develop
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Develop #15
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
cc340b4
feat: добавлена возможность удаления фильмов и пользователей
alex9379992 18a27c4
add-recommendations
kasisaki 84a304b
add-recommendations
kasisaki ba12d81
get-add-common-films
kasisaki 4ffb8a3
get-add-common-films
kasisaki a3dbd23
get-add-common-films
kasisaki f8f02db
get-add-common-films
kasisaki 4963073
Merge pull request #7 from Ilusha92/add-remove-endpoint
alex9379992 d559d60
feat: реализовать ТЗ
aed5f21
feat & fix: исправить согласно тестам
760e987
Add director (#9)
AleksandraBoycova 2bf798e
Merge remote-tracking branch 'origin/develop' into develop
ce692e9
fix: исправить замечания по контроллеру и сервису
374aa4c
Merge pull request #11 from Ilusha92/add-reviews
igorshmidt99 83aefe0
fead: добавлены Events
alex9379992 25f8e00
add-feed
kasisaki 534f5a3
add-feed
kasisaki c203e93
Merge pull request #12 from Ilusha92/add-feed
igorshmidt99 69fcb7b
add search by title and director
0fa59a0
декомпозирован код метода search
71f4046
Merge pull request #13 from Ilusha92/add-search
igorshmidt99 d609e78
restructed schema
8a63d16
Merge pull request #14 from Ilusha92/add-search
Ilusha92 b41ed34
fix: перенести взаимодействия review & event dao в ReviewService
22af136
добавлены тесты
alex9379992 3cddda6
refactor develop
kasisaki 7e20e67
fix: генерация ключей
b41ccdb
refactor: удаления методов генерации ключей
8492176
Merge branch 'develop-mutaev' into bug-fix-reviews
f3473d2
Update README.md
f995940
Merge pull request #16 from Ilusha92/develop-nazyan
Ilusha92 0ca95ff
refactor: устранить запросы внутри цикла
0f76289
Merge branch 'develop-nazyan' into bug-fix-reviews
77d0c20
Merge branch 'develop' into bug-fix-reviews
a4c914d
Merge pull request #20 from Ilusha92/develop-shmidt
Ilusha92 60dbe89
Осталось разобраться с FilmMapper
46cdbc2
refactor develop
kasisaki a040e0e
Merge pull request #21 from Ilusha92/develop-refactor
Ilusha92 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,25 @@ | ||
| # java-filmorate | ||
| Template repository for Filmorate project. | ||
| # Filmorate | ||
|  | ||
|
|
||
|  | ||
|
|
||
|  | ||
|
|
||
|  | ||
|
|
||
| #### Приложение имеет: | ||
|
|
||
| 1. Full Rest API для работы с пользователями, фильмами, жанрами и режисёрами фильмов. | ||
| 2. Для хранения данных задействована H2DB. | ||
| 3. Входные данные проходят валидацию. | ||
| 4. Реализовано логирование на Slf4j. | ||
| 5. Приложение имеет стандартные функциональности соцсети: Лента событий, добавление отзывов о фильме, добавление друзей и т.д. | ||
| 6. Дополнительные характеристики фильма: рейтинг на основе кол-ва лайков от пользователей, возрастные рекомендации для просмотра, жанр фильма. | ||
| 7. У фильмов реализовано свойство - режиссёр фильма с функциональностью: | ||
| - вывод всех фильмов режиссёра, отсортированных по количеству лайков. | ||
| - вывод всех фильмов режиссёра, отсортированных по годам. | ||
| 8. Основные свойства пользователя: e-mail, логин, имя, день рождения. | ||
| 9. Дополнительные связи пользователя: друзья, отзывы и лайки фильмам. | ||
| 10. Есть возможность получения списка фильмов по определнным фильтрам и заданной сортировке | ||
|
|
||
|
|
57 changes: 57 additions & 0 deletions
57
src/main/java/ru/yandex/practicum/filmorate/controller/DirectorController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| package ru.yandex.practicum.filmorate.controller; | ||
|
|
||
| import lombok.extern.slf4j.Slf4j; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.http.HttpStatus; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.*; | ||
| import ru.yandex.practicum.filmorate.model.Director; | ||
| import ru.yandex.practicum.filmorate.service.DirectorService; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @RestController | ||
| @RequiredArgsConstructor | ||
| @RequestMapping ("directors") | ||
| @Slf4j | ||
| public class DirectorController { | ||
| private final DirectorService directorService; | ||
|
|
||
| @GetMapping | ||
| public ResponseEntity<List<Director>> getAll () { | ||
| log.info("Получен запрос на список директоров"); | ||
| List<Director> directorList = directorService.getAll(); | ||
| return new ResponseEntity<>(directorList, HttpStatus.OK); | ||
| } | ||
|
|
||
| @GetMapping ("{id}") | ||
| public ResponseEntity<Director> getById (@PathVariable Integer id) { | ||
| log.info("Получен запрос на директора по id " + id); | ||
| Director director = directorService.getById(id); | ||
| return new ResponseEntity<>(director, HttpStatus.OK); | ||
| } | ||
|
|
||
|
|
||
|
|
||
| @PostMapping | ||
| public ResponseEntity<Director> create (@RequestBody Director director) { | ||
| log.info("Получен запрос на создание директора"); | ||
| Director createdDirector = directorService.create(director); | ||
| return new ResponseEntity<>(createdDirector, HttpStatus.OK); | ||
| } | ||
|
|
||
|
|
||
| @PutMapping | ||
| public ResponseEntity<Director> update (@RequestBody Director director) { | ||
| log.info("Получен запрос на обновление директора с id " + director.getId()); | ||
| Director updatedDirector = directorService.update(director); | ||
| return new ResponseEntity<>(updatedDirector, HttpStatus.OK); | ||
| } | ||
|
|
||
| @DeleteMapping ("{id}") | ||
| public ResponseEntity<Director> delete (@PathVariable Integer id) { | ||
| log.info("Получен запрос на удаление директора с id " + id); | ||
| Director director = directorService.delete(id); | ||
| return new ResponseEntity<>(director, HttpStatus.OK); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,9 @@ | |
| import ru.yandex.practicum.filmorate.service.FilmService; | ||
|
|
||
| import javax.validation.Valid; | ||
| import java.util.*; | ||
| import javax.validation.constraints.NotBlank; | ||
| import java.util.Collection; | ||
| import java.util.List; | ||
|
|
||
| @Slf4j | ||
| @RestController | ||
|
|
@@ -18,48 +20,71 @@ public class FilmController { | |
|
|
||
| private final FilmService filmService; | ||
|
|
||
| @GetMapping("/common") | ||
| public List<Film> getCommonFilms(@RequestParam("userId") int userId, @RequestParam("friendId") int friendId) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Просил добавить логирование, ладно…. |
||
| return filmService.getCommonFilms(userId, friendId); | ||
| } | ||
|
|
||
| @GetMapping | ||
| public Collection<Film> getAllFilms() { | ||
| return filmService.getAllFilms(); | ||
| } | ||
|
|
||
| @GetMapping("/{id}") | ||
| public Film getFilm(@PathVariable int id) { | ||
| log.info("Get Film {}", id); | ||
| return filmService.getFilmById(id); | ||
| } | ||
|
|
||
| @PostMapping | ||
| @ResponseStatus(HttpStatus.CREATED) | ||
| public Film createFilm(@Valid @RequestBody Film film) { | ||
| log.info("Creating Film " + film); | ||
| log.info("Creating Film {}", film.getName()); | ||
Ilusha92 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return filmService.createFilm(film); | ||
| } | ||
|
|
||
| @PutMapping | ||
| public Film updateFilm(@Valid @RequestBody Film film) { | ||
| log.info("Updating Film " + film); | ||
| log.info("Updating Film {}", film.getName()); | ||
| return filmService.updateFilm(film); | ||
| } | ||
|
|
||
| @DeleteMapping("/{id}") | ||
| public void deleteFilm(@PathVariable int id) { | ||
| log.info("Deleting Film " + id); | ||
| log.info("Deleting Film {}", id); | ||
| filmService.deleteFilmById(id); | ||
| } | ||
|
|
||
| @GetMapping("/popular") | ||
| public List<Film> getPopularFilms(@RequestParam(defaultValue = "10") int count) { | ||
| log.info("Получен запрос на список популярных фильмов"); | ||
| return filmService.getPopularFilms(count); | ||
| } | ||
|
|
||
| @PutMapping("/{id}/like/{userId}") | ||
| public Film likeFilm(@PathVariable int id, @PathVariable int userId) { | ||
| log.info("Получен запрос на добавление лайка фильму id " + id + " юзером " + userId); | ||
| return filmService.likeFilm(id, userId); | ||
| } | ||
|
|
||
| @DeleteMapping("/{id}/like/{userId}") | ||
| public Film deleteLikeFromFilm(@PathVariable int id, @PathVariable int userId) { | ||
| log.info("Получен запрос на удаление лайка фильму id " + id + " юзером " + userId); | ||
| return filmService.deleteLikeFromFilm(id, userId); | ||
| } | ||
|
|
||
| @GetMapping ("director/{directorId}") | ||
| public List<Film> getFilmsByDirectorId (@PathVariable Integer directorId, | ||
| @RequestParam (value = "sortBy")String param) { | ||
| log.info("Получен запрос на получение"); | ||
| return filmService.getFilmsSortedByLikesOrYear(directorId, param); | ||
| } | ||
|
|
||
| @GetMapping("/search") | ||
| public List<Film> searchFilms(@RequestParam @NotBlank String query, | ||
| @RequestParam @NotBlank List<String> by) { | ||
| log.info("Получен запрос на поиск фильмов"); | ||
| return filmService.searchFilms(query, by); | ||
| } | ||
| } | ||
|
|
||
16 changes: 8 additions & 8 deletions
16
src/main/java/ru/yandex/practicum/filmorate/controller/GenreController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,32 +1,32 @@ | ||
| package ru.yandex.practicum.filmorate.controller; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.PathVariable; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
| import ru.yandex.practicum.filmorate.model.Genre; | ||
| import ru.yandex.practicum.filmorate.service.FilmService; | ||
| import ru.yandex.practicum.filmorate.service.GenreService; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Slf4j | ||
| @RestController | ||
| @RequiredArgsConstructor | ||
| @RequestMapping("/genres") | ||
| public class GenreController { | ||
| private final FilmService filmService; | ||
|
|
||
| public GenreController(FilmService filmService) { | ||
| this.filmService = filmService; | ||
| } | ||
| private final GenreService genreService; | ||
|
|
||
| @GetMapping | ||
| public List<Genre> getAllGenres(){ | ||
| return filmService.getAllGenres(); | ||
| log.info("Получен запрос на получение списка жанров"); | ||
| return genreService.getAllGenres(); | ||
| } | ||
|
|
||
| @GetMapping("/{id}") | ||
| public Genre getGenreById(@PathVariable("id") int id){ | ||
| return filmService.getGenreById(id); | ||
| log.info("Получен запрос на получение жанра по id " + id); | ||
| return genreService.getGenreById(id); | ||
| } | ||
| } |
16 changes: 8 additions & 8 deletions
16
src/main/java/ru/yandex/practicum/filmorate/controller/MpaController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,33 +1,33 @@ | ||
| package ru.yandex.practicum.filmorate.controller; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.PathVariable; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
| import ru.yandex.practicum.filmorate.model.Mpa; | ||
| import ru.yandex.practicum.filmorate.service.FilmService; | ||
| import ru.yandex.practicum.filmorate.service.MpaService; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Slf4j | ||
| @RestController | ||
| @RequiredArgsConstructor | ||
| @RequestMapping("/mpa") | ||
| public class MpaController { | ||
| private final FilmService filmService; | ||
|
|
||
| public MpaController(FilmService filmService) { | ||
| this.filmService = filmService; | ||
| } | ||
| private final MpaService mpaService; | ||
|
|
||
| @GetMapping | ||
| public List<Mpa> getAllMpa(){ | ||
| return filmService.getAllMpa(); | ||
| log.info("Получен запрос на получение списка Mpa"); | ||
| return mpaService.getAllMpa(); | ||
| } | ||
|
|
||
|
|
||
| @GetMapping("/{id}") | ||
| public Mpa getMpaById(@PathVariable("id") int id){ | ||
| return filmService.getMpaById(id); | ||
| log.info("Получен запрос на получение Mpa по id " + id); | ||
| return mpaService.getMpaById(id); | ||
| } | ||
| } |
92 changes: 92 additions & 0 deletions
92
src/main/java/ru/yandex/practicum/filmorate/controller/ReviewController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| package ru.yandex.practicum.filmorate.controller; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.web.bind.annotation.*; | ||
| import ru.yandex.practicum.filmorate.model.Review; | ||
| import ru.yandex.practicum.filmorate.service.review.ReviewService; | ||
|
|
||
| import javax.validation.Valid; | ||
| import java.util.List; | ||
|
|
||
| @RestController | ||
| @Slf4j | ||
| @AllArgsConstructor | ||
| @RequestMapping("/reviews") | ||
| public class ReviewController { | ||
| private final ReviewService service; | ||
|
|
||
| @GetMapping("/{id}") | ||
| public Review getReviewById(@PathVariable("id") Long reviewId) { | ||
| Review review = service.getById(reviewId); | ||
| log.info("Обзор с ID #{} пользователя с ID #{} передан", review.getReviewId(), review.getUserId()); | ||
| return review; | ||
|
|
||
| } | ||
|
|
||
| @PostMapping | ||
| public Review postReview(@RequestBody @Valid Review review) { | ||
| review = service.add(review); | ||
| log.info("Отзыв с ID #{} добавлен.", review.getReviewId()); | ||
| return review; | ||
| } | ||
|
|
||
| @PutMapping | ||
| public Review putReview(@RequestBody @Valid Review review) { | ||
| review = service.update(review); | ||
| log.info("Отзыв с ID #{} обновлен.", review.getReviewId()); | ||
| return review; | ||
| } | ||
|
|
||
| @DeleteMapping("/{id}") | ||
| public void deleteReview(@PathVariable("id") long reviewId) { | ||
| service.delete(reviewId); | ||
| log.info("Отзыв с ID #{} удален.", reviewId); | ||
| } | ||
|
|
||
| @GetMapping | ||
| public List<Review> getReviewsByFilmId(@RequestParam(required = false) Long filmId, | ||
| @RequestParam(defaultValue = "10") Integer count) { | ||
| List<Review> reviews; | ||
| if (filmId == null) { | ||
| reviews = service.getAllReviews(); | ||
| log.info("Передан список всех отзывов в размере {}", reviews.size()); | ||
| return reviews; | ||
| } | ||
| reviews = service.getAllReviewsByFilmId(filmId, count); | ||
| log.info("Список отзывов в размере {} фильма с ID {}", count, filmId); | ||
| return reviews; | ||
| } | ||
|
|
||
| @PutMapping("/{id}/like/{userId}") | ||
| public Review addLike(@PathVariable("id") Long reviewId, @PathVariable Long userId) { | ||
| Review review = service.addLike(reviewId, userId); | ||
| log.info("Лайк отзыв с ID #{} пользователя c ID #{} добавлен. Количество лайков отзыва {}", | ||
| reviewId, userId, review.getUseful()); | ||
| return review; | ||
| } | ||
|
|
||
| @PutMapping("/{id}/dislike/{userId}") | ||
| public Review addDislike(@PathVariable("id") Long reviewId, @PathVariable Long userId) { | ||
| Review review = service.addDislike(reviewId, userId); | ||
| log.info("Дизлайк отзыва с ID #{} пользователя c ID #{} добавлен. Количество лайков отзыва {}", | ||
| reviewId, userId, review.getUseful()); | ||
| return review; | ||
| } | ||
|
|
||
| @DeleteMapping("/{id}/like/{userId}") | ||
| public Review deleteLike(@PathVariable("id") Long reviewId, @PathVariable Long userId) { | ||
| Review review = service.deleteLike(reviewId, userId); | ||
| log.info("Лайк отзыва с ID #{} пользователя c ID #{} удален. Количество лайков отзыва {}", | ||
| reviewId, userId, review.getUseful()); | ||
| return review; | ||
| } | ||
|
|
||
| @DeleteMapping("/{id}/dislike/{userId}") | ||
| public Review deleteDislike(@PathVariable("id") Long reviewId, @PathVariable Long userId) { | ||
| Review review = service.deleteDislike(reviewId, userId); | ||
| log.info("Дизлайк отзыва с ID #{} пользователя c ID #{} удален. Количество лайков отзыва {}", | ||
| reviewId, userId, review.getUseful()); | ||
| return review; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.