├── .idea
├── .name
├── sqldialects.xml
├── vcs.xml
├── encodings.xml
├── modules.xml
├── .gitignore
├── misc.xml
├── libraries
│ ├── Maven__antlr_antlr_2_7_7.xml
│ ├── Maven__junit_junit_4_13_2.xml
│ ├── Maven__org_ow2_asm_asm_5_0_4.xml
│ ├── Maven__org_dom4j_dom4j_2_1_3.xml
│ ├── Maven__com_h2database_h2_1_4_200.xml
│ ├── Maven__org_hamcrest_hamcrest_2_2.xml
│ ├── Maven__org_yaml_snakeyaml_1_27.xml
│ ├── Maven__com_zaxxer_HikariCP_3_4_5.xml
│ ├── Maven__net_minidev_json_smart_2_3.xml
│ ├── Maven__org_glassfish_jaxb_txw2_2_3_3.xml
│ ├── Maven__org_objenesis_objenesis_3_1.xml
│ ├── Maven__org_slf4j_slf4j_api_1_7_30.xml
│ ├── Maven__com_fasterxml_classmate_1_5_1.xml
│ ├── Maven__org_jboss_jandex_2_2_3_Final.xml
│ ├── Maven__com_google_guava_guava_30_1_jre.xml
│ ├── Maven__org_glassfish_jakarta_el_3_0_3.xml
│ ├── Maven__org_hamcrest_hamcrest_core_2_2.xml
│ ├── Maven__org_quartz_scheduler_quartz_2_3_2.xml
│ ├── Maven__org_atteo_evo_inflector_1_2_2.xml
│ ├── Maven__org_opentest4j_opentest4j_1_2_0.xml
│ ├── Maven__org_projectlombok_lombok_1_18_18.xml
│ ├── Maven__org_slf4j_jul_to_slf4j_1_7_30.xml
│ ├── Maven__org_xmlunit_xmlunit_core_2_7_0.xml
│ ├── Maven__org_skyscreamer_jsonassert_1_5_0.xml
│ ├── Maven__net_bytebuddy_byte_buddy_1_10_20.xml
│ ├── Maven__net_minidev_accessors_smart_1_2.xml
│ ├── Maven__org_aspectj_aspectjweaver_1_9_6.xml
│ ├── Maven__org_assertj_assertj_core_3_18_1.xml
│ ├── Maven__org_mockito_mockito_core_3_6_28.xml
│ ├── Maven__ch_qos_logback_logback_core_1_2_3.xml
│ ├── Maven__com_google_code_findbugs_jsr305_3_0_2.xml
│ ├── Maven__com_jayway_jsonpath_json_path_2_4_0.xml
│ ├── Maven__org_springframework_spring_tx_5_3_4.xml
│ ├── Maven__org_javassist_javassist_3_27_0_GA.xml
│ ├── Maven__org_springframework_spring_aop_5_3_4.xml
│ ├── Maven__org_springframework_spring_jcl_5_3_4.xml
│ ├── Maven__org_springframework_spring_orm_5_3_4.xml
│ ├── Maven__org_springframework_spring_web_5_3_4.xml
│ ├── Maven__org_springframework_spring_core_5_3_4.xml
│ ├── Maven__org_springframework_spring_jdbc_5_3_4.xml
│ ├── Maven__org_springframework_spring_test_5_3_4.xml
│ ├── Maven__com_google_guava_failureaccess_1_0_1.xml
│ ├── Maven__org_apache_commons_commons_lang3_3_11.xml
│ ├── Maven__org_glassfish_jaxb_jaxb_runtime_2_3_3.xml
│ ├── Maven__ch_qos_logback_logback_classic_1_2_3.xml
│ ├── Maven__mysql_mysql_connector_java_8_0_23.xml
│ ├── Maven__org_junit_jupiter_junit_jupiter_5_7_1.xml
│ ├── Maven__org_springframework_spring_beans_5_3_4.xml
│ ├── Maven__org_apiguardian_apiguardian_api_1_1_0.xml
│ ├── Maven__org_checkerframework_checker_qual_3_5_0.xml
│ ├── Maven__org_apache_logging_log4j_log4j_api_2_13_3.xml
│ ├── Maven__org_springframework_spring_webmvc_5_3_4.xml
│ ├── Maven__org_springframework_boot_spring_boot_2_4_3.xml
│ ├── Maven__org_springframework_spring_aspects_5_3_4.xml
│ ├── Maven__org_springframework_spring_context_5_3_4.xml
│ ├── Maven__com_google_j2objc_j2objc_annotations_1_3.xml
│ ├── Maven__net_bytebuddy_byte_buddy_agent_1_10_20.xml
│ ├── Maven__com_mchange_mchange_commons_java_0_2_15.xml
│ ├── Maven__org_junit_jupiter_junit_jupiter_api_5_7_1.xml
│ ├── Maven__org_hibernate_hibernate_core_5_4_28_Final.xml
│ ├── Maven__org_mockito_mockito_junit_jupiter_3_6_28.xml
│ ├── Maven__org_springframework_spring_expression_5_3_4.xml
│ ├── Maven__com_fasterxml_jackson_core_jackson_core_2_11_4.xml
│ ├── Maven__com_sun_activation_jakarta_activation_1_2_2.xml
│ ├── Maven__org_jboss_logging_jboss_logging_3_4_1_Final.xml
│ ├── Maven__jakarta_xml_bind_jakarta_xml_bind_api_2_3_3.xml
│ ├── Maven__org_apache_logging_log4j_log4j_to_slf4j_2_13_3.xml
│ ├── Maven__org_springframework_data_spring_data_jpa_2_4_5.xml
│ ├── Maven__org_junit_jupiter_junit_jupiter_engine_5_7_1.xml
│ ├── Maven__org_junit_jupiter_junit_jupiter_params_5_7_1.xml
│ ├── Maven__org_springframework_boot_spring_boot_test_2_4_3.xml
│ ├── Maven__org_springframework_hateoas_spring_hateoas_1_2_4.xml
│ ├── Maven__com_sun_istack_istack_commons_runtime_3_0_11.xml
│ ├── Maven__org_junit_platform_junit_platform_engine_1_7_1.xml
│ ├── Maven__org_apache_tomcat_embed_tomcat_embed_core_9_0_43.xml
│ ├── Maven__com_fasterxml_jackson_core_jackson_databind_2_11_4.xml
│ ├── Maven__jakarta_activation_jakarta_activation_api_1_2_2.xml
│ ├── Maven__jakarta_annotation_jakarta_annotation_api_1_3_5.xml
│ ├── Maven__jakarta_validation_jakarta_validation_api_2_0_2.xml
│ ├── Maven__org_junit_platform_junit_platform_commons_1_7_1.xml
│ ├── Maven__org_springframework_boot_spring_boot_starter_2_4_3.xml
│ ├── Maven__org_springframework_data_spring_data_commons_2_4_5.xml
│ ├── Maven__org_springframework_spring_context_support_5_3_4.xml
│ ├── Maven__jakarta_persistence_jakarta_persistence_api_2_2_3.xml
│ ├── Maven__jakarta_transaction_jakarta_transaction_api_1_3_3.xml
│ ├── Maven__org_springframework_data_spring_data_rest_core_3_4_5.xml
│ ├── Maven__com_fasterxml_jackson_core_jackson_annotations_2_11_4.xml
│ ├── Maven__com_google_errorprone_error_prone_annotations_2_3_4.xml
│ ├── Maven__org_apache_tomcat_embed_tomcat_embed_websocket_9_0_43.xml
│ ├── Maven__org_springframework_boot_spring_boot_starter_aop_2_4_3.xml
│ ├── Maven__org_springframework_boot_spring_boot_starter_web_2_4_3.xml
│ ├── Maven__org_springframework_data_spring_data_rest_webmvc_3_4_5.xml
│ ├── Maven__org_springframework_boot_spring_boot_starter_jdbc_2_4_3.xml
│ ├── Maven__org_springframework_boot_spring_boot_starter_json_2_4_3.xml
│ ├── Maven__org_springframework_boot_spring_boot_starter_test_2_4_3.xml
│ ├── Maven__org_hibernate_validator_hibernate_validator_6_1_7_Final.xml
│ ├── Maven__org_springframework_boot_spring_boot_autoconfigure_2_4_3.xml
│ ├── Maven__org_springframework_boot_spring_boot_starter_cache_2_4_3.xml
│ ├── Maven__com_fasterxml_jackson_datatype_jackson_datatype_jdk8_2_11_4.xml
│ ├── Maven__org_springframework_boot_spring_boot_starter_quartz_2_4_3.xml
│ ├── Maven__org_springframework_boot_spring_boot_starter_tomcat_2_4_3.xml
│ ├── Maven__org_springframework_boot_spring_boot_starter_logging_2_4_3.xml
│ ├── Maven__org_springframework_plugin_spring_plugin_core_2_0_0_RELEASE.xml
│ ├── Maven__com_fasterxml_jackson_datatype_jackson_datatype_jsr310_2_11_4.xml
│ ├── Maven__com_vaadin_external_google_android_json_0_0_20131108_vaadin1.xml
│ ├── Maven__org_springframework_boot_spring_boot_starter_data_jpa_2_4_3.xml
│ ├── Maven__org_springframework_boot_spring_boot_starter_data_rest_2_4_3.xml
│ ├── Maven__org_springframework_boot_spring_boot_starter_validation_2_4_3.xml
│ ├── Maven__org_springframework_boot_spring_boot_test_autoconfigure_2_4_3.xml
│ ├── Maven__org_hibernate_common_hibernate_commons_annotations_5_1_2_Final.xml
│ ├── Maven__com_fasterxml_jackson_module_jackson_module_parameter_names_2_11_4.xml
│ └── Maven__com_google_guava_listenablefuture_9999_0_empty_to_avoid_conflict_with_guava.xml
├── dataSources.xml
├── jarRepositories.xml
├── compiler.xml
└── uiDesigner.xml
├── demo-app.log.2021-03-13.0.gz
├── target
├── classes
│ ├── io
│ │ └── hari
│ │ │ └── demo
│ │ │ ├── dao
│ │ │ ├── BaseDao.class
│ │ │ ├── MovieDao.class
│ │ │ ├── ScreenDao.class
│ │ │ ├── SeatDao.class
│ │ │ ├── ShowDao.class
│ │ │ ├── TicketDao.class
│ │ │ ├── UserDAO.class
│ │ │ ├── SeatLockDao.class
│ │ │ └── TheaterDao.class
│ │ │ ├── entity
│ │ │ ├── Movie.class
│ │ │ ├── Screen.class
│ │ │ ├── Seat.class
│ │ │ ├── Show.class
│ │ │ ├── Ticket.class
│ │ │ ├── User.class
│ │ │ ├── SeatLock.class
│ │ │ ├── Theatre.class
│ │ │ ├── BaseEntity.class
│ │ │ ├── Seat$SeatBuilder.class
│ │ │ ├── Show$ShowBuilder.class
│ │ │ ├── User$UserBuilder.class
│ │ │ ├── Movie$MovieBuilder.class
│ │ │ ├── Screen$ScreenBuilder.class
│ │ │ ├── Ticket$TicketBuilder.class
│ │ │ ├── Theatre$TheatreBuilder.class
│ │ │ └── SeatLock$SeatLockBuilder.class
│ │ │ ├── DemoApplication.class
│ │ │ ├── config
│ │ │ └── AppConfig.class
│ │ │ └── service
│ │ │ ├── BaseService.class
│ │ │ ├── MovieService.class
│ │ │ ├── SeatsService.class
│ │ │ ├── ShowService.class
│ │ │ ├── UserService.class
│ │ │ ├── ScreenService.class
│ │ │ ├── SeatLockService.class
│ │ │ └── TheatreService.class
│ ├── application.properties
│ └── application-dev.yml
└── test-classes
│ └── io
│ └── hari
│ └── demo
│ └── DemoApplicationTests.class
├── src
├── main
│ ├── resources
│ │ ├── application.properties
│ │ ├── application-dev.yml
│ │ └── application-prod.yml
│ └── java
│ │ └── io
│ │ └── hari
│ │ └── demo
│ │ ├── dao
│ │ ├── UserDAO.java
│ │ ├── MovieDao.java
│ │ ├── TicketDao.java
│ │ ├── BaseDao.java
│ │ ├── TheaterDao.java
│ │ ├── ScreenDao.java
│ │ ├── SeatLockDao.java
│ │ ├── SeatDao.java
│ │ └── ShowDao.java
│ │ ├── entity
│ │ ├── Days.java
│ │ ├── MovieAttribute.java
│ │ ├── WeekDay.java
│ │ ├── EntitySeat.java
│ │ ├── BaseEntity.java
│ │ ├── Event.java
│ │ ├── Screen.java
│ │ ├── Seat.java
│ │ ├── Theatre.java
│ │ ├── User.java
│ │ ├── MovieAttributeConvertor.java
│ │ ├── WeekDayConvert.java
│ │ ├── Movie.java
│ │ ├── EntitySeatConverter.java
│ │ ├── Ticket.java
│ │ ├── Show.java
│ │ └── SeatLock.java
│ │ ├── service
│ │ ├── MovieService.java
│ │ ├── ScreenService.java
│ │ ├── SeatLockService.java
│ │ ├── TheatreService.java
│ │ ├── NotificationService.java
│ │ ├── BaseService.java
│ │ ├── ShowService.java
│ │ ├── SeatsService.java
│ │ ├── TicketService.java
│ │ └── UserService.java
│ │ ├── config
│ │ └── AppConfig.java
│ │ ├── event
│ │ ├── ConsumerService.java
│ │ └── SchedulerService.java
│ │ └── DemoApplication.java
└── test
│ └── java
│ └── io
│ └── hari
│ └── demo
│ └── DemoApplicationTests.java
├── README.md
├── pom.xml
└── demo.iml
/.idea/.name:
--------------------------------------------------------------------------------
1 | demo
--------------------------------------------------------------------------------
/demo-app.log.2021-03-13.0.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hocyadav/spring-boot-book-my-show/HEAD/demo-app.log.2021-03-13.0.gz
--------------------------------------------------------------------------------
/target/classes/io/hari/demo/dao/BaseDao.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hocyadav/spring-boot-book-my-show/HEAD/target/classes/io/hari/demo/dao/BaseDao.class
--------------------------------------------------------------------------------
/target/classes/io/hari/demo/dao/MovieDao.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hocyadav/spring-boot-book-my-show/HEAD/target/classes/io/hari/demo/dao/MovieDao.class
--------------------------------------------------------------------------------
/target/classes/io/hari/demo/dao/ScreenDao.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hocyadav/spring-boot-book-my-show/HEAD/target/classes/io/hari/demo/dao/ScreenDao.class
--------------------------------------------------------------------------------
/target/classes/io/hari/demo/dao/SeatDao.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hocyadav/spring-boot-book-my-show/HEAD/target/classes/io/hari/demo/dao/SeatDao.class
--------------------------------------------------------------------------------
/target/classes/io/hari/demo/dao/ShowDao.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hocyadav/spring-boot-book-my-show/HEAD/target/classes/io/hari/demo/dao/ShowDao.class
--------------------------------------------------------------------------------
/target/classes/io/hari/demo/dao/TicketDao.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hocyadav/spring-boot-book-my-show/HEAD/target/classes/io/hari/demo/dao/TicketDao.class
--------------------------------------------------------------------------------
/target/classes/io/hari/demo/dao/UserDAO.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hocyadav/spring-boot-book-my-show/HEAD/target/classes/io/hari/demo/dao/UserDAO.class
--------------------------------------------------------------------------------
/target/classes/io/hari/demo/entity/Movie.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hocyadav/spring-boot-book-my-show/HEAD/target/classes/io/hari/demo/entity/Movie.class
--------------------------------------------------------------------------------
/target/classes/io/hari/demo/entity/Screen.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hocyadav/spring-boot-book-my-show/HEAD/target/classes/io/hari/demo/entity/Screen.class
--------------------------------------------------------------------------------
/target/classes/io/hari/demo/entity/Seat.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hocyadav/spring-boot-book-my-show/HEAD/target/classes/io/hari/demo/entity/Seat.class
--------------------------------------------------------------------------------
/target/classes/io/hari/demo/entity/Show.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hocyadav/spring-boot-book-my-show/HEAD/target/classes/io/hari/demo/entity/Show.class
--------------------------------------------------------------------------------
/target/classes/io/hari/demo/entity/Ticket.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hocyadav/spring-boot-book-my-show/HEAD/target/classes/io/hari/demo/entity/Ticket.class
--------------------------------------------------------------------------------
/target/classes/io/hari/demo/entity/User.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hocyadav/spring-boot-book-my-show/HEAD/target/classes/io/hari/demo/entity/User.class
--------------------------------------------------------------------------------
/target/classes/io/hari/demo/DemoApplication.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hocyadav/spring-boot-book-my-show/HEAD/target/classes/io/hari/demo/DemoApplication.class
--------------------------------------------------------------------------------
/target/classes/io/hari/demo/dao/SeatLockDao.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hocyadav/spring-boot-book-my-show/HEAD/target/classes/io/hari/demo/dao/SeatLockDao.class
--------------------------------------------------------------------------------
/target/classes/io/hari/demo/dao/TheaterDao.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hocyadav/spring-boot-book-my-show/HEAD/target/classes/io/hari/demo/dao/TheaterDao.class
--------------------------------------------------------------------------------
/target/classes/io/hari/demo/entity/SeatLock.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hocyadav/spring-boot-book-my-show/HEAD/target/classes/io/hari/demo/entity/SeatLock.class
--------------------------------------------------------------------------------
/target/classes/io/hari/demo/entity/Theatre.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hocyadav/spring-boot-book-my-show/HEAD/target/classes/io/hari/demo/entity/Theatre.class
--------------------------------------------------------------------------------
/target/classes/io/hari/demo/config/AppConfig.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hocyadav/spring-boot-book-my-show/HEAD/target/classes/io/hari/demo/config/AppConfig.class
--------------------------------------------------------------------------------
/target/classes/io/hari/demo/entity/BaseEntity.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hocyadav/spring-boot-book-my-show/HEAD/target/classes/io/hari/demo/entity/BaseEntity.class
--------------------------------------------------------------------------------
/target/classes/application.properties:
--------------------------------------------------------------------------------
1 | server.port=8080
2 | spring.profiles.active=dev
3 | spring.application.name= demo-app
4 | logging.file.name= ${spring.application.name}.log
--------------------------------------------------------------------------------
/target/classes/io/hari/demo/service/BaseService.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hocyadav/spring-boot-book-my-show/HEAD/target/classes/io/hari/demo/service/BaseService.class
--------------------------------------------------------------------------------
/target/classes/io/hari/demo/service/MovieService.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hocyadav/spring-boot-book-my-show/HEAD/target/classes/io/hari/demo/service/MovieService.class
--------------------------------------------------------------------------------
/target/classes/io/hari/demo/service/SeatsService.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hocyadav/spring-boot-book-my-show/HEAD/target/classes/io/hari/demo/service/SeatsService.class
--------------------------------------------------------------------------------
/target/classes/io/hari/demo/service/ShowService.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hocyadav/spring-boot-book-my-show/HEAD/target/classes/io/hari/demo/service/ShowService.class
--------------------------------------------------------------------------------
/target/classes/io/hari/demo/service/UserService.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hocyadav/spring-boot-book-my-show/HEAD/target/classes/io/hari/demo/service/UserService.class
--------------------------------------------------------------------------------
/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=8080
2 | spring.profiles.active=dev
3 | spring.application.name= demo-app
4 | logging.file.name= ${spring.application.name}.log
--------------------------------------------------------------------------------
/target/classes/io/hari/demo/entity/Seat$SeatBuilder.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hocyadav/spring-boot-book-my-show/HEAD/target/classes/io/hari/demo/entity/Seat$SeatBuilder.class
--------------------------------------------------------------------------------
/target/classes/io/hari/demo/entity/Show$ShowBuilder.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hocyadav/spring-boot-book-my-show/HEAD/target/classes/io/hari/demo/entity/Show$ShowBuilder.class
--------------------------------------------------------------------------------
/target/classes/io/hari/demo/entity/User$UserBuilder.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hocyadav/spring-boot-book-my-show/HEAD/target/classes/io/hari/demo/entity/User$UserBuilder.class
--------------------------------------------------------------------------------
/target/classes/io/hari/demo/service/ScreenService.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hocyadav/spring-boot-book-my-show/HEAD/target/classes/io/hari/demo/service/ScreenService.class
--------------------------------------------------------------------------------
/target/classes/io/hari/demo/service/SeatLockService.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hocyadav/spring-boot-book-my-show/HEAD/target/classes/io/hari/demo/service/SeatLockService.class
--------------------------------------------------------------------------------
/target/classes/io/hari/demo/service/TheatreService.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hocyadav/spring-boot-book-my-show/HEAD/target/classes/io/hari/demo/service/TheatreService.class
--------------------------------------------------------------------------------
/target/classes/io/hari/demo/entity/Movie$MovieBuilder.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hocyadav/spring-boot-book-my-show/HEAD/target/classes/io/hari/demo/entity/Movie$MovieBuilder.class
--------------------------------------------------------------------------------
/target/test-classes/io/hari/demo/DemoApplicationTests.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hocyadav/spring-boot-book-my-show/HEAD/target/test-classes/io/hari/demo/DemoApplicationTests.class
--------------------------------------------------------------------------------
/target/classes/io/hari/demo/entity/Screen$ScreenBuilder.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hocyadav/spring-boot-book-my-show/HEAD/target/classes/io/hari/demo/entity/Screen$ScreenBuilder.class
--------------------------------------------------------------------------------
/target/classes/io/hari/demo/entity/Ticket$TicketBuilder.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hocyadav/spring-boot-book-my-show/HEAD/target/classes/io/hari/demo/entity/Ticket$TicketBuilder.class
--------------------------------------------------------------------------------
/target/classes/io/hari/demo/entity/Theatre$TheatreBuilder.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hocyadav/spring-boot-book-my-show/HEAD/target/classes/io/hari/demo/entity/Theatre$TheatreBuilder.class
--------------------------------------------------------------------------------
/target/classes/io/hari/demo/entity/SeatLock$SeatLockBuilder.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hocyadav/spring-boot-book-my-show/HEAD/target/classes/io/hari/demo/entity/SeatLock$SeatLockBuilder.class
--------------------------------------------------------------------------------
/.idea/sqldialects.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/src/main/resources/application-dev.yml:
--------------------------------------------------------------------------------
1 | #h2
2 | spring.datasource.url: jdbc:h2:mem:h2db
3 | spring.h2.console.enabled: true
4 | spring.datasource.platform: h2
5 | #spring.jpa.show-sql: true
6 |
7 | app-config:
8 | simpleKey: "value"
9 | timeout : 5s # working
10 |
11 |
12 |
--------------------------------------------------------------------------------
/target/classes/application-dev.yml:
--------------------------------------------------------------------------------
1 | #h2
2 | spring.datasource.url: jdbc:h2:mem:h2db
3 | spring.h2.console.enabled: true
4 | spring.datasource.platform: h2
5 | #spring.jpa.show-sql: true
6 |
7 | app-config:
8 | simpleKey: "value"
9 | timeout : 5s # working
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Datasource local storage ignored files
5 | /../../../../../../../:\Users\Hariom Yadav\Desktop\demo\book-my-show\.idea/dataSources/
6 | /dataSources.local.xml
7 | # Editor-based HTTP Client requests
8 | /httpRequests/
9 |
--------------------------------------------------------------------------------
/src/main/java/io/hari/demo/dao/UserDAO.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo.dao;
2 |
3 | import io.hari.demo.entity.User;
4 | import org.springframework.stereotype.Repository;
5 |
6 | /**
7 | * @Author Hariom Yadav
8 | * @create 02-03-2021
9 | */
10 | @Repository
11 | public interface UserDAO extends BaseDao {
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/io/hari/demo/entity/Days.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo.entity;
2 |
3 | import lombok.Getter;
4 |
5 | /**
6 | * @Author Hariom Yadav
7 | * @create 07-03-2021
8 | */
9 | @Getter
10 | public enum Days {
11 | sun,
12 | mon,
13 | tue,
14 | wed,
15 | thu,
16 | fri,
17 | sat;
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/io/hari/demo/dao/MovieDao.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo.dao;
2 |
3 | import io.hari.demo.entity.Movie;
4 | import org.springframework.stereotype.Repository;
5 |
6 | /**
7 | * @Author Hariom Yadav
8 | * @create 02-03-2021
9 | */
10 | @Repository
11 | public interface MovieDao extends BaseDao {
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/io/hari/demo/dao/TicketDao.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo.dao;
2 |
3 | import io.hari.demo.entity.Ticket;
4 | import org.springframework.stereotype.Repository;
5 |
6 | /**
7 | * @Author Hariom Yadav
8 | * @create 02-03-2021
9 | */
10 | @Repository
11 | public interface TicketDao extends BaseDao {
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/io/hari/demo/dao/BaseDao.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo.dao;
2 |
3 | import org.springframework.data.jpa.repository.JpaRepository;
4 | import org.springframework.data.repository.NoRepositoryBean;
5 |
6 | /**
7 | * @Author Hariom Yadav
8 | * @create 02-03-2021
9 | */
10 | @NoRepositoryBean
11 | public interface BaseDao extends JpaRepository {
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/io/hari/demo/dao/TheaterDao.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo.dao;
2 |
3 | import io.hari.demo.entity.Theatre;
4 | import org.springframework.stereotype.Repository;
5 |
6 | import java.util.List;
7 |
8 | /**
9 | * @Author Hariom Yadav
10 | * @create 02-03-2021
11 | */
12 | @Repository
13 | public interface TheaterDao extends BaseDao {
14 | List findAllByScreens_Id(Long screenId);
15 | }
16 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # spring-boot-book-my-show
2 | Simple backend LLD machine coding implemetaion for book my show
3 |
4 | sample deployment : https://book-my-show-backend.herokuapp.com/
5 |
6 |
7 |
8 | all shows response : https://book-my-show-backend.herokuapp.com/shows
9 |
10 |
11 | movies response : https://book-my-show-backend.herokuapp.com/movies
12 |
13 |
14 |
15 | ticket response : https://book-my-show-backend.herokuapp.com/tickets/1
16 |
--------------------------------------------------------------------------------
/src/main/java/io/hari/demo/dao/ScreenDao.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo.dao;
2 |
3 | import io.hari.demo.entity.Screen;
4 | import lombok.NonNull;
5 | import org.springframework.stereotype.Repository;
6 |
7 | import java.util.List;
8 |
9 | /**
10 | * @Author Hariom Yadav
11 | * @create 02-03-2021
12 | */
13 | @Repository
14 | public interface ScreenDao extends BaseDao {
15 | List findAllByShows_Id(Long showId);
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/io/hari/demo/entity/MovieAttribute.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo.entity;
2 |
3 | import lombok.*;
4 |
5 | import java.util.HashMap;
6 | import java.util.Map;
7 |
8 | /**
9 | * @Author Hariom Yadav
10 | * @create 07-03-2021
11 | */
12 | @AllArgsConstructor
13 | @NoArgsConstructor
14 | @Getter
15 | @Setter
16 | @Builder
17 | @ToString
18 | public class MovieAttribute {
19 | Map attributes = new HashMap<>();
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/io/hari/demo/entity/WeekDay.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo.entity;
2 |
3 | import lombok.*;
4 |
5 | import java.util.ArrayList;
6 | import java.util.List;
7 |
8 | /**
9 | * @Author Hariom Yadav
10 | * @create 07-03-2021
11 | */
12 | @Getter
13 | @Setter
14 | @AllArgsConstructor
15 | @NoArgsConstructor
16 | @Builder
17 | @ToString
18 | public class WeekDay {
19 | List days = new ArrayList<>();//todo test for list of Entity class
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/io/hari/demo/service/MovieService.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo.service;
2 |
3 | import io.hari.demo.dao.BaseDao;
4 | import io.hari.demo.entity.Movie;
5 | import org.springframework.stereotype.Service;
6 |
7 | /**
8 | * @Author Hariom Yadav
9 | * @create 02-03-2021
10 | */
11 | @Service
12 | public class MovieService extends BaseService {
13 |
14 | public MovieService(BaseDao dao) {
15 | super(dao);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/io/hari/demo/service/ScreenService.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo.service;
2 |
3 | import io.hari.demo.dao.BaseDao;
4 | import io.hari.demo.entity.Screen;
5 | import org.springframework.stereotype.Service;
6 |
7 | /**
8 | * @Author Hariom Yadav
9 | * @create 02-03-2021
10 | */
11 | @Service
12 | public class ScreenService extends BaseService {
13 |
14 | public ScreenService(BaseDao ScreenDao) {
15 | super(ScreenDao);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/io/hari/demo/service/SeatLockService.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo.service;
2 |
3 | import io.hari.demo.dao.BaseDao;
4 | import io.hari.demo.entity.SeatLock;
5 | import org.springframework.stereotype.Service;
6 |
7 | /**
8 | * @Author Hariom Yadav
9 | * @create 02-03-2021
10 | */
11 | @Service
12 | public class SeatLockService extends BaseService {
13 |
14 | public SeatLockService(BaseDao dao) {
15 | super(dao);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/io/hari/demo/service/TheatreService.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo.service;
2 |
3 | import io.hari.demo.dao.BaseDao;
4 | import io.hari.demo.entity.Theatre;
5 | import org.springframework.stereotype.Service;
6 |
7 | /**
8 | * @Author Hariom Yadav
9 | * @create 02-03-2021
10 | */
11 | @Service
12 | public class TheatreService extends BaseService {
13 | public TheatreService(BaseDao theatreDao) {
14 | super(theatreDao);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/io/hari/demo/entity/EntitySeat.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo.entity;
2 |
3 | import lombok.*;
4 |
5 | import java.util.ArrayList;
6 | import java.util.List;
7 |
8 | /**
9 | * @Author Hariom Yadav
10 | * @create 07-03-2021
11 | */
12 | @Getter
13 | @Setter
14 | @NoArgsConstructor
15 | @AllArgsConstructor
16 | @Builder
17 | @ToString
18 | public class EntitySeat {//not working converter test again // TODO: 07-03-2021
19 | List seats = new ArrayList<>();
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/io/hari/demo/dao/SeatLockDao.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo.dao;
2 |
3 | import io.hari.demo.entity.SeatLock;
4 | import org.springframework.stereotype.Repository;
5 |
6 | /**
7 | * @Author Hariom Yadav
8 | * @create 02-03-2021
9 | */
10 | @Repository
11 | public interface SeatLockDao extends BaseDao {
12 | SeatLock findByShowIdAndSeatId(Long showId, Long seatId);
13 | SeatLock findByShowIdAndSeatIdAndLockStatus(Long showId, Long seatId, String lockStatus);
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/io/hari/demo/config/AppConfig.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo.config;
2 |
3 | import lombok.*;
4 | import org.springframework.boot.context.properties.ConfigurationProperties;
5 | import org.springframework.stereotype.Component;
6 |
7 | import java.time.Duration;
8 |
9 | @Getter
10 | @Setter
11 | @ToString
12 | @NoArgsConstructor
13 | @AllArgsConstructor
14 | @Component
15 | @ConfigurationProperties(prefix = "app-config")
16 | public class AppConfig {
17 | String simpleKey;
18 | Duration timeout;
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/io/hari/demo/entity/BaseEntity.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo.entity;
2 |
3 | import lombok.Getter;
4 | import lombok.ToString;
5 |
6 | import javax.persistence.*;
7 | import java.io.Serializable;
8 | import java.time.LocalDateTime;
9 |
10 | /**
11 | * @Author Hariom Yadav
12 | * @create 02-03-2021
13 | */
14 | @Getter
15 | @ToString
16 | @MappedSuperclass
17 | public class BaseEntity implements Serializable {
18 | @Id
19 | @GeneratedValue(strategy = GenerationType.IDENTITY)
20 | Long id;
21 | }
22 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__antlr_antlr_2_7_7.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__junit_junit_4_13_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_ow2_asm_asm_5_0_4.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_dom4j_dom4j_2_1_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/main/java/io/hari/demo/service/NotificationService.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo.service;
2 |
3 | import io.hari.demo.entity.User;
4 | import lombok.extern.slf4j.Slf4j;
5 | import org.springframework.stereotype.Service;
6 |
7 | /**
8 | * @Author Hariom Yadav
9 | * @create 11-03-2021
10 | */
11 | @Service
12 | @Slf4j
13 | public class NotificationService {
14 |
15 | //async method
16 | public void sendNotificationToUser(User user) {
17 | log.info("payment failed for user {} , please select and book ticket again", user.getName());
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_h2database_h2_1_4_200.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/dataSources.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | mysql.8
6 | true
7 | com.mysql.cj.jdbc.Driver
8 | jdbc:mysql://localhost:3306
9 | $ProjectFileDir$
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_hamcrest_hamcrest_2_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_yaml_snakeyaml_1_27.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_zaxxer_HikariCP_3_4_5.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__net_minidev_json_smart_2_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_glassfish_jaxb_txw2_2_3_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_objenesis_objenesis_3_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_slf4j_slf4j_api_1_7_30.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/main/resources/application-prod.yml:
--------------------------------------------------------------------------------
1 | # 1. Datasource config
2 | spring.datasource.driver-class-name: com.mysql.cj.jdbc.Driver
3 | spring.datasource.url: jdbc:mysql://localhost:3306/book_my_show
4 | spring.datasource.username: root
5 | spring.datasource.password: hariom
6 |
7 | ## 2. Hibernate config
8 | spring.jpa.show-sql: true
9 | #spring.jpa.hibernate.ddl-auto: create-drop
10 | spring.jpa.hibernate.ddl-auto: create
11 | spring.jpa.properties.hibernate.dialect: org.hibernate.dialect.MySQL5Dialect
12 |
13 | app-config:
14 | simpleKey: "value"
15 | timeout : 5s # working
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/main/java/io/hari/demo/entity/Event.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo.entity;
2 |
3 | import lombok.*;
4 | import org.springframework.context.ApplicationEvent;
5 |
6 | import java.time.LocalDateTime;
7 | import java.util.HashMap;
8 | import java.util.Map;
9 |
10 | /**
11 | * @Author Hariom Yadav
12 | * @create 07-03-2021
13 | */
14 | @AllArgsConstructor
15 | @Builder
16 | @ToString
17 | @Getter
18 | @Setter
19 | @NoArgsConstructor
20 | public class Event {
21 | String name;
22 | String type;
23 | Map params = new HashMap<>();
24 | LocalDateTime localDateTime;
25 | }
26 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_fasterxml_classmate_1_5_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_jboss_jandex_2_2_3_Final.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_google_guava_guava_30_1_jre.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_glassfish_jakarta_el_3_0_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_hamcrest_hamcrest_core_2_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_quartz_scheduler_quartz_2_3_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_atteo_evo_inflector_1_2_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_opentest4j_opentest4j_1_2_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_projectlombok_lombok_1_18_18.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_slf4j_jul_to_slf4j_1_7_30.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_xmlunit_xmlunit_core_2_7_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_skyscreamer_jsonassert_1_5_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__net_bytebuddy_byte_buddy_1_10_20.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__net_minidev_accessors_smart_1_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_aspectj_aspectjweaver_1_9_6.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_assertj_assertj_core_3_18_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_mockito_mockito_core_3_6_28.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__ch_qos_logback_logback_core_1_2_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_google_code_findbugs_jsr305_3_0_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_jayway_jsonpath_json_path_2_4_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_spring_tx_5_3_4.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/main/java/io/hari/demo/dao/SeatDao.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo.dao;
2 |
3 | import io.hari.demo.entity.Seat;
4 | import org.springframework.data.jpa.repository.Query;
5 | import org.springframework.stereotype.Repository;
6 |
7 | import java.util.List;
8 |
9 | /**
10 | *@Author Hariom Yadav
11 | *@create 02-03-2021
12 | */
13 | @Repository
14 | public interface SeatDao extends BaseDao {
15 |
16 | @Query(value = "select * from seats where id in (select seat_id from seat_lock where show_id = :showId and lock_status = 'available')",
17 | nativeQuery = true)
18 | List findAllAvailableShowSeats(Long showId);
19 | }
20 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_javassist_javassist_3_27_0_GA.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_spring_aop_5_3_4.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_spring_jcl_5_3_4.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_spring_orm_5_3_4.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_spring_web_5_3_4.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_spring_core_5_3_4.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_spring_jdbc_5_3_4.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_spring_test_5_3_4.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_google_guava_failureaccess_1_0_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_apache_commons_commons_lang3_3_11.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_glassfish_jaxb_jaxb_runtime_2_3_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__ch_qos_logback_logback_classic_1_2_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__mysql_mysql_connector_java_8_0_23.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_5_7_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_spring_beans_5_3_4.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_apiguardian_apiguardian_api_1_1_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_checkerframework_checker_qual_3_5_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_apache_logging_log4j_log4j_api_2_13_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_spring_webmvc_5_3_4.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_boot_spring_boot_2_4_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_spring_aspects_5_3_4.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_spring_context_5_3_4.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_google_j2objc_j2objc_annotations_1_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__net_bytebuddy_byte_buddy_agent_1_10_20.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/test/java/io/hari/demo/DemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | import static org.assertj.core.api.Assertions.assertThat;
9 |
10 | @RunWith(SpringRunner.class)
11 | @SpringBootTest
12 | //@SpringBootTest(classes = {})
13 | class DemoApplicationTests {
14 |
15 | @Test
16 | void contextLoads() {
17 | assertThat("hari om yadav")
18 | .isNotNull()
19 | .startsWith("hari")
20 | .contains("om")
21 | .endsWith("yadav");
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_mchange_mchange_commons_java_0_2_15.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_api_5_7_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/main/java/io/hari/demo/entity/Screen.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo.entity;
2 |
3 | import lombok.*;
4 |
5 | import javax.persistence.*;
6 | import java.util.ArrayList;
7 | import java.util.List;
8 |
9 | /**
10 | * @Author Hariom Yadav
11 | * @create 02-03-2021
12 | */
13 | @Getter
14 | @Setter
15 | @NoArgsConstructor
16 | @ToString(exclude = {"shows"})
17 | @AllArgsConstructor
18 | @Builder
19 | @Entity
20 | @Table(name = "screens")
21 | public class Screen extends BaseEntity {
22 | String screenName;
23 |
24 | @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)//+ 1 dao method
25 | List shows = new ArrayList<>();
26 |
27 | // other metadata
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/io/hari/demo/entity/Seat.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo.entity;
2 |
3 | import com.fasterxml.jackson.annotation.JsonProperty;
4 | import lombok.*;
5 |
6 | import javax.persistence.*;
7 |
8 | /**
9 | * @Author Hariom Yadav
10 | * @create 02-03-2021
11 | */
12 | @Getter
13 | @Setter
14 | @NoArgsConstructor
15 | @ToString(exclude = {}, callSuper = true)
16 | @AllArgsConstructor
17 | @Builder
18 | @Entity
19 | @Table(name = "seats")
20 | public class Seat extends BaseEntity {
21 | String seatType = "silver";//default value
22 | //other metadata GOLD, SILVER
23 |
24 | @JsonProperty
25 | public Long getSeatId() {
26 | return super.getId();
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_hibernate_hibernate_core_5_4_28_Final.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_mockito_mockito_junit_jupiter_3_6_28.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_spring_expression_5_3_4.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/main/java/io/hari/demo/entity/Theatre.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo.entity;
2 |
3 | import lombok.*;
4 |
5 | import javax.persistence.*;
6 | import java.util.ArrayList;
7 | import java.util.List;
8 |
9 | /**
10 | * @Author Hariom Yadav
11 | * @create 02-03-2021
12 | */
13 | @Getter
14 | @Setter
15 | @NoArgsConstructor
16 | @ToString(exclude = {"screens"})
17 | @AllArgsConstructor
18 | @Builder
19 | @Entity
20 | @Table(name = "theatres")
21 | public class Theatre extends BaseEntity {
22 | String theaterName;
23 |
24 | @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)// + 1 dao method
25 | List screens = new ArrayList<>();
26 |
27 | //other metadata
28 | }
29 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_11_4.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_sun_activation_jakarta_activation_1_2_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_jboss_logging_jboss_logging_3_4_1_Final.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__jakarta_xml_bind_jakarta_xml_bind_api_2_3_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_apache_logging_log4j_log4j_to_slf4j_2_13_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_data_spring_data_jpa_2_4_5.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_engine_5_7_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_params_5_7_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_boot_spring_boot_test_2_4_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_hateoas_spring_hateoas_1_2_4.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_sun_istack_istack_commons_runtime_3_0_11.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_junit_platform_junit_platform_engine_1_7_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_core_9_0_43.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_11_4.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__jakarta_activation_jakarta_activation_api_1_2_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__jakarta_annotation_jakarta_annotation_api_1_3_5.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__jakarta_validation_jakarta_validation_api_2_0_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_junit_platform_junit_platform_commons_1_7_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_2_4_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_data_spring_data_commons_2_4_5.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_spring_context_support_5_3_4.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__jakarta_persistence_jakarta_persistence_api_2_2_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__jakarta_transaction_jakarta_transaction_api_1_3_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_data_spring_data_rest_core_3_4_5.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_11_4.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_google_errorprone_error_prone_annotations_2_3_4.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_websocket_9_0_43.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_aop_2_4_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_web_2_4_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_data_spring_data_rest_webmvc_3_4_5.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_jdbc_2_4_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_json_2_4_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_test_2_4_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_hibernate_validator_hibernate_validator_6_1_7_Final.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_boot_spring_boot_autoconfigure_2_4_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_cache_2_4_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_fasterxml_jackson_datatype_jackson_datatype_jdk8_2_11_4.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_quartz_2_4_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_tomcat_2_4_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_logging_2_4_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_plugin_spring_plugin_core_2_0_0_RELEASE.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_fasterxml_jackson_datatype_jackson_datatype_jsr310_2_11_4.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_vaadin_external_google_android_json_0_0_20131108_vaadin1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_data_jpa_2_4_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_data_rest_2_4_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_validation_2_4_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_boot_spring_boot_test_autoconfigure_2_4_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_hibernate_common_hibernate_commons_annotations_5_1_2_Final.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_fasterxml_jackson_module_jackson_module_parameter_names_2_11_4.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/jarRepositories.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_google_guava_listenablefuture_9999_0_empty_to_avoid_conflict_with_guava.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/main/java/io/hari/demo/entity/User.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo.entity;
2 |
3 | import lombok.*;
4 |
5 | import javax.persistence.CascadeType;
6 | import javax.persistence.Entity;
7 | import javax.persistence.OneToMany;
8 | import javax.persistence.Table;
9 | import java.util.ArrayList;
10 | import java.util.List;
11 |
12 | /**
13 | * @Author Hariom Yadav
14 | * @create 02-03-2021
15 | */
16 | @Getter
17 | @Setter
18 | @NoArgsConstructor
19 | @ToString(exclude = {"shows"}, callSuper = true)
20 | @AllArgsConstructor
21 | @Builder
22 | @Entity
23 | @Table(name = "users")
24 | public class User extends BaseEntity {
25 |
26 | String name;
27 |
28 | // @OneToMany(fetch = FetchType.EAGER)//remove cascade and store in db before passing here
29 | @OneToMany(cascade = CascadeType.ALL)
30 | List tickets = new ArrayList<>();//TODO : change to Enum and inside enum store List ticket id,
31 | // so that every time we can easily add new ticket
32 |
33 | //other metadata;
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/io/hari/demo/service/BaseService.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo.service;
2 |
3 |
4 | import io.hari.demo.dao.BaseDao;
5 | import lombok.Getter;
6 |
7 | import java.util.List;
8 | import java.util.Optional;
9 |
10 | /**
11 | * @Author Hariom Yadav
12 | * @create 02-03-2021
13 | */
14 | @Getter
15 | public abstract class BaseService {
16 | BaseDao dao;
17 |
18 | public BaseService(BaseDao dao) {
19 | this.dao = dao;
20 | }
21 |
22 | public List findAll() {
23 | return dao.findAll();
24 | }
25 |
26 | public T save(T entity) {
27 | return dao.save(entity);
28 | }
29 |
30 | public T findById(Long id) {
31 | final Optional optional = dao.findById(id);
32 | return optional.get();
33 | }
34 |
35 | public List extends T> saveAll(Iterable extends T> saveAll) {
36 | return dao.saveAll(saveAll);
37 | }
38 |
39 | public void deleteById(Long id) {
40 | dao.deleteById(id);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/io/hari/demo/entity/MovieAttributeConvertor.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo.entity;
2 |
3 | import com.fasterxml.jackson.databind.ObjectMapper;
4 | import io.hari.demo.entity.MovieAttribute;
5 | import lombok.SneakyThrows;
6 |
7 | import javax.persistence.AttributeConverter;
8 |
9 | /**
10 | * @Author Hariom Yadav
11 | * @create 07-03-2021
12 | */
13 | public class MovieAttributeConvertor implements AttributeConverter {
14 | ObjectMapper objectMapper = new ObjectMapper();
15 |
16 | @SneakyThrows
17 | @Override
18 | public String convertToDatabaseColumn(MovieAttribute movieAttribute) {
19 | if (movieAttribute == null) return "";
20 | return objectMapper.writeValueAsString(movieAttribute);
21 | }
22 |
23 | @SneakyThrows
24 | @Override
25 | public MovieAttribute convertToEntityAttribute(String s) {
26 | if (s == null || s.equals("")) return new MovieAttribute();
27 | return objectMapper.readValue(s, MovieAttribute.class);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/io/hari/demo/entity/WeekDayConvert.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo.entity;
2 |
3 | import io.hari.demo.entity.Days;
4 | import io.hari.demo.entity.WeekDay;
5 |
6 | import javax.persistence.AttributeConverter;
7 | import java.util.List;
8 | import java.util.stream.Collectors;
9 | import java.util.stream.Stream;
10 |
11 | /**
12 | * @Author Hariom Yadav
13 | * @create 07-03-2021
14 | */
15 | public class WeekDayConvert implements AttributeConverter {
16 | @Override
17 | public String convertToDatabaseColumn(WeekDay weekDay) {
18 | if (weekDay == null) return "";
19 | final List days = weekDay.getDays();
20 | final String allDay = days.stream().map(i -> i.toString()).collect(Collectors.joining(","));
21 | return allDay;
22 | }
23 |
24 | @Override
25 | public WeekDay convertToEntityAttribute(String s) {
26 | if (s == null || s.equals("")) return new WeekDay();
27 | final String[] split = s.split(",");
28 | final List days = Stream.of(split).map(i -> Days.valueOf(i)).collect(Collectors.toList());
29 | return WeekDay.builder().days(days).build();
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/io/hari/demo/entity/Movie.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo.entity;
2 |
3 | import com.fasterxml.jackson.annotation.JsonIgnore;
4 | import lombok.*;
5 |
6 | import javax.persistence.Convert;
7 | import javax.persistence.Entity;
8 | import javax.persistence.Table;
9 | import javax.persistence.Transient;
10 | import java.util.HashMap;
11 | import java.util.Map;
12 |
13 | /**
14 | * @Author Hariom Yadav
15 | * @create 02-03-2021
16 | */
17 | @Getter
18 | @Setter
19 | @NoArgsConstructor
20 | @ToString(exclude = {})
21 | @AllArgsConstructor
22 | @Builder
23 | @Entity
24 | @Table(name = "movies")
25 | public class Movie extends BaseEntity {
26 | String movieName;
27 |
28 |
29 | //other metadata
30 | Float ratings;
31 |
32 | @Convert(converter = MovieAttributeConvertor.class)//move to base entity and test
33 | MovieAttribute movieAttribute;
34 |
35 | @Transient
36 | Map attributes = new HashMap<>();
37 |
38 | @JsonIgnore//optional : hide from json web response, coz already above we are showing movie attribute
39 | public Map getAttributes() {
40 | return movieAttribute.getAttributes();
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/io/hari/demo/service/ShowService.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo.service;
2 |
3 | import io.hari.demo.dao.BaseDao;
4 | import io.hari.demo.dao.SeatLockDao;
5 | import io.hari.demo.entity.SeatLock;
6 | import io.hari.demo.entity.Show;
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.stereotype.Service;
9 |
10 | /**
11 | * @Author Hariom Yadav
12 | * @create 02-03-2021
13 | */
14 | @Service
15 | public class ShowService extends BaseService {
16 |
17 | @Autowired
18 | SeatLockDao seatLockDao;
19 |
20 | public ShowService(BaseDao showDao) {
21 | super(showDao);
22 | }
23 |
24 | //create new entry in lock db table when we are creating new show
25 | //k1 : showid, key2 : seatid, value lock status, key 1 and key2 relation is 1:M
26 | @Override
27 | public Show save(Show show) {
28 | final Show show1 = super.save(show);//we will get id generated by JPA
29 | show1.getSeats().forEach(seat -> {
30 | final SeatLock seatLock = SeatLock.builder().showId(show.getId())
31 | .seatId(seat.getId()).lockStatus("available").build();
32 | seatLockDao.save(seatLock);
33 | });
34 | return show1;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/io/hari/demo/event/ConsumerService.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo.event;
2 |
3 | import io.hari.demo.entity.Event;
4 | import io.hari.demo.entity.Seat;
5 | import org.springframework.context.event.EventListener;
6 | import org.springframework.stereotype.Component;
7 |
8 | import java.time.LocalDateTime;
9 | import java.util.List;
10 | import java.util.Map;
11 | import java.util.concurrent.ConcurrentHashMap;
12 |
13 | /**
14 | * @Author Hariom Yadav
15 | * @create 07-03-2021
16 | */
17 | @Component
18 | public class ConsumerService {
19 | public static ConcurrentHashMap concurrentHashMap = new ConcurrentHashMap<>();
20 |
21 | @EventListener
22 | public void consumerStart(Event event) {
23 | System.out.println("event consuming = " + event);
24 | final Map params = event.getParams();
25 | final Long showId = (Long) params.get("showId");
26 | final List seats = (List) params.get("seats");
27 | final LocalDateTime localDateTime = event.getLocalDateTime();
28 | System.out.println("showId = " + showId);
29 | System.out.println("seats = " + seats);
30 | System.out.println("localDateTime = " + localDateTime);
31 | concurrentHashMap.put(event.getName(), event);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/io/hari/demo/entity/EntitySeatConverter.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo.entity;
2 |
3 | import io.hari.demo.dao.SeatDao;
4 | import io.hari.demo.entity.EntitySeat;
5 | import io.hari.demo.entity.Seat;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 |
8 | import javax.persistence.AttributeConverter;
9 | import java.util.List;
10 | import java.util.Optional;
11 | import java.util.stream.Collectors;
12 | import java.util.stream.Stream;
13 |
14 | /**
15 | * @Author Hariom Yadav
16 | * @create 07-03-2021
17 | */
18 | public class EntitySeatConverter implements AttributeConverter {//m1 using collect join , m2 using object mapper
19 |
20 | @Autowired
21 | SeatDao seatDao;
22 |
23 | @Override
24 | public String convertToDatabaseColumn(EntitySeat entitySeat) {
25 | if (entitySeat == null) return null;
26 | final List seats = entitySeat.getSeats();
27 | final String dbString = seats.stream().map(i -> i.getId().toString()).collect(Collectors.joining(","));
28 | return dbString;
29 | }
30 |
31 | @Override
32 | public EntitySeat convertToEntityAttribute(String s) {
33 | if (s == null) return null;
34 | final String[] split = s.split(",");
35 | final List seats = Stream.of(split).map(i -> {
36 | System.out.println("i = " + i);
37 | final Seat silver = Seat.builder().seatType("silver").build();
38 | // final Optional seat = seatDao.findById(Long.valueOf(i));
39 | return silver;
40 | }).collect(Collectors.toList());
41 | return EntitySeat.builder().seats(seats).build();
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/io/hari/demo/event/SchedulerService.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo.event;
2 |
3 | import io.hari.demo.dao.SeatLockDao;
4 | import io.hari.demo.entity.Seat;
5 | import io.hari.demo.entity.SeatLock;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.scheduling.annotation.Scheduled;
8 | import org.springframework.stereotype.Component;
9 |
10 | import java.util.List;
11 | import java.util.Map;
12 | import java.util.concurrent.atomic.AtomicInteger;
13 |
14 | /**
15 | * @Author Hariom Yadav
16 | * @create 07-03-2021
17 | */
18 | @Component
19 | public class SchedulerService {
20 | AtomicInteger atomicInteger = new AtomicInteger(0);
21 | @Autowired
22 | SeatLockDao seatLockDao;
23 |
24 | @Scheduled(fixedDelay = 1000 * 10)
25 | public void myScheduler() {
26 | System.err.println("ConsumerService.myScheduler");
27 | ConsumerService.concurrentHashMap.forEach((k, v) -> {
28 | final Map params = v.getParams();
29 | final Long showId = (Long) params.get("showId");
30 | final List seats = (List) params.get("seats");
31 | seats.forEach(s -> {
32 | final int incrementAndGet = atomicInteger.incrementAndGet();
33 | System.out.println("incrementAndGet = " + incrementAndGet);
34 | final SeatLock oldSeatLock = seatLockDao.findByShowIdAndSeatId(showId, s.getId());
35 | System.out.println("oldSeatLock = " + oldSeatLock);
36 |
37 | if (incrementAndGet == 10) {//think this is time out/session out for that event / user's event
38 | oldSeatLock.setLockStatus("available");
39 | seatLockDao.save(oldSeatLock);
40 | }
41 | });
42 | });
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/io/hari/demo/dao/ShowDao.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo.dao;
2 |
3 | import io.hari.demo.entity.Show;
4 | import org.springframework.data.jpa.repository.Modifying;
5 | import org.springframework.data.jpa.repository.Query;
6 | import org.springframework.data.repository.query.Param;
7 | import org.springframework.stereotype.Repository;
8 |
9 | /**
10 | * @Author Hariom Yadav
11 | * @create 02-03-2021
12 | */
13 | @Repository
14 | public interface ShowDao extends BaseDao {
15 |
16 | // @Query(value = "insert into shows_seats(show_id, seats_id) values(1, 5)",
17 | // @Query(value = "insert into shows_seats(show_id, seats_id) select :showId, :seatId",
18 | @Query(value = "insert into shows_seats(show_id, seats_id) values (:showId, :seatId)",
19 | nativeQuery = true)
20 | @Modifying //https://thorben-janssen.com/spring-data-jpa-query-annotation/
21 | void addNewShowSeat(Long showId, Long seatId);//not working
22 | // void addNewShowSeat(@Param("showId") Long showId, @Param("seatsId") Long seatId);//not working
23 | //insert into shows_seats(show_id, seats_id) values(1, 5); //working sql
24 |
25 |
26 | // https://thorben-janssen.com/change-before-persist/
27 | // https://www.netsurfingzone.com/jpa/spring-data-jpa-modifying-annotation-example/
28 | // https://stackoverflow.com/questions/45747810/spring-data-jpa-to-insert-using-query-modifying-without-using-nativequery-or
29 | // @Modifying
30 | // @Query(value = "insert into Student (id,student_name,roll_number, university) "
31 | // + "VALUES(:id,:studentName,:rollNumber,:university)",
32 | // nativeQuery = true)
33 | // public void insertStudentUsingQueryAnnotation(@Param("id") int id,
34 | // @Param("studentName") String studentName,
35 | // @Param("rollNumber") String rollNumber,
36 | // @Param("university") String university);
37 |
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/io/hari/demo/entity/Ticket.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo.entity;
2 |
3 | import com.fasterxml.jackson.annotation.JsonProperty;
4 | import lombok.*;
5 |
6 | import javax.persistence.Entity;
7 | import javax.persistence.OneToOne;
8 | import javax.persistence.Table;
9 | import java.time.LocalDateTime;
10 | import java.util.Optional;
11 |
12 | /**
13 | * @Author Hariom Yadav
14 | * @create 02-03-2021
15 | */
16 | @Getter
17 | @Setter
18 | @NoArgsConstructor
19 | @ToString(exclude = {"user", "show", "seats"})
20 | @AllArgsConstructor
21 | @Builder
22 | @Entity
23 | @Table(name = "tickets")
24 | public class Ticket extends BaseEntity {
25 | @OneToOne
26 | User user;
27 |
28 | @OneToOne
29 | Show show;
30 |
31 | // @OneToMany(fetch = FetchType.EAGER)//fetch all
32 | // List seats = new ArrayList<>();
33 | String seatIds;
34 |
35 | //not working
36 | // @Convert(converter = EntitySeatConverter.class)
37 | // EntitySeat entitySeat;
38 |
39 | String paymentMod;
40 |
41 | //other metadata
42 |
43 |
44 | @Override
45 | @JsonProperty
46 | public Long getId() {
47 | return super.getId();
48 | }
49 |
50 | // mapping internal value to show in json response
51 | @JsonProperty
52 | public String getShowName() {
53 | return show.getShowName();
54 | }
55 |
56 | @JsonProperty
57 | public LocalDateTime getStartTime() {
58 | final LocalDateTime startTime = show.getStartTime();
59 | return startTime;
60 | }
61 |
62 | @JsonProperty
63 | public LocalDateTime getEndTime() {
64 | final LocalDateTime endTime = show.getEndTime();
65 | return endTime;
66 | }
67 | @JsonProperty
68 | public Long getMovieLength() {
69 | return show.getMovieLength();
70 | }
71 |
72 | @JsonProperty
73 | public Optional getMovieName() {
74 | return show.getMovieNames().stream().findFirst();
75 | }
76 |
77 | @JsonProperty
78 | public String getUserName() {
79 | return user.getName();
80 | }
81 | }
82 |
83 |
--------------------------------------------------------------------------------
/src/main/java/io/hari/demo/service/SeatsService.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo.service;
2 |
3 | import io.hari.demo.dao.SeatDao;
4 | import io.hari.demo.dao.SeatLockDao;
5 | import io.hari.demo.entity.Seat;
6 | import io.hari.demo.entity.SeatLock;
7 | import lombok.Getter;
8 | import lombok.extern.slf4j.Slf4j;
9 | import org.springframework.stereotype.Service;
10 |
11 | import javax.transaction.Transactional;
12 | import java.sql.SQLException;
13 | import java.time.Duration;
14 | import java.time.LocalDateTime;
15 |
16 | /**
17 | * @Author Hariom Yadav
18 | * @create 02-03-2021
19 | */
20 | @Getter
21 | @Service
22 | @Slf4j
23 | @Transactional // class level
24 | //@Transactional(rollbackOn = { RuntimeException.class })
25 | public class SeatsService extends BaseService {
26 |
27 | final SeatDao seatDao;
28 | final SeatLockDao seatLockDao;
29 |
30 | public SeatsService(SeatDao seatDao, SeatLockDao seatLockDao) {
31 | super(seatDao);
32 | this.seatDao = seatDao;
33 | this.seatLockDao = seatLockDao;
34 | }
35 |
36 | /**
37 | * 1 save seat
38 | * 2 save seat lock
39 | * 3 add @transaction if any one fail then rollback
40 | */
41 | // @Transactional
42 | public void saveSeatAndLock(Long showId, Seat seat) {
43 | seatDao.save(seat);
44 | log.info("seat = {}", seat);
45 | saveSeatLock(showId, seat);
46 | }
47 |
48 | // @Transactional //method level
49 | public void saveSeatLock(Long showId, Seat seat) {
50 | final SeatLock seatLock = SeatLock.builder()
51 | .showId(showId)
52 | .seatId(seat.getId())
53 | .lockStatus("available")
54 | // .lockedTime(LocalDateTime.now())
55 | // .timeoutInSec(Long.valueOf(10))
56 | // .timeOutDuration(Duration.ofSeconds(10))
57 | .build();
58 | seatLockDao.save(seatLock);
59 | log.info("seatLock = {}",seatLock);
60 |
61 | //not working @Txn
62 | // if (true) {
63 | // throw new RuntimeException("query failed : sample exception");
64 | // }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/src/main/java/io/hari/demo/entity/Show.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo.entity;
2 |
3 | import com.fasterxml.jackson.annotation.JsonIgnore;
4 | import com.fasterxml.jackson.annotation.JsonProperty;
5 | import lombok.*;
6 |
7 | import javax.persistence.*;
8 | import java.time.LocalDateTime;
9 | import java.util.ArrayList;
10 | import java.util.List;
11 | import java.util.Map;
12 | import java.util.stream.Collectors;
13 |
14 | /**
15 | * @Author Hariom Yadav
16 | * @create 02-03-2021
17 | */
18 | @Getter
19 | @Setter
20 | @NoArgsConstructor
21 | @ToString(exclude = {"seats", "movies"}, callSuper = true)
22 | @AllArgsConstructor
23 | @Builder
24 | @Entity
25 | @Table(name = "shows")
26 | public class Show extends BaseEntity {
27 | String showName;
28 |
29 | @ManyToMany(fetch = FetchType.EAGER)//+ 1 dao method
30 | List seats = new ArrayList<>();
31 |
32 | @OneToMany
33 | // (fetch = FetchType.EAGER)//not working - error cant fetch multiple bags since above also we are fetching
34 | //test locally how to fetch or fetch at run time and see
35 | List movies = new ArrayList<>();
36 |
37 | //other metadata
38 | LocalDateTime startTime; //only LocalTime is enough here , TODO
39 | LocalDateTime endTime;
40 | Long movieLength;//start - end time
41 |
42 | @JsonIgnore
43 | @Convert(converter = WeekDayConvert.class)
44 | WeekDay weekDay;//this is simple pojo and inside that also simple pojo list
45 |
46 |
47 | @Transient
48 | List days = new ArrayList<>();
49 | public List getDays() {// in weekday enum we are showing values
50 | return weekDay.getDays();
51 | }
52 |
53 | // @JsonProperty(value = "seat_types")
54 | // public Map> getSeatsTypes() {
55 | // final Map> collect = seats.stream().collect(Collectors.groupingBy(
56 | // i -> i.getSeatType(),
57 | // Collectors.mapping(i -> i.getSeatId(), Collectors.toList())
58 | // ));
59 | // return collect;
60 | // }
61 |
62 | @JsonProperty
63 | public List getMovieNames() {
64 | return movies;
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/src/main/java/io/hari/demo/entity/SeatLock.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo.entity;
2 |
3 | import lombok.*;
4 | import org.springframework.beans.factory.annotation.Value;
5 |
6 | import javax.persistence.Entity;
7 | import javax.persistence.PrePersist;
8 | import java.time.Duration;
9 | import java.time.LocalDateTime;
10 |
11 | /**
12 | * @Author Hariom Yadav
13 | * @create 02-03-2021
14 | */
15 | @Getter
16 | @Setter
17 | @NoArgsConstructor
18 | @ToString(exclude = {}, callSuper = true)
19 | @AllArgsConstructor
20 | @Builder
21 | @Entity
22 | public class SeatLock extends BaseEntity {
23 | Long showId;
24 | Long seatId;
25 | String lockStatus;//available, locked
26 | //other metadata - timeout
27 |
28 | LocalDateTime lockedTime;
29 |
30 | Long timeoutInSec;//m1 : we can store timeout in Long
31 | Duration timeOutDuration;// m2 : we can store timeout in duration object
32 |
33 | //m1 check
34 | public boolean lockExpiredCheck() {//todo DONE : working : period class, duration class, instance class
35 | final Duration between = Duration.between(lockedTime, LocalDateTime.now());
36 | return between.getSeconds() - timeoutInSec >= 0 ? true : false;
37 | }
38 | //m2 check
39 | public boolean lockExpiredUsingDuration() {//TODO done : working
40 | System.out.println("compareTo = " + Duration.ofSeconds(10).compareTo(Duration.ofSeconds(10)));//0
41 | System.out.println("compareTo = " + Duration.ofSeconds(10).compareTo(Duration.ofSeconds(100)));//-1
42 | System.out.println("compareTo = " + Duration.ofSeconds(100).compareTo(Duration.ofSeconds(10)));//1
43 |
44 | final Duration myTimeDiff = Duration.between(lockedTime, LocalDateTime.now());//10
45 | final int diffWithTimeout = myTimeDiff.compareTo(timeOutDuration);//10 - 100 = -90 = -1, allow me
46 | //case 2 : diff 10 , diff with timeout = 90 that means timeout
47 | return diffWithTimeout < 0 ? false : true;
48 | // return diffWithTimeout >= 0 ? true : false;//m2
49 | }
50 |
51 | @PrePersist
52 | public void prePersist() {
53 | if (timeOutDuration == null) {
54 | timeOutDuration = Duration.ofSeconds(100);
55 | }
56 |
57 | if (timeoutInSec == null) {
58 | timeoutInSec = Long.valueOf(300);
59 | }
60 | }
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/src/main/java/io/hari/demo/service/TicketService.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo.service;
2 |
3 | import io.hari.demo.dao.BaseDao;
4 | import io.hari.demo.dao.SeatLockDao;
5 | import io.hari.demo.entity.SeatLock;
6 | import io.hari.demo.entity.Ticket;
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.cache.annotation.Cacheable;
9 | import org.springframework.stereotype.Service;
10 |
11 | import java.util.Arrays;
12 | import java.util.Optional;
13 |
14 | /**
15 | * @Author Hariom Yadav
16 | * @create 02-03-2021
17 | */
18 | @Service
19 | public class TicketService extends BaseService {
20 |
21 | @Autowired
22 | SeatLockDao seatLockDao;
23 |
24 | public TicketService(BaseDao dao) {
25 | super(dao);
26 | }
27 |
28 | /**
29 | * Creating ticket
30 | * Approach :
31 | * 1. get ticket obj : contains show, seats id in string, userid
32 | * 2. get lock obj using show id & seat id
33 | * 3. check if status is locked then stop coz someone has booked this show's seat
34 | * 4. if status is available then change to locked and create ticket object
35 | * 5. do above in synchronized block
36 | * @param ticket
37 | * @return
38 | */
39 | @Override
40 | public Ticket save(Ticket ticket) {
41 | synchronized (this) {
42 | final Ticket fetchedTicket = super.save(ticket);
43 | final Long showId = ticket.getShow().getId();
44 | final String[] split = ticket.getSeatIds().split(",");
45 | Arrays.stream(split).forEach(System.err::println);
46 |
47 | Arrays.stream(split).forEach(s -> {
48 | final Long seatId = Long.valueOf(s);
49 | final SeatLock beforeLock = seatLockDao.findByShowIdAndSeatId(showId, seatId);
50 | System.err.println("beforeLock = " + beforeLock);
51 |
52 | beforeLock.setLockStatus("locked");
53 | final SeatLock afterLock = seatLockDao.save(beforeLock);
54 | System.err.println("afterLock = " + afterLock);
55 | });
56 | return fetchedTicket;
57 | }
58 | }
59 |
60 | @Cacheable("tickets")//2
61 | public Ticket fetchTicket(Long ticketId) {//testing caching
62 | final Ticket ticket = daoCall(ticketId);
63 | return ticket;
64 | }
65 |
66 | private Ticket daoCall(Long ticketId) {
67 | System.out.println("db call");//3 for testing
68 | final Optional ticketOptional = dao.findById(ticketId);
69 | return ticketOptional.get();
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 2.4.3
9 |
10 |
11 | io.hari
12 | demo
13 | 0.0.1-SNAPSHOT
14 | demo
15 | Online Booking Ticket (Book My Show) project by Hariom Yadav
16 |
17 | 1.8
18 |
19 |
20 |
21 | org.springframework.boot
22 | spring-boot-starter-data-jpa
23 |
24 |
25 | org.springframework.boot
26 | spring-boot-starter-data-rest
27 |
28 |
29 | org.springframework.boot
30 | spring-boot-starter-quartz
31 |
32 |
33 | org.springframework.boot
34 | spring-boot-starter-validation
35 |
36 |
37 | org.springframework.boot
38 | spring-boot-starter-web
39 |
40 |
41 |
42 | org.apache.commons
43 | commons-lang3
44 |
45 |
46 |
47 | com.google.guava
48 | guava
49 | 30.1-jre
50 |
51 |
52 |
53 | org.springframework.boot
54 | spring-boot-starter-cache
55 |
56 |
57 |
58 | com.h2database
59 | h2
60 | runtime
61 |
62 |
63 | mysql
64 | mysql-connector-java
65 | runtime
66 |
67 |
68 | org.projectlombok
69 | lombok
70 | true
71 |
72 |
73 | org.springframework.boot
74 | spring-boot-starter-test
75 | test
76 |
77 |
78 | junit
79 | junit
80 | test
81 |
82 |
83 |
84 |
85 |
86 |
87 | org.springframework.boot
88 | spring-boot-maven-plugin
89 |
90 |
91 |
92 | org.projectlombok
93 | lombok
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
--------------------------------------------------------------------------------
/src/main/java/io/hari/demo/service/UserService.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo.service;
2 |
3 | import com.google.common.collect.ImmutableMap;
4 | import io.hari.demo.dao.BaseDao;
5 | import io.hari.demo.dao.SeatLockDao;
6 | import io.hari.demo.entity.*;
7 | import lombok.extern.slf4j.Slf4j;
8 | import org.springframework.beans.factory.annotation.Autowired;
9 | import org.springframework.context.ApplicationEventPublisher;
10 | import org.springframework.stereotype.Service;
11 |
12 | import java.time.LocalDateTime;
13 | import java.util.List;
14 | import java.util.stream.Collectors;
15 |
16 | /**
17 | * @Author Hariom Yadav
18 | * @create 02-03-2021
19 | */
20 | @Service
21 | @Slf4j
22 | public class UserService extends BaseService {
23 |
24 | @Autowired
25 | SeatLockDao seatLockDao;
26 |
27 | @Autowired
28 | ApplicationEventPublisher applicationEventPublisher;
29 |
30 | @Autowired
31 | NotificationService notificationService;
32 |
33 | public UserService(BaseDao dao) {
34 | super(dao);
35 | }
36 |
37 | public synchronized void selectSeats(Long showId, List seats) {
38 | if (!validSeats(showId, seats)) {
39 | throw new RuntimeException("one or more seats are not available at this moment");
40 | }
41 | seats.forEach(s -> changeSeatLockStatus(s, showId, "temp_lock"));
42 |
43 | //event use when user selected seats but not booked, so scheduler will mark them as availablea after timeout
44 | final Event event = Event.builder()
45 | .name("event1")
46 | .type("type1").params(ImmutableMap.of("showId", showId, "seats", seats))
47 | .localDateTime(LocalDateTime.now()).build();
48 | applicationEventPublisher.publishEvent(event);
49 | }
50 |
51 | private synchronized boolean validSeats(Long showId, List requestedSeats) {
52 | log.info("showId = " + showId + ", requestedSeats = " + requestedSeats);
53 | final List actualAvailableSeats = requestedSeats.stream()
54 | .map(seat -> {
55 | // return seatLockDao.findByShowIdAndSeatId(showId, seat.getId());
56 | return seatLockDao.findByShowIdAndSeatIdAndLockStatus(showId, seat.getId(), "available");
57 | })
58 | // .filter(i -> i.getLockStatus().equals("available"))//above already we fetched based on status, so not reauired
59 | .collect(Collectors.toList());
60 | log.info("actualAvailableSeats = " + actualAvailableSeats);
61 | return actualAvailableSeats.size() == requestedSeats.size() ? true : false;
62 | }
63 |
64 | public synchronized void paymentFail_Or_UnexpectedError(User currentUser, Show selectedShow, List selectedSeats) {
65 | //reset lock status
66 | selectedSeats.forEach(seat -> {
67 | changeSeatLockStatus(seat, selectedShow.getId(), "available");
68 | log.info("seat lock reset for {} {}", selectedShow.getId(), seat.getId());
69 | });
70 |
71 | notificationService.sendNotificationToUser(currentUser);//optional, create a notification service
72 | }
73 |
74 | public synchronized void changeSeatLockStatus(final Seat seat, final Long showId, final String newStatus) {
75 | final SeatLock seatLock = seatLockDao.findByShowIdAndSeatId(showId, seat.getId());
76 | seatLock.setLockStatus(newStatus);
77 | seatLockDao.save(seatLock);
78 | }
79 |
80 | private void sendNotificationToUser(User user) {
81 | log.info("payment failed for user {} , please select and book ticket again", user.getName());
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/.idea/uiDesigner.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | -
6 |
7 |
8 | -
9 |
10 |
11 | -
12 |
13 |
14 | -
15 |
16 |
17 | -
18 |
19 |
20 |
21 |
22 |
23 | -
24 |
25 |
26 |
27 |
28 |
29 | -
30 |
31 |
32 |
33 |
34 |
35 | -
36 |
37 |
38 |
39 |
40 |
41 | -
42 |
43 |
44 |
45 |
46 | -
47 |
48 |
49 |
50 |
51 | -
52 |
53 |
54 |
55 |
56 | -
57 |
58 |
59 |
60 |
61 | -
62 |
63 |
64 |
65 |
66 | -
67 |
68 |
69 |
70 |
71 | -
72 |
73 |
74 | -
75 |
76 |
77 |
78 |
79 | -
80 |
81 |
82 |
83 |
84 | -
85 |
86 |
87 |
88 |
89 | -
90 |
91 |
92 |
93 |
94 | -
95 |
96 |
97 |
98 |
99 | -
100 |
101 |
102 | -
103 |
104 |
105 | -
106 |
107 |
108 | -
109 |
110 |
111 | -
112 |
113 |
114 |
115 |
116 | -
117 |
118 |
119 | -
120 |
121 |
122 |
123 |
124 |
--------------------------------------------------------------------------------
/demo.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
--------------------------------------------------------------------------------
/src/main/java/io/hari/demo/DemoApplication.java:
--------------------------------------------------------------------------------
1 | package io.hari.demo;
2 |
3 | import com.google.common.collect.ImmutableList;
4 | import io.hari.demo.config.AppConfig;
5 | import io.hari.demo.dao.ScreenDao;
6 | import io.hari.demo.dao.SeatDao;
7 | import io.hari.demo.dao.SeatLockDao;
8 | import io.hari.demo.dao.ShowDao;
9 | import io.hari.demo.entity.*;
10 | import io.hari.demo.service.*;
11 | import lombok.*;
12 | import org.springframework.beans.factory.annotation.Autowired;
13 | import org.springframework.boot.CommandLineRunner;
14 | import org.springframework.boot.SpringApplication;
15 | import org.springframework.boot.autoconfigure.SpringBootApplication;
16 | import org.springframework.cache.annotation.EnableCaching;
17 | import org.springframework.scheduling.annotation.EnableScheduling;
18 |
19 | import java.time.*;
20 | import java.util.*;
21 | import java.util.stream.Collectors;
22 |
23 | @SpringBootApplication
24 | @EnableScheduling
25 | @EnableCaching//1. before that dependency in pom
26 | public class DemoApplication implements CommandLineRunner {
27 |
28 | public static void main(String[] args) {
29 | SpringApplication.run(DemoApplication.class, args);
30 | }
31 |
32 | @Autowired
33 | AppConfig appConfig;
34 | @Autowired
35 | SeatsService seatsService;
36 | @Autowired
37 | ShowService showService;
38 | @Autowired
39 | ShowDao showDao;
40 | @Autowired
41 | MovieService movieService;
42 | @Autowired
43 | SeatDao seatDao;
44 | @Autowired
45 | UserService userService;
46 | @Autowired
47 | TicketService ticketService;
48 | @Autowired
49 | SeatLockDao seatLockDao;
50 | @Autowired
51 | ScreenDao screenDao;
52 |
53 | @Override
54 | public void run(String... args) throws Exception {
55 | System.out.println("config = " + appConfig);
56 |
57 | final Map map = new HashMap<>();
58 | map.put("rating", "4.5");
59 | map.put("top_10", "yes");
60 | final Movie movie1 = Movie.builder().movieName("Movie1 - Avengers")
61 | .movieAttribute(MovieAttribute.builder().attributes(map).build())
62 | .ratings(Float.valueOf("4.5")).build();
63 | movieService.save(movie1);
64 | final Seat seat1 = Seat.builder().seatType("gold").build();
65 | final Seat seat2 = Seat.builder().seatType("silver").build();
66 | final Seat seat3 = Seat.builder().seatType("gold").build();
67 | final Seat seat4 = Seat.builder().seatType("silver").build();
68 | seatsService.saveAll(Arrays.asList(seat1, seat2, seat3, seat4));
69 |
70 | final LocalDateTime startTime = LocalDateTime.of(LocalDate.now(), LocalTime.of(12, 00));
71 | final LocalDateTime endTime = LocalDateTime.of(LocalDate.now(), LocalTime.of(14, 00));
72 | //period will give only days, month and yr
73 | final Period between = Period.between(startTime.toLocalDate(), endTime.toLocalDate());
74 | System.out.println("between.getDays() = " + between.getDays());
75 | //duration will give min, sec : https://mkyong.com/java8/java-8-difference-between-two-localdate-or-localdatetime/
76 | final Duration between1 = Duration.between(startTime, endTime);
77 | System.out.println("between1.toMinutes() = " + between1.toMinutes());
78 |
79 | final Show show1 = Show.builder().showName("show1 - afternoon show").movies(Arrays.asList(movie1))
80 | .startTime(startTime)
81 | .endTime(endTime)
82 | .movieLength(Duration.between(startTime, endTime).toMinutes())
83 | .weekDay(WeekDay.builder().days(Arrays.asList(Days.sun, Days.mon)).build())
84 | .seats(Arrays.asList(seat1, seat2, seat3, seat4)).build();
85 | final Show save = showService.save(show1);
86 | System.out.println("save = " + save);
87 |
88 | final List seats = seatDao.findAllAvailableShowSeats(show1.getId());
89 | System.out.println("seats = " + seats);
90 |
91 | // user1 operations
92 | //create user1
93 | final User user1 = userService.save(User.builder().name("hariom").build());
94 | final User user2 = userService.save(User.builder().name("chandan").build());
95 | System.out.println("user1 = " + user1);
96 |
97 | // add new show to user1 entity , make sure show is already in db
98 | final User hariom = userService.findById(1L);
99 | //find all available seats
100 | final List showSeats = seatDao.findAllAvailableShowSeats(1L);
101 | System.out.println("All available Seats = " + showSeats);
102 | //check lock value
103 | showSeats.forEach(seat -> {
104 | final SeatLock seatLock = seatLockDao.findByShowIdAndSeatId(1L, seat.getId());
105 | System.err.println("seatLock = " + seatLock);
106 | });
107 | //select seats
108 | final ImmutableList immutableList =
109 | ImmutableList.of(showSeats.get(0), showSeats.get(1), showSeats.get(2));
110 | System.err.println("selecting seats = " + immutableList);
111 |
112 | //user1 1 select seats - change lock status to temp locked
113 | userService.selectSeats(1L, immutableList);
114 |
115 | //find all available seats
116 | final List showSeats3 = seatDao.findAllAvailableShowSeats(1L);
117 | System.err.println("before payment fail of user 1 - All available Seats3 for user 2= " + showSeats3);
118 |
119 | //if we test this then dont book below ticket obj and save - just comment and test
120 | // userService.paymentFail_Or_UnexpectedError(user1, show1, immutableList);
121 |
122 | //find all available seats
123 | final List showSeats4 = seatDao.findAllAvailableShowSeats(1L);
124 | System.err.println("after payment fail All available Seats3 for user 2= " + showSeats4);
125 |
126 | //book ticket
127 | final Ticket ticket = Ticket.builder()
128 | .user(hariom)
129 | .paymentMod("cc")
130 | .show(show1)
131 | .seatIds(immutableList.stream().map(i -> i.getId().toString()).collect(Collectors.joining(",")))
132 | .build();
133 | ticketService.save(ticket);
134 |
135 | final Ticket ticket1 = ticketService.fetchTicket(ticket.getId());
136 | System.out.println("-------- "+ticket1);
137 | final Ticket ticket2 = ticketService.fetchTicket(ticket.getId());
138 | System.out.println("-------- "+ticket2);
139 |
140 | //attach ticket to user1
141 | hariom.setTickets(Arrays.asList(ticket));//after creating ticket set to user1 and update user1 db
142 | userService.save(hariom);
143 |
144 | //find all available seats
145 | final List showSeats2 = seatDao.findAllAvailableShowSeats(1L);
146 | System.err.println("All available Seats2 = " + showSeats2);
147 |
148 | //create show 2 with show 1 seats , since both are running on same screen
149 | Movie movie2 = Movie.builder().movieName("Movie2 - Hulk").ratings(4.6f).build();
150 | movieService.save(movie2);
151 |
152 | final LocalDateTime startTime1 = LocalDateTime.of(LocalDate.now(), LocalTime.of(14, 00));
153 | final LocalDateTime endTime1 = LocalDateTime.of(LocalDate.now(), LocalTime.of(16, 30));
154 | final Show show2 = Show.builder().showName("show2 - evening show")
155 | .movies(Arrays.asList(movie2))
156 | .startTime(startTime1)
157 | .endTime(endTime1)
158 | .movieLength(Duration.between(startTime1, endTime1).toMinutes())
159 | .weekDay(WeekDay.builder().days(Arrays.asList(Days.mon, Days.tue)).build())
160 | .seats(Arrays.asList(seat1, seat2, seat3, seat4))
161 | .build();
162 | final Show fetchedShow = showService.save(show2);
163 | System.out.println("show2 = " + fetchedShow);
164 |
165 | //find day wise shows, here we need to go deep inside other obj list, i.e. WeekDay list is days,
166 | //1. create a Transient property same as that weekday
167 | //2. create a getter,
168 | //3. now we can call that getter in stream as we are calling field
169 | final List shows = showService.findAll();
170 | final Map> collect = shows.stream().filter(Objects::nonNull)//always add object null filter
171 | .collect(Collectors.partitioningBy(i -> i.getDays().contains(Days.sun)));
172 | System.out.println("sunday shows = " + collect.get(true));//sunday shows
173 |
174 | final Map> monShows = shows.stream().filter(Objects::nonNull)
175 | .collect(Collectors.partitioningBy(i -> i.getDays().contains(Days.mon)));
176 | final Map> tueShows = shows.stream().filter(Objects::nonNull)
177 | .collect(Collectors.partitioningBy(i -> i.getDays().contains(Days.tue)));
178 | System.out.println("monShows = " + monShows.get(true));
179 | System.out.println("tueShows = " + tueShows.get(true));
180 |
181 | //movie i want to search for monday or tuesday
182 | final Map> monAndTueShows = shows.stream().filter(Objects::nonNull)
183 | .collect(Collectors.partitioningBy(i -> {
184 | final List days = i.getDays();
185 | if (days.contains(Days.mon)) return true;
186 | if (days.contains(Days.tue)) return false;
187 | return false;
188 | }));
189 | System.out.println("monAndTueShows = " + monAndTueShows.get(true));
190 |
191 | final Map> collect1 = shows.stream().filter(Objects::nonNull)
192 | .collect(Collectors.partitioningBy(
193 | i -> i.getDays().contains(Days.sun),
194 | Collectors.toList()
195 | ));
196 | System.out.println("collect1 = " + collect1.get(true));
197 | // movies on monday, : adding new argument in partitioning
198 | final Map collect2 = shows.stream().filter(Objects::nonNull).collect(Collectors.partitioningBy(
199 | i -> i.getDays().contains(Days.mon),
200 | Collectors.counting()
201 | ));
202 | System.out.println("collect2 = " + collect2.get(true));
203 |
204 | final Map>> collect3 = shows.stream().filter(Objects::nonNull)
205 | .collect(Collectors.partitioningBy(i -> i.getDays().contains(Days.mon),
206 | Collectors.groupingBy(i -> i.getShowName())));
207 | System.out.println("collect3 = " + collect3.get(true));
208 |
209 | //key :sun, value : movies name in string
210 | final Map> collect4 = shows.stream().filter(Objects::nonNull)
211 | .collect(Collectors.partitioningBy(i -> i.getDays().contains(Days.mon),//filter
212 | Collectors.mapping(i -> i.getShowName(), Collectors.toList())//we can place price here, or we can create new obj
213 | ));
214 | System.out.println("collect4 = " + collect4);
215 |
216 | final Map>> collect5 = shows.stream().filter(Objects::nonNull)
217 | .collect(Collectors.partitioningBy(i -> i.getDays().contains(Days.sun),
218 | Collectors.mapping(i -> i.getSeats(), Collectors.toList())//sunday movie seat
219 | ));
220 | System.out.println("collect5 = " + collect5.get(true));
221 |
222 | //client output from show entity, key : mon, value new entity
223 | final Map> collect6 = shows.stream().filter(Objects::nonNull)
224 | .collect(Collectors.partitioningBy(//using 2 argument partitioning method
225 | show -> show.getDays().contains(Days.mon),//1st argument
226 | Collectors.mapping(show -> {
227 | final ShowDto showDto = ShowDto.builder().movieName(show.getShowName())
228 | .availableSeats(show.getSeats().size()).movieLength(show.getMovieLength()).build();
229 | return showDto;
230 | }, Collectors.toList())
231 | ));
232 |
233 | System.out.println("collect6 = " + collect6.get(true));
234 |
235 | ShowDto.nonNullTest("hari");
236 | // ShowDto.nonNullTest(null);
237 |
238 |
239 | //todo :DONE create timeout in lock obj - using localdattime seconds as timeout
240 | final SeatLock seatLock = SeatLock.builder()
241 | .lockedTime(LocalDateTime.now())
242 | .timeoutInSec(Long.valueOf(5))
243 | .build();
244 | seatLockDao.save(seatLock);
245 | System.out.println("seatLock = " + seatLock);
246 | final boolean check = seatLock.lockExpiredCheck();
247 | System.out.println("check = " + check);
248 |
249 | Thread.sleep(5000);//check after 5 sec
250 | System.out.println("lockExpiredCheck = " + seatLock.lockExpiredCheck());
251 |
252 | //todo : DONE create timeout in lock obj - using Localdattime and Duration as timeout
253 | final SeatLock seatLock1 = SeatLock.builder()
254 | .lockedTime(LocalDateTime.now())
255 | .timeOutDuration(Duration.ofSeconds(10))
256 | .build();
257 | seatLockDao.save(seatLock1);
258 | System.out.println("seatLock1 = " + seatLock1);
259 | System.out.println("usingDuration = " + seatLock1.lockExpiredUsingDuration());
260 | Thread.sleep(10000);
261 | System.out.println("usingDuration = " + seatLock1.lockExpiredUsingDuration());
262 |
263 | System.out.println("compareTo = " + Duration.ofSeconds(10).compareTo(Duration.ofSeconds(10)));//0
264 | System.out.println("compareTo = " + Duration.ofSeconds(10).compareTo(Duration.ofSeconds(100)));//-1
265 | System.out.println("compareTo = " + Duration.ofSeconds(100).compareTo(Duration.ofSeconds(10)));//1
266 |
267 | //todo :DONE read timeouts from config
268 | final Duration timeout = appConfig.getTimeout();
269 | System.out.println("timeout = " + timeout);
270 | System.out.println("appConfig = " + timeout.getSeconds());
271 | final SeatLock seatLock2 = SeatLock.builder()
272 | .lockedTime(LocalDateTime.now())
273 | .timeOutDuration(timeout).build();
274 | seatLockDao.save(seatLock2);
275 | System.out.println("seatLock2 = " + seatLock2);
276 | System.out.println("seatLock2.lockExpiredUsingDuration() = " + seatLock2.lockExpiredUsingDuration());
277 | Thread.sleep(5000);//test with 10 sec
278 | System.out.println("seatLock2.lockExpiredUsingDuration() = " + seatLock2.lockExpiredUsingDuration());
279 |
280 | //todo : DONE : create a seat and lock and test for rollback if any one fail
281 | final Seat seat = Seat.builder().seatType("platinum").build();
282 | // seatsService.saveSeatAndLock(show1.getId(), seat);
283 |
284 | //todo : NOT DONE : link new seat id to show, required bi directional mapping
285 | // show1.getSeats().add(seat);//error coz of uni direction not bidirectional
286 | // showDao.save(show1);
287 |
288 | System.err.println(show1.getId() +" "+seat.getId());
289 | // showDao.addNewShowSeat(show1.getId(), seat.getId());//not working
290 |
291 | }
292 | }
293 |
294 | @Getter
295 | @Setter
296 | @NoArgsConstructor
297 | @AllArgsConstructor
298 | @Builder
299 | @ToString
300 | class ShowDto {
301 | String movieName;
302 | Long movieLength;
303 | Integer availableSeats;
304 |
305 | public static void nonNullTest(@NonNull String string) {//null check of string, throw exception
306 | System.out.println("string = " + string);
307 | }
308 | }
309 |
310 |
311 |
--------------------------------------------------------------------------------