├── .gitignore ├── Documents └── Отчет.docx ├── Projects ├── 01. Jdbc Example │ ├── db.properties │ └── src │ │ └── ru │ │ └── itis │ │ ├── Main.java │ │ ├── MainForSave.java │ │ ├── models │ │ └── User.java │ │ └── repositories │ │ ├── CrudRepository.java │ │ ├── RowMapper.java │ │ ├── UsersRepository.java │ │ └── UsersRepositoryJdbcImpl.java ├── 02. HTML Example │ └── index.html ├── 03. NodeJsExample │ ├── app │ │ └── routes │ │ │ ├── index.js │ │ │ └── users_routes.js │ ├── data.txt │ ├── package-lock.json │ ├── public │ │ └── html │ │ │ └── index.html │ └── server.js ├── 04. Bootstrap │ └── index.html ├── 05. Generics And Strings │ ├── src │ │ └── ru │ │ │ └── itis │ │ │ ├── generics │ │ │ ├── Collection.java │ │ │ ├── LinkedList.java │ │ │ ├── List.java │ │ │ └── Main.java │ │ │ ├── strings │ │ │ └── Main.java │ │ │ └── wrappers │ │ │ └── Main.java │ └── temp.md ├── 06. Thread Pool │ ├── out │ │ └── production │ │ │ └── # 54. Thread Pool │ │ │ └── META-INF │ │ │ └── # 54. Thread Pool.kotlin_module │ └── src │ │ └── ru │ │ └── itis │ │ ├── Main.java │ │ ├── MainExecutorService.java │ │ ├── ThreadPool.java │ │ └── runnable │ │ ├── CustomThread.java │ │ ├── CustomThreadRunnable.java │ │ └── Main.java ├── 07. Simple Maven Project │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── Program.java ├── 08. JavaSocket │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── ru │ │ └── itis │ │ └── sockets │ │ ├── clients │ │ └── SocketClient.java │ │ ├── programs │ │ ├── clients │ │ │ ├── ProgramClientChatStart.java │ │ │ └── ProgramClientGreetingStart.java │ │ └── servers │ │ │ ├── ProgramChatMultiServer.java │ │ │ └── ProgramServerStart.java │ │ └── servers │ │ ├── ChatMultiServer.java │ │ └── GreetServer.java ├── 09. JSON Example │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ ├── AuthData.java │ │ ├── Main.java │ │ └── User.java ├── 10. Architecture │ └── src │ │ ├── Main.java │ │ └── ru │ │ └── itis │ │ ├── context │ │ ├── ApplicationContext.java │ │ ├── ApplicationContextReflectionBased.java │ │ └── Component.java │ │ ├── dispatcher │ │ └── RequestsDispatcher.java │ │ ├── dto │ │ ├── Dto.java │ │ └── UserDto.java │ │ ├── models │ │ └── User.java │ │ ├── protocol │ │ ├── Request.java │ │ ├── RequestsHandler.java │ │ └── Response.java │ │ ├── repositories │ │ ├── CrudRepository.java │ │ ├── UsersRepository.java │ │ └── UsersRepositoryFakeImpl.java │ │ └── services │ │ ├── SignInService.java │ │ └── SignInServiceImpl.java ├── 11. Servlets With Context │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── ru │ │ │ └── itis │ │ │ ├── context │ │ │ └── PrimitiveContext.java │ │ │ ├── dto │ │ │ └── User.java │ │ │ ├── listeners │ │ │ └── PrimitiveContextServletListener.java │ │ │ ├── repositories │ │ │ ├── DataRepository.java │ │ │ └── DataRepositoryImpl.java │ │ │ ├── services │ │ │ ├── SignUpService.java │ │ │ └── SignUpServiceImpl.java │ │ │ └── servlets │ │ │ ├── JsonServlet.java │ │ │ └── SignUpServlet.java │ │ └── webapp │ │ └── WEB-INF │ │ └── web.xml ├── 12. Prepared Statements │ ├── images │ │ ├── 1.png │ │ ├── 2.png │ │ ├── 3.png │ │ ├── 4.png │ │ ├── 5.png │ │ ├── 6.png │ │ ├── 7.png │ │ └── 8.png │ ├── pom.xml │ ├── sql │ │ └── queries.sql │ └── src │ │ └── main │ │ └── java │ │ └── MainForPreparedStatements.java ├── 13. Spring JDBC Example │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── ru │ │ │ └── itis │ │ │ └── spring │ │ │ ├── App.java │ │ │ ├── AppForJdbcTemplate.java │ │ │ ├── AppForSpringContext.java │ │ │ ├── models │ │ │ ├── Course.java │ │ │ └── Lesson.java │ │ │ └── repositories │ │ │ ├── CoursesRepository.java │ │ │ ├── CoursesRepositoryJdbcImpl.java │ │ │ ├── CrudRepository.java │ │ │ ├── LessonsRepository.java │ │ │ ├── LessonsRepositoryJdbcImpl.java │ │ │ ├── RowMapper.java │ │ │ └── spring │ │ │ └── CoursesRepositoryJdbcTemplateImpl.java │ │ └── resources │ │ └── context.xml ├── 14. Servlets With Spring │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── ru │ │ │ └── itis │ │ │ └── servlets │ │ │ ├── listeners │ │ │ └── SpringContextServletContextListener.java │ │ │ ├── models │ │ │ └── Course.java │ │ │ ├── repositories │ │ │ ├── CoursesRepository.java │ │ │ ├── CoursesRepositoryJdbcTemplateImpl.java │ │ │ └── CrudRepository.java │ │ │ ├── services │ │ │ ├── CoursesService.java │ │ │ └── CoursesServiceImpl.java │ │ │ └── servlets │ │ │ └── CoursesServlet.java │ │ ├── resources │ │ └── context.xml │ │ └── webapp │ │ └── WEB-INF │ │ ├── jsp │ │ └── courses.jsp │ │ └── web.xml ├── 15. Servlets With Spring Java Config │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── ru │ │ │ └── itis │ │ │ └── servlets │ │ │ ├── config │ │ │ └── ApplicationContextConfig.java │ │ │ ├── listeners │ │ │ └── SpringContextServletContextListener.java │ │ │ ├── models │ │ │ └── Course.java │ │ │ ├── repositories │ │ │ ├── CoursesRepository.java │ │ │ ├── CoursesRepositoryJdbcTemplateImpl.java │ │ │ └── CrudRepository.java │ │ │ ├── services │ │ │ ├── CoursesService.java │ │ │ └── CoursesServiceImpl.java │ │ │ └── servlets │ │ │ └── CoursesServlet.java │ │ ├── resources │ │ └── context.xml │ │ └── webapp │ │ └── WEB-INF │ │ ├── jsp │ │ └── courses.jsp │ │ └── web.xml ├── 16. Servlets With Spring Java Config With Properties │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── ru │ │ │ └── itis │ │ │ └── servlets │ │ │ ├── config │ │ │ └── ApplicationContextConfig.java │ │ │ ├── listeners │ │ │ └── SpringContextServletContextListener.java │ │ │ ├── models │ │ │ └── Course.java │ │ │ ├── repositories │ │ │ ├── CoursesRepository.java │ │ │ ├── CoursesRepositoryJdbcTemplateImpl.java │ │ │ └── CrudRepository.java │ │ │ ├── services │ │ │ ├── CoursesService.java │ │ │ └── CoursesServiceImpl.java │ │ │ └── servlets │ │ │ └── CoursesServlet.java │ │ ├── resources │ │ ├── application.properties │ │ └── context.xml │ │ └── webapp │ │ └── WEB-INF │ │ ├── jsp │ │ └── courses.jsp │ │ └── web.xml ├── 17. Servlets With Spring Full Java Config With Properties │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── ru │ │ │ └── itis │ │ │ └── servlets │ │ │ ├── config │ │ │ └── ApplicationContextConfig.java │ │ │ ├── listeners │ │ │ └── SpringContextServletContextListener.java │ │ │ ├── models │ │ │ └── Course.java │ │ │ ├── repositories │ │ │ ├── CoursesRepository.java │ │ │ ├── CoursesRepositoryJdbcTemplateImpl.java │ │ │ └── CrudRepository.java │ │ │ ├── services │ │ │ ├── CoursesService.java │ │ │ └── CoursesServiceImpl.java │ │ │ └── servlets │ │ │ └── CoursesServlet.java │ │ ├── resources │ │ └── application.properties │ │ └── webapp │ │ └── WEB-INF │ │ ├── jsp │ │ └── courses.jsp │ │ └── web.xml ├── 18. Dispatcher Servlet │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── ru │ │ │ └── itis │ │ │ └── servlets │ │ │ ├── config │ │ │ └── ApplicationContextConfig.java │ │ │ ├── controllers │ │ │ ├── CoursesController.java │ │ │ ├── CoursesControllerOnAnnotations.java │ │ │ └── FilesController.java │ │ │ ├── listeners │ │ │ └── SpringContextServletContextListener.java │ │ │ ├── models │ │ │ ├── Course.java │ │ │ └── FileInfo.java │ │ │ ├── repositories │ │ │ ├── CoursesRepository.java │ │ │ ├── CoursesRepositoryJdbcTemplateImpl.java │ │ │ └── CrudRepository.java │ │ │ └── services │ │ │ ├── CoursesService.java │ │ │ └── CoursesServiceImpl.java │ │ ├── resources │ │ └── application.properties │ │ └── webapp │ │ └── WEB-INF │ │ ├── dispatcherServlet-servlet.xml │ │ ├── ftl │ │ └── file_upload.ftlh │ │ ├── html │ │ └── file_upload.html │ │ ├── jsp │ │ └── courses.jsp │ │ └── web.xml ├── 19. Hibernate And Jpa │ ├── INFO.adoc │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── ru │ │ │ └── itis │ │ │ └── orm │ │ │ ├── Course.java │ │ │ ├── Lesson.java │ │ │ ├── hibernate │ │ │ ├── Main.java │ │ │ └── MainForStateOfObjects.java │ │ │ ├── jpa │ │ │ └── Main.java │ │ │ └── spring │ │ │ ├── AppContext.java │ │ │ ├── CoursesRepository.java │ │ │ ├── CoursesRepositoryJpaImpl.java │ │ │ └── Main.java │ │ └── resources │ │ ├── META-INF │ │ └── persistence.xml │ │ └── hibernate │ │ ├── Course.hbm.xml │ │ ├── Lesson.hbm.xml │ │ └── hibernate.cfg.xml ├── 20. Long Polling │ ├── .gitignore │ ├── .mvn │ │ └── wrapper │ │ │ ├── MavenWrapperDownloader.java │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── ru │ │ │ │ └── itis │ │ │ │ └── chat │ │ │ │ ├── LongPollingApplication.java │ │ │ │ ├── controllers │ │ │ │ ├── ChatController.java │ │ │ │ └── MessagesController.java │ │ │ │ └── dto │ │ │ │ └── MessageDto.java │ │ └── resources │ │ │ ├── application.properties │ │ │ ├── requests.http │ │ │ ├── static │ │ │ └── js │ │ │ │ └── chat.js │ │ │ └── templates │ │ │ └── chat.ftlh │ │ └── test │ │ └── java │ │ └── ru │ │ └── itis │ │ └── chat │ │ └── LongPollingApplicationTests.java ├── 21. websockets │ ├── .gitignore │ ├── .mvn │ │ └── wrapper │ │ │ ├── MavenWrapperDownloader.java │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── ru │ │ │ │ └── itis │ │ │ │ └── websockets │ │ │ │ ├── WebSocketsApplication.java │ │ │ │ ├── config │ │ │ │ └── WebSocketConfiguration.java │ │ │ │ ├── controllers │ │ │ │ └── IndexController.java │ │ │ │ ├── dto │ │ │ │ └── Message.java │ │ │ │ └── handlers │ │ │ │ ├── AuthHandshakeHandler.java │ │ │ │ └── WebSocketMessagesHandler.java │ │ └── resources │ │ │ ├── application.properties │ │ │ └── templates │ │ │ └── index.ftlh │ │ └── test │ │ └── java │ │ └── ru │ │ └── itis │ │ └── websockets │ │ └── WebsocketsApplicationTests.java ├── 22. Spring MVC Profiles │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── ru │ │ │ └── itis │ │ │ └── servlets │ │ │ ├── config │ │ │ ├── AppInitializer.java │ │ │ └── ApplicationContextConfig.java │ │ │ ├── controllers │ │ │ └── CoursesMvcController.java │ │ │ ├── filters │ │ │ ├── ResponseUtil.java │ │ │ └── SecurityFilter.java │ │ │ ├── models │ │ │ └── Course.java │ │ │ ├── repositories │ │ │ ├── CoursesRepository.java │ │ │ ├── CoursesRepositoryJdbcTemplateImpl.java │ │ │ └── CrudRepository.java │ │ │ └── services │ │ │ ├── CoursesService.java │ │ │ └── CoursesServiceImpl.java │ │ ├── resources │ │ └── application.properties │ │ └── webapp │ │ └── WEB-INF │ │ ├── ftl │ │ └── file_upload.ftlh │ │ ├── html │ │ └── file_upload.html │ │ └── jsp │ │ └── courses.jsp ├── 23. stomp-example │ ├── .gitignore │ ├── .mvn │ │ └── wrapper │ │ │ ├── MavenWrapperDownloader.java │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── info │ │ ├── httpatomoreillycomsourceoreillyimages695362.png │ │ ├── info.md │ │ ├── message-flow-broker-relay.png │ │ └── message-flow-simple-broker.png │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── ru │ │ │ │ └── itis │ │ │ │ └── stomp │ │ │ │ ├── StompExampleApplication.java │ │ │ │ ├── config │ │ │ │ └── StompConfig.java │ │ │ │ ├── controller │ │ │ │ └── MessagesController.java │ │ │ │ └── interceptors │ │ │ │ └── HandShakeInterceptor.java │ │ └── resources │ │ │ ├── application.properties │ │ │ └── static │ │ │ ├── html │ │ │ └── index.html │ │ │ └── js │ │ │ └── app.js │ │ └── test │ │ └── java │ │ └── ru │ │ └── itis │ │ └── stomp │ │ └── StompExampleApplicationTests.java ├── 41. Spring MVC Example │ ├── INFO.md │ ├── README.md │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── ru │ │ │ │ └── itdrive │ │ │ │ └── web │ │ │ │ ├── config │ │ │ │ ├── ApplicationConfig.java │ │ │ │ └── ApplicationInitializer.java │ │ │ │ ├── controllers │ │ │ │ ├── RoomsRestController.java │ │ │ │ ├── UsersController.java │ │ │ │ └── UsersRestController.java │ │ │ │ ├── dto │ │ │ │ └── RoomDto.java │ │ │ │ ├── models │ │ │ │ ├── Message.java │ │ │ │ ├── Room.java │ │ │ │ └── User.java │ │ │ │ ├── repositories │ │ │ │ ├── CrudRepository.java │ │ │ │ ├── MessagesRepository.java │ │ │ │ ├── MessagesRepositoryJpaImpl.java │ │ │ │ ├── RoomsRepository.java │ │ │ │ ├── UsersRepository.java │ │ │ │ └── UsersRepositoryJdbcTemplateImpl.java │ │ │ │ └── services │ │ │ │ ├── RoomsService.java │ │ │ │ ├── RoomsServiceImpl.java │ │ │ │ ├── UsersSearchService.java │ │ │ │ ├── UsersSearchServiceImpl.java │ │ │ │ ├── UsersService.java │ │ │ │ └── UsersServiceImpl.java │ │ ├── resources │ │ │ ├── application.properties │ │ │ └── requests.http │ │ └── webapp │ │ │ └── view │ │ │ └── usersPage.ftlh │ │ └── test │ │ ├── java │ │ └── ru │ │ │ └── itdrive │ │ │ └── web │ │ │ ├── config │ │ │ └── TestApplicationConfig.java │ │ │ └── repositories │ │ │ ├── MessagesRepositoryJpaImplTest.java │ │ │ ├── RoomsRepositoryTest.java │ │ │ └── UsersRepositoryJdbcTemplateImplTest.java │ │ └── resources │ │ ├── data.sql │ │ └── schema.sql ├── 44. Rest API Demo │ ├── .gitignore │ ├── .mvn │ │ └── wrapper │ │ │ ├── MavenWrapperDownloader.java │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── SPRING_SECURITY.png │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── ru │ │ │ │ └── itis │ │ │ │ └── service │ │ │ │ ├── RestApiDemoApplication.java │ │ │ │ ├── controllers │ │ │ │ ├── CoursesController.java │ │ │ │ └── DisciplinesController.java │ │ │ │ ├── dto │ │ │ │ ├── CourseDto.java │ │ │ │ └── LessonDto.java │ │ │ │ ├── models │ │ │ │ ├── Authority.java │ │ │ │ ├── Course.java │ │ │ │ ├── Discipline.java │ │ │ │ ├── Lesson.java │ │ │ │ └── User.java │ │ │ │ ├── repositories │ │ │ │ ├── CoursesRepository.java │ │ │ │ ├── DisciplinesRepository.java │ │ │ │ ├── LessonsRepository.java │ │ │ │ └── UsersRepository.java │ │ │ │ ├── security │ │ │ │ ├── authentication │ │ │ │ │ └── TokenAuthentication.java │ │ │ │ ├── config │ │ │ │ │ └── SecurityConfig.java │ │ │ │ ├── details │ │ │ │ │ └── UsersDetailsImpl.java │ │ │ │ ├── filter │ │ │ │ │ └── TokenAuthenticationFilter.java │ │ │ │ └── providers │ │ │ │ │ └── TokenAuthenticationProvider.java │ │ │ │ └── utils │ │ │ │ └── TestDataUtil.java │ │ └── resources │ │ │ ├── application.properties │ │ │ └── http │ │ │ └── requests.http │ │ └── test │ │ └── java │ │ └── ru │ │ └── itis │ │ └── service │ │ ├── RestApiDemoApplicationTests.java │ │ └── controllers │ │ └── DisciplinesControllerTest.java ├── 45. Rabbit MQ Producers │ ├── downloaded │ │ ├── 0b5d23f5-0ca2-438e-b99c-7c226cbf3b6e.jpg │ │ └── 3e6726ad-7ead-4fb7-b4a5-85c501225232.jpg │ ├── files.txt │ ├── images.txt │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── ru │ │ └── itis │ │ ├── example1 │ │ ├── Consumer.java │ │ └── Producer.java │ │ ├── example2 │ │ ├── ImagesDownloader.java │ │ └── ImagesProducer.java │ │ ├── example3 │ │ ├── ImagesDownloader.java │ │ └── ImagesProducer.java │ │ ├── example4 │ │ ├── ImagesJpegDownloader.java │ │ ├── ImagesPngDownloader.java │ │ └── ImagesProducer.java │ │ ├── example5 │ │ ├── DocumentsDownloader.java │ │ ├── FilesAnalytics.java │ │ ├── FilesProducer.java │ │ ├── ImagesJpegDownloader.java │ │ └── ImagesPngDownloader.java │ │ └── example6 │ │ ├── Client.java │ │ ├── MainClient.java │ │ ├── MainServer.java │ │ └── Server.java ├── 46.Annotations │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── ru │ │ │ └── itis │ │ │ └── html │ │ │ └── generator │ │ │ ├── HtmlForm.java │ │ │ ├── HtmlInput.java │ │ │ ├── HtmlProcessor.java │ │ │ └── User.java │ │ └── resources │ │ └── form.html ├── 47. hateoas-service │ ├── .gitignore │ ├── .mvn │ │ └── wrapper │ │ │ ├── MavenWrapperDownloader.java │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── asciidoc │ │ │ └── apidoc.adoc │ │ ├── java │ │ │ └── ru │ │ │ │ └── itis │ │ │ │ └── hateoas │ │ │ │ └── hateoasservice │ │ │ │ ├── HateoasServiceApplication.java │ │ │ │ ├── config │ │ │ │ └── CoursesRepresentationProcessor.java │ │ │ │ ├── controllers │ │ │ │ └── CoursesController.java │ │ │ │ ├── models │ │ │ │ ├── Course.java │ │ │ │ ├── Lesson.java │ │ │ │ └── User.java │ │ │ │ ├── repositories │ │ │ │ ├── CoursesRepository.java │ │ │ │ ├── LessonsRepository.java │ │ │ │ └── UsersRepository.java │ │ │ │ └── services │ │ │ │ ├── CoursesService.java │ │ │ │ └── CoursesServiceImpl.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── ru │ │ └── itis │ │ └── hateoas │ │ └── hateoasservice │ │ ├── CoursesTest.java │ │ └── HateoasServiceApplicationTests.java ├── 48. MongoDb │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── ru │ │ │ └── itis │ │ │ └── mongo │ │ │ ├── driver │ │ │ └── Main.java │ │ │ ├── jpa │ │ │ ├── Course.java │ │ │ ├── CoursesRepository.java │ │ │ ├── Main.java │ │ │ ├── RepositoriesConfig.java │ │ │ ├── Teacher.java │ │ │ └── TeachersRepository.java │ │ │ └── spring │ │ │ ├── Course.java │ │ │ ├── Main.java │ │ │ ├── SimpleMongoConfig.java │ │ │ └── Teacher.java │ ├── База данных.png │ ├── Нормализация.svg │ └── Структура.png ├── 49. MongoHateoas │ ├── .gitignore │ ├── .mvn │ │ └── wrapper │ │ │ ├── MavenWrapperDownloader.java │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── ru │ │ │ └── itis │ │ │ └── hateoasrest │ │ │ ├── HateoasRestApplication.java │ │ │ ├── models │ │ │ ├── Course.java │ │ │ └── Teacher.java │ │ │ └── repositories │ │ │ ├── CoursesRepository.java │ │ │ └── TeachersRepository.java │ │ └── resources │ │ └── application.properties ├── 50. query-dsl-demo │ ├── .gitignore │ ├── .mvn │ │ └── wrapper │ │ │ ├── MavenWrapperDownloader.java │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── ru │ │ │ │ └── itis │ │ │ │ └── search │ │ │ │ ├── QueryDslDemoApplication.java │ │ │ │ ├── controllers │ │ │ │ └── SearchController.java │ │ │ │ ├── dto │ │ │ │ ├── UserDto.java │ │ │ │ └── UserRequest.java │ │ │ │ ├── models │ │ │ │ ├── Comment.java │ │ │ │ ├── Course.java │ │ │ │ ├── Lesson.java │ │ │ │ ├── Role.java │ │ │ │ ├── User.java │ │ │ │ └── UserState.java │ │ │ │ └── repositories │ │ │ │ ├── AccountsByRequestRepository.java │ │ │ │ ├── AccountsByRequestRepositoryImpl.java │ │ │ │ ├── AccountsRepository.java │ │ │ │ ├── CommentsRepository.java │ │ │ │ ├── CoursesRepository.java │ │ │ │ └── LessonsRepository.java │ │ └── resources │ │ │ ├── application.properties │ │ │ └── http │ │ │ └── requests.http │ │ └── test │ │ └── java │ │ └── ru │ │ └── itis │ │ └── search │ │ └── QueryDslDemoApplicationTests.java ├── 51. Reactive │ ├── PureReactive │ │ ├── images.txt │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── ru │ │ │ └── itis │ │ │ └── files │ │ │ ├── app │ │ │ └── Main.java │ │ │ ├── dto │ │ │ └── FileInfo.java │ │ │ ├── publishers │ │ │ ├── FilesInfoService.java │ │ │ ├── FilesInfoServiceImpl.java │ │ │ ├── FilesService.java │ │ │ └── FilesServiceImpl.java │ │ │ └── utils │ │ │ └── FileUtils.java │ ├── completed-service │ │ ├── .gitignore │ │ ├── .mvn │ │ │ └── wrapper │ │ │ │ ├── MavenWrapperDownloader.java │ │ │ │ ├── maven-wrapper.jar │ │ │ │ └── maven-wrapper.properties │ │ ├── images.txt │ │ ├── mvnw │ │ ├── mvnw.cmd │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ ├── java │ │ │ │ └── ru │ │ │ │ │ └── itis │ │ │ │ │ └── files │ │ │ │ │ ├── CompletedServiceApplication.java │ │ │ │ │ ├── controllers │ │ │ │ │ └── CompletedController.java │ │ │ │ │ ├── dto │ │ │ │ │ └── FileInfo.java │ │ │ │ │ └── services │ │ │ │ │ ├── CompletedMimeServiceImpl.java │ │ │ │ │ └── CompletedService.java │ │ │ └── resources │ │ │ │ ├── application.properties │ │ │ │ └── static │ │ │ │ └── index.html │ │ │ └── test │ │ │ └── java │ │ │ └── ru │ │ │ └── itis │ │ │ └── files │ │ │ └── FilesServiceApplicationTests.java │ ├── files-service │ │ ├── .gitignore │ │ ├── .mvn │ │ │ └── wrapper │ │ │ │ ├── MavenWrapperDownloader.java │ │ │ │ ├── maven-wrapper.jar │ │ │ │ └── maven-wrapper.properties │ │ ├── images.txt │ │ ├── mvnw │ │ ├── mvnw.cmd │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ ├── java │ │ │ │ └── ru │ │ │ │ │ └── itis │ │ │ │ │ └── files │ │ │ │ │ ├── FilesServiceApplication.java │ │ │ │ │ ├── controllers │ │ │ │ │ └── FilesController.java │ │ │ │ │ ├── dto │ │ │ │ │ └── FileInfo.java │ │ │ │ │ └── services │ │ │ │ │ ├── FilesService.java │ │ │ │ │ └── FilesServiceImpl.java │ │ │ └── resources │ │ │ │ └── application.properties │ │ │ └── test │ │ │ └── java │ │ │ └── ru │ │ │ └── itis │ │ │ └── files │ │ │ └── FilesServiceApplicationTests.java │ ├── mimes-service │ │ ├── .gitignore │ │ ├── .mvn │ │ │ └── wrapper │ │ │ │ ├── MavenWrapperDownloader.java │ │ │ │ ├── maven-wrapper.jar │ │ │ │ └── maven-wrapper.properties │ │ ├── images.txt │ │ ├── mvnw │ │ ├── mvnw.cmd │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ ├── java │ │ │ │ └── ru │ │ │ │ │ └── itis │ │ │ │ │ └── files │ │ │ │ │ ├── FilesServiceApplication.java │ │ │ │ │ ├── controllers │ │ │ │ │ └── MimesController.java │ │ │ │ │ ├── dto │ │ │ │ │ └── FileInfo.java │ │ │ │ │ └── services │ │ │ │ │ ├── FileMimeService.java │ │ │ │ │ └── FilesMimeServiceImpl.java │ │ │ └── resources │ │ │ │ └── application.properties │ │ │ └── test │ │ │ └── java │ │ │ └── ru │ │ │ └── itis │ │ │ └── files │ │ │ └── FilesServiceApplicationTests.java │ └── sizes-service │ │ ├── .gitignore │ │ ├── .mvn │ │ └── wrapper │ │ │ ├── MavenWrapperDownloader.java │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ │ ├── images.txt │ │ ├── mvnw │ │ ├── mvnw.cmd │ │ ├── pom.xml │ │ └── src │ │ ├── main │ │ ├── java │ │ │ └── ru │ │ │ │ └── itis │ │ │ │ └── files │ │ │ │ ├── FilesServiceApplication.java │ │ │ │ ├── controllers │ │ │ │ └── SizesController.java │ │ │ │ ├── dto │ │ │ │ └── FileInfo.java │ │ │ │ └── services │ │ │ │ ├── FileSizeService.java │ │ │ │ └── FilesSizeServiceImpl.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── ru │ │ └── itis │ │ └── files │ │ └── FilesServiceApplicationTests.java └── 52. JwtRedis │ ├── .gitignore │ ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── ru │ │ │ └── itis │ │ │ └── api │ │ │ ├── JwtRedisApplication.java │ │ │ ├── controllers │ │ │ ├── LoginController.java │ │ │ ├── TeachersController.java │ │ │ └── UsersController.java │ │ │ ├── dto │ │ │ ├── EmailPasswordDto.java │ │ │ ├── TeacherDto.java │ │ │ └── TokenDto.java │ │ │ ├── models │ │ │ ├── Teacher.java │ │ │ └── User.java │ │ │ ├── redis │ │ │ ├── models │ │ │ │ └── RedisUser.java │ │ │ ├── repository │ │ │ │ ├── BlacklistRepositoryRedisTemplateImpl.java │ │ │ │ └── RedisUsersRepository.java │ │ │ └── services │ │ │ │ ├── RedisUsersService.java │ │ │ │ └── RedisUsersServiceImpl.java │ │ │ ├── repository │ │ │ ├── BlacklistRepository.java │ │ │ ├── TeachersRepository.java │ │ │ └── UsersRepository.java │ │ │ ├── security │ │ │ ├── config │ │ │ │ └── SecurityConfig.java │ │ │ └── jwt │ │ │ │ ├── JwtAuthentication.java │ │ │ │ ├── JwtAuthenticationFilter.java │ │ │ │ ├── JwtAuthenticationProvider.java │ │ │ │ └── JwtLogoutFilter.java │ │ │ └── services │ │ │ ├── JwtBlacklistService.java │ │ │ ├── JwtBlacklistServiceImpl.java │ │ │ ├── LoginService.java │ │ │ ├── LoginServiceImpl.java │ │ │ ├── TeachersService.java │ │ │ ├── TeachersServiceImpl.java │ │ │ ├── UsersService.java │ │ │ └── UsersServiceImpl.java │ └── resources │ │ ├── application.properties │ │ └── http │ │ └── requests.http │ └── test │ └── java │ └── ru │ └── itis │ └── api │ └── JwtRedisApplicationTests.java └── Themes ├── # 01. Базы даных.md ├── # 02. Базы данных в Java.md ├── # 03. Клиент-серверное взаимодействие.md ├── # 04. NodeJs.md ├── # 05. Сборка приложений.md ├── # 06. Prepared Statements.md ├── # 07. Spring Context.md └── ДЗ.md /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | 3 | # Mobile Tools for Java (J2ME) 4 | .mtj.tmp/ 5 | 6 | # Package Files # 7 | *.jar 8 | *.war 9 | *.ear 10 | 11 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 12 | hs_err_pid* 13 | .settings/ 14 | .project 15 | .classpath 16 | .springBeans 17 | **/target/ 18 | /commit.txt 19 | /*/logs/ 20 | /*/wrk/ 21 | effective-pom.xml 22 | effective-settings.xml 23 | /*/.gwt/ 24 | .cache 25 | .idea/ 26 | *.iml 27 | *.log 28 | *.lck 29 | *.jar 30 | */dependency-reduced-pom.xml 31 | node_modules 32 | -------------------------------------------------------------------------------- /Documents/Отчет.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarselSidikov/JAVA_ENTERPRISE_3/be49e21a250a65a28835e168c2d83e85d01662c6/Documents/Отчет.docx -------------------------------------------------------------------------------- /Projects/01. Jdbc Example/db.properties: -------------------------------------------------------------------------------- 1 | db.password=qwerty007 2 | db.username=postgres 3 | db.url=jdbc:postgresql://localhost:5432/java_itis -------------------------------------------------------------------------------- /Projects/01. Jdbc Example/src/ru/itis/repositories/CrudRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.repositories; 2 | 3 | import javax.swing.text.html.Option; 4 | import java.util.List; 5 | import java.util.Optional; 6 | 7 | public interface CrudRepository { 8 | void save(T model); 9 | void update(T model); 10 | void delete(ID id); 11 | Optional find(ID id); 12 | 13 | List findAll(); 14 | } 15 | -------------------------------------------------------------------------------- /Projects/01. Jdbc Example/src/ru/itis/repositories/RowMapper.java: -------------------------------------------------------------------------------- 1 | package ru.itis.repositories; 2 | 3 | import java.sql.ResultSet; 4 | import java.sql.SQLException; 5 | 6 | public interface RowMapper { 7 | T mapRow(ResultSet row) throws SQLException; 8 | } 9 | -------------------------------------------------------------------------------- /Projects/01. Jdbc Example/src/ru/itis/repositories/UsersRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.repositories; 2 | 3 | import ru.itis.models.User; 4 | 5 | import java.util.Optional; 6 | 7 | public interface UsersRepository extends CrudRepository { 8 | Optional findOneByFirstName(String firstName); 9 | } 10 | -------------------------------------------------------------------------------- /Projects/02. HTML Example/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |
5 | 6 | 7 |
8 |
9 | 10 | -------------------------------------------------------------------------------- /Projects/03. NodeJsExample/app/routes/index.js: -------------------------------------------------------------------------------- 1 | // подключаем модуль users_routes 2 | const usersRoutes = require('./users_routes'); 3 | // создаем функцию для export-а, именно ее вызываем в server.js 4 | module.exports = function(app, fs) { 5 | // вызываем функцию из users_routes для обработки запросов 6 | usersRoutes(app, fs); 7 | }; -------------------------------------------------------------------------------- /Projects/03. NodeJsExample/app/routes/users_routes.js: -------------------------------------------------------------------------------- 1 | bodyParser = require('body-parser').json(); 2 | 3 | // описываем фунцию для обработки post-запроса на url /users 4 | module.exports = function (app, fs) { 5 | app.post('/users', bodyParser, function (request, response) { 6 | // вытаскиваю тело в формате JSON 7 | var body = request.body; 8 | console.log(body); 9 | // записываю его в файл 10 | fs.appendFile('data.txt', body.name + ' ' + body.surname + '\n', 11 | function (err) { 12 | if (err) throw err; 13 | console.log('Saved!'); 14 | response.redirect("/html/index.html"); 15 | }); 16 | }); 17 | app.get('/users', function (request, response) { 18 | fs.readFile('data.txt', 'utf-8', function(err, data) { 19 | var lines = data.split('\n'); 20 | 21 | var result = []; 22 | for (var i = 0; i < lines.length; i++) { 23 | result.push({'name' : lines[i].split(' ')[0], 24 | 'surname': lines[i].split(' ')[1]}); 25 | } 26 | response.setHeader('Content-Type', 'application/json'); 27 | response.send(JSON.stringify(result)); 28 | }); 29 | }); 30 | }; -------------------------------------------------------------------------------- /Projects/03. NodeJsExample/data.txt: -------------------------------------------------------------------------------- 1 | Марсель Сидиков 2 | Дария Шагиева 3 | Максим Поздеев 4 | Эмиль Пашаев 5 | Ильнур Сагитов 6 | Марат Исангулов 7 | Даша Выпендрежница 8 | Данила Исаичкин 9 | Аделя Гариева 10 | Айрат Гатин 11 | -------------------------------------------------------------------------------- /Projects/03. NodeJsExample/server.js: -------------------------------------------------------------------------------- 1 | // Объявляем четыре константы, каждая из констант 2 | // содержит модуль из определенной библиотеки 3 | 4 | // для отдачи статики 5 | const express = require('express'); 6 | // создаем объект для работы 7 | const app = express(); 8 | // для работы с файловым хранилищем 9 | const fs = require('fs'); 10 | // для обработки тела post-запросов 11 | const bodyParser = require('body-parser'); 12 | // подключаем его к модулю express 13 | app.use(bodyParser.urlencoded({ extended: true })); 14 | // вызываем функцию для обработки маршутов из папки 15 | // routes (конкретно файл index.js, в эту функцию 16 | // передаем объект express и объект файлового хранилища 17 | require('./app/routes')(app, fs); 18 | // говорим, что раздаем папку public 19 | app.use(express.static('public')); 20 | app.listen(80); 21 | console.log("Server started at 80"); -------------------------------------------------------------------------------- /Projects/05. Generics And Strings/src/ru/itis/generics/Collection.java: -------------------------------------------------------------------------------- 1 | package ru.itis.generics; 2 | 3 | public interface Collection { 4 | void add(A a); 5 | } 6 | -------------------------------------------------------------------------------- /Projects/05. Generics And Strings/src/ru/itis/generics/LinkedList.java: -------------------------------------------------------------------------------- 1 | package ru.itis.generics; 2 | 3 | public class LinkedList implements List { 4 | 5 | private Node head; 6 | 7 | private static class Node { 8 | D value; 9 | Node next; 10 | } 11 | 12 | @Override 13 | public void add(C c) { 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Projects/05. Generics And Strings/src/ru/itis/generics/List.java: -------------------------------------------------------------------------------- 1 | package ru.itis.generics; 2 | 3 | public interface List extends Collection { 4 | } 5 | -------------------------------------------------------------------------------- /Projects/05. Generics And Strings/src/ru/itis/generics/Main.java: -------------------------------------------------------------------------------- 1 | package ru.itis.generics; 2 | 3 | public class Main { 4 | 5 | public static void main(String[] args) { 6 | Collection collection = new LinkedList(); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Projects/05. Generics And Strings/src/ru/itis/strings/Main.java: -------------------------------------------------------------------------------- 1 | package ru.itis.strings; 2 | 3 | public class Main { 4 | public static void main(String[] args) { 5 | String s1 = new String("Hello"); 6 | String s2 = new String("Hello"); 7 | System.out.println(s1 == s2); 8 | String s3 = "Hello"; 9 | String s5 = "Hell" + "o"; 10 | String s4 = "Hello"; 11 | System.out.println(s3 == s4); 12 | System.out.println(s1 == s4); 13 | System.out.println(s1.intern() == s4.intern()); 14 | System.out.println(s5 == s4); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Projects/05. Generics And Strings/src/ru/itis/wrappers/Main.java: -------------------------------------------------------------------------------- 1 | package ru.itis.wrappers; 2 | 3 | import java.util.List; 4 | 5 | public class Main { 6 | public static void main(String[] args) { 7 | Integer i1 = new Integer(5); 8 | // autoboxing 9 | Integer i = 5; 10 | Integer i3 = 5; 11 | // autounboxing 12 | int x = i; 13 | int y = i1.intValue(); 14 | 15 | Integer a = 123; 16 | Integer b = 123; 17 | 18 | Integer a1 = 129; 19 | Integer b1 = 129; 20 | System.out.println(a == b); // true 21 | System.out.println(a1 == b1); // false 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Projects/05. Generics And Strings/temp.md: -------------------------------------------------------------------------------- 1 | 135 - верхняя граница кеша 2 | 3 | int i = 135 4 | 5 | h = Math.min(135, Integer.MAX_VALUE - 128 -1); 6 | 7 | размер кэша - (135 - -128 + 1) = 264 8 | 9 | 18 10 | return IntegerCache.cache[18 + 128]; // cache 11 | -------------------------------------------------------------------------------- /Projects/06. Thread Pool/out/production/# 54. Thread Pool/META-INF/# 54. Thread Pool.kotlin_module: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /Projects/06. Thread Pool/src/ru/itis/Main.java: -------------------------------------------------------------------------------- 1 | package ru.itis; 2 | 3 | public class Main { 4 | public static void main(String[] args) { 5 | ThreadPool threadPool = new ThreadPool(3); 6 | 7 | Runnable task1 = () -> { 8 | for (int i = 0; i < 100; i++) { 9 | System.out.println("Hello " + Thread.currentThread().getName()); 10 | } 11 | }; 12 | 13 | Runnable task2 = () -> { 14 | for (int i = 0; i < 100; i++) { 15 | System.out.println("Bye " + Thread.currentThread().getName()); 16 | } 17 | }; 18 | 19 | Runnable task3 = () -> { 20 | for (int i = 0; i < 100; i++) { 21 | System.out.println("Marsel " + Thread.currentThread().getName()); 22 | } 23 | }; 24 | 25 | threadPool.submit(task1); 26 | threadPool.submit(task2); 27 | threadPool.submit(task3); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Projects/06. Thread Pool/src/ru/itis/MainExecutorService.java: -------------------------------------------------------------------------------- 1 | package ru.itis; 2 | 3 | import java.util.concurrent.ExecutorService; 4 | import java.util.concurrent.Executors; 5 | 6 | public class MainExecutorService { 7 | public static void main(String[] args) { 8 | ExecutorService executorService = Executors.newFixedThreadPool(3); 9 | 10 | Runnable task1 = () -> { 11 | for (int i = 0; i < 100; i++) { 12 | System.out.println("Hello " + Thread.currentThread().getName()); 13 | } 14 | }; 15 | 16 | Runnable task2 = () -> { 17 | for (int i = 0; i < 100; i++) { 18 | System.out.println("Bye " + Thread.currentThread().getName()); 19 | } 20 | }; 21 | 22 | Runnable task3 = () -> { 23 | for (int i = 0; i < 100; i++) { 24 | System.out.println("Marsel " + Thread.currentThread().getName()); 25 | } 26 | }; 27 | 28 | executorService.submit(task1); 29 | executorService.submit(task2); 30 | executorService.submit(task3); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Projects/06. Thread Pool/src/ru/itis/runnable/CustomThread.java: -------------------------------------------------------------------------------- 1 | package ru.itis.runnable; 2 | 3 | public class CustomThread extends Thread { 4 | @Override 5 | public void run() { 6 | for (int i = 0; i < 100; i++) { 7 | System.out.println(i + " " + Thread.currentThread().getName()); 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Projects/06. Thread Pool/src/ru/itis/runnable/CustomThreadRunnable.java: -------------------------------------------------------------------------------- 1 | package ru.itis.runnable; 2 | 3 | public class CustomThreadRunnable implements Runnable { 4 | @Override 5 | public void run() { 6 | for (int i = 0; i < 100; i++) { 7 | System.out.println(i + " " + Thread.currentThread().getName()); 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Projects/06. Thread Pool/src/ru/itis/runnable/Main.java: -------------------------------------------------------------------------------- 1 | package ru.itis.runnable; 2 | 3 | public class Main { 4 | 5 | public static void main(String[] args) { 6 | CustomThread customThread = new CustomThread(); 7 | customThread.start(); 8 | customThread.run(); 9 | 10 | CustomThreadRunnable runnable = new CustomThreadRunnable(); 11 | Thread thread = new Thread(runnable); 12 | thread.start(); 13 | 14 | Runnable lambdaRunnable = () -> { 15 | for (int i = 0; i < 100; i++) { 16 | System.out.println(i + Thread.currentThread().getName()); 17 | } 18 | }; 19 | 20 | Thread anotherThread = new Thread(lambdaRunnable); 21 | anotherThread.start(); 22 | 23 | Thread oneMoreThread = new Thread( 24 | () -> { 25 | for (int i = 0; i < 100; i++) { 26 | System.out.println("Hello"); 27 | } 28 | } 29 | ); 30 | oneMoreThread.start(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Projects/07. Simple Maven Project/src/main/java/Program.java: -------------------------------------------------------------------------------- 1 | class Program { 2 | public static void main(String[] args) { 3 | System.out.println("Hello!"); 4 | } 5 | } -------------------------------------------------------------------------------- /Projects/08. JavaSocket/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | ru.itis 8 | java-sockets 9 | 0.1 10 | 11 | 12 | 13 | org.apache.maven.plugins 14 | maven-compiler-plugin 15 | 16 | 1.7 17 | 1.7 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Projects/08. JavaSocket/src/main/java/ru/itis/sockets/programs/clients/ProgramClientChatStart.java: -------------------------------------------------------------------------------- 1 | package ru.itis.sockets.programs.clients; 2 | 3 | import ru.itis.sockets.clients.SocketClient; 4 | 5 | import java.util.Scanner; 6 | 7 | /** 8 | * 12.02.2019 9 | * ProgramClientChatStart 10 | * 11 | * @author Sidikov Marsel (First Software Engineering Platform) 12 | * @version v1.0 13 | */ 14 | public class ProgramClientChatStart { 15 | public static void main(String[] args) { 16 | Scanner scanner = new Scanner(System.in); 17 | SocketClient client = new SocketClient(); 18 | client.startConnection("127.0.0.1", 6666); 19 | while (true) { 20 | String message = scanner.nextLine(); 21 | client.sendMessage(message); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Projects/08. JavaSocket/src/main/java/ru/itis/sockets/programs/clients/ProgramClientGreetingStart.java: -------------------------------------------------------------------------------- 1 | package ru.itis.sockets.programs.clients; 2 | 3 | import ru.itis.sockets.clients.SocketClient; 4 | 5 | public class ProgramClientGreetingStart { 6 | public static void main(String[] args) { 7 | // создали объект клиента 8 | SocketClient client = new SocketClient(); 9 | // подключились к серверу 10 | client.startConnection("127.0.0.1", 6666); 11 | // отправляете сообщение и получаете ответ 12 | client.sendMessage("hello server"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Projects/08. JavaSocket/src/main/java/ru/itis/sockets/programs/servers/ProgramChatMultiServer.java: -------------------------------------------------------------------------------- 1 | package ru.itis.sockets.programs.servers; 2 | 3 | import ru.itis.sockets.servers.ChatMultiServer; 4 | 5 | public class ProgramChatMultiServer { 6 | public static void main(String[] args) { 7 | ChatMultiServer server = new ChatMultiServer(); 8 | server.start(6666); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Projects/08. JavaSocket/src/main/java/ru/itis/sockets/programs/servers/ProgramServerStart.java: -------------------------------------------------------------------------------- 1 | package ru.itis.sockets.programs.servers; 2 | 3 | import ru.itis.sockets.servers.GreetServer; 4 | 5 | public class ProgramServerStart { 6 | public static void main(String[] args) { 7 | // создаем экземпляр сервера 8 | GreetServer server = new GreetServer(); 9 | // размещаем сокет на порту 6666 10 | server.start(6666); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Projects/09. JSON Example/src/main/java/AuthData.java: -------------------------------------------------------------------------------- 1 | public class AuthData { 2 | private String email; 3 | private String password; 4 | 5 | public AuthData() { 6 | } 7 | 8 | public String getEmail() { 9 | return email; 10 | } 11 | 12 | public void setEmail(String email) { 13 | this.email = email; 14 | } 15 | 16 | public String getPassword() { 17 | return password; 18 | } 19 | 20 | public void setPassword(String password) { 21 | this.password = password; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Projects/09. JSON Example/src/main/java/User.java: -------------------------------------------------------------------------------- 1 | import java.util.List; 2 | 3 | public class User { 4 | private String firstName; 5 | private String lastName; 6 | 7 | private Integer age; 8 | 9 | private List marks; 10 | 11 | private AuthData authData; 12 | 13 | public User() { 14 | } 15 | 16 | public String getFirstName() { 17 | return firstName; 18 | } 19 | 20 | public void setFirstName(String firstName) { 21 | this.firstName = firstName; 22 | } 23 | 24 | public String getLastName() { 25 | return lastName; 26 | } 27 | 28 | public void setLastName(String lastName) { 29 | this.lastName = lastName; 30 | } 31 | 32 | public Integer getAge() { 33 | return age; 34 | } 35 | 36 | public void setAge(Integer age) { 37 | this.age = age; 38 | } 39 | 40 | public List getMarks() { 41 | return marks; 42 | } 43 | 44 | public void setMarks(List marks) { 45 | this.marks = marks; 46 | } 47 | 48 | public AuthData getAuthData() { 49 | return authData; 50 | } 51 | 52 | public void setAuthData(AuthData authData) { 53 | this.authData = authData; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Projects/10. Architecture/src/Main.java: -------------------------------------------------------------------------------- 1 | import ru.itis.context.ApplicationContext; 2 | import ru.itis.context.ApplicationContextReflectionBased; 3 | import ru.itis.dispatcher.RequestsDispatcher; 4 | import ru.itis.services.SignInService; 5 | 6 | public class Main { 7 | 8 | public static void main(String[] args) { 9 | ApplicationContext context = new ApplicationContextReflectionBased(); 10 | SignInService service = context.getComponent(SignInService.class, "signInService"); 11 | RequestsDispatcher dispatcher = new RequestsDispatcher(service); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Projects/10. Architecture/src/ru/itis/context/ApplicationContext.java: -------------------------------------------------------------------------------- 1 | package ru.itis.context; 2 | 3 | // объект этого класса 4 | // создает объекты 5 | // всех интерфейсов Component с помощью рефлексии 6 | public interface ApplicationContext { 7 | // при получении компонента, если у этого компонента 8 | // есть зависимости - то нужно их тоже проставить 9 | T getComponent(Class componentType, String name); 10 | } 11 | -------------------------------------------------------------------------------- /Projects/10. Architecture/src/ru/itis/context/ApplicationContextReflectionBased.java: -------------------------------------------------------------------------------- 1 | package ru.itis.context; 2 | 3 | public class ApplicationContextReflectionBased implements ApplicationContext { 4 | @Override 5 | public Component getComponent(String name) { 6 | return null; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Projects/10. Architecture/src/ru/itis/context/Component.java: -------------------------------------------------------------------------------- 1 | package ru.itis.context; 2 | 3 | public interface Component { 4 | String getName(); 5 | } 6 | -------------------------------------------------------------------------------- /Projects/10. Architecture/src/ru/itis/dispatcher/RequestsDispatcher.java: -------------------------------------------------------------------------------- 1 | package ru.itis.dispatcher; 2 | 3 | import ru.itis.dto.Dto; 4 | import ru.itis.protocol.Request; 5 | import ru.itis.services.SignInService; 6 | 7 | public class RequestsDispatcher { 8 | 9 | private SignInService service; 10 | 11 | public RequestsDispatcher(SignInService service) { 12 | this.service = service; 13 | } 14 | 15 | public Dto doDispatch(Request request) { 16 | if (request.getCommand().equals("signIn")) { 17 | return service.signIn(request.getParameter("login"), 18 | request.getParameter("password")); 19 | } else throw new IllegalArgumentException(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Projects/10. Architecture/src/ru/itis/dto/Dto.java: -------------------------------------------------------------------------------- 1 | package ru.itis.dto; 2 | 3 | public interface Dto { 4 | } 5 | -------------------------------------------------------------------------------- /Projects/10. Architecture/src/ru/itis/dto/UserDto.java: -------------------------------------------------------------------------------- 1 | package ru.itis.dto; 2 | 3 | import ru.itis.models.User; 4 | 5 | public class UserDto implements Dto { 6 | private Long id; 7 | private String login; 8 | 9 | // TODO: вместо конструктора Builder 10 | private UserDto(Long id, String login) { 11 | this.id = id; 12 | this.login = login; 13 | } 14 | 15 | public static UserDto from(User user) { 16 | return new UserDto(user.getId(), user.getPassword()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Projects/10. Architecture/src/ru/itis/models/User.java: -------------------------------------------------------------------------------- 1 | package ru.itis.models; 2 | 3 | public class User { 4 | private Long id; 5 | private String login; 6 | private String password; 7 | 8 | public User(String login, String password) { 9 | this.login = login; 10 | this.password = password; 11 | } 12 | 13 | public String getLogin() { 14 | return login; 15 | } 16 | 17 | public Long getId() { 18 | return id; 19 | } 20 | 21 | public void setId(Long id) { 22 | this.id = id; 23 | } 24 | 25 | public void setLogin(String login) { 26 | this.login = login; 27 | } 28 | 29 | public String getPassword() { 30 | return password; 31 | } 32 | 33 | public void setPassword(String password) { 34 | this.password = password; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Projects/10. Architecture/src/ru/itis/protocol/Request.java: -------------------------------------------------------------------------------- 1 | package ru.itis.protocol; 2 | 3 | public class Request { 4 | 5 | public String getCommand() { 6 | return "signIn"; 7 | } 8 | 9 | public String getParameter(String name) { 10 | if (name.equals("password")) { 11 | return "qwerty007"; 12 | } else { 13 | return "marsel"; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Projects/10. Architecture/src/ru/itis/protocol/RequestsHandler.java: -------------------------------------------------------------------------------- 1 | package ru.itis.protocol; 2 | 3 | import ru.itis.dispatcher.RequestsDispatcher; 4 | 5 | // обрабатывает запрос на уровне протокола 6 | public class RequestsHandler { 7 | 8 | private RequestsDispatcher dispatcher; 9 | 10 | public RequestsHandler() { 11 | this.dispatcher = new RequestsDispatcher(); 12 | } 13 | 14 | // метод-реакция на запрос 15 | public Response handleRequest(Request request) { 16 | // направление запроса куда-то дальше 17 | // чтобы диспетчер мог его перенаправить на слой логики 18 | // получили данные 19 | // обернули в протокол 20 | return Response.build(dispatcher.doDispatch(request)); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Projects/10. Architecture/src/ru/itis/protocol/Response.java: -------------------------------------------------------------------------------- 1 | package ru.itis.protocol; 2 | 3 | // объект, который относится к протоколу 4 | 5 | // например, HttpServletResponse 6 | public class Response { 7 | private T data; 8 | 9 | private Response(T data) { 10 | this.data = data; 11 | } 12 | 13 | public static Response build(E data) { 14 | return new Response<>(data); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Projects/10. Architecture/src/ru/itis/repositories/CrudRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.repositories; 2 | 3 | import java.util.List; 4 | import java.util.Optional; 5 | 6 | public interface CrudRepository { 7 | Optional findOne(ID id); 8 | List findAll(); 9 | } 10 | -------------------------------------------------------------------------------- /Projects/10. Architecture/src/ru/itis/repositories/UsersRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.repositories; 2 | 3 | import ru.itis.models.User; 4 | 5 | import java.util.Optional; 6 | 7 | public interface UsersRepository extends CrudRepository { 8 | Optional findByLogin(String login); 9 | } 10 | -------------------------------------------------------------------------------- /Projects/10. Architecture/src/ru/itis/repositories/UsersRepositoryFakeImpl.java: -------------------------------------------------------------------------------- 1 | package ru.itis.repositories; 2 | 3 | import ru.itis.context.Component; 4 | import ru.itis.models.User; 5 | 6 | import java.util.Collections; 7 | import java.util.List; 8 | import java.util.Optional; 9 | 10 | public class UsersRepositoryFakeImpl implements UsersRepository, Component { 11 | public Optional findByLogin(String login) { 12 | return Optional.ofNullable(new User("marsel", "qwerty007")); 13 | } 14 | 15 | @Override 16 | public Optional findOne(Long aLong) { 17 | return Optional.empty(); 18 | } 19 | 20 | @Override 21 | public List findAll() { 22 | return Collections.emptyList(); 23 | } 24 | 25 | @Override 26 | public String getName() { 27 | return "usersRepository"; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Projects/10. Architecture/src/ru/itis/services/SignInService.java: -------------------------------------------------------------------------------- 1 | package ru.itis.services; 2 | 3 | import ru.itis.dto.UserDto; 4 | 5 | public interface SignInService { 6 | UserDto signIn(String login, String password); 7 | } 8 | -------------------------------------------------------------------------------- /Projects/11. Servlets With Context/src/main/java/ru/itis/context/PrimitiveContext.java: -------------------------------------------------------------------------------- 1 | package ru.itis.context; 2 | 3 | import ru.itis.repositories.DataRepository; 4 | import ru.itis.repositories.DataRepositoryImpl; 5 | import ru.itis.services.SignUpService; 6 | import ru.itis.services.SignUpServiceImpl; 7 | 8 | public class PrimitiveContext { 9 | public DataRepository dataRepository() { 10 | return new DataRepositoryImpl(); 11 | } 12 | 13 | public SignUpService signUpService() { 14 | return new SignUpServiceImpl(dataRepository()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Projects/11. Servlets With Context/src/main/java/ru/itis/dto/User.java: -------------------------------------------------------------------------------- 1 | package ru.itis.dto; 2 | 3 | public class User { 4 | private Long id; 5 | private String password; 6 | 7 | public User(Long id, String password) { 8 | this.id = id; 9 | this.password = password; 10 | } 11 | 12 | public User() { 13 | } 14 | 15 | public Long getId() { 16 | return id; 17 | } 18 | 19 | public void setId(Long id) { 20 | this.id = id; 21 | } 22 | 23 | public String getPassword() { 24 | return password; 25 | } 26 | 27 | public void setPassword(String password) { 28 | this.password = password; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Projects/11. Servlets With Context/src/main/java/ru/itis/listeners/PrimitiveContextServletListener.java: -------------------------------------------------------------------------------- 1 | package ru.itis.listeners; 2 | 3 | import ru.itis.context.PrimitiveContext; 4 | 5 | import javax.servlet.ServletContext; 6 | import javax.servlet.ServletContextEvent; 7 | import javax.servlet.ServletContextListener; 8 | import javax.servlet.annotation.WebListener; 9 | 10 | @WebListener 11 | public class PrimitiveContextServletListener implements ServletContextListener { 12 | 13 | public void contextInitialized(ServletContextEvent servletContextEvent) { 14 | System.out.println("IN LISTENER"); 15 | ServletContext servletContext = servletContextEvent.getServletContext(); 16 | PrimitiveContext primitiveContext = new PrimitiveContext(); 17 | servletContext.setAttribute("componentsContext", primitiveContext); 18 | } 19 | 20 | public void contextDestroyed(ServletContextEvent servletContextEvent) { 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Projects/11. Servlets With Context/src/main/java/ru/itis/repositories/DataRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.repositories; 2 | 3 | public interface DataRepository { 4 | void save(String data); 5 | } 6 | -------------------------------------------------------------------------------- /Projects/11. Servlets With Context/src/main/java/ru/itis/repositories/DataRepositoryImpl.java: -------------------------------------------------------------------------------- 1 | package ru.itis.repositories; 2 | 3 | public class DataRepositoryImpl implements DataRepository { 4 | public void save(String data) { 5 | System.out.println("In DataRepository " + data); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Projects/11. Servlets With Context/src/main/java/ru/itis/services/SignUpService.java: -------------------------------------------------------------------------------- 1 | package ru.itis.services; 2 | 3 | public interface SignUpService { 4 | void signUp(String data); 5 | } 6 | -------------------------------------------------------------------------------- /Projects/11. Servlets With Context/src/main/java/ru/itis/services/SignUpServiceImpl.java: -------------------------------------------------------------------------------- 1 | package ru.itis.services; 2 | 3 | import ru.itis.repositories.DataRepository; 4 | 5 | public class SignUpServiceImpl implements SignUpService { 6 | 7 | private DataRepository dataRepository; 8 | 9 | public SignUpServiceImpl(DataRepository dataRepository) { 10 | this.dataRepository = dataRepository; 11 | } 12 | 13 | public void signUp(String data) { 14 | dataRepository.save(data); 15 | System.out.println("In SignUp " + data); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Projects/11. Servlets With Context/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /Projects/12. Prepared Statements/images/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarselSidikov/JAVA_ENTERPRISE_3/be49e21a250a65a28835e168c2d83e85d01662c6/Projects/12. Prepared Statements/images/1.png -------------------------------------------------------------------------------- /Projects/12. Prepared Statements/images/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarselSidikov/JAVA_ENTERPRISE_3/be49e21a250a65a28835e168c2d83e85d01662c6/Projects/12. Prepared Statements/images/2.png -------------------------------------------------------------------------------- /Projects/12. Prepared Statements/images/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarselSidikov/JAVA_ENTERPRISE_3/be49e21a250a65a28835e168c2d83e85d01662c6/Projects/12. Prepared Statements/images/3.png -------------------------------------------------------------------------------- /Projects/12. Prepared Statements/images/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarselSidikov/JAVA_ENTERPRISE_3/be49e21a250a65a28835e168c2d83e85d01662c6/Projects/12. Prepared Statements/images/4.png -------------------------------------------------------------------------------- /Projects/12. Prepared Statements/images/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarselSidikov/JAVA_ENTERPRISE_3/be49e21a250a65a28835e168c2d83e85d01662c6/Projects/12. Prepared Statements/images/5.png -------------------------------------------------------------------------------- /Projects/12. Prepared Statements/images/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarselSidikov/JAVA_ENTERPRISE_3/be49e21a250a65a28835e168c2d83e85d01662c6/Projects/12. Prepared Statements/images/6.png -------------------------------------------------------------------------------- /Projects/12. Prepared Statements/images/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarselSidikov/JAVA_ENTERPRISE_3/be49e21a250a65a28835e168c2d83e85d01662c6/Projects/12. Prepared Statements/images/7.png -------------------------------------------------------------------------------- /Projects/12. Prepared Statements/images/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarselSidikov/JAVA_ENTERPRISE_3/be49e21a250a65a28835e168c2d83e85d01662c6/Projects/12. Prepared Statements/images/8.png -------------------------------------------------------------------------------- /Projects/12. Prepared Statements/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | ru.itdrive 8 | jdbc-statements 9 | 0.1 10 | 11 | 12 | 13 | 14 | org.postgresql 15 | postgresql 16 | 42.2.9 17 | 18 | 19 | 20 | org.projectlombok 21 | lombok 22 | 1.18.10 23 | provided 24 | 25 | 26 | -------------------------------------------------------------------------------- /Projects/12. Prepared Statements/sql/queries.sql: -------------------------------------------------------------------------------- 1 | explain (costs false) select s.first_name, s.last_name, c.title 2 | from student s 3 | inner join student_course sc on s.id = sc.student_id 4 | inner join course c on sc.course_id = c.id 5 | inner join lesson l on c.id = l.course_id 6 | where l.name = 'Simple Math'; 7 | 8 | prepare get_students_by_lesson(char) as select s.first_name, s.last_name, c.title 9 | from student s 10 | inner join student_course sc on s.id = sc.student_id 11 | inner join course c on sc.course_id = c.id 12 | inner join lesson l on c.id = l.course_id 13 | where l.name = $1; 14 | 15 | explain execute get_students_by_lesson('Simple Math'); 16 | 17 | select * from pg_prepared_statements; 18 | 19 | -------------------------------------------------------------------------------- /Projects/13. Spring JDBC Example/src/main/java/ru/itis/spring/AppForSpringContext.java: -------------------------------------------------------------------------------- 1 | package ru.itis.spring; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.support.ClassPathXmlApplicationContext; 5 | import org.springframework.jdbc.core.JdbcTemplate; 6 | import ru.itis.spring.repositories.CoursesRepository; 7 | 8 | import javax.sql.DataSource; 9 | 10 | public class AppForSpringContext { 11 | public static void main(String[] args) { 12 | ApplicationContext context = new ClassPathXmlApplicationContext("context.xml"); 13 | // DataSource dataSource = context.getBean(DataSource.class); 14 | // JdbcTemplate template = context.getBean(JdbcTemplate.class); 15 | CoursesRepository coursesRepository = context.getBean(CoursesRepository.class); 16 | 17 | System.out.println(coursesRepository.findAll()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Projects/13. Spring JDBC Example/src/main/java/ru/itis/spring/models/Course.java: -------------------------------------------------------------------------------- 1 | package ru.itis.spring.models; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | @Data 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | @Builder 12 | public class Course { 13 | private Long id; 14 | private String title; 15 | } 16 | -------------------------------------------------------------------------------- /Projects/13. Spring JDBC Example/src/main/java/ru/itis/spring/models/Lesson.java: -------------------------------------------------------------------------------- 1 | package ru.itis.spring.models; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | @Data 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | @Builder 12 | public class Lesson { 13 | private Long id; 14 | private String name; 15 | } 16 | -------------------------------------------------------------------------------- /Projects/13. Spring JDBC Example/src/main/java/ru/itis/spring/repositories/CoursesRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.spring.repositories; 2 | 3 | import ru.itis.spring.models.Course; 4 | 5 | public interface CoursesRepository extends CrudRepository { 6 | } 7 | -------------------------------------------------------------------------------- /Projects/13. Spring JDBC Example/src/main/java/ru/itis/spring/repositories/CrudRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.spring.repositories; 2 | 3 | import java.util.List; 4 | import java.util.Optional; 5 | 6 | public interface CrudRepository { 7 | Optional find(ID id); 8 | List findAll(); 9 | void save(V entity); 10 | void delete(ID id); 11 | } 12 | -------------------------------------------------------------------------------- /Projects/13. Spring JDBC Example/src/main/java/ru/itis/spring/repositories/LessonsRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.spring.repositories; 2 | 3 | import ru.itis.spring.models.Lesson; 4 | 5 | public interface LessonsRepository extends CrudRepository { 6 | } 7 | -------------------------------------------------------------------------------- /Projects/13. Spring JDBC Example/src/main/java/ru/itis/spring/repositories/RowMapper.java: -------------------------------------------------------------------------------- 1 | package ru.itis.spring.repositories; 2 | 3 | import java.sql.ResultSet; 4 | import java.sql.SQLException; 5 | 6 | public interface RowMapper { 7 | T mapRow(ResultSet row) throws SQLException; 8 | } 9 | -------------------------------------------------------------------------------- /Projects/14. Servlets With Spring/src/main/java/ru/itis/servlets/listeners/SpringContextServletContextListener.java: -------------------------------------------------------------------------------- 1 | package ru.itis.servlets.listeners; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.support.ClassPathXmlApplicationContext; 5 | 6 | import javax.servlet.ServletContext; 7 | import javax.servlet.ServletContextEvent; 8 | import javax.servlet.ServletContextListener; 9 | import javax.servlet.annotation.WebListener; 10 | 11 | @WebListener 12 | public class SpringContextServletContextListener implements ServletContextListener { 13 | 14 | public void contextInitialized(ServletContextEvent servletContextEvent) { 15 | ApplicationContext springContext = new ClassPathXmlApplicationContext("context.xml"); 16 | ServletContext servletContext = servletContextEvent.getServletContext(); 17 | servletContext.setAttribute("springContext", springContext); 18 | } 19 | 20 | public void contextDestroyed(ServletContextEvent servletContextEvent) { 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Projects/14. Servlets With Spring/src/main/java/ru/itis/servlets/models/Course.java: -------------------------------------------------------------------------------- 1 | package ru.itis.servlets.models; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | @Data 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | @Builder 12 | public class Course { 13 | private Long id; 14 | private String title; 15 | } 16 | -------------------------------------------------------------------------------- /Projects/14. Servlets With Spring/src/main/java/ru/itis/servlets/repositories/CoursesRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.servlets.repositories; 2 | 3 | 4 | import ru.itis.servlets.models.Course; 5 | 6 | public interface CoursesRepository extends CrudRepository { 7 | } 8 | -------------------------------------------------------------------------------- /Projects/14. Servlets With Spring/src/main/java/ru/itis/servlets/repositories/CrudRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.servlets.repositories; 2 | 3 | import java.util.List; 4 | import java.util.Optional; 5 | 6 | public interface CrudRepository { 7 | Optional find(ID id); 8 | List findAll(); 9 | void save(V entity); 10 | void delete(ID id); 11 | } 12 | -------------------------------------------------------------------------------- /Projects/14. Servlets With Spring/src/main/java/ru/itis/servlets/services/CoursesService.java: -------------------------------------------------------------------------------- 1 | package ru.itis.servlets.services; 2 | 3 | import ru.itis.servlets.models.Course; 4 | 5 | import java.util.List; 6 | 7 | public interface CoursesService { 8 | List getAllCourses(); 9 | } 10 | -------------------------------------------------------------------------------- /Projects/14. Servlets With Spring/src/main/java/ru/itis/servlets/services/CoursesServiceImpl.java: -------------------------------------------------------------------------------- 1 | package ru.itis.servlets.services; 2 | 3 | import ru.itis.servlets.models.Course; 4 | import ru.itis.servlets.repositories.CoursesRepository; 5 | 6 | import java.util.List; 7 | 8 | public class CoursesServiceImpl implements CoursesService { 9 | 10 | private CoursesRepository coursesRepository; 11 | 12 | public CoursesServiceImpl(CoursesRepository coursesRepository) { 13 | this.coursesRepository = coursesRepository; 14 | } 15 | 16 | @Override 17 | public List getAllCourses() { 18 | return coursesRepository.findAll(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Projects/14. Servlets With Spring/src/main/webapp/WEB-INF/jsp/courses.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | <%-- 3 | Created by IntelliJ IDEA. 4 | User: Marsel 5 | Date: 25.02.2020 6 | Time: 12:50 7 | To change this template use File | Settings | File Templates. 8 | --%> 9 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 10 | 11 | 12 | Title 13 | 14 | 15 | 16 | ${course.title}
17 |
18 | 19 | 20 | -------------------------------------------------------------------------------- /Projects/14. Servlets With Spring/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /Projects/15. Servlets With Spring Java Config/src/main/java/ru/itis/servlets/config/ApplicationContextConfig.java: -------------------------------------------------------------------------------- 1 | package ru.itis.servlets.config; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.beans.factory.annotation.Qualifier; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.jdbc.core.JdbcTemplate; 7 | import org.springframework.stereotype.Component; 8 | 9 | import javax.sql.DataSource; 10 | 11 | @Component 12 | public class ApplicationContextConfig { 13 | 14 | @Autowired 15 | @Qualifier(value = "hikariDataSource") 16 | private DataSource dataSource; 17 | 18 | @Bean 19 | public JdbcTemplate jdbcTemplate() { 20 | return new JdbcTemplate(dataSource); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Projects/15. Servlets With Spring Java Config/src/main/java/ru/itis/servlets/listeners/SpringContextServletContextListener.java: -------------------------------------------------------------------------------- 1 | package ru.itis.servlets.listeners; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.support.ClassPathXmlApplicationContext; 5 | 6 | import javax.servlet.ServletContext; 7 | import javax.servlet.ServletContextEvent; 8 | import javax.servlet.ServletContextListener; 9 | import javax.servlet.annotation.WebListener; 10 | 11 | @WebListener 12 | public class SpringContextServletContextListener implements ServletContextListener { 13 | 14 | public void contextInitialized(ServletContextEvent servletContextEvent) { 15 | ApplicationContext springContext = new ClassPathXmlApplicationContext("context.xml"); 16 | ServletContext servletContext = servletContextEvent.getServletContext(); 17 | servletContext.setAttribute("springContext", springContext); 18 | } 19 | 20 | public void contextDestroyed(ServletContextEvent servletContextEvent) { 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Projects/15. Servlets With Spring Java Config/src/main/java/ru/itis/servlets/models/Course.java: -------------------------------------------------------------------------------- 1 | package ru.itis.servlets.models; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | @Data 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | @Builder 12 | public class Course { 13 | private Long id; 14 | private String title; 15 | } 16 | -------------------------------------------------------------------------------- /Projects/15. Servlets With Spring Java Config/src/main/java/ru/itis/servlets/repositories/CoursesRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.servlets.repositories; 2 | 3 | 4 | import ru.itis.servlets.models.Course; 5 | 6 | public interface CoursesRepository extends CrudRepository { 7 | } 8 | -------------------------------------------------------------------------------- /Projects/15. Servlets With Spring Java Config/src/main/java/ru/itis/servlets/repositories/CrudRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.servlets.repositories; 2 | 3 | import java.util.List; 4 | import java.util.Optional; 5 | 6 | public interface CrudRepository { 7 | Optional find(ID id); 8 | List findAll(); 9 | void save(V entity); 10 | void delete(ID id); 11 | } 12 | -------------------------------------------------------------------------------- /Projects/15. Servlets With Spring Java Config/src/main/java/ru/itis/servlets/services/CoursesService.java: -------------------------------------------------------------------------------- 1 | package ru.itis.servlets.services; 2 | 3 | import ru.itis.servlets.models.Course; 4 | 5 | import java.util.List; 6 | 7 | public interface CoursesService { 8 | List getAllCourses(); 9 | } 10 | -------------------------------------------------------------------------------- /Projects/15. Servlets With Spring Java Config/src/main/java/ru/itis/servlets/services/CoursesServiceImpl.java: -------------------------------------------------------------------------------- 1 | package ru.itis.servlets.services; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Component; 5 | import ru.itis.servlets.models.Course; 6 | import ru.itis.servlets.repositories.CoursesRepository; 7 | 8 | import java.util.List; 9 | 10 | @Component 11 | public class CoursesServiceImpl implements CoursesService { 12 | 13 | @Autowired 14 | private CoursesRepository coursesRepository; 15 | 16 | @Override 17 | public List getAllCourses() { 18 | return coursesRepository.findAll(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Projects/15. Servlets With Spring Java Config/src/main/webapp/WEB-INF/jsp/courses.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | <%-- 3 | Created by IntelliJ IDEA. 4 | User: Marsel 5 | Date: 25.02.2020 6 | Time: 12:50 7 | To change this template use File | Settings | File Templates. 8 | --%> 9 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 10 | 11 | 12 | Title 13 | 14 | 15 | 16 | ${course.title}
17 |
18 | 19 | 20 | -------------------------------------------------------------------------------- /Projects/15. Servlets With Spring Java Config/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /Projects/16. Servlets With Spring Java Config With Properties/src/main/java/ru/itis/servlets/listeners/SpringContextServletContextListener.java: -------------------------------------------------------------------------------- 1 | package ru.itis.servlets.listeners; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.support.ClassPathXmlApplicationContext; 5 | 6 | import javax.servlet.ServletContext; 7 | import javax.servlet.ServletContextEvent; 8 | import javax.servlet.ServletContextListener; 9 | import javax.servlet.annotation.WebListener; 10 | 11 | @WebListener 12 | public class SpringContextServletContextListener implements ServletContextListener { 13 | 14 | public void contextInitialized(ServletContextEvent servletContextEvent) { 15 | ApplicationContext springContext = new ClassPathXmlApplicationContext("context.xml"); 16 | ServletContext servletContext = servletContextEvent.getServletContext(); 17 | servletContext.setAttribute("springContext", springContext); 18 | } 19 | 20 | public void contextDestroyed(ServletContextEvent servletContextEvent) { 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Projects/16. Servlets With Spring Java Config With Properties/src/main/java/ru/itis/servlets/models/Course.java: -------------------------------------------------------------------------------- 1 | package ru.itis.servlets.models; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | @Data 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | @Builder 12 | public class Course { 13 | private Long id; 14 | private String title; 15 | } 16 | -------------------------------------------------------------------------------- /Projects/16. Servlets With Spring Java Config With Properties/src/main/java/ru/itis/servlets/repositories/CoursesRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.servlets.repositories; 2 | 3 | 4 | import ru.itis.servlets.models.Course; 5 | 6 | public interface CoursesRepository extends CrudRepository { 7 | } 8 | -------------------------------------------------------------------------------- /Projects/16. Servlets With Spring Java Config With Properties/src/main/java/ru/itis/servlets/repositories/CrudRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.servlets.repositories; 2 | 3 | import java.util.List; 4 | import java.util.Optional; 5 | 6 | public interface CrudRepository { 7 | Optional find(ID id); 8 | List findAll(); 9 | void save(V entity); 10 | void delete(ID id); 11 | } 12 | -------------------------------------------------------------------------------- /Projects/16. Servlets With Spring Java Config With Properties/src/main/java/ru/itis/servlets/services/CoursesService.java: -------------------------------------------------------------------------------- 1 | package ru.itis.servlets.services; 2 | 3 | import ru.itis.servlets.models.Course; 4 | 5 | import java.util.List; 6 | 7 | public interface CoursesService { 8 | List getAllCourses(); 9 | } 10 | -------------------------------------------------------------------------------- /Projects/16. Servlets With Spring Java Config With Properties/src/main/java/ru/itis/servlets/services/CoursesServiceImpl.java: -------------------------------------------------------------------------------- 1 | package ru.itis.servlets.services; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Component; 5 | import ru.itis.servlets.models.Course; 6 | import ru.itis.servlets.repositories.CoursesRepository; 7 | 8 | import java.util.List; 9 | 10 | @Component 11 | public class CoursesServiceImpl implements CoursesService { 12 | 13 | @Autowired 14 | private CoursesRepository coursesRepository; 15 | 16 | @Override 17 | public List getAllCourses() { 18 | return coursesRepository.findAll(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Projects/16. Servlets With Spring Java Config With Properties/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | db.driver=org.postgresql.Driver 2 | db.url=jdbc:postgresql://localhost:5432/education_center 3 | db.user=postgres 4 | db.password=qwerty007 -------------------------------------------------------------------------------- /Projects/16. Servlets With Spring Java Config With Properties/src/main/resources/context.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Projects/16. Servlets With Spring Java Config With Properties/src/main/webapp/WEB-INF/jsp/courses.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | <%-- 3 | Created by IntelliJ IDEA. 4 | User: Marsel 5 | Date: 25.02.2020 6 | Time: 12:50 7 | To change this template use File | Settings | File Templates. 8 | --%> 9 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 10 | 11 | 12 | Title 13 | 14 | 15 | 16 | ${course.title}
17 |
18 | 19 | 20 | -------------------------------------------------------------------------------- /Projects/16. Servlets With Spring Java Config With Properties/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /Projects/17. Servlets With Spring Full Java Config With Properties/src/main/java/ru/itis/servlets/listeners/SpringContextServletContextListener.java: -------------------------------------------------------------------------------- 1 | package ru.itis.servlets.listeners; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 5 | import org.springframework.context.support.ClassPathXmlApplicationContext; 6 | import ru.itis.servlets.config.ApplicationContextConfig; 7 | 8 | import javax.servlet.ServletContext; 9 | import javax.servlet.ServletContextEvent; 10 | import javax.servlet.ServletContextListener; 11 | import javax.servlet.annotation.WebListener; 12 | 13 | @WebListener 14 | public class SpringContextServletContextListener implements ServletContextListener { 15 | 16 | public void contextInitialized(ServletContextEvent servletContextEvent) { 17 | ApplicationContext springContext = new AnnotationConfigApplicationContext(ApplicationContextConfig.class); 18 | ServletContext servletContext = servletContextEvent.getServletContext(); 19 | servletContext.setAttribute("springContext", springContext); 20 | } 21 | 22 | public void contextDestroyed(ServletContextEvent servletContextEvent) { 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Projects/17. Servlets With Spring Full Java Config With Properties/src/main/java/ru/itis/servlets/models/Course.java: -------------------------------------------------------------------------------- 1 | package ru.itis.servlets.models; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | @Data 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | @Builder 12 | public class Course { 13 | private Long id; 14 | private String title; 15 | } 16 | -------------------------------------------------------------------------------- /Projects/17. Servlets With Spring Full Java Config With Properties/src/main/java/ru/itis/servlets/repositories/CoursesRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.servlets.repositories; 2 | 3 | 4 | import ru.itis.servlets.models.Course; 5 | 6 | public interface CoursesRepository extends CrudRepository { 7 | } 8 | -------------------------------------------------------------------------------- /Projects/17. Servlets With Spring Full Java Config With Properties/src/main/java/ru/itis/servlets/repositories/CrudRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.servlets.repositories; 2 | 3 | import java.util.List; 4 | import java.util.Optional; 5 | 6 | public interface CrudRepository { 7 | Optional find(ID id); 8 | List findAll(); 9 | void save(V entity); 10 | void delete(ID id); 11 | } 12 | -------------------------------------------------------------------------------- /Projects/17. Servlets With Spring Full Java Config With Properties/src/main/java/ru/itis/servlets/services/CoursesService.java: -------------------------------------------------------------------------------- 1 | package ru.itis.servlets.services; 2 | 3 | import ru.itis.servlets.models.Course; 4 | 5 | import java.util.List; 6 | 7 | public interface CoursesService { 8 | List getAllCourses(); 9 | } 10 | -------------------------------------------------------------------------------- /Projects/17. Servlets With Spring Full Java Config With Properties/src/main/java/ru/itis/servlets/services/CoursesServiceImpl.java: -------------------------------------------------------------------------------- 1 | package ru.itis.servlets.services; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Component; 5 | import ru.itis.servlets.models.Course; 6 | import ru.itis.servlets.repositories.CoursesRepository; 7 | 8 | import java.util.List; 9 | 10 | @Component(value = "myCoursesService") 11 | public class CoursesServiceImpl implements CoursesService { 12 | 13 | @Autowired 14 | private CoursesRepository coursesRepository; 15 | 16 | @Override 17 | public List getAllCourses() { 18 | return coursesRepository.findAll(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Projects/17. Servlets With Spring Full Java Config With Properties/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | db.driver=org.postgresql.Driver 2 | db.url=jdbc:postgresql://localhost:5432/education_center 3 | db.user=postgres 4 | db.password=qwerty007 -------------------------------------------------------------------------------- /Projects/17. Servlets With Spring Full Java Config With Properties/src/main/webapp/WEB-INF/jsp/courses.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | <%-- 3 | Created by IntelliJ IDEA. 4 | User: Marsel 5 | Date: 25.02.2020 6 | Time: 12:50 7 | To change this template use File | Settings | File Templates. 8 | --%> 9 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 10 | 11 | 12 | Title 13 | 14 | 15 | 16 | ${course.title}
17 |
18 | 19 | 20 | -------------------------------------------------------------------------------- /Projects/17. Servlets With Spring Full Java Config With Properties/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /Projects/18. Dispatcher Servlet/src/main/java/ru/itis/servlets/controllers/FilesController.java: -------------------------------------------------------------------------------- 1 | package ru.itis.servlets.controllers; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.PathVariable; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RequestMethod; 7 | import org.springframework.web.bind.annotation.RequestParam; 8 | import org.springframework.web.multipart.MultipartFile; 9 | import org.springframework.web.servlet.ModelAndView; 10 | 11 | @Controller 12 | public class FilesController { 13 | @RequestMapping(value = "/files", method = RequestMethod.POST) 14 | public ModelAndView uploadFile(@RequestParam("file") MultipartFile multipartFile) { 15 | int i = 0; 16 | return null; 17 | } 18 | 19 | // localhost:8080/files/123809183093qsdas09df8af.jpeg 20 | 21 | @RequestMapping(value ="/files/{file-name:.+}" , method = RequestMethod.GET) 22 | public ModelAndView getFile(@PathVariable("file-name") String fileName) { 23 | // TODO: найти на диске 24 | // TODO: отдать пользователю 25 | return null; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Projects/18. Dispatcher Servlet/src/main/java/ru/itis/servlets/listeners/SpringContextServletContextListener.java: -------------------------------------------------------------------------------- 1 | package ru.itis.servlets.listeners; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 5 | import org.springframework.context.support.ClassPathXmlApplicationContext; 6 | import ru.itis.servlets.config.ApplicationContextConfig; 7 | 8 | import javax.servlet.ServletContext; 9 | import javax.servlet.ServletContextEvent; 10 | import javax.servlet.ServletContextListener; 11 | import javax.servlet.annotation.WebListener; 12 | 13 | @WebListener 14 | public class SpringContextServletContextListener implements ServletContextListener { 15 | 16 | public void contextInitialized(ServletContextEvent servletContextEvent) { 17 | ApplicationContext springContext = new AnnotationConfigApplicationContext(ApplicationContextConfig.class); 18 | ServletContext servletContext = servletContextEvent.getServletContext(); 19 | servletContext.setAttribute("springContext", springContext); 20 | } 21 | 22 | public void contextDestroyed(ServletContextEvent servletContextEvent) { 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Projects/18. Dispatcher Servlet/src/main/java/ru/itis/servlets/models/Course.java: -------------------------------------------------------------------------------- 1 | package ru.itis.servlets.models; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | @Data 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | @Builder 12 | public class Course { 13 | private Long id; 14 | private String title; 15 | } 16 | -------------------------------------------------------------------------------- /Projects/18. Dispatcher Servlet/src/main/java/ru/itis/servlets/models/FileInfo.java: -------------------------------------------------------------------------------- 1 | package ru.itis.servlets.models; 2 | 3 | import lombok.*; 4 | 5 | /** 6 | * 01.12.2017 7 | * FileInfo 8 | * 9 | * @author Sidikov Marsel (First Software Engineering Platform) 10 | * @version v1.0 11 | */ 12 | @Getter 13 | @Setter 14 | @ToString 15 | @NoArgsConstructor 16 | @AllArgsConstructor 17 | @Builder() 18 | public class FileInfo { 19 | 20 | private Long id; 21 | // название файла в хранилище 22 | private String storageFileName; 23 | // название файла оригинальное 24 | private String originalFileName; 25 | // размер файла 26 | private Long size; 27 | // тип файла (MIME) 28 | private String type; 29 | // по какому URL можно получить файл 30 | private String url; 31 | } 32 | -------------------------------------------------------------------------------- /Projects/18. Dispatcher Servlet/src/main/java/ru/itis/servlets/repositories/CoursesRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.servlets.repositories; 2 | 3 | 4 | import ru.itis.servlets.models.Course; 5 | 6 | public interface CoursesRepository extends CrudRepository { 7 | } 8 | -------------------------------------------------------------------------------- /Projects/18. Dispatcher Servlet/src/main/java/ru/itis/servlets/repositories/CrudRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.servlets.repositories; 2 | 3 | import java.util.List; 4 | import java.util.Optional; 5 | 6 | public interface CrudRepository { 7 | Optional find(ID id); 8 | List findAll(); 9 | void save(V entity); 10 | void delete(ID id); 11 | } 12 | -------------------------------------------------------------------------------- /Projects/18. Dispatcher Servlet/src/main/java/ru/itis/servlets/services/CoursesService.java: -------------------------------------------------------------------------------- 1 | package ru.itis.servlets.services; 2 | 3 | import ru.itis.servlets.models.Course; 4 | 5 | import java.util.List; 6 | 7 | public interface CoursesService { 8 | List getAllCourses(); 9 | } 10 | -------------------------------------------------------------------------------- /Projects/18. Dispatcher Servlet/src/main/java/ru/itis/servlets/services/CoursesServiceImpl.java: -------------------------------------------------------------------------------- 1 | package ru.itis.servlets.services; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Component; 5 | import ru.itis.servlets.models.Course; 6 | import ru.itis.servlets.repositories.CoursesRepository; 7 | 8 | import java.util.List; 9 | 10 | @Component(value = "myCoursesService") 11 | public class CoursesServiceImpl implements CoursesService { 12 | 13 | @Autowired 14 | private CoursesRepository coursesRepository; 15 | 16 | @Override 17 | public List getAllCourses() { 18 | return coursesRepository.findAll(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Projects/18. Dispatcher Servlet/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | db.driver=org.postgresql.Driver 2 | db.url=jdbc:postgresql://localhost:5432/education_center 3 | db.user=postgres 4 | db.password=qwerty007 5 | storage.path=C:\\STORAGE -------------------------------------------------------------------------------- /Projects/18. Dispatcher Servlet/src/main/webapp/WEB-INF/dispatcherServlet-servlet.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Projects/18. Dispatcher Servlet/src/main/webapp/WEB-INF/ftl/file_upload.ftlh: -------------------------------------------------------------------------------- 1 | 2 | 28 |
29 | 30 | 33 | 34 |
35 |
-------------------------------------------------------------------------------- /Projects/18. Dispatcher Servlet/src/main/webapp/WEB-INF/jsp/courses.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | <%-- 3 | Created by IntelliJ IDEA. 4 | User: Marsel 5 | Date: 25.02.2020 6 | Time: 12:50 7 | To change this template use File | Settings | File Templates. 8 | --%> 9 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 10 | 11 | 12 | Title 13 | 14 | 15 | 16 | ${course.title}
17 |
18 | 19 | 20 | -------------------------------------------------------------------------------- /Projects/18. Dispatcher Servlet/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | dispatcherServlet 8 | org.springframework.web.servlet.DispatcherServlet 9 | 10 | 11 | 12 | dispatcherServlet 13 | / 14 | 15 | -------------------------------------------------------------------------------- /Projects/19. Hibernate And Jpa/src/main/java/ru/itis/orm/Course.java: -------------------------------------------------------------------------------- 1 | package ru.itis.orm; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import javax.persistence.*; 9 | import java.util.List; 10 | 11 | @Data 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | @Builder 15 | @Entity 16 | public class Course { 17 | @Id 18 | @GeneratedValue(strategy = GenerationType.IDENTITY) 19 | private Long id; 20 | private String title; 21 | 22 | @OneToMany(mappedBy = "course") 23 | private List lessons; 24 | } 25 | -------------------------------------------------------------------------------- /Projects/19. Hibernate And Jpa/src/main/java/ru/itis/orm/Lesson.java: -------------------------------------------------------------------------------- 1 | package ru.itis.orm; 2 | 3 | import lombok.*; 4 | 5 | import javax.persistence.*; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | @Builder 11 | @ToString(exclude = "course") 12 | @Entity 13 | public class Lesson { 14 | 15 | @Id 16 | @GeneratedValue(strategy = GenerationType.IDENTITY) 17 | private Long id; 18 | private String name; 19 | 20 | @ManyToOne 21 | @JoinColumn(name = "course_id") 22 | private Course course; 23 | } 24 | -------------------------------------------------------------------------------- /Projects/19. Hibernate And Jpa/src/main/java/ru/itis/orm/jpa/Main.java: -------------------------------------------------------------------------------- 1 | package ru.itis.orm.jpa; 2 | 3 | import ru.itis.orm.Course; 4 | 5 | import javax.persistence.EntityManager; 6 | import javax.persistence.EntityManagerFactory; 7 | import javax.persistence.EntityTransaction; 8 | import javax.persistence.Persistence; 9 | 10 | public class Main { 11 | public static void main(String[] args) { 12 | EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("ru.itis.orm.education_center"); 13 | 14 | EntityManager entityManager = entityManagerFactory.createEntityManager(); 15 | EntityTransaction entityTransaction = entityManager.getTransaction(); 16 | entityTransaction.begin(); 17 | Course course = Course.builder() 18 | .title("Java Course") 19 | .build(); 20 | entityManager.persist(course); 21 | entityTransaction.commit(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Projects/19. Hibernate And Jpa/src/main/java/ru/itis/orm/spring/CoursesRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.orm.spring; 2 | 3 | import ru.itis.orm.Course; 4 | 5 | public interface CoursesRepository { 6 | void save(Course course); 7 | } 8 | -------------------------------------------------------------------------------- /Projects/19. Hibernate And Jpa/src/main/java/ru/itis/orm/spring/CoursesRepositoryJpaImpl.java: -------------------------------------------------------------------------------- 1 | package ru.itis.orm.spring; 2 | 3 | import org.springframework.stereotype.Component; 4 | import org.springframework.transaction.annotation.Transactional; 5 | import ru.itis.orm.Course; 6 | 7 | import javax.persistence.EntityManager; 8 | import javax.persistence.PersistenceContext; 9 | 10 | @Component 11 | public class CoursesRepositoryJpaImpl implements CoursesRepository { 12 | 13 | @PersistenceContext 14 | private EntityManager entityManager; 15 | 16 | @Override 17 | @Transactional 18 | public void save(Course course) { 19 | entityManager.persist(course); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Projects/19. Hibernate And Jpa/src/main/java/ru/itis/orm/spring/Main.java: -------------------------------------------------------------------------------- 1 | package ru.itis.orm.spring; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 5 | import ru.itis.orm.Course; 6 | 7 | public class Main { 8 | public static void main(String[] args) { 9 | ApplicationContext context = new AnnotationConfigApplicationContext(AppContext.class); 10 | CoursesRepository coursesRepositoryJpa = context.getBean(CoursesRepository.class); 11 | coursesRepositoryJpa.save(Course.builder() 12 | .title("Лучший в мире курс") 13 | .build()); 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Projects/19. Hibernate And Jpa/src/main/resources/META-INF/persistence.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | ru.itis.orm.Course 6 | ru.itis.orm.Lesson 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Projects/19. Hibernate And Jpa/src/main/resources/hibernate/Course.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Projects/19. Hibernate And Jpa/src/main/resources/hibernate/Lesson.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Projects/19. Hibernate And Jpa/src/main/resources/hibernate/hibernate.cfg.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | org.postgresql.Driver 7 | postgres 8 | qwerty007 9 | jdbc:postgresql://localhost:5432/education_center 10 | org.hibernate.dialect.PostgreSQL9Dialect 11 | create 12 | true 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Projects/20. Long Polling/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | 30 | ### VS Code ### 31 | .vscode/ 32 | -------------------------------------------------------------------------------- /Projects/20. Long Polling/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarselSidikov/JAVA_ENTERPRISE_3/be49e21a250a65a28835e168c2d83e85d01662c6/Projects/20. Long Polling/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /Projects/20. Long Polling/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /Projects/20. Long Polling/src/main/java/ru/itis/chat/LongPollingApplication.java: -------------------------------------------------------------------------------- 1 | package ru.itis.chat; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class LongPollingApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(LongPollingApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Projects/20. Long Polling/src/main/java/ru/itis/chat/controllers/ChatController.java: -------------------------------------------------------------------------------- 1 | package ru.itis.chat.controllers; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.ui.Model; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | 7 | import java.util.UUID; 8 | 9 | @Controller 10 | public class ChatController { 11 | 12 | @GetMapping("/chat") 13 | public String getChatPage(Model model) { 14 | model.addAttribute("pageId", UUID.randomUUID().toString()); 15 | return "chat"; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Projects/20. Long Polling/src/main/java/ru/itis/chat/dto/MessageDto.java: -------------------------------------------------------------------------------- 1 | package ru.itis.chat.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | @Data 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | @Builder 12 | public class MessageDto { 13 | private String pageId; 14 | private String text; 15 | } 16 | -------------------------------------------------------------------------------- /Projects/20. Long Polling/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Projects/20. Long Polling/src/main/resources/requests.http: -------------------------------------------------------------------------------- 1 | POST http://localhost:8080/messages 2 | Content-Type: application/json 3 | 4 | { 5 | "pageId" : "FIRST_PAGE", 6 | "text" : "Bye!" 7 | } 8 | 9 | ### -------------------------------------------------------------------------------- /Projects/20. Long Polling/src/main/resources/static/js/chat.js: -------------------------------------------------------------------------------- 1 | function sendMessage(pageId, text) { 2 | let body = { 3 | pageId: pageId, 4 | text: text 5 | }; 6 | 7 | $.ajax({ 8 | url: "/messages", 9 | method: "POST", 10 | data: JSON.stringify(body), 11 | contentType: "application/json", 12 | dataType: "json", 13 | complete: function () { 14 | if (text === 'Login') { 15 | receiveMessage(pageId) 16 | } 17 | } 18 | }); 19 | } 20 | 21 | // LONG POLLING 22 | function receiveMessage(pageId) { 23 | $.ajax({ 24 | url: "/messages?pageId=" + pageId, 25 | method: "GET", 26 | dataType: "json", 27 | contentType: "application/json", 28 | success: function (response) { 29 | $('#messages').first().after('
  • ' + response[0]['text'] + '
  • '); 30 | receiveMessage(pageId); 31 | } 32 | }) 33 | } -------------------------------------------------------------------------------- /Projects/20. Long Polling/src/main/resources/templates/chat.ftlh: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | Document 9 | 13 | 14 | 15 | 16 |

    Ваш идентификатор - ${pageId}

    17 |
    18 | 19 | 21 |
    22 |
    23 |
      24 | 25 |
    26 |
    27 | 28 | -------------------------------------------------------------------------------- /Projects/20. Long Polling/src/test/java/ru/itis/chat/LongPollingApplicationTests.java: -------------------------------------------------------------------------------- 1 | package ru.itis.chat; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class LongPollingApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Projects/21. websockets/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | 30 | ### VS Code ### 31 | .vscode/ 32 | -------------------------------------------------------------------------------- /Projects/21. websockets/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarselSidikov/JAVA_ENTERPRISE_3/be49e21a250a65a28835e168c2d83e85d01662c6/Projects/21. websockets/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /Projects/21. websockets/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /Projects/21. websockets/src/main/java/ru/itis/websockets/WebSocketsApplication.java: -------------------------------------------------------------------------------- 1 | package ru.itis.websockets; 2 | 3 | import com.fasterxml.jackson.databind.ObjectMapper; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.context.annotation.Bean; 7 | 8 | @SpringBootApplication 9 | public class WebSocketsApplication { 10 | 11 | @Bean 12 | public ObjectMapper objectMapper() { 13 | return new ObjectMapper(); 14 | } 15 | 16 | public static void main(String[] args) { 17 | SpringApplication.run(WebSocketsApplication.class, args); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /Projects/21. websockets/src/main/java/ru/itis/websockets/config/WebSocketConfiguration.java: -------------------------------------------------------------------------------- 1 | package ru.itis.websockets.config; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.socket.config.annotation.WebSocketConfigurer; 6 | import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry; 7 | import ru.itis.websockets.handlers.AuthHandshakeHandler; 8 | import ru.itis.websockets.handlers.WebSocketMessagesHandler; 9 | 10 | @Configuration 11 | public class WebSocketConfiguration implements WebSocketConfigurer { 12 | 13 | @Autowired 14 | private WebSocketMessagesHandler handler; 15 | 16 | @Autowired 17 | private AuthHandshakeHandler handshakeHandler; 18 | 19 | @Override 20 | public void registerWebSocketHandlers(WebSocketHandlerRegistry webSocketHandlerRegistry) { 21 | webSocketHandlerRegistry.addHandler(handler, "/chat") 22 | .setHandshakeHandler(handshakeHandler) 23 | .withSockJS(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Projects/21. websockets/src/main/java/ru/itis/websockets/controllers/IndexController.java: -------------------------------------------------------------------------------- 1 | package ru.itis.websockets.controllers; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.ui.Model; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | 7 | import java.util.UUID; 8 | 9 | @Controller 10 | public class IndexController { 11 | @GetMapping("/index") 12 | public String getIndexPage(Model model) { 13 | model.addAttribute("pageId", UUID.randomUUID().toString()); 14 | return "index"; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Projects/21. websockets/src/main/java/ru/itis/websockets/dto/Message.java: -------------------------------------------------------------------------------- 1 | package ru.itis.websockets.dto; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class Message { 7 | private String text; 8 | private String from; 9 | } 10 | -------------------------------------------------------------------------------- /Projects/21. websockets/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Projects/21. websockets/src/test/java/ru/itis/websockets/WebsocketsApplicationTests.java: -------------------------------------------------------------------------------- 1 | package ru.itis.websockets; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class WebsocketsApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Projects/22. Spring MVC Profiles/src/main/java/ru/itis/servlets/controllers/CoursesMvcController.java: -------------------------------------------------------------------------------- 1 | package ru.itis.servlets.controllers; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.annotation.Profile; 5 | import org.springframework.http.HttpMethod; 6 | import org.springframework.stereotype.Controller; 7 | import org.springframework.web.bind.annotation.PathVariable; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RequestMethod; 10 | import org.springframework.web.servlet.ModelAndView; 11 | import ru.itis.servlets.services.CoursesService; 12 | 13 | @Controller 14 | public class CoursesMvcController { 15 | 16 | @Autowired 17 | private CoursesService coursesService; 18 | 19 | @RequestMapping(value = "/courses", method = RequestMethod.GET) 20 | public ModelAndView getCourses() { 21 | ModelAndView modelAndView = new ModelAndView(); 22 | modelAndView.addObject("courses", coursesService.getAllCourses()); 23 | modelAndView.setViewName("courses"); 24 | return modelAndView; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Projects/22. Spring MVC Profiles/src/main/java/ru/itis/servlets/filters/ResponseUtil.java: -------------------------------------------------------------------------------- 1 | package ru.itis.servlets.filters; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | import javax.servlet.http.HttpServletResponse; 5 | import java.io.IOException; 6 | 7 | // signIn -> profile 8 | // users?userId=2 -> /signIn?redirect=users?userId=2 -> /users?userId=2 9 | // signIn -> signIn 10 | public class ResponseUtil { 11 | public static void sendForbidden(HttpServletRequest request, HttpServletResponse response) throws IOException { 12 | StringBuilder path = new StringBuilder(); 13 | path.append("/signIn"); 14 | if (!request.getRequestURI().equals("/signIn")) { 15 | // signIn?redirect=users 16 | path 17 | .append("?redirect=") 18 | .append(request.getRequestURI()); 19 | } 20 | if (request.getQueryString() != null) { 21 | path.append("?") 22 | .append(request.getQueryString()); 23 | } 24 | response.setStatus(403); 25 | response.sendRedirect(path.toString()); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Projects/22. Spring MVC Profiles/src/main/java/ru/itis/servlets/models/Course.java: -------------------------------------------------------------------------------- 1 | package ru.itis.servlets.models; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | @Data 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | @Builder 12 | public class Course { 13 | private Long id; 14 | private String title; 15 | } 16 | -------------------------------------------------------------------------------- /Projects/22. Spring MVC Profiles/src/main/java/ru/itis/servlets/repositories/CoursesRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.servlets.repositories; 2 | 3 | 4 | import ru.itis.servlets.models.Course; 5 | 6 | public interface CoursesRepository extends CrudRepository { 7 | } 8 | -------------------------------------------------------------------------------- /Projects/22. Spring MVC Profiles/src/main/java/ru/itis/servlets/repositories/CrudRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.servlets.repositories; 2 | 3 | import java.util.List; 4 | import java.util.Optional; 5 | 6 | public interface CrudRepository { 7 | Optional find(ID id); 8 | List findAll(); 9 | void save(V entity); 10 | void delete(ID id); 11 | } 12 | -------------------------------------------------------------------------------- /Projects/22. Spring MVC Profiles/src/main/java/ru/itis/servlets/services/CoursesService.java: -------------------------------------------------------------------------------- 1 | package ru.itis.servlets.services; 2 | 3 | import ru.itis.servlets.models.Course; 4 | 5 | import java.util.List; 6 | 7 | public interface CoursesService { 8 | List getAllCourses(); 9 | } 10 | -------------------------------------------------------------------------------- /Projects/22. Spring MVC Profiles/src/main/java/ru/itis/servlets/services/CoursesServiceImpl.java: -------------------------------------------------------------------------------- 1 | package ru.itis.servlets.services; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Component; 5 | import ru.itis.servlets.models.Course; 6 | import ru.itis.servlets.repositories.CoursesRepository; 7 | 8 | import java.util.List; 9 | 10 | @Component(value = "myCoursesService") 11 | public class CoursesServiceImpl implements CoursesService { 12 | 13 | @Autowired 14 | private CoursesRepository coursesRepository; 15 | 16 | @Override 17 | public List getAllCourses() { 18 | return coursesRepository.findAll(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Projects/22. Spring MVC Profiles/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | db.driver=org.postgresql.Driver 2 | db.url=jdbc:postgresql://localhost:5432/education_center 3 | db.user=postgres 4 | db.password=qwerty007 5 | storage.path=C:\\STORAGE 6 | #current.profile=mvc -------------------------------------------------------------------------------- /Projects/22. Spring MVC Profiles/src/main/webapp/WEB-INF/ftl/file_upload.ftlh: -------------------------------------------------------------------------------- 1 | 2 | 28 |
    29 | 30 | 33 | 34 |
    35 |
    -------------------------------------------------------------------------------- /Projects/22. Spring MVC Profiles/src/main/webapp/WEB-INF/jsp/courses.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | <%-- 3 | Created by IntelliJ IDEA. 4 | User: Marsel 5 | Date: 25.02.2020 6 | Time: 12:50 7 | To change this template use File | Settings | File Templates. 8 | --%> 9 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 10 | 11 | 12 | Title 13 | 14 | 15 | 16 | ${course.title}
    17 |
    18 | 19 | 20 | -------------------------------------------------------------------------------- /Projects/23. stomp-example/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | 30 | ### VS Code ### 31 | .vscode/ 32 | -------------------------------------------------------------------------------- /Projects/23. stomp-example/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarselSidikov/JAVA_ENTERPRISE_3/be49e21a250a65a28835e168c2d83e85d01662c6/Projects/23. stomp-example/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /Projects/23. stomp-example/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /Projects/23. stomp-example/info/httpatomoreillycomsourceoreillyimages695362.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarselSidikov/JAVA_ENTERPRISE_3/be49e21a250a65a28835e168c2d83e85d01662c6/Projects/23. stomp-example/info/httpatomoreillycomsourceoreillyimages695362.png -------------------------------------------------------------------------------- /Projects/23. stomp-example/info/info.md: -------------------------------------------------------------------------------- 1 | ## Message Oriented Middleware 2 | 3 | * Делает системы асинхронными 4 | 5 | * Каждый модуль системы независим от реализации других модулей 6 | 7 | ## Simple (or Streaming) Text Oriented Message Protocol (STOMP) 8 | 9 | * Подписаться на что-либо 10 | * Получать информацию от чего-либо 11 | * Отправлять информацию куда-либо 12 | 13 | * FRAME 14 | 15 | ``` 16 | COMMAND 17 | header1:value1 18 | header2:value2 19 | 20 | Body^@ 21 | ``` 22 | 23 | * Подключение к серверу 24 | 25 | ``` 26 | CONNECT 27 | accept-version:1.0,1.1,2.0 28 | host:stomp.github.org 29 | 30 | ^@ 31 | ``` 32 | 33 | 34 | 35 | * Подписка на URL 36 | 37 | ``` 38 | SUBSCRIBE 39 | destination:/topic 40 | 41 | ^@ 42 | ``` 43 | 44 | * Получение сообщения от URL 45 | 46 | ``` 47 | MESSAGE 48 | 49 | {"ticker":"MMM","price":129.45}^@ 50 | ``` 51 | 52 | * Отправка сообщения 53 | 54 | ``` 55 | SEND 56 | destination:/queue/trade 57 | content-type:application/json 58 | content-length:44 59 | 60 | {"action":"BUY","ticker":"MMM","shares",44}^@ 61 | ``` -------------------------------------------------------------------------------- /Projects/23. stomp-example/info/message-flow-broker-relay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarselSidikov/JAVA_ENTERPRISE_3/be49e21a250a65a28835e168c2d83e85d01662c6/Projects/23. stomp-example/info/message-flow-broker-relay.png -------------------------------------------------------------------------------- /Projects/23. stomp-example/info/message-flow-simple-broker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarselSidikov/JAVA_ENTERPRISE_3/be49e21a250a65a28835e168c2d83e85d01662c6/Projects/23. stomp-example/info/message-flow-simple-broker.png -------------------------------------------------------------------------------- /Projects/23. stomp-example/src/main/java/ru/itis/stomp/StompExampleApplication.java: -------------------------------------------------------------------------------- 1 | package ru.itis.stomp; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class StompExampleApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(StompExampleApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Projects/23. stomp-example/src/main/java/ru/itis/stomp/controller/MessagesController.java: -------------------------------------------------------------------------------- 1 | package ru.itis.stomp.controller; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.messaging.Message; 5 | import org.springframework.messaging.handler.annotation.MessageMapping; 6 | import org.springframework.messaging.handler.annotation.SendTo; 7 | import org.springframework.messaging.simp.SimpMessagingTemplate; 8 | import org.springframework.stereotype.Controller; 9 | import org.springframework.web.socket.TextMessage; 10 | 11 | @Controller 12 | public class MessagesController { 13 | 14 | @Autowired 15 | private SimpMessagingTemplate template; 16 | 17 | @MessageMapping("/hello") 18 | public void receiveMessageFromClient(Message message) { 19 | System.out.println(message); 20 | template.convertAndSend("/topic/chat", "Hello, " + message.getPayload()); 21 | } 22 | 23 | @MessageMapping("/bye") 24 | @SendTo("/topic/chat") 25 | public TextMessage sendToTopic(Message message) { 26 | return new TextMessage("Bye, " + message.getPayload()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Projects/23. stomp-example/src/main/java/ru/itis/stomp/interceptors/HandShakeInterceptor.java: -------------------------------------------------------------------------------- 1 | package ru.itis.stomp.interceptors; 2 | 3 | import org.springframework.messaging.Message; 4 | import org.springframework.messaging.MessageChannel; 5 | import org.springframework.messaging.simp.stomp.StompHeaderAccessor; 6 | import org.springframework.messaging.support.ChannelInterceptor; 7 | import org.springframework.messaging.support.MessageHeaderAccessor; 8 | import org.springframework.stereotype.Component; 9 | 10 | @Component 11 | public class HandShakeInterceptor implements ChannelInterceptor { 12 | @Override 13 | public Message preSend(Message message, MessageChannel channel) { 14 | StompHeaderAccessor accessor = 15 | MessageHeaderAccessor.getAccessor(message, StompHeaderAccessor.class); 16 | System.out.println(accessor.getCommand()); 17 | return message; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Projects/23. stomp-example/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Projects/23. stomp-example/src/test/java/ru/itis/stomp/StompExampleApplicationTests.java: -------------------------------------------------------------------------------- 1 | package ru.itis.stomp; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class StompExampleApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Projects/41. Spring MVC Example/INFO.md: -------------------------------------------------------------------------------- 1 | Servlet 2 | JSP 3 | MVC 4 | Controller 5 | ApplicationInitilizer 6 | 7 | ---------------------------------- 8 | 1. Придумать свой проект 9 | - Соц сеть 10 | - Интернет магазин 11 | - Аналог существующего решения 12 | - и т.д. 13 | 14 | 2. Спроектировать структуру БД 15 | 3. Спроектировать структуру классов -------------------------------------------------------------------------------- /Projects/41. Spring MVC Example/README.md: -------------------------------------------------------------------------------- 1 | # MVC - Model View Controller 2 | 3 | * Model - модели предметной области, бизнес-логика, репозитории (по сути - данные) 4 | 5 | * View - то, что видит клиент (пользователь) в браузере. 6 | 7 | * Controller - компонент, который обрабатывает запросы, соединяет модель и View и отдает результат. 8 | 9 | ## Момент 1 10 | 11 | * Теперь обработка запроса выполняется компонентами Spring (Контроллерами) и 12 | вы можете внутри этих компонентов использовать @Autowired 13 | 14 | ## Момент 2 15 | 16 | * Теперь вы не работаете с requestDispatcher, вы используете ModelAndView 17 | 18 | ## Момент 3 19 | 20 | * Маппинг URL-ов - это ID-бина контроллера 21 | -------------------------------------------------------------------------------- /Projects/41. Spring MVC Example/src/main/java/ru/itdrive/web/models/Message.java: -------------------------------------------------------------------------------- 1 | package ru.itdrive.web.models; 2 | 3 | import lombok.*; 4 | 5 | import javax.persistence.*; 6 | 7 | /** 8 | * 19.06.2020 9 | * 42. Hibernate Demo 10 | * 11 | * @author Sidikov Marsel (First Software Engineering Platform) 12 | * @version v1.0 13 | */ 14 | @Data 15 | @AllArgsConstructor 16 | @NoArgsConstructor 17 | @Builder 18 | @ToString(exclude = {"author", "room"}) 19 | @EqualsAndHashCode(exclude = {"author", "room"}) 20 | @Entity 21 | public class Message { 22 | 23 | @Id 24 | @GeneratedValue(strategy = GenerationType.IDENTITY) 25 | private Long id; 26 | 27 | @Column(length = 3000) 28 | private String text; 29 | 30 | @ManyToOne 31 | @JoinColumn(name = "author_id") 32 | private User author; 33 | 34 | @ManyToOne 35 | @JoinColumn(name = "room_id") 36 | private Room room; 37 | } 38 | -------------------------------------------------------------------------------- /Projects/41. Spring MVC Example/src/main/java/ru/itdrive/web/models/Room.java: -------------------------------------------------------------------------------- 1 | package ru.itdrive.web.models; 2 | 3 | import lombok.*; 4 | 5 | import javax.persistence.*; 6 | import javax.persistence.criteria.Root; 7 | import java.util.Set; 8 | 9 | /** 10 | * 19.06.2020 11 | * 42. Hibernate Demo 12 | * 13 | * @author Sidikov Marsel (First Software Engineering Platform) 14 | * @version v1.0 15 | */ 16 | @Data 17 | @AllArgsConstructor 18 | @NoArgsConstructor 19 | @Builder 20 | @ToString(exclude = {"creator", "users"}) 21 | @EqualsAndHashCode(exclude = {"creator", "users"}) 22 | @Entity 23 | public class Room { 24 | @Id 25 | @GeneratedValue(strategy = GenerationType.IDENTITY) 26 | private Long id; 27 | 28 | @ManyToOne 29 | @JoinColumn(name = "creator_id") 30 | private User creator; 31 | 32 | private String name; 33 | 34 | @ManyToMany 35 | @JoinTable(name = "account_room", 36 | joinColumns = @JoinColumn(name = "room_id", referencedColumnName = "id"), 37 | inverseJoinColumns = @JoinColumn(name = "account_id", referencedColumnName = "id")) 38 | private Set users; 39 | 40 | @OneToMany(mappedBy = "room") 41 | private Set messages; 42 | } 43 | -------------------------------------------------------------------------------- /Projects/41. Spring MVC Example/src/main/java/ru/itdrive/web/models/User.java: -------------------------------------------------------------------------------- 1 | package ru.itdrive.web.models; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import javax.persistence.*; 9 | import java.util.Set; 10 | 11 | @Data 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | @Builder 15 | @Entity 16 | @Table(name = "simple_user") 17 | public class User { 18 | 19 | @Id 20 | @GeneratedValue(strategy = GenerationType.IDENTITY) 21 | private Long id; 22 | private String email; 23 | private String password; 24 | private String confirmCode; 25 | 26 | 27 | private String username; 28 | 29 | @ManyToMany(mappedBy = "users") 30 | private Set rooms; 31 | 32 | @OneToMany(mappedBy = "author") 33 | private Set messages; 34 | 35 | @OneToMany(mappedBy = "creator") 36 | private Set createdRooms; 37 | } 38 | -------------------------------------------------------------------------------- /Projects/41. Spring MVC Example/src/main/java/ru/itdrive/web/repositories/CrudRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itdrive.web.repositories; 2 | 3 | import java.util.List; 4 | import java.util.Optional; 5 | 6 | public interface CrudRepository { 7 | Optional find(Long id); 8 | List findAll(); 9 | void save(T entity); 10 | void update(T entity); 11 | } 12 | -------------------------------------------------------------------------------- /Projects/41. Spring MVC Example/src/main/java/ru/itdrive/web/repositories/MessagesRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itdrive.web.repositories; 2 | 3 | import org.springframework.stereotype.Repository; 4 | import ru.itdrive.web.models.Message; 5 | import ru.itdrive.web.models.Room; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * 23.06.2020 11 | * 41. Spring MVC Example 12 | * 13 | * @author Sidikov Marsel (First Software Engineering Platform) 14 | * @version v1.0 15 | */ 16 | public interface MessagesRepository extends CrudRepository { 17 | } 18 | -------------------------------------------------------------------------------- /Projects/41. Spring MVC Example/src/main/java/ru/itdrive/web/repositories/RoomsRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itdrive.web.repositories; 2 | 3 | import org.springframework.data.domain.Pageable; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.data.jpa.repository.Query; 6 | import ru.itdrive.web.dto.RoomDto; 7 | import ru.itdrive.web.models.Room; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * 24.06.2020 13 | * 41. Spring MVC Example 14 | * 15 | * @author Sidikov Marsel (First Software Engineering Platform) 16 | * @version v1.0 17 | */ 18 | public interface RoomsRepository extends JpaRepository { 19 | 20 | @Query("select new ru.itdrive.web.dto.RoomDto(room.id, room.name, room.creator.username, count(messages)) from Room room " + 21 | "left join room.messages as messages " + 22 | "group by room.id, room.creator.username") 23 | List findAllWithoutSubEntitiesAsDto(); 24 | 25 | List findAllByNameAndCreator_Email(String name, String creatorEmail); 26 | 27 | List findAllByNameIgnoreCaseContainsAndCreator_UsernameIgnoreCaseContains(String roomName, String userName, Pageable pageable); 28 | } 29 | -------------------------------------------------------------------------------- /Projects/41. Spring MVC Example/src/main/java/ru/itdrive/web/repositories/UsersRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itdrive.web.repositories; 2 | 3 | import ru.itdrive.web.models.User; 4 | 5 | import java.util.List; 6 | 7 | public interface UsersRepository extends CrudRepository { 8 | List searchByEmail(String emailPattern); 9 | } 10 | -------------------------------------------------------------------------------- /Projects/41. Spring MVC Example/src/main/java/ru/itdrive/web/services/RoomsService.java: -------------------------------------------------------------------------------- 1 | package ru.itdrive.web.services; 2 | 3 | import ru.itdrive.web.dto.RoomDto; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * 26.06.2020 9 | * 41. Spring MVC Example 10 | * 11 | * @author Sidikov Marsel (First Software Engineering Platform) 12 | * @version v1.0 13 | */ 14 | public interface RoomsService { 15 | List search(String name, String creatorName, Integer page, Integer size); 16 | 17 | List getAll(); 18 | } 19 | -------------------------------------------------------------------------------- /Projects/41. Spring MVC Example/src/main/java/ru/itdrive/web/services/UsersSearchService.java: -------------------------------------------------------------------------------- 1 | package ru.itdrive.web.services; 2 | 3 | import ru.itdrive.web.models.User; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * 08.06.2020 9 | * 40. WebAppExample 10 | * 11 | * @author Sidikov Marsel (First Software Engineering Platform) 12 | * @version v1.0 13 | */ 14 | public interface UsersSearchService { 15 | List searchByEmail(String emailPattern); 16 | } 17 | -------------------------------------------------------------------------------- /Projects/41. Spring MVC Example/src/main/java/ru/itdrive/web/services/UsersSearchServiceImpl.java: -------------------------------------------------------------------------------- 1 | package ru.itdrive.web.services; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.beans.factory.annotation.Qualifier; 5 | import org.springframework.stereotype.Component; 6 | import ru.itdrive.web.models.User; 7 | import ru.itdrive.web.repositories.UsersRepository; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * 08.06.2020 13 | * 40. WebAppExample 14 | * 15 | * @author Sidikov Marsel (First Software Engineering Platform) 16 | * @version v1.0 17 | */ 18 | @Component 19 | public class UsersSearchServiceImpl implements UsersSearchService { 20 | 21 | @Autowired 22 | @Qualifier("usersRepositoryJdbcTemplateImpl") 23 | private UsersRepository usersRepository; 24 | 25 | @Override 26 | public List searchByEmail(String emailPattern) { 27 | return usersRepository.searchByEmail(emailPattern); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Projects/41. Spring MVC Example/src/main/java/ru/itdrive/web/services/UsersService.java: -------------------------------------------------------------------------------- 1 | package ru.itdrive.web.services; 2 | 3 | import ru.itdrive.web.models.User; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * 11.06.2020 9 | * 41. Spring MVC Example 10 | * 11 | * @author Sidikov Marsel (First Software Engineering Platform) 12 | * @version v1.0 13 | */ 14 | public interface UsersService { 15 | List getAllUsers(); 16 | void addUser(User user); 17 | } 18 | -------------------------------------------------------------------------------- /Projects/41. Spring MVC Example/src/main/java/ru/itdrive/web/services/UsersServiceImpl.java: -------------------------------------------------------------------------------- 1 | package ru.itdrive.web.services; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.beans.factory.annotation.Qualifier; 5 | import org.springframework.stereotype.Component; 6 | import ru.itdrive.web.models.User; 7 | import ru.itdrive.web.repositories.UsersRepository; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * 11.06.2020 13 | * 41. Spring MVC Example 14 | * 15 | * @author Sidikov Marsel (First Software Engineering Platform) 16 | * @version v1.0 17 | */ 18 | @Component 19 | public class UsersServiceImpl implements UsersService { 20 | 21 | private UsersRepository usersRepository; 22 | 23 | @Autowired 24 | public UsersServiceImpl(@Qualifier("usersRepositoryJdbcTemplateImpl") UsersRepository usersRepository) { 25 | this.usersRepository = usersRepository; 26 | } 27 | 28 | @Override 29 | public List getAllUsers() { 30 | return usersRepository.findAll(); 31 | } 32 | 33 | @Override 34 | public void addUser(User user) { 35 | usersRepository.save(user); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Projects/41. Spring MVC Example/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | db.url=jdbc:postgresql://localhost:5432/education_center 2 | db.user=postgres 3 | db.password=qwerty007 4 | db.driver.name=org.postgresql.Driver -------------------------------------------------------------------------------- /Projects/41. Spring MVC Example/src/main/resources/requests.http: -------------------------------------------------------------------------------- 1 | GET http://localhost:8080/users/search?email=r 2 | Accept: */* 3 | Cache-Control: no-cache 4 | ### 5 | 6 | POST http://localhost:8080/users/add 7 | Content-Type: application/json 8 | 9 | { 10 | "email" : "superemail@gmail.com", 11 | "password" : "qwerty00999" 12 | } 13 | 14 | ### 15 | 16 | GET http://localhost:8080/rooms/search?page=0&size=10&name=Room&creatorName=Marsel 17 | 18 | ### 19 | GET http://localhost:8080/rooms 20 | 21 | ### 22 | -------------------------------------------------------------------------------- /Projects/41. Spring MVC Example/src/test/java/ru/itdrive/web/repositories/MessagesRepositoryJpaImplTest.java: -------------------------------------------------------------------------------- 1 | package ru.itdrive.web.repositories; 2 | 3 | import org.junit.jupiter.api.BeforeEach; 4 | import org.junit.jupiter.api.Test; 5 | import org.springframework.context.ApplicationContext; 6 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 7 | import ru.itdrive.web.config.TestApplicationConfig; 8 | import ru.itdrive.web.models.Message; 9 | 10 | /** 11 | * 23.06.2020 12 | * 41. Spring MVC Example 13 | * 14 | * @author Sidikov Marsel (First Software Engineering Platform) 15 | * @version v1.0 16 | */ 17 | class MessagesRepositoryJpaImplTest { 18 | 19 | private MessagesRepository messagesRepository; 20 | 21 | @BeforeEach 22 | void setUp() { 23 | ApplicationContext context = new AnnotationConfigApplicationContext(TestApplicationConfig.class); 24 | messagesRepository = context.getBean("messagesRepositoryJpaImpl", MessagesRepository.class); 25 | } 26 | 27 | @Test 28 | void save() { 29 | messagesRepository.save(Message.builder().text("Hello!").build()); 30 | System.out.println(messagesRepository.findAll()); 31 | } 32 | } -------------------------------------------------------------------------------- /Projects/41. Spring MVC Example/src/test/resources/data.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO simple_user (email, password, confirmcode) VALUES ('USER', 'USER', '0a4d8114-5b6c-4929-b72c-9f1a7d05293d'); 2 | INSERT INTO simple_user (email, password, confirmcode) VALUES ('sidikov.marsel@gmail.com', 'qwerty007', '03107298-64a6-4426-ba40-cbbe558f8798'); 3 | INSERT INTO simple_user (email, password, confirmcode) VALUES ('TEMP', 'qwerty008', '03107298-64a6-4426-ba40-cbbe558f8798'); -------------------------------------------------------------------------------- /Projects/41. Spring MVC Example/src/test/resources/schema.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS account_room; 2 | DROP TABLE IF EXISTS message; 3 | DROP TABLE IF EXISTS room; 4 | DROP TABLE IF EXISTS simple_user; 5 | 6 | CREATE TABLE simple_user 7 | ( 8 | id INT AUTO_INCREMENT PRIMARY KEY, 9 | email VARCHAR(250), 10 | password VARCHAR(250) NOT NULL, 11 | confirmcode VARCHAR(250) DEFAULT NULL 12 | ); -------------------------------------------------------------------------------- /Projects/44. Rest API Demo/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | 30 | ### VS Code ### 31 | .vscode/ 32 | -------------------------------------------------------------------------------- /Projects/44. Rest API Demo/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarselSidikov/JAVA_ENTERPRISE_3/be49e21a250a65a28835e168c2d83e85d01662c6/Projects/44. Rest API Demo/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /Projects/44. Rest API Demo/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /Projects/44. Rest API Demo/SPRING_SECURITY.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarselSidikov/JAVA_ENTERPRISE_3/be49e21a250a65a28835e168c2d83e85d01662c6/Projects/44. Rest API Demo/SPRING_SECURITY.png -------------------------------------------------------------------------------- /Projects/44. Rest API Demo/src/main/java/ru/itis/service/dto/CourseDto.java: -------------------------------------------------------------------------------- 1 | package ru.itis.service.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | import ru.itis.service.models.Course; 8 | 9 | import java.util.List; 10 | import java.util.stream.Collectors; 11 | 12 | /** 13 | * 03.07.2020 14 | * 44. Rest API Demo 15 | * 16 | * @author Sidikov Marsel (First Software Engineering Platform) 17 | * @version v1.0 18 | */ 19 | @Data 20 | @AllArgsConstructor 21 | @NoArgsConstructor 22 | @Builder 23 | public class CourseDto { 24 | private Long id; 25 | private String title; 26 | 27 | public static CourseDto from(Course course) { 28 | return CourseDto.builder() 29 | .id(course.getId()) 30 | .title(course.getTitle()) 31 | .build(); 32 | } 33 | 34 | public static List from(List courses) { 35 | return courses.stream().map(CourseDto::from).collect(Collectors.toList()); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Projects/44. Rest API Demo/src/main/java/ru/itis/service/models/Authority.java: -------------------------------------------------------------------------------- 1 | package ru.itis.service.models; 2 | 3 | /** 4 | * 01.07.2020 5 | * 43. Spring Boot Demo 6 | * 7 | * @author Sidikov Marsel (First Software Engineering Platform) 8 | * @version v1.0 9 | */ 10 | public enum Authority { 11 | USER, ADMIN 12 | } 13 | -------------------------------------------------------------------------------- /Projects/44. Rest API Demo/src/main/java/ru/itis/service/models/Course.java: -------------------------------------------------------------------------------- 1 | package ru.itis.service.models; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import javax.persistence.*; 9 | import java.util.List; 10 | 11 | /** 12 | * 03.07.2020 13 | * 44. Rest API Demo 14 | * 15 | * @author Sidikov Marsel (First Software Engineering Platform) 16 | * @version v1.0 17 | */ 18 | @Data 19 | @AllArgsConstructor 20 | @NoArgsConstructor 21 | @Builder 22 | @Entity 23 | public class Course { 24 | 25 | @Id 26 | @GeneratedValue(strategy = GenerationType.IDENTITY) 27 | private Long id; 28 | 29 | private String title; 30 | 31 | @OneToMany(mappedBy = "course") 32 | private List lessons; 33 | 34 | @ManyToOne 35 | @JoinColumn(name = "discipline_id") 36 | private Discipline discipline; 37 | 38 | @ManyToMany(mappedBy = "courses") 39 | private List students; 40 | } 41 | -------------------------------------------------------------------------------- /Projects/44. Rest API Demo/src/main/java/ru/itis/service/models/Discipline.java: -------------------------------------------------------------------------------- 1 | package ru.itis.service.models; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import javax.persistence.*; 9 | import java.util.List; 10 | 11 | /** 12 | * 03.07.2020 13 | * 44. Rest API Demo 14 | * 15 | * @author Sidikov Marsel (First Software Engineering Platform) 16 | * @version v1.0 17 | */ 18 | @Data 19 | @AllArgsConstructor 20 | @NoArgsConstructor 21 | @Builder 22 | @Entity 23 | public class Discipline { 24 | @Id 25 | @GeneratedValue(strategy = GenerationType.IDENTITY) 26 | private Long id; 27 | 28 | private String name; 29 | 30 | @OneToMany(mappedBy = "discipline") 31 | private List courses; 32 | } 33 | -------------------------------------------------------------------------------- /Projects/44. Rest API Demo/src/main/java/ru/itis/service/models/Lesson.java: -------------------------------------------------------------------------------- 1 | package ru.itis.service.models; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import javax.persistence.*; 9 | 10 | /** 11 | * 03.07.2020 12 | * 44. Rest API Demo 13 | * 14 | * @author Sidikov Marsel (First Software Engineering Platform) 15 | * @version v1.0 16 | */ 17 | @Data 18 | @AllArgsConstructor 19 | @NoArgsConstructor 20 | @Builder 21 | @Entity 22 | public class Lesson { 23 | @Id 24 | @GeneratedValue(strategy = GenerationType.IDENTITY) 25 | private Long id; 26 | 27 | private String name; 28 | 29 | @ManyToOne 30 | @JoinColumn(name = "course_id") 31 | private Course course; 32 | } 33 | -------------------------------------------------------------------------------- /Projects/44. Rest API Demo/src/main/java/ru/itis/service/repositories/CoursesRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.service.repositories; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import ru.itis.service.models.Course; 5 | import ru.itis.service.models.User; 6 | 7 | /** 8 | * 03.07.2020 9 | * 44. Rest API Demo 10 | * 11 | * @author Sidikov Marsel (First Software Engineering Platform) 12 | * @version v1.0 13 | */ 14 | public interface CoursesRepository extends JpaRepository { 15 | } 16 | -------------------------------------------------------------------------------- /Projects/44. Rest API Demo/src/main/java/ru/itis/service/repositories/DisciplinesRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.service.repositories; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import ru.itis.service.models.Discipline; 5 | import ru.itis.service.models.User; 6 | 7 | /** 8 | * 03.07.2020 9 | * 44. Rest API Demo 10 | * 11 | * @author Sidikov Marsel (First Software Engineering Platform) 12 | * @version v1.0 13 | */ 14 | public interface DisciplinesRepository extends JpaRepository { 15 | } 16 | -------------------------------------------------------------------------------- /Projects/44. Rest API Demo/src/main/java/ru/itis/service/repositories/LessonsRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.service.repositories; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import ru.itis.service.models.Course; 5 | import ru.itis.service.models.Lesson; 6 | import ru.itis.service.models.User; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * 03.07.2020 12 | * 44. Rest API Demo 13 | * 14 | * @author Sidikov Marsel (First Software Engineering Platform) 15 | * @version v1.0 16 | */ 17 | public interface LessonsRepository extends JpaRepository { 18 | List findAllByCourse(Course course); 19 | } 20 | -------------------------------------------------------------------------------- /Projects/44. Rest API Demo/src/main/java/ru/itis/service/repositories/UsersRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.service.repositories; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import org.springframework.data.jpa.repository.Query; 5 | import ru.itis.service.models.User; 6 | 7 | import java.util.Optional; 8 | 9 | /** 10 | * 03.07.2020 11 | * 44. Rest API Demo 12 | * 13 | * @author Sidikov Marsel (First Software Engineering Platform) 14 | * @version v1.0 15 | */ 16 | public interface UsersRepository extends JpaRepository { 17 | Optional findByEmail(String email); 18 | 19 | @Query("select user FROM User user JOIN user.tokens token WHERE token = ?1") 20 | Optional findByToken(String token); 21 | } 22 | -------------------------------------------------------------------------------- /Projects/44. Rest API Demo/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.h2.console.enabled=true 2 | spring.datasource.url=jdbc:h2:mem:users-service 3 | spring.datasource.driverClassName=org.h2.Driver 4 | spring.datasource.username=sa 5 | spring.datasource.password= 6 | spring.jpa.show-sql=true 7 | spring.jpa.hibernate.ddl-auto=update 8 | spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect 9 | server.port=80 10 | -------------------------------------------------------------------------------- /Projects/44. Rest API Demo/src/main/resources/http/requests.http: -------------------------------------------------------------------------------- 1 | GET http://localhost/disciplines/2/courses?token=token3 2 | 3 | ### 4 | 5 | POST http://localhost/courses/2/lessons?token=token1 6 | Content-Type: application/json 7 | 8 | { 9 | "name" : "Rest api" 10 | } 11 | 12 | ### -------------------------------------------------------------------------------- /Projects/44. Rest API Demo/src/test/java/ru/itis/service/RestApiDemoApplicationTests.java: -------------------------------------------------------------------------------- 1 | package ru.itis.service; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class RestApiDemoApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Projects/45. Rabbit MQ Producers/downloaded/0b5d23f5-0ca2-438e-b99c-7c226cbf3b6e.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarselSidikov/JAVA_ENTERPRISE_3/be49e21a250a65a28835e168c2d83e85d01662c6/Projects/45. Rabbit MQ Producers/downloaded/0b5d23f5-0ca2-438e-b99c-7c226cbf3b6e.jpg -------------------------------------------------------------------------------- /Projects/45. Rabbit MQ Producers/downloaded/3e6726ad-7ead-4fb7-b4a5-85c501225232.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarselSidikov/JAVA_ENTERPRISE_3/be49e21a250a65a28835e168c2d83e85d01662c6/Projects/45. Rabbit MQ Producers/downloaded/3e6726ad-7ead-4fb7-b4a5-85c501225232.jpg -------------------------------------------------------------------------------- /Projects/45. Rabbit MQ Producers/src/main/java/ru/itis/example6/MainClient.java: -------------------------------------------------------------------------------- 1 | package ru.itis.example6; 2 | 3 | import java.util.Scanner; 4 | 5 | public class MainClient { 6 | public static void main(String[] args) { 7 | // запускаем клиента 8 | Client client = new Client(); 9 | 10 | Scanner scanner = new Scanner(System.in); 11 | // в бесконечном цикле 12 | while (true) { 13 | // передаем ему имя файла 14 | String fileName = scanner.nextLine(); 15 | // вызываем метод клиента, который скачивает файл и возвращает его разрмер 16 | System.out.println(client.downloadFileAndGetSize(fileName)); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Projects/45. Rabbit MQ Producers/src/main/java/ru/itis/example6/MainServer.java: -------------------------------------------------------------------------------- 1 | package ru.itis.example6; 2 | 3 | public class MainServer { 4 | public static void main(String[] args) { 5 | Server server = new Server(); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Projects/46.Annotations/src/main/java/ru/itis/html/generator/HtmlForm.java: -------------------------------------------------------------------------------- 1 | package ru.itis.html.generator; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * 30.10.2020 10 | * 46. Annotations 11 | * 12 | * @author Sidikov Marsel (First Software Engineering Platform) 13 | * @version v1.0 14 | */ 15 | @Retention(RetentionPolicy.SOURCE) 16 | @Target(ElementType.TYPE) 17 | public @interface HtmlForm { 18 | String method() default "get"; 19 | String action() default "/"; 20 | } 21 | -------------------------------------------------------------------------------- /Projects/46.Annotations/src/main/java/ru/itis/html/generator/HtmlInput.java: -------------------------------------------------------------------------------- 1 | package ru.itis.html.generator; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * 30.10.2020 10 | * 46. Annotations 11 | * 12 | * @author Sidikov Marsel (First Software Engineering Platform) 13 | * @version v1.0 14 | */ 15 | @Retention(RetentionPolicy.SOURCE) 16 | @Target(ElementType.FIELD) 17 | public @interface HtmlInput { 18 | String type() default "text"; 19 | String name() default ""; 20 | String placeholder() default ""; 21 | } 22 | -------------------------------------------------------------------------------- /Projects/46.Annotations/src/main/java/ru/itis/html/generator/User.java: -------------------------------------------------------------------------------- 1 | package ru.itis.html.generator; 2 | 3 | /** 4 | * 30.10.2020 5 | * 46. Annotations 6 | * 7 | * @author Sidikov Marsel (First Software Engineering Platform) 8 | * @version v1.0 9 | */ 10 | @HtmlForm(method = "post", action = "/users") 11 | public class User { 12 | @HtmlInput(type = "text", name = "first_name", placeholder = "Имя") 13 | private String firstName; 14 | @HtmlInput(type = "text", name = "last_name", placeholder = "Фамилия") 15 | private String lastName; 16 | @HtmlInput(type = "email", name = "email", placeholder = "Email") 17 | private String email; 18 | @HtmlInput(type = "password", name = "password", placeholder = "Пароль") 19 | private String password; 20 | } 21 | -------------------------------------------------------------------------------- /Projects/46.Annotations/src/main/resources/form.html: -------------------------------------------------------------------------------- 1 |
    2 | 3 | 4 | 5 | 6 |
    -------------------------------------------------------------------------------- /Projects/47. hateoas-service/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /Projects/47. hateoas-service/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarselSidikov/JAVA_ENTERPRISE_3/be49e21a250a65a28835e168c2d83e85d01662c6/Projects/47. hateoas-service/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /Projects/47. hateoas-service/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /Projects/47. hateoas-service/src/main/asciidoc/apidoc.adoc: -------------------------------------------------------------------------------- 1 | = Course API 2 | 3 | == Methods 4 | 5 | === Course publish 6 | 7 | You can publish a course with status *DRAFT* 8 | 9 | .request 10 | 11 | include::{snippets}\publish_course\http-request.adoc[] 12 | 13 | .response 14 | 15 | include::{snippets}\publish_course\http-response.adoc[] 16 | 17 | .response-fields 18 | 19 | include::{snippets}\publish_course\response-fields.adoc[] -------------------------------------------------------------------------------- /Projects/47. hateoas-service/src/main/java/ru/itis/hateoas/hateoasservice/controllers/CoursesController.java: -------------------------------------------------------------------------------- 1 | package ru.itis.hateoas.hateoasservice.controllers; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.data.rest.webmvc.RepositoryRestController; 5 | import org.springframework.hateoas.EntityModel; 6 | import org.springframework.http.ResponseEntity; 7 | import org.springframework.web.bind.annotation.PathVariable; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RequestMethod; 10 | import org.springframework.web.bind.annotation.ResponseBody; 11 | import ru.itis.hateoas.hateoasservice.services.CoursesService; 12 | 13 | @RepositoryRestController 14 | public class CoursesController { 15 | 16 | @Autowired 17 | private CoursesService coursesService; 18 | 19 | @RequestMapping(value = "/courses/{course-id}/publish", method = RequestMethod.PUT) 20 | public @ResponseBody 21 | ResponseEntity publish(@PathVariable("course-id") Long courseId) { 22 | return ResponseEntity.ok( 23 | EntityModel.of(coursesService.publish(courseId))); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Projects/47. hateoas-service/src/main/java/ru/itis/hateoas/hateoasservice/models/Course.java: -------------------------------------------------------------------------------- 1 | package ru.itis.hateoas.hateoasservice.models; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import javax.persistence.*; 9 | import java.util.List; 10 | 11 | @Entity 12 | @Data 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @Builder 16 | public class Course { 17 | @Id 18 | @GeneratedValue 19 | private Long id; 20 | 21 | private String title; 22 | private String description; 23 | 24 | @OneToMany(mappedBy = "course") 25 | private List lessons; 26 | 27 | @ManyToMany(mappedBy = "courses") 28 | private List students; 29 | 30 | private String state; 31 | 32 | public void publish() { 33 | if (this.state.equals("Draft")) { 34 | this.state = "Published"; 35 | } else if (this.state.equals("Deleted")) { 36 | throw new IllegalStateException(); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Projects/47. hateoas-service/src/main/java/ru/itis/hateoas/hateoasservice/models/Lesson.java: -------------------------------------------------------------------------------- 1 | package ru.itis.hateoas.hateoasservice.models; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import javax.persistence.*; 9 | 10 | @Entity 11 | @Data 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | @Builder 15 | public class Lesson { 16 | @Id 17 | @GeneratedValue 18 | private Long id; 19 | 20 | private String title; 21 | private Integer rate; 22 | 23 | @ManyToOne 24 | @JoinColumn(name = "course_id") 25 | private Course course; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /Projects/47. hateoas-service/src/main/java/ru/itis/hateoas/hateoasservice/models/User.java: -------------------------------------------------------------------------------- 1 | package ru.itis.hateoas.hateoasservice.models; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import javax.persistence.*; 9 | import java.util.List; 10 | 11 | @Entity 12 | @Data 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @Builder 16 | public class User { 17 | @Id 18 | @GeneratedValue 19 | private Long id; 20 | 21 | private String firstName; 22 | private String lastName; 23 | 24 | @ManyToMany 25 | @JoinTable(name = "student_course", 26 | joinColumns = @JoinColumn(name = "student_id", referencedColumnName = "id"), 27 | inverseJoinColumns = @JoinColumn(name = "course_id", referencedColumnName = "id")) 28 | private List courses; 29 | } 30 | -------------------------------------------------------------------------------- /Projects/47. hateoas-service/src/main/java/ru/itis/hateoas/hateoasservice/repositories/CoursesRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.hateoas.hateoasservice.repositories; 2 | 3 | import org.springframework.data.domain.Page; 4 | import org.springframework.data.domain.Pageable; 5 | import org.springframework.data.jpa.repository.Query; 6 | import org.springframework.data.repository.PagingAndSortingRepository; 7 | import org.springframework.data.rest.core.annotation.RepositoryRestResource; 8 | import org.springframework.data.rest.core.annotation.RestResource; 9 | import ru.itis.hateoas.hateoasservice.models.Course; 10 | 11 | import java.util.List; 12 | 13 | @RepositoryRestResource 14 | public interface CoursesRepository extends PagingAndSortingRepository { 15 | @RestResource(path = "published", rel = "published") 16 | @Query("from Course course where course.state = 'Published'") 17 | Page findAllPublished(Pageable pageable); 18 | // 19 | @RestResource(path = "byTitle", rel = "title") 20 | List findAllByTitle(String title); 21 | } 22 | -------------------------------------------------------------------------------- /Projects/47. hateoas-service/src/main/java/ru/itis/hateoas/hateoasservice/repositories/LessonsRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.hateoas.hateoasservice.repositories; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import ru.itis.hateoas.hateoasservice.models.Lesson; 5 | 6 | 7 | public interface LessonsRepository extends JpaRepository { 8 | } 9 | -------------------------------------------------------------------------------- /Projects/47. hateoas-service/src/main/java/ru/itis/hateoas/hateoasservice/repositories/UsersRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.hateoas.hateoasservice.repositories; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import ru.itis.hateoas.hateoasservice.models.User; 5 | 6 | public interface UsersRepository extends JpaRepository { 7 | } 8 | -------------------------------------------------------------------------------- /Projects/47. hateoas-service/src/main/java/ru/itis/hateoas/hateoasservice/services/CoursesService.java: -------------------------------------------------------------------------------- 1 | package ru.itis.hateoas.hateoasservice.services; 2 | 3 | import ru.itis.hateoas.hateoasservice.models.Course; 4 | 5 | public interface CoursesService { 6 | Course publish(Long courseId); 7 | } 8 | -------------------------------------------------------------------------------- /Projects/47. hateoas-service/src/main/java/ru/itis/hateoas/hateoasservice/services/CoursesServiceImpl.java: -------------------------------------------------------------------------------- 1 | package ru.itis.hateoas.hateoasservice.services; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Service; 5 | import ru.itis.hateoas.hateoasservice.models.Course; 6 | import ru.itis.hateoas.hateoasservice.repositories.CoursesRepository; 7 | 8 | @Service 9 | public class CoursesServiceImpl implements CoursesService { 10 | 11 | @Autowired 12 | private CoursesRepository coursesRepository; 13 | 14 | @Override 15 | public Course publish(Long courseId) { 16 | Course course = coursesRepository.findById(courseId).orElseThrow(IllegalArgumentException::new); 17 | course.publish(); 18 | coursesRepository.save(course); 19 | return course; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Projects/47. hateoas-service/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.h2.console.enabled=true 2 | spring.datasource.url=jdbc:h2:mem:education-center 3 | spring.datasource.driverClassName=org.h2.Driver 4 | spring.datasource.username=sa 5 | spring.datasource.password= 6 | spring.jpa.show-sql=true 7 | spring.jpa.hibernate.ddl-auto=update 8 | spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect 9 | #spring.data.rest.base-path=/api/courses-management/ 10 | server.port=80 11 | -------------------------------------------------------------------------------- /Projects/47. hateoas-service/src/test/java/ru/itis/hateoas/hateoasservice/HateoasServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package ru.itis.hateoas.hateoasservice; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class HateoasServiceApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Projects/48. MongoDb/src/main/java/ru/itis/mongo/jpa/Course.java: -------------------------------------------------------------------------------- 1 | package ru.itis.mongo.jpa; 2 | 3 | import lombok.Data; 4 | import lombok.AllArgsConstructor; 5 | import lombok.NoArgsConstructor; 6 | import org.springframework.data.annotation.Id; 7 | import org.springframework.data.mongodb.core.mapping.DBRef; 8 | import org.springframework.data.mongodb.core.mapping.Document; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * 21.11.2020 14 | * MongoDb 15 | * 16 | * @author Sidikov Marsel (First Software Engineering Platform) 17 | * @version v1.0 18 | */ 19 | @Data 20 | @AllArgsConstructor 21 | @Document(collection = "courses") 22 | public class Course { 23 | @Id 24 | private String _id; 25 | private Integer studentsCount; 26 | private Integer hours; 27 | private List keywords; 28 | private Boolean active; 29 | @DBRef 30 | private List teachers; 31 | } 32 | -------------------------------------------------------------------------------- /Projects/48. MongoDb/src/main/java/ru/itis/mongo/jpa/CoursesRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.mongo.jpa; 2 | 3 | import org.springframework.data.mongodb.repository.MongoRepository; 4 | import org.springframework.data.mongodb.repository.Query; 5 | import org.springframework.data.repository.CrudRepository; 6 | import org.springframework.data.repository.PagingAndSortingRepository; 7 | import org.springframework.data.repository.query.Param; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * 23.11.2020 13 | * MongoDb 14 | * 15 | * @author Sidikov Marsel (First Software Engineering Platform) 16 | * @version v1.0 17 | */ 18 | public interface CoursesRepository extends MongoRepository { 19 | 20 | @Query(value = "{active: false, $or: [{keywords: ?keywords}, {studentsCount: {$lt: ?1}}]}") 21 | List find(@Param("keywords") List keywords, @Param("studentsCount") int maxStudentsCount); 22 | } 23 | -------------------------------------------------------------------------------- /Projects/48. MongoDb/src/main/java/ru/itis/mongo/jpa/RepositoriesConfig.java: -------------------------------------------------------------------------------- 1 | package ru.itis.mongo.jpa; 2 | 3 | import com.mongodb.client.MongoClients; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.data.mongodb.core.MongoTemplate; 6 | import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; 7 | 8 | /** 9 | * 23.11.2020 10 | * MongoDb 11 | * 12 | * @author Sidikov Marsel (First Software Engineering Platform) 13 | * @version v1.0 14 | */ 15 | @EnableMongoRepositories(basePackages = "ru.itis.mongo.jpa") 16 | public class RepositoriesConfig { 17 | @Bean 18 | public MongoTemplate mongoTemplate() { 19 | return new MongoTemplate(MongoClients.create(), "education"); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Projects/48. MongoDb/src/main/java/ru/itis/mongo/jpa/Teacher.java: -------------------------------------------------------------------------------- 1 | package ru.itis.mongo.jpa; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | import org.springframework.data.annotation.Id; 8 | import org.springframework.data.mongodb.core.mapping.Document; 9 | 10 | import java.util.StringJoiner; 11 | 12 | /** 13 | * 21.11.2020 14 | * MongoDb 15 | * 16 | * @author Sidikov Marsel (First Software Engineering Platform) 17 | * @version v1.0 18 | */ 19 | @AllArgsConstructor 20 | @NoArgsConstructor 21 | @Builder 22 | @Data 23 | @Document(collection = "teachers") 24 | public class Teacher { 25 | @Id 26 | private String _id; 27 | private String firstName; 28 | private String lastName; 29 | } 30 | -------------------------------------------------------------------------------- /Projects/48. MongoDb/src/main/java/ru/itis/mongo/jpa/TeachersRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.mongo.jpa; 2 | 3 | import org.springframework.data.repository.CrudRepository; 4 | import org.springframework.data.repository.PagingAndSortingRepository; 5 | 6 | /** 7 | * 23.11.2020 8 | * MongoDb 9 | * 10 | * @author Sidikov Marsel (First Software Engineering Platform) 11 | * @version v1.0 12 | */ 13 | public interface TeachersRepository extends PagingAndSortingRepository { 14 | } 15 | -------------------------------------------------------------------------------- /Projects/48. MongoDb/src/main/java/ru/itis/mongo/spring/SimpleMongoConfig.java: -------------------------------------------------------------------------------- 1 | package ru.itis.mongo.spring; 2 | 3 | import com.mongodb.client.MongoClients; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.data.mongodb.core.MongoTemplate; 7 | 8 | @Configuration 9 | public class SimpleMongoConfig { 10 | 11 | @Bean 12 | public MongoTemplate mongoTemplate() { 13 | return new MongoTemplate(MongoClients.create(), "education"); 14 | } 15 | } -------------------------------------------------------------------------------- /Projects/48. MongoDb/База данных.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarselSidikov/JAVA_ENTERPRISE_3/be49e21a250a65a28835e168c2d83e85d01662c6/Projects/48. MongoDb/База данных.png -------------------------------------------------------------------------------- /Projects/48. MongoDb/Структура.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarselSidikov/JAVA_ENTERPRISE_3/be49e21a250a65a28835e168c2d83e85d01662c6/Projects/48. MongoDb/Структура.png -------------------------------------------------------------------------------- /Projects/49. MongoHateoas/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | 30 | ### VS Code ### 31 | .vscode/ 32 | -------------------------------------------------------------------------------- /Projects/49. MongoHateoas/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarselSidikov/JAVA_ENTERPRISE_3/be49e21a250a65a28835e168c2d83e85d01662c6/Projects/49. MongoHateoas/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /Projects/49. MongoHateoas/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /Projects/49. MongoHateoas/src/main/java/ru/itis/hateoasrest/HateoasRestApplication.java: -------------------------------------------------------------------------------- 1 | package ru.itis.hateoasrest; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class HateoasRestApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(HateoasRestApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Projects/49. MongoHateoas/src/main/java/ru/itis/hateoasrest/models/Course.java: -------------------------------------------------------------------------------- 1 | package ru.itis.hateoasrest.models; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import org.springframework.data.annotation.Id; 6 | import org.springframework.data.mongodb.core.mapping.DBRef; 7 | import org.springframework.data.mongodb.core.mapping.Document; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * 21.11.2020 13 | * MongoDb 14 | * 15 | * @author Sidikov Marsel (First Software Engineering Platform) 16 | * @version v1.0 17 | */ 18 | @Data 19 | @AllArgsConstructor 20 | @Document(collection = "courses") 21 | public class Course { 22 | @Id 23 | private String _id; 24 | private Integer studentsCount; 25 | private Integer hours; 26 | private List keywords; 27 | private Boolean active; 28 | @DBRef 29 | private List teachers; 30 | } 31 | -------------------------------------------------------------------------------- /Projects/49. MongoHateoas/src/main/java/ru/itis/hateoasrest/models/Teacher.java: -------------------------------------------------------------------------------- 1 | package ru.itis.hateoasrest.models; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | import org.springframework.data.annotation.Id; 8 | import org.springframework.data.mongodb.core.mapping.Document; 9 | 10 | /** 11 | * 21.11.2020 12 | * MongoDb 13 | * 14 | * @author Sidikov Marsel (First Software Engineering Platform) 15 | * @version v1.0 16 | */ 17 | @AllArgsConstructor 18 | @NoArgsConstructor 19 | @Builder 20 | @Data 21 | @Document 22 | public class Teacher { 23 | @Id 24 | private String _id; 25 | private String firstName; 26 | private String lastName; 27 | } 28 | -------------------------------------------------------------------------------- /Projects/49. MongoHateoas/src/main/java/ru/itis/hateoasrest/repositories/CoursesRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.hateoasrest.repositories; 2 | 3 | import org.springframework.data.mongodb.repository.MongoRepository; 4 | import org.springframework.data.mongodb.repository.Query; 5 | import org.springframework.data.repository.query.Param; 6 | import org.springframework.data.rest.core.annotation.RestResource; 7 | import ru.itis.hateoasrest.models.Course; 8 | 9 | import java.awt.print.Pageable; 10 | import java.util.List; 11 | 12 | /** 13 | * 23.11.2020 14 | * MongoDb 15 | * 16 | * @author Sidikov Marsel (First Software Engineering Platform) 17 | * @version v1.0 18 | */ 19 | public interface CoursesRepository extends MongoRepository { 20 | 21 | @RestResource(path = "inactives", rel = "inactives") 22 | @Query(value = "{active: false, $or: [{keywords: ?0}, {studentsCount: {$lt: ?1 }}]}") 23 | List find(@Param("keywords") List keywords, @Param("studentsCount") int maxStudentsCount, Pageable pageable); 24 | } 25 | -------------------------------------------------------------------------------- /Projects/49. MongoHateoas/src/main/java/ru/itis/hateoasrest/repositories/TeachersRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.hateoasrest.repositories; 2 | 3 | import org.springframework.data.repository.PagingAndSortingRepository; 4 | import ru.itis.hateoasrest.models.Teacher; 5 | 6 | /** 7 | * 23.11.2020 8 | * MongoDb 9 | * 10 | * @author Sidikov Marsel (First Software Engineering Platform) 11 | * @version v1.0 12 | */ 13 | public interface TeachersRepository extends PagingAndSortingRepository { 14 | } 15 | -------------------------------------------------------------------------------- /Projects/49. MongoHateoas/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.data.mongodb.database=education 2 | server.port=80 3 | logging.level.org.springframework.data.mongodb.core.MongoTemplate=DEBUG -------------------------------------------------------------------------------- /Projects/50. query-dsl-demo/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /Projects/50. query-dsl-demo/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarselSidikov/JAVA_ENTERPRISE_3/be49e21a250a65a28835e168c2d83e85d01662c6/Projects/50. query-dsl-demo/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /Projects/50. query-dsl-demo/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /Projects/50. query-dsl-demo/src/main/java/ru/itis/search/dto/UserDto.java: -------------------------------------------------------------------------------- 1 | package ru.itis.search.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * 17.12.2020 12 | * 50. query-dsl-demo 13 | * 14 | * @author Sidikov Marsel (First Software Engineering Platform) 15 | * @version v1.0 16 | */ 17 | @Builder 18 | @AllArgsConstructor 19 | @NoArgsConstructor 20 | @Data 21 | public class UserDto { 22 | private String firstName; 23 | private String lastName; 24 | private List courseNames; 25 | } 26 | -------------------------------------------------------------------------------- /Projects/50. query-dsl-demo/src/main/java/ru/itis/search/dto/UserRequest.java: -------------------------------------------------------------------------------- 1 | package ru.itis.search.dto; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * 17.12.2020 7 | * 50. query-dsl-demo 8 | * 9 | * @author Sidikov Marsel (First Software Engineering Platform) 10 | * @version v1.0 11 | */ 12 | @Data 13 | public class UserRequest { 14 | private String firstName; 15 | private String lastName; 16 | private String courseName; 17 | } 18 | -------------------------------------------------------------------------------- /Projects/50. query-dsl-demo/src/main/java/ru/itis/search/models/Comment.java: -------------------------------------------------------------------------------- 1 | package ru.itis.search.models; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import javax.persistence.*; 9 | 10 | /** 11 | * 13.11.2018 12 | * Comment 13 | * 14 | * @author Sidikov Marsel (First Software Engineering Platform) 15 | * @version v1.0 16 | */ 17 | @Entity 18 | @Data 19 | @NoArgsConstructor 20 | @AllArgsConstructor 21 | @Builder() 22 | public class Comment { 23 | 24 | @Id 25 | @GeneratedValue(strategy = GenerationType.IDENTITY) 26 | private Long id; 27 | 28 | private String text; 29 | 30 | @ManyToOne(fetch = FetchType.LAZY) 31 | @JoinColumn(name = "user_id") 32 | private User user; 33 | } 34 | -------------------------------------------------------------------------------- /Projects/50. query-dsl-demo/src/main/java/ru/itis/search/models/Lesson.java: -------------------------------------------------------------------------------- 1 | package ru.itis.search.models; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import javax.persistence.*; 9 | import java.time.LocalTime; 10 | 11 | /** 12 | * 26.08.2017 13 | * Lesson 14 | * 15 | * @author Sidikov Marsel (First Software Engineering Platform) 16 | * @version v1.0 17 | */ 18 | 19 | @Entity 20 | @Data 21 | @NoArgsConstructor 22 | @AllArgsConstructor 23 | @Builder() 24 | public class Lesson { 25 | 26 | @Id 27 | @GeneratedValue(strategy = GenerationType.IDENTITY) 28 | private Long id; 29 | 30 | @ManyToOne(fetch = FetchType.LAZY) 31 | @JoinColumn(name = "course_id") 32 | private Course course; 33 | 34 | private LocalTime startTime; 35 | private LocalTime finishTime; 36 | } 37 | -------------------------------------------------------------------------------- /Projects/50. query-dsl-demo/src/main/java/ru/itis/search/models/Role.java: -------------------------------------------------------------------------------- 1 | package ru.itis.search.models; 2 | 3 | public enum Role { 4 | ADMIN, PARTNER, TEACHER, STUDENT, TEMP_STUDENT, MANAGER 5 | } -------------------------------------------------------------------------------- /Projects/50. query-dsl-demo/src/main/java/ru/itis/search/models/UserState.java: -------------------------------------------------------------------------------- 1 | package ru.itis.search.models; 2 | 3 | /** 4 | * 02.08.2017 5 | * 6 | * @author Marsel Sidikov (First Software Engineering Platform) 7 | * @version 1.0 8 | */ 9 | public enum UserState { 10 | NOT_CONFIRMED, CONFIRMED, DELETED, BANNED 11 | } 12 | -------------------------------------------------------------------------------- /Projects/50. query-dsl-demo/src/main/java/ru/itis/search/repositories/AccountsByRequestRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.search.repositories; 2 | 3 | import ru.itis.search.dto.UserDto; 4 | import ru.itis.search.dto.UserRequest; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * 17.12.2020 10 | * 50. query-dsl-demo 11 | * 12 | * @author Sidikov Marsel (First Software Engineering Platform) 13 | * @version v1.0 14 | */ 15 | public interface AccountsByRequestRepository { 16 | List findByRequest(UserRequest userRequest); 17 | } 18 | -------------------------------------------------------------------------------- /Projects/50. query-dsl-demo/src/main/java/ru/itis/search/repositories/AccountsRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.search.repositories; 2 | 3 | import com.querydsl.core.types.dsl.StringExpression; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.data.querydsl.QuerydslPredicateExecutor; 6 | import org.springframework.data.querydsl.binding.QuerydslBinderCustomizer; 7 | import org.springframework.data.querydsl.binding.QuerydslBindings; 8 | import ru.itis.search.models.QUser; 9 | import ru.itis.search.models.User; 10 | 11 | /** 12 | * 17.12.2020 13 | * 50. query-dsl-demo 14 | * 15 | * @author Sidikov Marsel (First Software Engineering Platform) 16 | * @version v1.0 17 | */ 18 | public interface AccountsRepository extends JpaRepository, QuerydslPredicateExecutor, QuerydslBinderCustomizer { 19 | @Override 20 | default void customize(QuerydslBindings bindings, QUser qUser) { 21 | bindings.bind(qUser.courses.any().name).as("courses.name").first( 22 | StringExpression::containsIgnoreCase 23 | ); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Projects/50. query-dsl-demo/src/main/java/ru/itis/search/repositories/CommentsRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.search.repositories; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import ru.itis.search.models.Comment; 5 | 6 | /** 7 | * 15.12.2020 8 | * search-example 9 | * 10 | * @author Sidikov Marsel (First Software Engineering Platform) 11 | * @version v1.0 12 | */ 13 | public interface CommentsRepository extends JpaRepository { 14 | } 15 | -------------------------------------------------------------------------------- /Projects/50. query-dsl-demo/src/main/java/ru/itis/search/repositories/CoursesRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.search.repositories; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import ru.itis.search.models.Course; 5 | 6 | /** 7 | * 15.12.2020 8 | * search-example 9 | * 10 | * @author Sidikov Marsel (First Software Engineering Platform) 11 | * @version v1.0 12 | */ 13 | public interface CoursesRepository extends JpaRepository { 14 | } 15 | -------------------------------------------------------------------------------- /Projects/50. query-dsl-demo/src/main/java/ru/itis/search/repositories/LessonsRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.search.repositories; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import ru.itis.search.models.Lesson; 5 | 6 | /** 7 | * 15.12.2020 8 | * search-example 9 | * 10 | * @author Sidikov Marsel (First Software Engineering Platform) 11 | * @version v1.0 12 | */ 13 | public interface LessonsRepository extends JpaRepository { 14 | } 15 | -------------------------------------------------------------------------------- /Projects/50. query-dsl-demo/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.driver-class-name=org.postgresql.Driver 2 | spring.datasource.username=postgres 3 | spring.datasource.password=qwerty007 4 | spring.jpa.hibernate.ddl-auto=update 5 | spring.datasource.url=jdbc:postgresql://localhost:5432/for_search_db 6 | spring.jpa.show-sql=true 7 | spring.jpa.properties.hibernate.format_sql=true -------------------------------------------------------------------------------- /Projects/50. query-dsl-demo/src/main/resources/http/requests.http: -------------------------------------------------------------------------------- 1 | GET http://localhost:8080/accounts/search?courses.name=sql -------------------------------------------------------------------------------- /Projects/50. query-dsl-demo/src/test/java/ru/itis/search/QueryDslDemoApplicationTests.java: -------------------------------------------------------------------------------- 1 | package ru.itis.search; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class QueryDslDemoApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Projects/51. Reactive/PureReactive/src/main/java/ru/itis/files/app/Main.java: -------------------------------------------------------------------------------- 1 | package ru.itis.files.app; 2 | 3 | import reactor.core.publisher.Flux; 4 | import ru.itis.files.dto.FileInfo; 5 | import ru.itis.files.publishers.FilesInfoService; 6 | import ru.itis.files.publishers.FilesService; 7 | import ru.itis.files.publishers.FilesServiceImpl; 8 | import ru.itis.files.publishers.FilesInfoServiceImpl; 9 | 10 | /** 11 | * 19.02.2021 12 | * PureReactive 13 | * 14 | * @author Sidikov Marsel (First Software Engineering Platform) 15 | * @version v1.0 16 | */ 17 | public class Main { 18 | public static void main(String[] args) throws Exception { 19 | FilesService filesService = new FilesServiceImpl(); 20 | FilesInfoService filesInfoService = new FilesInfoServiceImpl(); 21 | 22 | Flux urls = filesService.getFileUrls(); 23 | Flux sizes = filesInfoService.getSizes(urls); 24 | Flux mimes = filesInfoService.getMimes(urls); 25 | Flux completed = filesInfoService.getCompleted(sizes, mimes); 26 | 27 | completed.subscribe(System.out::println); 28 | 29 | Thread.sleep(40000); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Projects/51. Reactive/PureReactive/src/main/java/ru/itis/files/dto/FileInfo.java: -------------------------------------------------------------------------------- 1 | package ru.itis.files.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | /** 9 | * 19.02.2021 10 | * PureReactive 11 | * 12 | * @author Sidikov Marsel (First Software Engineering Platform) 13 | * @version v1.0 14 | */ 15 | @Data 16 | @AllArgsConstructor 17 | @NoArgsConstructor 18 | @Builder 19 | public class FileInfo { 20 | private String url; 21 | private Long size; 22 | private String MIME; 23 | private boolean isAvailable; 24 | private boolean isCompleted; 25 | } 26 | -------------------------------------------------------------------------------- /Projects/51. Reactive/PureReactive/src/main/java/ru/itis/files/publishers/FilesInfoService.java: -------------------------------------------------------------------------------- 1 | package ru.itis.files.publishers; 2 | 3 | import reactor.core.publisher.Flux; 4 | import ru.itis.files.dto.FileInfo; 5 | 6 | /** 7 | * 19.02.2021 8 | * PureReactive 9 | * 10 | * @author Sidikov Marsel (First Software Engineering Platform) 11 | * @version v1.0 12 | */ 13 | public interface FilesInfoService { 14 | Flux getSizes(Flux urls); 15 | Flux getMimes(Flux urls); 16 | Flux getCompleted(Flux sizes, Flux mimes); 17 | } 18 | -------------------------------------------------------------------------------- /Projects/51. Reactive/PureReactive/src/main/java/ru/itis/files/publishers/FilesService.java: -------------------------------------------------------------------------------- 1 | package ru.itis.files.publishers; 2 | 3 | import reactor.core.publisher.Flux; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * 19.02.2021 9 | * PureReactive 10 | * 11 | * @author Sidikov Marsel (First Software Engineering Platform) 12 | * @version v1.0 13 | */ 14 | public interface FilesService { 15 | Flux getFileUrls(); 16 | } 17 | -------------------------------------------------------------------------------- /Projects/51. Reactive/PureReactive/src/main/java/ru/itis/files/publishers/FilesServiceImpl.java: -------------------------------------------------------------------------------- 1 | package ru.itis.files.publishers; 2 | 3 | import reactor.core.publisher.Flux; 4 | 5 | import java.nio.file.Files; 6 | import java.nio.file.Paths; 7 | import java.util.List; 8 | import java.util.stream.Stream; 9 | 10 | /** 11 | * 19.02.2021 12 | * PureReactive 13 | * 14 | * @author Sidikov Marsel (First Software Engineering Platform) 15 | * @version v1.0 16 | */ 17 | public class FilesServiceImpl implements FilesService { 18 | @Override 19 | public Flux getFileUrls() { 20 | return Flux.using(() -> Files.lines(Paths.get("images.txt")), Flux::fromStream, 21 | Stream::close); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Projects/51. Reactive/completed-service/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /Projects/51. Reactive/completed-service/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarselSidikov/JAVA_ENTERPRISE_3/be49e21a250a65a28835e168c2d83e85d01662c6/Projects/51. Reactive/completed-service/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /Projects/51. Reactive/completed-service/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /Projects/51. Reactive/completed-service/src/main/java/ru/itis/files/CompletedServiceApplication.java: -------------------------------------------------------------------------------- 1 | package ru.itis.files; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.web.reactive.function.client.WebClient; 7 | 8 | @SpringBootApplication 9 | public class CompletedServiceApplication { 10 | 11 | @Bean 12 | public WebClient webClient() { 13 | return WebClient.create(); 14 | } 15 | 16 | public static void main(String[] args) { 17 | SpringApplication.run(CompletedServiceApplication.class, args); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /Projects/51. Reactive/completed-service/src/main/java/ru/itis/files/controllers/CompletedController.java: -------------------------------------------------------------------------------- 1 | package ru.itis.files.controllers; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.http.MediaType; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | import reactor.core.publisher.Flux; 8 | import ru.itis.files.dto.FileInfo; 9 | import ru.itis.files.services.CompletedService; 10 | 11 | /** 12 | * 19.02.2021 13 | * files-service 14 | * 15 | * @author Sidikov Marsel (First Software Engineering Platform) 16 | * @version v1.0 17 | */ 18 | @RestController 19 | public class CompletedController { 20 | @Autowired 21 | private CompletedService completedService; 22 | 23 | @GetMapping(value = "/files/completed", produces = MediaType.TEXT_EVENT_STREAM_VALUE) 24 | public Flux getFiles() { 25 | return completedService.getCompleted(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Projects/51. Reactive/completed-service/src/main/java/ru/itis/files/dto/FileInfo.java: -------------------------------------------------------------------------------- 1 | package ru.itis.files.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | /** 9 | * 19.02.2021 10 | * PureReactive 11 | * 12 | * @author Sidikov Marsel (First Software Engineering Platform) 13 | * @version v1.0 14 | */ 15 | @Data 16 | @AllArgsConstructor 17 | @NoArgsConstructor 18 | @Builder 19 | public class FileInfo { 20 | private String url; 21 | private Long size; 22 | private String MIME; 23 | private boolean isAvailable; 24 | private boolean isCompleted; 25 | } 26 | -------------------------------------------------------------------------------- /Projects/51. Reactive/completed-service/src/main/java/ru/itis/files/services/CompletedService.java: -------------------------------------------------------------------------------- 1 | package ru.itis.files.services; 2 | 3 | import reactor.core.publisher.Flux; 4 | import ru.itis.files.dto.FileInfo; 5 | 6 | /** 7 | * 19.02.2021 8 | * files-service 9 | * 10 | * @author Sidikov Marsel (First Software Engineering Platform) 11 | * @version v1.0 12 | */ 13 | public interface CompletedService { 14 | Flux getCompleted(); 15 | } 16 | -------------------------------------------------------------------------------- /Projects/51. Reactive/completed-service/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8083 2 | sizes.service.url=http://localhost:8081/files/sizes 3 | mimes.service.url=http://localhost:8082/files/mimes 4 | -------------------------------------------------------------------------------- /Projects/51. Reactive/completed-service/src/main/resources/static/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Title 6 | 7 | 20 | 21 | 22 |
    23 | 24 | -------------------------------------------------------------------------------- /Projects/51. Reactive/completed-service/src/test/java/ru/itis/files/FilesServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package ru.itis.files; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class FilesServiceApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Projects/51. Reactive/files-service/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /Projects/51. Reactive/files-service/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarselSidikov/JAVA_ENTERPRISE_3/be49e21a250a65a28835e168c2d83e85d01662c6/Projects/51. Reactive/files-service/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /Projects/51. Reactive/files-service/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /Projects/51. Reactive/files-service/src/main/java/ru/itis/files/FilesServiceApplication.java: -------------------------------------------------------------------------------- 1 | package ru.itis.files; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class FilesServiceApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(FilesServiceApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Projects/51. Reactive/files-service/src/main/java/ru/itis/files/controllers/FilesController.java: -------------------------------------------------------------------------------- 1 | package ru.itis.files.controllers; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.http.MediaType; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | import reactor.core.publisher.Flux; 8 | import ru.itis.files.dto.FileInfo; 9 | import ru.itis.files.services.FilesService; 10 | 11 | import java.time.Duration; 12 | 13 | /** 14 | * 19.02.2021 15 | * files-service 16 | * 17 | * @author Sidikov Marsel (First Software Engineering Platform) 18 | * @version v1.0 19 | */ 20 | @RestController 21 | public class FilesController { 22 | @Autowired 23 | private FilesService filesService; 24 | 25 | @GetMapping(value = "/files", produces = MediaType.TEXT_EVENT_STREAM_VALUE) 26 | public Flux getFiles() { 27 | return filesService.getFiles(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Projects/51. Reactive/files-service/src/main/java/ru/itis/files/dto/FileInfo.java: -------------------------------------------------------------------------------- 1 | package ru.itis.files.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | /** 9 | * 19.02.2021 10 | * PureReactive 11 | * 12 | * @author Sidikov Marsel (First Software Engineering Platform) 13 | * @version v1.0 14 | */ 15 | @Data 16 | @AllArgsConstructor 17 | @NoArgsConstructor 18 | @Builder 19 | public class FileInfo { 20 | private String url; 21 | private Long size; 22 | private String MIME; 23 | private boolean isAvailable; 24 | private boolean isCompleted; 25 | } 26 | -------------------------------------------------------------------------------- /Projects/51. Reactive/files-service/src/main/java/ru/itis/files/services/FilesService.java: -------------------------------------------------------------------------------- 1 | package ru.itis.files.services; 2 | 3 | import reactor.core.publisher.Flux; 4 | import ru.itis.files.dto.FileInfo; 5 | 6 | /** 7 | * 19.02.2021 8 | * files-service 9 | * 10 | * @author Sidikov Marsel (First Software Engineering Platform) 11 | * @version v1.0 12 | */ 13 | public interface FilesService { 14 | Flux getFiles(); 15 | } 16 | -------------------------------------------------------------------------------- /Projects/51. Reactive/files-service/src/main/java/ru/itis/files/services/FilesServiceImpl.java: -------------------------------------------------------------------------------- 1 | package ru.itis.files.services; 2 | 3 | import org.springframework.stereotype.Component; 4 | import org.springframework.stereotype.Service; 5 | import reactor.core.publisher.Flux; 6 | import ru.itis.files.dto.FileInfo; 7 | 8 | import java.nio.file.Files; 9 | import java.nio.file.Paths; 10 | import java.util.stream.Stream; 11 | 12 | /** 13 | * 19.02.2021 14 | * files-service 15 | * 16 | * @author Sidikov Marsel (First Software Engineering Platform) 17 | * @version v1.0 18 | */ 19 | @Service 20 | public class FilesServiceImpl implements FilesService { 21 | @Override 22 | public Flux getFiles() { 23 | return Flux.using(() -> Files.lines(Paths.get("images.txt")), Flux::fromStream, 24 | Stream::close).map(fileUrl -> FileInfo.builder() 25 | .url(fileUrl) 26 | .build()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Projects/51. Reactive/files-service/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8080 2 | -------------------------------------------------------------------------------- /Projects/51. Reactive/files-service/src/test/java/ru/itis/files/FilesServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package ru.itis.files; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class FilesServiceApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Projects/51. Reactive/mimes-service/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /Projects/51. Reactive/mimes-service/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarselSidikov/JAVA_ENTERPRISE_3/be49e21a250a65a28835e168c2d83e85d01662c6/Projects/51. Reactive/mimes-service/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /Projects/51. Reactive/mimes-service/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /Projects/51. Reactive/mimes-service/src/main/java/ru/itis/files/FilesServiceApplication.java: -------------------------------------------------------------------------------- 1 | package ru.itis.files; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.web.reactive.function.client.WebClient; 7 | 8 | @SpringBootApplication 9 | public class FilesServiceApplication { 10 | 11 | @Bean 12 | public WebClient webClient() { 13 | return WebClient.create(); 14 | } 15 | 16 | public static void main(String[] args) { 17 | SpringApplication.run(FilesServiceApplication.class, args); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /Projects/51. Reactive/mimes-service/src/main/java/ru/itis/files/controllers/MimesController.java: -------------------------------------------------------------------------------- 1 | package ru.itis.files.controllers; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.http.MediaType; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | import reactor.core.publisher.Flux; 8 | import ru.itis.files.dto.FileInfo; 9 | import ru.itis.files.services.FileMimeService; 10 | 11 | /** 12 | * 19.02.2021 13 | * files-service 14 | * 15 | * @author Sidikov Marsel (First Software Engineering Platform) 16 | * @version v1.0 17 | */ 18 | @RestController 19 | public class MimesController { 20 | @Autowired 21 | private FileMimeService fileMimesService; 22 | 23 | @GetMapping(value = "/files/mimes", produces = MediaType.TEXT_EVENT_STREAM_VALUE) 24 | public Flux getFiles() { 25 | return fileMimesService.getMimes(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Projects/51. Reactive/mimes-service/src/main/java/ru/itis/files/dto/FileInfo.java: -------------------------------------------------------------------------------- 1 | package ru.itis.files.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | /** 9 | * 19.02.2021 10 | * PureReactive 11 | * 12 | * @author Sidikov Marsel (First Software Engineering Platform) 13 | * @version v1.0 14 | */ 15 | @Data 16 | @AllArgsConstructor 17 | @NoArgsConstructor 18 | @Builder 19 | public class FileInfo { 20 | private String url; 21 | private Long size; 22 | private String MIME; 23 | private boolean isAvailable; 24 | private boolean isCompleted; 25 | } 26 | -------------------------------------------------------------------------------- /Projects/51. Reactive/mimes-service/src/main/java/ru/itis/files/services/FileMimeService.java: -------------------------------------------------------------------------------- 1 | package ru.itis.files.services; 2 | 3 | import reactor.core.publisher.Flux; 4 | import ru.itis.files.dto.FileInfo; 5 | 6 | /** 7 | * 19.02.2021 8 | * files-service 9 | * 10 | * @author Sidikov Marsel (First Software Engineering Platform) 11 | * @version v1.0 12 | */ 13 | public interface FileMimeService { 14 | Flux getMimes(); 15 | } 16 | -------------------------------------------------------------------------------- /Projects/51. Reactive/mimes-service/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8082 2 | files.service.url=http://localhost:8080/files 3 | -------------------------------------------------------------------------------- /Projects/51. Reactive/mimes-service/src/test/java/ru/itis/files/FilesServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package ru.itis.files; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class FilesServiceApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Projects/51. Reactive/sizes-service/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /Projects/51. Reactive/sizes-service/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarselSidikov/JAVA_ENTERPRISE_3/be49e21a250a65a28835e168c2d83e85d01662c6/Projects/51. Reactive/sizes-service/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /Projects/51. Reactive/sizes-service/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /Projects/51. Reactive/sizes-service/src/main/java/ru/itis/files/FilesServiceApplication.java: -------------------------------------------------------------------------------- 1 | package ru.itis.files; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.web.reactive.function.client.WebClient; 7 | 8 | @SpringBootApplication 9 | public class FilesServiceApplication { 10 | 11 | @Bean 12 | public WebClient webClient() { 13 | return WebClient.create(); 14 | } 15 | 16 | public static void main(String[] args) { 17 | SpringApplication.run(FilesServiceApplication.class, args); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /Projects/51. Reactive/sizes-service/src/main/java/ru/itis/files/controllers/SizesController.java: -------------------------------------------------------------------------------- 1 | package ru.itis.files.controllers; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.http.MediaType; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | import reactor.core.publisher.Flux; 8 | import ru.itis.files.dto.FileInfo; 9 | import ru.itis.files.services.FileSizeService; 10 | 11 | import java.time.Duration; 12 | 13 | /** 14 | * 19.02.2021 15 | * files-service 16 | * 17 | * @author Sidikov Marsel (First Software Engineering Platform) 18 | * @version v1.0 19 | */ 20 | @RestController 21 | public class SizesController { 22 | @Autowired 23 | private FileSizeService filesSizeService; 24 | 25 | @GetMapping(value = "/files/sizes", produces = MediaType.TEXT_EVENT_STREAM_VALUE) 26 | public Flux getFiles() { 27 | return filesSizeService.getSizes(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Projects/51. Reactive/sizes-service/src/main/java/ru/itis/files/dto/FileInfo.java: -------------------------------------------------------------------------------- 1 | package ru.itis.files.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | /** 9 | * 19.02.2021 10 | * PureReactive 11 | * 12 | * @author Sidikov Marsel (First Software Engineering Platform) 13 | * @version v1.0 14 | */ 15 | @Data 16 | @AllArgsConstructor 17 | @NoArgsConstructor 18 | @Builder 19 | public class FileInfo { 20 | private String url; 21 | private Long size; 22 | private String MIME; 23 | private boolean isAvailable; 24 | private boolean isCompleted; 25 | } 26 | -------------------------------------------------------------------------------- /Projects/51. Reactive/sizes-service/src/main/java/ru/itis/files/services/FileSizeService.java: -------------------------------------------------------------------------------- 1 | package ru.itis.files.services; 2 | 3 | import reactor.core.publisher.Flux; 4 | import ru.itis.files.dto.FileInfo; 5 | 6 | /** 7 | * 19.02.2021 8 | * files-service 9 | * 10 | * @author Sidikov Marsel (First Software Engineering Platform) 11 | * @version v1.0 12 | */ 13 | public interface FileSizeService { 14 | Flux getSizes(); 15 | } 16 | -------------------------------------------------------------------------------- /Projects/51. Reactive/sizes-service/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8081 2 | files.service.url=http://localhost:8080/files 3 | -------------------------------------------------------------------------------- /Projects/51. Reactive/sizes-service/src/test/java/ru/itis/files/FilesServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package ru.itis.files; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class FilesServiceApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Projects/52. JwtRedis/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /Projects/52. JwtRedis/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarselSidikov/JAVA_ENTERPRISE_3/be49e21a250a65a28835e168c2d83e85d01662c6/Projects/52. JwtRedis/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /Projects/52. JwtRedis/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.1/apache-maven-3.8.1-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /Projects/52. JwtRedis/src/main/java/ru/itis/api/JwtRedisApplication.java: -------------------------------------------------------------------------------- 1 | package ru.itis.api; 2 | 3 | import com.auth0.jwt.algorithms.Algorithm; 4 | import org.springframework.beans.factory.annotation.Value; 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 9 | import org.springframework.security.crypto.password.PasswordEncoder; 10 | 11 | @SpringBootApplication 12 | public class JwtRedisApplication { 13 | 14 | @Value("${jwt.secret}") 15 | private String secret; 16 | 17 | @Bean 18 | public Algorithm algorithm() { 19 | return Algorithm.HMAC256(secret); 20 | } 21 | 22 | @Bean 23 | public PasswordEncoder passwordEncoder() { 24 | return new BCryptPasswordEncoder(); 25 | } 26 | 27 | public static void main(String[] args) { 28 | SpringApplication.run(JwtRedisApplication.class, args); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /Projects/52. JwtRedis/src/main/java/ru/itis/api/controllers/LoginController.java: -------------------------------------------------------------------------------- 1 | package ru.itis.api.controllers; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.http.ResponseEntity; 5 | import org.springframework.web.bind.annotation.PostMapping; 6 | import org.springframework.web.bind.annotation.RequestBody; 7 | import org.springframework.web.bind.annotation.RestController; 8 | import ru.itis.api.dto.EmailPasswordDto; 9 | import ru.itis.api.dto.TokenDto; 10 | import ru.itis.api.services.LoginService; 11 | 12 | /** 13 | * 05.04.2021 14 | * 21. REST API 15 | * 16 | * @author Sidikov Marsel (First Software Engineering Platform) 17 | * @version v1.0 18 | */ 19 | @RestController 20 | public class LoginController { 21 | 22 | @Autowired 23 | private LoginService loginService; 24 | 25 | @PostMapping("/login") 26 | public ResponseEntity login(@RequestBody EmailPasswordDto emailPassword) { 27 | return ResponseEntity.ok(loginService.login(emailPassword)); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Projects/52. JwtRedis/src/main/java/ru/itis/api/controllers/TeachersController.java: -------------------------------------------------------------------------------- 1 | package ru.itis.api.controllers; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.http.ResponseEntity; 5 | import org.springframework.web.bind.annotation.*; 6 | import ru.itis.api.dto.TeacherDto; 7 | import ru.itis.api.services.TeachersService; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * 24.03.2021 13 | * 04. REST API 14 | * 15 | * @author Sidikov Marsel (First Software Engineering Platform) 16 | * @version v1.0 17 | */ 18 | @RestController 19 | public class TeachersController { 20 | 21 | @Autowired 22 | private TeachersService teachersService; 23 | 24 | @GetMapping("/teachers") 25 | public ResponseEntity> getTeachers() { 26 | return ResponseEntity.ok(teachersService.getAllTeachers()); 27 | } 28 | 29 | @PostMapping("/teachers") 30 | public ResponseEntity addTeacher(@RequestBody TeacherDto teacher) { 31 | return ResponseEntity.ok(teachersService.addTeacher(teacher)); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Projects/52. JwtRedis/src/main/java/ru/itis/api/controllers/UsersController.java: -------------------------------------------------------------------------------- 1 | package ru.itis.api.controllers; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.http.ResponseEntity; 5 | import org.springframework.web.bind.annotation.PathVariable; 6 | import org.springframework.web.bind.annotation.PostMapping; 7 | import org.springframework.web.bind.annotation.RestController; 8 | import ru.itis.api.services.UsersService; 9 | 10 | /** 11 | * 09.04.2021 12 | * 52. JwtRedis 13 | * 14 | * @author Sidikov Marsel (First Software Engineering Platform) 15 | * @version v1.0 16 | */ 17 | @RestController 18 | public class UsersController { 19 | @Autowired 20 | private UsersService usersService; 21 | 22 | @PostMapping("/users/{user-id}/block") 23 | public ResponseEntity blockUser(@PathVariable("user-id") Long userId) { 24 | usersService.blockUser(userId); 25 | return ResponseEntity.ok().build(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Projects/52. JwtRedis/src/main/java/ru/itis/api/dto/EmailPasswordDto.java: -------------------------------------------------------------------------------- 1 | package ru.itis.api.dto; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * 05.04.2021 7 | * 21. REST API 8 | * 9 | * @author Sidikov Marsel (First Software Engineering Platform) 10 | * @version v1.0 11 | */ 12 | @Data 13 | public class EmailPasswordDto { 14 | private String email; 15 | private String password; 16 | } 17 | -------------------------------------------------------------------------------- /Projects/52. JwtRedis/src/main/java/ru/itis/api/dto/TeacherDto.java: -------------------------------------------------------------------------------- 1 | package ru.itis.api.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | import ru.itis.api.models.Teacher; 8 | 9 | import java.util.List; 10 | import java.util.stream.Collectors; 11 | 12 | /** 13 | * 24.03.2021 14 | * 04. REST API 15 | * 16 | * @author Sidikov Marsel (First Software Engineering Platform) 17 | * @version v1.0 18 | */ 19 | @Data 20 | @AllArgsConstructor 21 | @NoArgsConstructor 22 | @Builder 23 | public class TeacherDto { 24 | private Long id; 25 | private String firstName; 26 | private String lastName; 27 | 28 | public static TeacherDto from(Teacher teacher) { 29 | return TeacherDto.builder() 30 | .id(teacher.getId()) 31 | .firstName(teacher.getFirstName()) 32 | .lastName(teacher.getLastName()) 33 | .build(); 34 | } 35 | 36 | public static List from(List teachers) { 37 | return teachers.stream().map(TeacherDto::from).collect(Collectors.toList()); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Projects/52. JwtRedis/src/main/java/ru/itis/api/dto/TokenDto.java: -------------------------------------------------------------------------------- 1 | package ru.itis.api.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | /** 9 | * 05.04.2021 10 | * 21. REST API 11 | * 12 | * @author Sidikov Marsel (First Software Engineering Platform) 13 | * @version v1.0 14 | */ 15 | @Data 16 | @AllArgsConstructor 17 | @NoArgsConstructor 18 | @Builder 19 | public class TokenDto { 20 | private String token; 21 | } 22 | -------------------------------------------------------------------------------- /Projects/52. JwtRedis/src/main/java/ru/itis/api/models/Teacher.java: -------------------------------------------------------------------------------- 1 | package ru.itis.api.models; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import javax.persistence.*; 9 | import java.util.List; 10 | 11 | /** 12 | * 24.03.2021 13 | * 04. REST API 14 | * 15 | * @author Sidikov Marsel (First Software Engineering Platform) 16 | * @version v1.0 17 | */ 18 | @Data 19 | @AllArgsConstructor 20 | @NoArgsConstructor 21 | @Builder 22 | @Entity 23 | public class Teacher { 24 | @Id 25 | @GeneratedValue(strategy = GenerationType.IDENTITY) 26 | private Long id; 27 | 28 | private String firstName; 29 | private String lastName; 30 | 31 | private Boolean isDeleted; 32 | } 33 | -------------------------------------------------------------------------------- /Projects/52. JwtRedis/src/main/java/ru/itis/api/redis/models/RedisUser.java: -------------------------------------------------------------------------------- 1 | package ru.itis.api.redis.models; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | import org.springframework.data.annotation.Id; 8 | import org.springframework.data.redis.core.RedisHash; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * 09.04.2021 14 | * 52. JwtRedis 15 | * 16 | * @author Sidikov Marsel (First Software Engineering Platform) 17 | * @version v1.0 18 | */ 19 | @Data 20 | @AllArgsConstructor 21 | @NoArgsConstructor 22 | @Builder 23 | @RedisHash("user") 24 | public class RedisUser { 25 | @Id 26 | private String id; 27 | private List tokens; 28 | private Long userId; 29 | } 30 | -------------------------------------------------------------------------------- /Projects/52. JwtRedis/src/main/java/ru/itis/api/redis/repository/BlacklistRepositoryRedisTemplateImpl.java: -------------------------------------------------------------------------------- 1 | package ru.itis.api.redis.repository; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.data.redis.core.RedisTemplate; 5 | import org.springframework.stereotype.Repository; 6 | import ru.itis.api.repository.BlacklistRepository; 7 | 8 | /** 9 | * 09.04.2021 10 | * 52. JwtRedis 11 | * 12 | * @author Sidikov Marsel (First Software Engineering Platform) 13 | * @version v1.0 14 | */ 15 | @Repository 16 | public class BlacklistRepositoryRedisTemplateImpl implements BlacklistRepository { 17 | 18 | @Autowired 19 | private RedisTemplate redisTemplate; 20 | 21 | @Override 22 | public void save(String token) { 23 | redisTemplate.opsForValue().set(token, ""); 24 | } 25 | 26 | @Override 27 | public boolean exists(String token) { 28 | Boolean hasToken = redisTemplate.hasKey(token); 29 | return hasToken != null && hasToken; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Projects/52. JwtRedis/src/main/java/ru/itis/api/redis/repository/RedisUsersRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.api.redis.repository; 2 | 3 | import org.springframework.data.keyvalue.repository.KeyValueRepository; 4 | import ru.itis.api.redis.models.RedisUser; 5 | 6 | /** 7 | * 09.04.2021 8 | * 52. JwtRedis 9 | * 10 | * @author Sidikov Marsel (First Software Engineering Platform) 11 | * @version v1.0 12 | */ 13 | public interface RedisUsersRepository extends KeyValueRepository { 14 | } 15 | -------------------------------------------------------------------------------- /Projects/52. JwtRedis/src/main/java/ru/itis/api/redis/services/RedisUsersService.java: -------------------------------------------------------------------------------- 1 | package ru.itis.api.redis.services; 2 | 3 | import ru.itis.api.models.User; 4 | 5 | /** 6 | * 09.04.2021 7 | * 52. JwtRedis 8 | * 9 | * @author Sidikov Marsel (First Software Engineering Platform) 10 | * @version v1.0 11 | */ 12 | public interface RedisUsersService { 13 | void addTokenToUser(User user, String token); 14 | 15 | void addAllTokensToBlackList(User user); 16 | } 17 | -------------------------------------------------------------------------------- /Projects/52. JwtRedis/src/main/java/ru/itis/api/repository/BlacklistRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.api.repository; 2 | 3 | /** 4 | * 09.04.2021 5 | * 52. JwtRedis 6 | * 7 | * @author Sidikov Marsel (First Software Engineering Platform) 8 | * @version v1.0 9 | */ 10 | public interface BlacklistRepository { 11 | void save(String token); 12 | 13 | boolean exists(String token); 14 | } 15 | -------------------------------------------------------------------------------- /Projects/52. JwtRedis/src/main/java/ru/itis/api/repository/TeachersRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.api.repository; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import ru.itis.api.models.Teacher; 5 | import java.util.List; 6 | 7 | /** 8 | * 24.03.2021 9 | * 04. REST API 10 | * 11 | * @author Sidikov Marsel (First Software Engineering Platform) 12 | * @version v1.0 13 | */ 14 | public interface TeachersRepository extends JpaRepository { 15 | List findAllByIsDeletedIsNull(); 16 | } 17 | -------------------------------------------------------------------------------- /Projects/52. JwtRedis/src/main/java/ru/itis/api/repository/UsersRepository.java: -------------------------------------------------------------------------------- 1 | package ru.itis.api.repository; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import ru.itis.api.models.User; 5 | 6 | import java.util.Optional; 7 | 8 | /** 9 | * 10.02.2021 10 | * spring-boot-demo 11 | * 12 | * @author Sidikov Marsel (First Software Engineering Platform) 13 | * @version v1.0 14 | */ 15 | public interface UsersRepository extends JpaRepository { 16 | Optional findByEmail(String email); 17 | } 18 | -------------------------------------------------------------------------------- /Projects/52. JwtRedis/src/main/java/ru/itis/api/services/JwtBlacklistService.java: -------------------------------------------------------------------------------- 1 | package ru.itis.api.services; 2 | 3 | /** 4 | * 09.04.2021 5 | * 52. JwtRedis 6 | * 7 | * @author Sidikov Marsel (First Software Engineering Platform) 8 | * @version v1.0 9 | */ 10 | public interface JwtBlacklistService { 11 | void add(String token); 12 | 13 | boolean exists(String token); 14 | } 15 | -------------------------------------------------------------------------------- /Projects/52. JwtRedis/src/main/java/ru/itis/api/services/JwtBlacklistServiceImpl.java: -------------------------------------------------------------------------------- 1 | package ru.itis.api.services; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Service; 5 | import ru.itis.api.repository.BlacklistRepository; 6 | 7 | /** 8 | * 09.04.2021 9 | * 52. JwtRedis 10 | * 11 | * @author Sidikov Marsel (First Software Engineering Platform) 12 | * @version v1.0 13 | */ 14 | @Service 15 | public class JwtBlacklistServiceImpl implements JwtBlacklistService { 16 | 17 | @Autowired 18 | private BlacklistRepository blacklistRepository; 19 | 20 | @Override 21 | public void add(String token) { 22 | blacklistRepository.save(token); 23 | } 24 | 25 | @Override 26 | public boolean exists(String token) { 27 | return blacklistRepository.exists(token); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Projects/52. JwtRedis/src/main/java/ru/itis/api/services/LoginService.java: -------------------------------------------------------------------------------- 1 | package ru.itis.api.services; 2 | 3 | 4 | import ru.itis.api.dto.EmailPasswordDto; 5 | import ru.itis.api.dto.TokenDto; 6 | 7 | /** 8 | * 05.04.2021 9 | * 21. REST API 10 | * 11 | * @author Sidikov Marsel (First Software Engineering Platform) 12 | * @version v1.0 13 | */ 14 | public interface LoginService { 15 | TokenDto login(EmailPasswordDto emailPassword); 16 | } 17 | -------------------------------------------------------------------------------- /Projects/52. JwtRedis/src/main/java/ru/itis/api/services/TeachersService.java: -------------------------------------------------------------------------------- 1 | package ru.itis.api.services; 2 | 3 | 4 | import ru.itis.api.dto.TeacherDto; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * 24.03.2021 10 | * 04. REST API 11 | * 12 | * @author Sidikov Marsel (First Software Engineering Platform) 13 | * @version v1.0 14 | */ 15 | public interface TeachersService { 16 | List getAllTeachers(); 17 | 18 | TeacherDto addTeacher(TeacherDto teacher); 19 | } 20 | -------------------------------------------------------------------------------- /Projects/52. JwtRedis/src/main/java/ru/itis/api/services/UsersService.java: -------------------------------------------------------------------------------- 1 | package ru.itis.api.services; 2 | 3 | /** 4 | * 09.04.2021 5 | * JwtRedis 6 | * 7 | * @author Sidikov Marsel (First Software Engineering Platform) 8 | * @version v1.0 9 | */ 10 | public interface UsersService { 11 | void blockUser(Long userId); 12 | } 13 | -------------------------------------------------------------------------------- /Projects/52. JwtRedis/src/main/java/ru/itis/api/services/UsersServiceImpl.java: -------------------------------------------------------------------------------- 1 | package ru.itis.api.services; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Service; 5 | import ru.itis.api.models.User; 6 | import ru.itis.api.redis.services.RedisUsersService; 7 | import ru.itis.api.repository.UsersRepository; 8 | 9 | /** 10 | * 09.04.2021 11 | * 52. JwtRedis 12 | * 13 | * @author Sidikov Marsel (First Software Engineering Platform) 14 | * @version v1.0 15 | */ 16 | @Service 17 | public class UsersServiceImpl implements UsersService { 18 | 19 | @Autowired 20 | private UsersRepository usersRepository; 21 | 22 | @Autowired 23 | private RedisUsersService redisUsersService; 24 | 25 | @Override 26 | public void blockUser(Long userId) { 27 | User user = usersRepository.findById(userId).orElseThrow(IllegalArgumentException::new); 28 | redisUsersService.addAllTokensToBlackList(user); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Projects/52. JwtRedis/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.redis.host=79.143.31.198 2 | spring.redis.port=6379 3 | 4 | server.port=80 5 | spring.datasource.username=postgres 6 | spring.datasource.password=qwerty007 7 | spring.datasource.url=jdbc:postgresql://localhost:5432/rest_db 8 | spring.jpa.hibernate.ddl-auto=update 9 | spring.jpa.show-sql=true 10 | spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration 11 | 12 | jwt.secret=secret -------------------------------------------------------------------------------- /Projects/52. JwtRedis/src/main/resources/http/requests.http: -------------------------------------------------------------------------------- 1 | POST http://localhost/login 2 | Content-Type: application/json 3 | 4 | { 5 | "email": "sidikov.marsel@gmail.com", 6 | "password": "qwerty007" 7 | } 8 | 9 | ### 10 | 11 | GET http://localhost/teachers 12 | Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIiwiY3JlYXRlZEF0IjoiMjAyMS0wNC0wOVQxNTozMDoyNS42MzciLCJyb2xlIjoiQURNSU4iLCJzdGF0ZSI6IkFDVElWRSIsImVtYWlsIjoic2lkaWtvdi5tYXJzZWxAZ21haWwuY29tIn0.ADgjiCC3psxg-CxjO2zAMXryiRXpbQ2mH13FPylnZrk 13 | ### 14 | 15 | GET http://localhost/logout 16 | Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIiwiY3JlYXRlZEF0IjoiMjAyMS0wNC0wOVQxNDo1NDozNS42MjMiLCJyb2xlIjoiQURNSU4iLCJzdGF0ZSI6IkFDVElWRSIsImVtYWlsIjoic2lkaWtvdi5tYXJzZWxAZ21haWwuY29tIn0._61QBr2RvzWYkEXzfoEQ2vZP-iMbMVnB2pT8Tkkq7Qk 17 | 18 | ### 19 | 20 | POST http://localhost/users/1/block 21 | Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIiwiY3JlYXRlZEF0IjoiMjAyMS0wNC0wOVQxNTozMDoyNS42MzciLCJyb2xlIjoiQURNSU4iLCJzdGF0ZSI6IkFDVElWRSIsImVtYWlsIjoic2lkaWtvdi5tYXJzZWxAZ21haWwuY29tIn0.ADgjiCC3psxg-CxjO2zAMXryiRXpbQ2mH13FPylnZrk -------------------------------------------------------------------------------- /Projects/52. JwtRedis/src/test/java/ru/itis/api/JwtRedisApplicationTests.java: -------------------------------------------------------------------------------- 1 | package ru.itis.api; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class JwtRedisApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Themes/# 06. Prepared Statements.md: -------------------------------------------------------------------------------- 1 | # Подготовленные запросы 2 | 3 | ## Жизненный цикл запроса 4 | 5 | 1. Создание Connection (или использование готового) 6 | 2. Отправка запроса на сервер 7 | 3. Выполняется парсинг запроса 8 | 4. Выполняется анализ запроса 9 | 5. Строится план запроса 10 | 6. Выполняется план запроса 11 | 12 | * План запроса - реальная последовательность действий, которую выполняет ядро СУБД для получения реального результата. 13 | 14 | * Оператор `explain` - показывает план запроса. 15 | 16 | * Подготовленный оператор - оператор, созданный на основе запроса. Данный запрос кэширован - он не проходит этапы 3 и 4. 17 | 18 | * Оператор `prepare` - создание подготовленного оператора. 19 | 20 | * Оператор `execute` - вызов подготовленного оператора по его названию. После 5-ти кратного вызова СУБД будет кэшировать также план запроса. 21 | --------------------------------------------------------------------------------