generated from yandex-praktikum/java-filmorate
-
Notifications
You must be signed in to change notification settings - Fork 0
add-database. Добавить базу данных для сохранения сущностей. #3
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
Merged
Changes from all commits
Commits
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
28 changes: 28 additions & 0 deletions
28
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 |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package ru.yandex.practicum.filmorate.controller; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
| 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.GenreService; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @RestController | ||
| @RequestMapping(value = "/genres") | ||
| @RequiredArgsConstructor | ||
| public class GenreController { | ||
| private final GenreService service; | ||
|
|
||
| @GetMapping | ||
| public List<Genre> getAll() { | ||
| return service.getAll(); | ||
| } | ||
|
|
||
| @GetMapping("/{id}") | ||
| public Genre getById(@PathVariable Long id) { | ||
| return service.getById(id); | ||
| } | ||
| } | ||
29 changes: 29 additions & 0 deletions
29
src/main/java/ru/yandex/practicum/filmorate/controller/RatingMPAController.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,29 @@ | ||
| package ru.yandex.practicum.filmorate.controller; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
| 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.RatingMPA; | ||
| import ru.yandex.practicum.filmorate.service.RatingMPAService; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @RestController | ||
| @RequestMapping(value = "/mpa") | ||
| @RequiredArgsConstructor | ||
| public class RatingMPAController { | ||
|
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. и сюда тоже |
||
|
|
||
| private final RatingMPAService service; | ||
|
|
||
| @GetMapping | ||
| public List<RatingMPA> getAll() { | ||
| return service.getAll(); | ||
| } | ||
|
|
||
| @GetMapping("/{id}") | ||
| public RatingMPA getById(@PathVariable Long id) { | ||
| return service.getById(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
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
14 changes: 14 additions & 0 deletions
14
src/main/java/ru/yandex/practicum/filmorate/model/Genre.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,14 @@ | ||
| package ru.yandex.practicum.filmorate.model; | ||
|
|
||
| import lombok.*; | ||
|
|
||
| @Data | ||
| @Builder(toBuilder = true) | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| public class Genre { | ||
|
|
||
| private Long id; | ||
| private String name; | ||
|
|
||
| } |
14 changes: 14 additions & 0 deletions
14
src/main/java/ru/yandex/practicum/filmorate/model/RatingMPA.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,14 @@ | ||
| package ru.yandex.practicum.filmorate.model; | ||
|
|
||
| import lombok.*; | ||
|
|
||
| @Data | ||
| @Builder(toBuilder = true) | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| public class RatingMPA { | ||
|
|
||
| private Long id; | ||
| private String name; | ||
|
|
||
| } |
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
27 changes: 27 additions & 0 deletions
27
src/main/java/ru/yandex/practicum/filmorate/service/GenreService.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,27 @@ | ||
| package ru.yandex.practicum.filmorate.service; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.stereotype.Service; | ||
| import ru.yandex.practicum.filmorate.model.Genre; | ||
| import ru.yandex.practicum.filmorate.storage.interfaces.GenreStorage; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Slf4j | ||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class GenreService { | ||
|
|
||
| private final GenreStorage storage; | ||
|
|
||
| public List<Genre> getAll() { | ||
| log.info("Запрос всех жанров"); | ||
| return storage.getAll(); | ||
| } | ||
|
|
||
| public Genre getById(Long id) { | ||
| log.info("Запрос жанра с id = " + id); | ||
| return storage.getById(id); | ||
| } | ||
| } |
27 changes: 27 additions & 0 deletions
27
src/main/java/ru/yandex/practicum/filmorate/service/RatingMPAService.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,27 @@ | ||
| package ru.yandex.practicum.filmorate.service; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.stereotype.Service; | ||
| import ru.yandex.practicum.filmorate.model.RatingMPA; | ||
| import ru.yandex.practicum.filmorate.storage.interfaces.RatingMPAStorage; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Slf4j | ||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class RatingMPAService { | ||
|
|
||
| private final RatingMPAStorage storage; | ||
|
|
||
| public List<RatingMPA> getAll() { | ||
| log.info("Запрос всех рейтингов MPA"); | ||
| return storage.getAll(); | ||
| } | ||
|
|
||
| public RatingMPA getById(Long id) { | ||
| log.info("Запрос рейтинга MPA с id = " + id); | ||
| return storage.getById(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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
добавь логи в методы