-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/hw 09 mongo db mvc #5
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
uoles
wants to merge
72
commits into
master
Choose a base branch
from
feature/hw-09-mongo-db-mvc
base: master
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
Changes from all commits
Commits
Show all changes
72 commits
Select commit
Hold shift + click to select a range
2dd30d9
Добавление файлов.
4533cd4
- Добавление скриптов.
628b8ae
- Добавление dao объектов.
b782bf3
Чтение вводимых данных.
56ba6a0
Доработки моделей.
f8f5da1
- Добавление DAO для таблиц авторов и жанров.
91e179e
Рефакторинг, добавление новых shell команд.
eaed856
Рефакторинг.
034a299
Добавление тестов для GenreDaoJdbc.
0c2804a
Добавление тестов для BookDaoJdbc.
64febb3
Доработка AuthorDaoJdbc, BookDaoJdbc и тесты к ним.
27e6538
Добавление тестов, расширение функционала сервиса.
f23fcd4
Добавление тестов для BooksManageSevice.
486d0a3
- Доработка функционала.
ff74ea4
- JdbcOperations заменен на NamedParameterJdbcOperations.
b019b1b
- Изменены тесты.
4599977
Описание задания.
0ed6680
Работа с бд через jpa.
a9d5968
Рефакторинг.
b228def
- Работа с бд через jpa.
uoles 88398c9
Настройка тестов для jpa.
6447037
- Доработка dao.
f8ca945
Доработка тестов и скриптов для бд.
e2f98fd
Рефакторинг.
31e0dfa
Обновление readme.
033c5da
- Добавлены названия тэстов.
uoles d790008
Изменена струкрура запроса для сущности Book.
2fde702
Использование Spring Data JPA.
93be77d
Merge branch 'feature/hw-06' into feature/hw-07-spring-data-jpa
6d1e02f
- Добавление сущности comment и клаччов к ней.
uoles d45245e
Переработка под Data Jpa.
13c56fc
- Изменение механизма добавления/обновления сущностей.
uoles f8d2433
Доработка выборки книг.
uoles 61e5a5a
Merge branch 'feature/hw-06' into feature/hw-07-spring-data-jpa
uoles 2e578aa
- Переработка под Data Jpa.
uoles de67a82
Переработка под Data Jpa.
871c88f
Переработка под Data Jpa.
297e33e
Рефакторинг.
691f77f
- Убрал @RunWith(SpringRunner.class).
39d6ef9
Интеграция Mockito.
30868a5
Доработка тестов.
cf5d07d
- Использование Mockito для тестирования сервисов.
uoles 057e0f9
Рефакторинг.
uoles 0fe48d3
Рефакторинг.
uoles cc47af7
- Подключение MongoDB.
uoles 4dfc484
Доработка тестов.
uoles 268a0ab
Доработка тестов.
uoles 1b4e453
Доработка тестов.
7d3e9d6
Доработка тестов.
6efbc36
Тип id у сущностей изменен на String.
38a5d80
Подключил Mongock.
uoles cd25af8
Рефакторинг.
d46d345
Подключение Thymeleaf.
aabb763
Добавление контроллеров и страниц.
1c041f1
Подключение bootstrap.
df7b8d3
Доработка страниц.
2f84ebd
- Доработка страниц.
2f389c1
Доработка страниц.
uoles 4ef6ded
Доработка сервисов.
uoles 639c3b0
- Добавление тестов.
uoles d7c0d98
Поле редактирования id изменил на readonly.
uoles 37fc204
- Добавление rest для создания сущности Author.
uoles 6463d82
Доработка страниц.
2fe0c2d
Редактирование автора и жанра для книги.
de886cf
Редактирование книги для комментария. Редактирование жанра.
7b1eda7
Доработка страниц.
uoles 186f7a6
Доработка тестов.
6b91981
Доработка тестов.
9545062
Доработка тестов rest-сервисов.
ddd0ec8
Доработка тестов для rest-контроллеров.
b68cd30
Рефакторинг.
94d75cc
Рефакторинг.
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,7 @@ | ||
| # OtusSpringHW-Library | ||
| Домашние задания по Spring для Otus с базами данных. | ||
|
|
||
| Домашнее задание #9: | ||
| - CRUD приложение с Web UI и хранением данных в БД. | ||
| - Создайте приложение с хранением сущностей в БД (можно взять DAOs из прошлых занятий). | ||
| - Использовать классический View, предусмотреть страницу отображения всех сущностей и создания/редактирования. | ||
| - View на Thymeleaf, classic Controllers. |
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,229 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <name>home-work</name> | ||
|
|
||
| <groupId>ru.otus.mkulikov</groupId> | ||
| <artifactId>home-work</artifactId> | ||
| <version>1.0-SNAPSHOT</version> | ||
|
|
||
| <parent> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-starter-parent</artifactId> | ||
| <version>2.1.3.RELEASE</version> | ||
| <relativePath/> <!-- lookup parent from repository --> | ||
| </parent> | ||
|
|
||
| <properties> | ||
| <encoding>UTF-8</encoding> | ||
| </properties> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>net.sf.opencsv</groupId> | ||
| <artifactId>opencsv</artifactId> | ||
| <version>2.3</version> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>javax.annotation</groupId> | ||
| <artifactId>javax.annotation-api</artifactId> | ||
| <version>1.3.2</version> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.projectlombok</groupId> | ||
| <artifactId>lombok</artifactId> | ||
| <version>1.18.4</version> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
|
|
||
| <!-- tests --> | ||
| <dependency> | ||
| <groupId>junit</groupId> | ||
| <artifactId>junit</artifactId> | ||
| <version>4.12</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.assertj</groupId> | ||
| <artifactId>assertj-core</artifactId> | ||
| <version>3.12.2</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.junit.jupiter</groupId> | ||
| <artifactId>junit-jupiter-api</artifactId> | ||
| <version>5.3.2</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.junit.jupiter</groupId> | ||
| <artifactId>junit-jupiter-engine</artifactId> | ||
| <version>5.3.2</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.junit.platform</groupId> | ||
| <artifactId>junit-platform-launcher</artifactId> | ||
| <version>1.4.1</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <!-- https://mvnrepository.com/artifact/org.mockito/mockito-all --> | ||
| <dependency> | ||
| <groupId>org.mockito</groupId> | ||
| <artifactId>mockito-core</artifactId> | ||
| <version>2.21.0</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.mockito</groupId> | ||
| <artifactId>mockito-junit-jupiter</artifactId> | ||
| <version>2.23.0</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <!-- Spring Boot --> | ||
| <dependency> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-starter</artifactId> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-starter-test</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-configuration-processor</artifactId> | ||
| <optional>true</optional> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.springframework.shell</groupId> | ||
| <artifactId>spring-shell-starter</artifactId> | ||
| <version>2.0.0.RELEASE</version> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-starter-web</artifactId> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-starter-thymeleaf</artifactId> | ||
| </dependency> | ||
|
|
||
| <!-- Mongo database --> | ||
| <dependency> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-starter-data-mongodb</artifactId> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>de.flapdoodle.embed</groupId> | ||
| <artifactId>de.flapdoodle.embed.mongo</artifactId> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.springframework.data</groupId> | ||
| <artifactId>spring-data-keyvalue</artifactId> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>com.github.cloudyrock.mongock</groupId> | ||
| <artifactId>mongock-spring</artifactId> | ||
| <version>2.0.0</version> | ||
| </dependency> | ||
|
|
||
| <!-- JPA --> | ||
| <dependency> | ||
| <groupId>org.springframework.data</groupId> | ||
| <artifactId>spring-data-jpa</artifactId> | ||
| <version>2.0.8.RELEASE</version> | ||
| </dependency> | ||
|
|
||
| <!-- Bootstrap --> | ||
| <!-- https://mvnrepository.com/artifact/org.webjars/jquery --> | ||
| <dependency> | ||
| <groupId>org.webjars</groupId> | ||
| <artifactId>jquery</artifactId> | ||
| <version>3.4.1</version> | ||
| </dependency> | ||
|
|
||
| <!-- https://mvnrepository.com/artifact/org.webjars/popper.js --> | ||
| <dependency> | ||
| <groupId>org.webjars</groupId> | ||
| <artifactId>popper.js</artifactId> | ||
| <version>1.15.0</version> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.webjars</groupId> | ||
| <artifactId>bootstrap</artifactId> | ||
| <version>4.3.1</version> | ||
| </dependency> | ||
| </dependencies> | ||
|
|
||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-compiler-plugin</artifactId> | ||
| <configuration> | ||
| <source>11</source> | ||
| <target>11</target> | ||
| </configuration> | ||
| </plugin> | ||
|
|
||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-resources-plugin</artifactId> | ||
| <configuration> | ||
| <encoding>${encoding}</encoding> | ||
| </configuration> | ||
| </plugin> | ||
|
|
||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-surefire-plugin</artifactId> | ||
| <version>2.22.0</version> | ||
|
|
||
| <configuration> | ||
| <skipTests>false</skipTests> | ||
| </configuration> | ||
| </plugin> | ||
|
|
||
| <plugin> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-maven-plugin</artifactId> | ||
| </plugin> | ||
| </plugins> | ||
|
|
||
| <resources> | ||
| <resource> | ||
| <directory>src/main/resources</directory> | ||
| <includes> | ||
| <include>**/*.yml</include> | ||
| <include>**/*.txt</include> | ||
| <include>**/*.yaml</include> | ||
| <include>**/*.html</include> | ||
| <include>**/*.css</include> | ||
| </includes> | ||
| <filtering>false</filtering> | ||
| </resource> | ||
| </resources> | ||
| </build> | ||
| </project> |
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,22 @@ | ||
| package ru.otus.mkulikov; | ||
|
|
||
| import org.springframework.boot.SpringApplication; | ||
| import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
| import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
|
|
||
| /** | ||
| * Created by IntelliJ IDEA. | ||
| * Developer: Maksim Kulikov | ||
| * Date: 2019-03-14 | ||
| * Time: 15:27 | ||
| */ | ||
|
|
||
| @SpringBootApplication | ||
| @EnableConfigurationProperties | ||
| public class Application { | ||
|
|
||
| public static void main(String[] args) throws Exception { | ||
| SpringApplication.run(Application.class); | ||
| //Console.main(args); | ||
| } | ||
| } | ||
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,15 @@ | ||
| package ru.otus.mkulikov.app.dao; | ||
|
|
||
| import org.springframework.data.mongodb.repository.MongoRepository; | ||
| import ru.otus.mkulikov.app.model.Author; | ||
|
|
||
| /** | ||
| * Created by IntelliJ IDEA. | ||
| * Developer: Maksim Kulikov | ||
| * Date: 23.05.2019 | ||
| * Time: 17:06 | ||
| */ | ||
|
|
||
| public interface AuthorDao extends MongoRepository<Author, String> { | ||
|
|
||
| } |
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,20 @@ | ||
| package ru.otus.mkulikov.app.dao; | ||
|
|
||
| import org.springframework.data.mongodb.repository.MongoRepository; | ||
| import ru.otus.mkulikov.app.model.Book; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| /** | ||
| * Created by IntelliJ IDEA. | ||
| * Developer: Maksim Kulikov | ||
| * Date: 23.05.2019 | ||
| * Time: 13:28 | ||
| */ | ||
|
|
||
| public interface BookDao extends MongoRepository<Book, String> { | ||
|
|
||
| List<Book> findByAuthor_Id(String id); | ||
|
|
||
| List<Book> findByGenre_Id(String 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| package ru.otus.mkulikov.app.dao; | ||
|
|
||
| import org.springframework.data.mongodb.repository.MongoRepository; | ||
| import ru.otus.mkulikov.app.model.Book; | ||
| import ru.otus.mkulikov.app.model.Comment; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| /** | ||
| * Created by IntelliJ IDEA. | ||
| * Developer: Maksim Kulikov | ||
| * Date: 20.06.2019 | ||
| * Time: 23:48 | ||
| */ | ||
|
|
||
| public interface CommentDao extends MongoRepository<Comment, String> { | ||
|
|
||
| List<Comment> findByBook(Book book); | ||
| } |
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,15 @@ | ||
| package ru.otus.mkulikov.app.dao; | ||
|
|
||
| import org.springframework.data.mongodb.repository.MongoRepository; | ||
| import ru.otus.mkulikov.app.model.Genre; | ||
|
|
||
| /** | ||
| * Created by IntelliJ IDEA. | ||
| * Developer: Maksim Kulikov | ||
| * Date: 23.05.2019 | ||
| * Time: 17:07 | ||
| */ | ||
|
|
||
| public interface GenreDao extends MongoRepository<Genre, String> { | ||
|
|
||
| } |
15 changes: 15 additions & 0 deletions
15
src/main/java/ru/otus/mkulikov/app/exception/ObjectNotFound.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,15 @@ | ||
| package ru.otus.mkulikov.app.exception; | ||
|
|
||
| /** | ||
| * Created by IntelliJ IDEA. | ||
| * Developer: Maksim Kulikov | ||
| * Date: 03.09.2019 | ||
| * Time: 1:58 | ||
| */ | ||
|
|
||
| public class ObjectNotFound extends RuntimeException { | ||
|
|
||
| public ObjectNotFound(String obj, String id) { | ||
| super("Not found object - " + obj + ", id - " + id); | ||
| } | ||
| } |
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.
Не оставляйте закоментированный код. это некрасиво