generated from yandex-praktikum/java-filmorate
-
Notifications
You must be signed in to change notification settings - Fork 1
Реализация функционала 13 спринта (групповой проект) #27
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
Merged
Changes from all commits
Commits
Show all changes
83 commits
Select commit
Hold shift + click to select a range
ac6f943
feature: add delete user
58c5023
feature: add delete film
9ba05f0
fix: code styles
8807e6d
fix: code styles
fc97220
fix: code styles
f339dde
fix: code styles
90ad9e1
feature: Add most populars - Вывод популярных фильмов по жанрам и годам
5854047
fix: sql request for popular films
bb45153
Merge branch 'add-remove-endpoint' into add-most-populars
d9ddde6
Merge pull request #15 from Kotezh/add-remove-endpoint
Kotezh 07bd937
Merge branch 'develop' into add-most-populars
7863706
feature: Add most populars - Вывод самых популярных фильмов по жанрам…
4eb3718
fix: code style errors
d019cc8
Ветка для реализации задачи add-reviews.
3b32b7e
Add director - Добавление режиссёров в фильмы.
slavakorg 61b5386
CheckStyle fix
slavakorg da48554
1. add interface ReviewService.
98d32dc
CheckStyle fix
slavakorg eac0cc1
CheckStyle fix
slavakorg 16b3758
Испоавления модели режиссёров и валидации в контроллере
slavakorg decb1d6
CheckStyle fix
slavakorg 602b51e
Удаление пустых строк и лишнего кода
slavakorg 638e0e8
CheckStyle fix
slavakorg b45b859
1. add interface ReviewService.
d9ae8e6
Merge pull request #18 from Kotezh/add-director
Just-Roman 6b389e3
merge
6d35c4a
feature: add common films - Общие фильмы
7a097ba
Merge branch 'develop' into add-common-films
e8ce4e4
fix code styles
26b5149
Merge pull request #17 from Kotezh/add-reviews
Just-Roman 1f661e2
delete CHECK (release_date <= CURRENT_DATE) for schema in table films
c774261
Merge branch 'develop' into add-most-populars
9fdb560
resolve conflicts
cc6101e
resolve conflicts
7e18e08
Merge pull request #16 from Kotezh/add-most-populars
Kotezh 374505e
Merge branch 'develop' into add-common-films
b2f74b3
Merge pull request #19 from Kotezh/add-common-films
Kotezh b9ca135
Функциональность «Поиск»
slavakorg 52f8220
fix: add connectDirectors to common films
e0c8082
Merge remote-tracking branch 'origin/develop' into develop
d577668
Merge pull request #21 from Kotezh/add-common-films
Kotezh 65df69c
Исправление валидации и запроса фильмов режиссёров.
slavakorg 49302d5
Merge remote-tracking branch 'origin/develop' into develop
1a8f013
Ветка для реализации задачи add-feed.
7552fd2
Merge pull request #23 from Kotezh/add-director
Kotezh 2418a7f
Функциональность «Поиск»
slavakorg f2caf55
Добавление регистронезависимого поиска
slavakorg 1e8b933
Merge remote-tracking branch 'origin/develop' into develop
89d078d
Merge branch 'refs/heads/develop' into add-feed
bbca18a
Merge remote-tracking branch 'origin/add-search' into add-search
slavakorg 06769f7
исправления
137beda
Merge pull request #20 from Kotezh/add-search
Kotezh 3088636
feature: add recommendations - добавление Рекомендаций
6b422d6
Merge branch 'develop' into add-recommendations
a75234a
clean ups
472830e
edit constant search for Activity
b0ea79f
Merge pull request #24 from Kotezh/add-feed
Just-Roman 9b33ae4
Merge branch 'develop' into add-recommendations
e1c8ebb
merge commit
72f8a06
Merge pull request #22 from Kotezh/add-recommendations
Kotezh a536203
fix
899d6e1
clean ups
f777dc6
fix 2
8f9f057
fix 2
43e3989
Merge remote-tracking branch 'origin/add-reviews' into add-reviews
a409452
fix 3
4855d36
fix fatalities
4ac3bf0
clean ups
ce78cd3
Merge pull request #26 from Kotezh/add-reviews
Kotezh 9f8c99c
fix test gitHub
ccf9f13
fix tests
ffe59ba
fix tests
1278e79
fix tests
0c1ace6
fix tests
6afc5b7
fix tests
39294f7
fix tests
1fd36b2
fix tests
660030a
Merge pull request #28 from Kotezh/add-reviews
Kotezh 0701c16
Merge remote-tracking branch 'origin/develop' into develop
a3e9d85
fix review
3bcce82
Merge pull request #29 from Kotezh/develop-fix
Kotezh a5607c6
Update application.properties
Kotezh 7281cf7
Merge pull request #30 from Kotezh/develop-fix
Kotezh 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
7 changes: 7 additions & 0 deletions
7
src/main/java/ru/yandex/practicum/filmorate/Enum/EventType.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,7 @@ | ||
| package ru.yandex.practicum.filmorate.Enum; | ||
|
|
||
| public enum EventType { | ||
| LIKE, | ||
| FRIEND, | ||
| REVIEW | ||
| } | ||
7 changes: 7 additions & 0 deletions
7
src/main/java/ru/yandex/practicum/filmorate/Enum/OperationType.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,7 @@ | ||
| package ru.yandex.practicum.filmorate.Enum; | ||
|
|
||
| public enum OperationType { | ||
| ADD, | ||
| UPDATE, | ||
| REMOVE | ||
| } |
2 changes: 1 addition & 1 deletion
2
.../practicum/filmorate/model/StartDate.java → ...ticum/filmorate/annotation/StartDate.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
2 changes: 1 addition & 1 deletion
2
...m/filmorate/model/StartDateValidator.java → ...morate/annotation/StartDateValidator.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
50 changes: 50 additions & 0 deletions
50
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,50 @@ | ||
| package ru.yandex.practicum.filmorate.controller; | ||
|
|
||
| import jakarta.validation.Valid; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.http.HttpStatus; | ||
| import org.springframework.validation.annotation.Validated; | ||
| import org.springframework.web.bind.annotation.*; | ||
| import ru.yandex.practicum.filmorate.model.Director; | ||
| import ru.yandex.practicum.filmorate.service.DirectorServiceImpl; | ||
|
|
||
Kotezh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| import java.util.List; | ||
|
|
||
Kotezh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| @RestController | ||
| @RequiredArgsConstructor | ||
| @RequestMapping("/directors") | ||
| @Validated | ||
| public class DirectorController { | ||
|
|
||
| private final DirectorServiceImpl directorService; | ||
|
|
||
| @PostMapping | ||
| @ResponseStatus(HttpStatus.OK) | ||
| public Director create(@Valid @RequestBody Director director) { | ||
| return directorService.create(director); | ||
| } | ||
|
|
||
| @GetMapping | ||
| @ResponseStatus(HttpStatus.OK) | ||
| public List<Director> getAll() { | ||
| return directorService.getAll(); | ||
| } | ||
|
|
||
| @GetMapping("/{id}") | ||
| @ResponseStatus(HttpStatus.OK) | ||
| public Director getById(@PathVariable("id") long id) { | ||
Kotezh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return directorService.getById(id); | ||
| } | ||
|
|
||
| @PutMapping | ||
| @ResponseStatus(HttpStatus.OK) | ||
| public Director updateDirector(@Valid @RequestBody Director director) { | ||
| return directorService.update(director); | ||
| } | ||
|
|
||
| @DeleteMapping("/{id}") | ||
| @ResponseStatus(HttpStatus.OK) | ||
| public void deleteDirector(@PathVariable("id") long id) { | ||
| directorService.delete(id); | ||
| } | ||
| } | ||
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
76 changes: 76 additions & 0 deletions
76
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,76 @@ | ||
| package ru.yandex.practicum.filmorate.controller; | ||
|
|
||
| import jakarta.validation.Valid; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.http.HttpStatus; | ||
| import org.springframework.validation.annotation.Validated; | ||
| import org.springframework.web.bind.annotation.*; | ||
| import ru.yandex.practicum.filmorate.model.Review; | ||
| import ru.yandex.practicum.filmorate.service.ReviewServiceImpl; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Optional; | ||
|
|
||
| @RestController | ||
| @RequiredArgsConstructor | ||
| @RequestMapping("/reviews") | ||
| @Validated | ||
| public class ReviewController { | ||
| private final ReviewServiceImpl reviewService; | ||
|
|
||
| @GetMapping("/{id}") | ||
| @ResponseStatus(HttpStatus.OK) | ||
| public Optional<Review> getReviewById(@PathVariable long id) { | ||
| return reviewService.getReviewById(id); | ||
| } | ||
|
|
||
| @GetMapping | ||
| @ResponseStatus(HttpStatus.OK) | ||
| public List<Review> getAllReviewsByFilmId(@RequestParam(value = "filmId", defaultValue = "-1") long filmId, | ||
| @RequestParam(value = "count", defaultValue = "10") long count) { | ||
| return reviewService.getAllReviewsByFilmId(filmId, count); | ||
| } | ||
|
|
||
| @PostMapping | ||
| @ResponseStatus(HttpStatus.CREATED) | ||
| public Review create(@Valid @RequestBody Review review) { | ||
| return reviewService.create(review); | ||
| } | ||
|
|
||
| @PutMapping | ||
| @ResponseStatus(HttpStatus.OK) | ||
| public Review update(@Valid @RequestBody Review review) { | ||
| return reviewService.update(review); | ||
| } | ||
|
|
||
| @DeleteMapping("/{id}") | ||
| @ResponseStatus(HttpStatus.OK) | ||
| public void deleteReview(@PathVariable long id) { | ||
| reviewService.deleteReview(id); | ||
| } | ||
|
|
||
| @PutMapping("/{reviewId}/like/{userId}") | ||
| @ResponseStatus(HttpStatus.OK) | ||
| public void addLike(@PathVariable long reviewId, @PathVariable long userId) { | ||
| reviewService.addLike(reviewId, userId); | ||
| } | ||
|
|
||
| @PutMapping("/{reviewId}/dislike/{userId}") | ||
| @ResponseStatus(HttpStatus.OK) | ||
| public void addDislike(@PathVariable long reviewId, @PathVariable long userId) { | ||
| reviewService.addDislike(reviewId, userId); | ||
| } | ||
|
|
||
| @DeleteMapping("/{reviewId}/like/{userId}") | ||
| @ResponseStatus(HttpStatus.OK) | ||
| public void deleteLike(@PathVariable long reviewId, @PathVariable long userId) { | ||
| reviewService.deleteReaction(reviewId, userId); | ||
| } | ||
|
|
||
| @DeleteMapping("/{reviewId}/dislike/{userId}") | ||
| @ResponseStatus(HttpStatus.OK) | ||
| public void deleteDislike(@PathVariable long reviewId, @PathVariable long userId) { | ||
| reviewService.deleteReaction(reviewId, userId); | ||
| } | ||
|
|
||
| } |
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
18 changes: 18 additions & 0 deletions
18
src/main/java/ru/yandex/practicum/filmorate/dal/DirectorRepository.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,18 @@ | ||
| package ru.yandex.practicum.filmorate.dal; | ||
|
|
||
| import ru.yandex.practicum.filmorate.model.Director; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Optional; | ||
|
|
||
| public interface DirectorRepository { | ||
| Director create(Director director); | ||
|
|
||
| List<Director> getAll(); | ||
|
|
||
| Optional<Director> getById(Long directorId); | ||
|
|
||
| Director update(Director director); | ||
|
|
||
| void delete(Long id); | ||
| } |
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
69 changes: 69 additions & 0 deletions
69
src/main/java/ru/yandex/practicum/filmorate/dal/JdbcDirectorRepository.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,69 @@ | ||
| package ru.yandex.practicum.filmorate.dal; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; | ||
| import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations; | ||
| import org.springframework.jdbc.support.GeneratedKeyHolder; | ||
| import org.springframework.stereotype.Repository; | ||
| import ru.yandex.practicum.filmorate.dal.mappers.DirectorRowMapper; | ||
| import ru.yandex.practicum.filmorate.model.Director; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Optional; | ||
| import java.util.stream.Stream; | ||
|
|
||
Kotezh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| @Repository | ||
| @RequiredArgsConstructor | ||
| public class JdbcDirectorRepository implements DirectorRepository { | ||
| private final NamedParameterJdbcOperations jdbc; | ||
| private final DirectorRowMapper mapper; | ||
|
|
||
| private static final String CREATE_DIRECTOR_QUERY = "INSERT INTO directors (director_name) VALUES(:director_name)"; | ||
| private static final String GET_ALL_DIRECTORS_QUERY = "SELECT * FROM directors ORDER BY director_id"; | ||
| private static final String GET_BY_ID_QUERY = "SELECT * FROM directors WHERE director_id = :director_id"; | ||
| private static final String UPDATE_DIRECTOR_QUERY = "UPDATE directors SET director_name=:director_name WHERE director_id=:director_id"; | ||
| private static final String DELETE_DIRECTOR_QUERY = "DELETE FROM directors WHERE director_id = :director_id"; | ||
|
|
||
| @Override | ||
| public Director create(Director director) { | ||
| GeneratedKeyHolder keyHolder = new GeneratedKeyHolder(); | ||
| MapSqlParameterSource params = new MapSqlParameterSource(); | ||
|
|
||
| params.addValue("director_name", director.getName()); | ||
| jdbc.update(CREATE_DIRECTOR_QUERY, params, keyHolder); | ||
| director.setId(keyHolder.getKeyAs(Long.class)); | ||
| return director; | ||
| } | ||
|
|
||
| @Override | ||
| public List<Director> getAll() { | ||
| return jdbc.query(GET_ALL_DIRECTORS_QUERY, mapper); | ||
| } | ||
|
|
||
| @Override | ||
| public Optional<Director> getById(Long directorId) { | ||
| MapSqlParameterSource params = new MapSqlParameterSource(); | ||
| params.addValue("director_id", directorId); | ||
| try (Stream<Director> stream = jdbc.queryForStream(GET_BY_ID_QUERY, params, mapper)) { | ||
| return stream.findAny(); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| @Override | ||
| public Director update(Director director) { | ||
| MapSqlParameterSource params = new MapSqlParameterSource(); | ||
| params.addValue("director_name", director.getName()); | ||
| params.addValue("director_id", director.getId()); | ||
| jdbc.update(UPDATE_DIRECTOR_QUERY, params); | ||
| return director; | ||
| } | ||
|
|
||
| @Override | ||
| public void delete(Long id) { | ||
| MapSqlParameterSource params = new MapSqlParameterSource(); | ||
| params.addValue("director_id", id); | ||
| jdbc.update(DELETE_DIRECTOR_QUERY, params); | ||
|
|
||
| } | ||
| } | ||
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.