├── commonservice ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── tanthanh │ │ │ └── commonservice │ │ │ ├── CommonserviceApplication.java │ │ │ ├── query │ │ │ ├── GetDetailsBookQuery.java │ │ │ └── GetDetailsEmployeeQuery.java │ │ │ ├── model │ │ │ ├── BookResponseCommonModel.java │ │ │ └── EmployeeResponseCommonModel.java │ │ │ ├── event │ │ │ ├── BookUpdateStatusEvent.java │ │ │ └── BookRollBackStatusEvent.java │ │ │ └── command │ │ │ ├── RollBackStatusBookCommand.java │ │ │ └── UpdateStatusBookCommand.java │ └── test │ │ └── java │ │ └── com │ │ └── tanthanh │ │ └── commonservice │ │ └── CommonserviceApplicationTests.java ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── .gitignore ├── pom.xml └── mvnw.cmd ├── .idea ├── .gitignore ├── vcs.xml ├── modules.xml └── microserviceapp.iml ├── apigateway.zip ├── bookservice.zip ├── userservice.zip ├── commonservice.zip ├── borrowingservice.zip ├── discoveryserver.zip ├── employeeservice.zip ├── notificationservice.zip ├── userservice ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── tanthanh │ │ │ │ └── userservice │ │ │ │ ├── lombok.config │ │ │ │ ├── data │ │ │ │ ├── UserRepository.java │ │ │ │ └── User.java │ │ │ │ ├── UserserviceApplication.java │ │ │ │ ├── model │ │ │ │ └── UserDTO.java │ │ │ │ ├── controller │ │ │ │ └── UserController.java │ │ │ │ └── service │ │ │ │ └── UserService.java │ │ └── resources │ │ │ └── application.properties │ └── test │ │ ├── java │ │ └── com │ │ │ └── tanthanh │ │ │ └── userservice │ │ │ ├── UserserviceApplicationTests.java │ │ │ ├── UserControllerTest.java │ │ │ ├── IntergrationTest.java │ │ │ └── UserServiceTest.java │ │ └── resources │ │ └── application.properties ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── .gitignore ├── pom.xml └── mvnw.cmd ├── apigateway ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── src │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── tanthanh │ │ │ └── apigateway │ │ │ └── ApigatewayApplicationTests.java │ └── main │ │ ├── java │ │ └── com │ │ │ └── tanthanh │ │ │ └── apigateway │ │ │ ├── ApigatewayApplication.java │ │ │ └── configuration │ │ │ └── AuthFilter.java │ │ └── resources │ │ └── application.yml ├── .gitignore ├── pom.xml └── mvnw.cmd ├── bookservice ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── tanthanh │ │ │ │ └── bookservice │ │ │ │ ├── query │ │ │ │ ├── queries │ │ │ │ │ ├── GetAllBooksQuery.java │ │ │ │ │ └── GetBookQuery.java │ │ │ │ ├── model │ │ │ │ │ └── BookResponseModel.java │ │ │ │ ├── controller │ │ │ │ │ └── BookQueryController.java │ │ │ │ └── projection │ │ │ │ │ └── BookProjection.java │ │ │ │ ├── command │ │ │ │ ├── data │ │ │ │ │ ├── BookRepository.java │ │ │ │ │ └── Book.java │ │ │ │ ├── event │ │ │ │ │ ├── BookDeletedEvent.java │ │ │ │ │ ├── BookCreatedEvent.java │ │ │ │ │ ├── BookUpdatedEvent.java │ │ │ │ │ └── BookEventsHandler.java │ │ │ │ ├── command │ │ │ │ │ ├── DeleteBookCommand.java │ │ │ │ │ ├── CreateBookCommand.java │ │ │ │ │ └── UpdateBookCommand.java │ │ │ │ ├── model │ │ │ │ │ └── BookRequestModel.java │ │ │ │ ├── controller │ │ │ │ │ └── BookCommandController.java │ │ │ │ └── aggregate │ │ │ │ │ └── BookAggregate.java │ │ │ │ ├── config │ │ │ │ └── AxonConfig.java │ │ │ │ └── BookserviceApplication.java │ │ └── resources │ │ │ └── application.properties │ └── test │ │ └── java │ │ └── com │ │ └── tanthanh │ │ └── bookservice │ │ └── BookserviceApplicationTests.java ├── .gitignore ├── pom.xml └── mvnw.cmd ├── discoveryserver ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── tanthanh │ │ │ └── discoveryserver │ │ │ └── DiscoveryserverApplication.java │ └── test │ │ └── java │ │ └── com │ │ └── tanthanh │ │ └── discoveryserver │ │ └── DiscoveryserverApplicationTests.java ├── .gitignore ├── pom.xml └── mvnw.cmd ├── borrowingservice ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── tanthanh │ │ │ │ └── borrowingservice │ │ │ │ ├── query │ │ │ │ ├── queries │ │ │ │ │ ├── GetAllBorrowing.java │ │ │ │ │ └── GetListBorrowingByEmployeeQuery.java │ │ │ │ ├── model │ │ │ │ │ └── BorrowingResponseModel.java │ │ │ │ ├── controller │ │ │ │ │ └── BorrowingQueryController.java │ │ │ │ └── projection │ │ │ │ │ └── BorrowingProjection.java │ │ │ │ ├── command │ │ │ │ └── api │ │ │ │ │ ├── events │ │ │ │ │ ├── BorrowDeletedEvent.java │ │ │ │ │ ├── BorrowingUpdateBookReturnEvent.java │ │ │ │ │ ├── BorrowSendMessageEvent.java │ │ │ │ │ ├── BorrowCreatedEvent.java │ │ │ │ │ └── BorrowingEventsHandler.java │ │ │ │ │ ├── data │ │ │ │ │ ├── BorrowRepository.java │ │ │ │ │ └── Borrowing.java │ │ │ │ │ ├── command │ │ │ │ │ ├── DeleteBorrowCommand.java │ │ │ │ │ ├── SendMessageCommand.java │ │ │ │ │ ├── UpdateBookReturnCommand.java │ │ │ │ │ └── CreateBorrowCommand.java │ │ │ │ │ ├── model │ │ │ │ │ ├── Message.java │ │ │ │ │ └── BorrowRequestModel.java │ │ │ │ │ ├── service │ │ │ │ │ └── BorrowService.java │ │ │ │ │ ├── controller │ │ │ │ │ └── BorrowCommandController.java │ │ │ │ │ ├── aggregate │ │ │ │ │ └── BorrowAggregate.java │ │ │ │ │ └── saga │ │ │ │ │ └── BorrowingSaga.java │ │ │ │ ├── config │ │ │ │ └── AxonConfig.java │ │ │ │ └── BorrowingserviceApplication.java │ │ └── resources │ │ │ └── application.properties │ └── test │ │ └── java │ │ └── com │ │ └── tanthanh │ │ └── borrowingservice │ │ └── BorrowingserviceApplicationTests.java ├── .gitignore ├── pom.xml └── mvnw.cmd ├── notificationservice ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── src │ ├── main │ │ ├── resources │ │ │ ├── application.yml │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── tanthanh │ │ │ └── notificationservice │ │ │ ├── Message.java │ │ │ ├── EmployeeReponseModel.java │ │ │ ├── configuration │ │ │ └── AppConfiguration.java │ │ │ └── NotificationserviceApplication.java │ └── test │ │ └── java │ │ └── com │ │ └── tanthanh │ │ └── notificationservice │ │ └── NotificationserviceApplicationTests.java ├── .gitignore ├── pom.xml └── mvnw.cmd └── employeeservice └── employeeservice ├── .mvn └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── src ├── main │ ├── java │ │ └── com │ │ │ └── tanthanh │ │ │ └── employeeservice │ │ │ ├── query │ │ │ ├── queries │ │ │ │ ├── GetAllEmployeeQuery.java │ │ │ │ └── GetEmployeesQuery.java │ │ │ ├── model │ │ │ │ └── EmployeeReponseModel.java │ │ │ ├── controller │ │ │ │ └── EmployeeQueryController.java │ │ │ └── projection │ │ │ │ └── EmployeeProjection.java │ │ │ ├── command │ │ │ ├── data │ │ │ │ ├── EmployeeRepository.java │ │ │ │ └── Employee.java │ │ │ ├── event │ │ │ │ ├── EmployeeDeletedEvent.java │ │ │ │ ├── EmployeeUpdatedEvent.java │ │ │ │ ├── EmployeeCreatedEvent.java │ │ │ │ └── EmployeeEventsHandler.java │ │ │ ├── command │ │ │ │ ├── DeleteEmployeeCommand.java │ │ │ │ ├── UpdateEmployeeCommand.java │ │ │ │ └── CreateEmployeeCommand.java │ │ │ ├── model │ │ │ │ └── EmployeeRequestModel.java │ │ │ ├── aggregate │ │ │ │ └── EmployeeAggregate.java │ │ │ └── controller │ │ │ │ └── EmployeeCommandController.java │ │ │ ├── EmployeeserviceApplication.java │ │ │ └── config │ │ │ └── AxonConfig.java │ └── resources │ │ └── application.properties └── test │ └── java │ └── com │ └── tanthanh │ └── employeeservice │ └── EmployeeserviceApplicationTests.java ├── .gitignore └── pom.xml /commonservice/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /apigateway.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo2706/microserviceapp/HEAD/apigateway.zip -------------------------------------------------------------------------------- /bookservice.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo2706/microserviceapp/HEAD/bookservice.zip -------------------------------------------------------------------------------- /userservice.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo2706/microserviceapp/HEAD/userservice.zip -------------------------------------------------------------------------------- /commonservice.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo2706/microserviceapp/HEAD/commonservice.zip -------------------------------------------------------------------------------- /borrowingservice.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo2706/microserviceapp/HEAD/borrowingservice.zip -------------------------------------------------------------------------------- /discoveryserver.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo2706/microserviceapp/HEAD/discoveryserver.zip -------------------------------------------------------------------------------- /employeeservice.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo2706/microserviceapp/HEAD/employeeservice.zip -------------------------------------------------------------------------------- /notificationservice.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo2706/microserviceapp/HEAD/notificationservice.zip -------------------------------------------------------------------------------- /userservice/src/main/java/com/tanthanh/userservice/lombok.config: -------------------------------------------------------------------------------- 1 | config.stopBubbling = true 2 | lombok.addLombokGeneratedAnnotation = true -------------------------------------------------------------------------------- /apigateway/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo2706/microserviceapp/HEAD/apigateway/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /bookservice/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo2706/microserviceapp/HEAD/bookservice/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /userservice/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo2706/microserviceapp/HEAD/userservice/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /commonservice/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo2706/microserviceapp/HEAD/commonservice/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /discoveryserver/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo2706/microserviceapp/HEAD/discoveryserver/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /borrowingservice/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo2706/microserviceapp/HEAD/borrowingservice/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /notificationservice/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo2706/microserviceapp/HEAD/notificationservice/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /employeeservice/employeeservice/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo2706/microserviceapp/HEAD/employeeservice/employeeservice/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /bookservice/src/main/java/com/tanthanh/bookservice/query/queries/GetAllBooksQuery.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.bookservice.query.queries; 2 | 3 | public class GetAllBooksQuery { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /borrowingservice/src/main/java/com/tanthanh/borrowingservice/query/queries/GetAllBorrowing.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.borrowingservice.query.queries; 2 | 3 | public class GetAllBorrowing { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /discoveryserver/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=discovery-server 2 | eureka.client.register-with-eureka=false 3 | eureka.client.fetch-registry=false 4 | server.port=8761 5 | -------------------------------------------------------------------------------- /employeeservice/employeeservice/src/main/java/com/tanthanh/employeeservice/query/queries/GetAllEmployeeQuery.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.employeeservice.query.queries; 2 | 3 | public class GetAllEmployeeQuery { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /apigateway/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar 3 | -------------------------------------------------------------------------------- /bookservice/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar 3 | -------------------------------------------------------------------------------- /commonservice/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar 3 | -------------------------------------------------------------------------------- /userservice/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar 3 | -------------------------------------------------------------------------------- /bookservice/src/main/java/com/tanthanh/bookservice/command/data/BookRepository.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.bookservice.command.data; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | public interface BookRepository extends JpaRepository{ 6 | 7 | } 8 | -------------------------------------------------------------------------------- /borrowingservice/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar 3 | -------------------------------------------------------------------------------- /discoveryserver/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar 3 | -------------------------------------------------------------------------------- /notificationservice/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar 3 | -------------------------------------------------------------------------------- /notificationservice/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | management: 2 | health: 3 | circuitbreakers: 4 | enabled: true 5 | endpoints: 6 | web: 7 | exposure: 8 | include: health 9 | endpoint: 10 | health: 11 | show-details: always 12 | -------------------------------------------------------------------------------- /employeeservice/employeeservice/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar 3 | -------------------------------------------------------------------------------- /userservice/src/main/java/com/tanthanh/userservice/data/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.userservice.data; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | public interface UserRepository extends JpaRepository{ 6 | User findByUsername(String username); 7 | } 8 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /employeeservice/employeeservice/src/main/java/com/tanthanh/employeeservice/command/data/EmployeeRepository.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.employeeservice.command.data; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | public interface EmployeeRepository extends JpaRepository{ 6 | 7 | } 8 | -------------------------------------------------------------------------------- /apigateway/src/test/java/com/tanthanh/apigateway/ApigatewayApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.apigateway; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class ApigatewayApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /bookservice/src/main/java/com/tanthanh/bookservice/query/queries/GetBookQuery.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.bookservice.query.queries; 2 | 3 | public class GetBookQuery { 4 | private String bookId; 5 | 6 | public String getBookId() { 7 | return bookId; 8 | } 9 | 10 | public void setBookId(String bookId) { 11 | this.bookId = bookId; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /bookservice/src/test/java/com/tanthanh/bookservice/BookserviceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.bookservice; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class BookserviceApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /userservice/src/test/java/com/tanthanh/userservice/UserserviceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.userservice; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class UserserviceApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /bookservice/src/main/java/com/tanthanh/bookservice/command/event/BookDeletedEvent.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.bookservice.command.event; 2 | 3 | public class BookDeletedEvent { 4 | private String bookId; 5 | 6 | public String getBookId() { 7 | return bookId; 8 | } 9 | public void setBookId(String bookId) { 10 | this.bookId = bookId; 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /commonservice/src/test/java/com/tanthanh/commonservice/CommonserviceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.commonservice; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class CommonserviceApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /.idea/microserviceapp.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /borrowingservice/src/main/java/com/tanthanh/borrowingservice/command/api/events/BorrowDeletedEvent.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.borrowingservice.command.api.events; 2 | 3 | public class BorrowDeletedEvent { 4 | 5 | private String id; 6 | 7 | public String getId() { 8 | return id; 9 | } 10 | 11 | public void setId(String id) { 12 | this.id = id; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /discoveryserver/src/test/java/com/tanthanh/discoveryserver/DiscoveryserverApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.discoveryserver; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class DiscoveryserverApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /borrowingservice/src/test/java/com/tanthanh/borrowingservice/BorrowingserviceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.borrowingservice; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class BorrowingserviceApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /employeeservice/employeeservice/src/test/java/com/tanthanh/employeeservice/EmployeeserviceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.employeeservice; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class EmployeeserviceApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /notificationservice/src/test/java/com/tanthanh/notificationservice/NotificationserviceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.notificationservice; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class NotificationserviceApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /notificationservice/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.cloud.stream.bindings.input.destination=tanthanh 2 | spring.cloud.stream.bindings.input.content-type=application/json 3 | server.port = 9007 4 | logging.level.org.springframework.boot.autoconfigure.web.servlet.DispatcherServlet= debug 5 | logging.level.root= info 6 | spring.application.name=notificationservice 7 | spring.zipkin.base-url=http://localhost:9411 8 | -------------------------------------------------------------------------------- /employeeservice/employeeservice/src/main/java/com/tanthanh/employeeservice/query/queries/GetEmployeesQuery.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.employeeservice.query.queries; 2 | 3 | public class GetEmployeesQuery { 4 | private String employeeId; 5 | 6 | public String getEmployeeId() { 7 | return employeeId; 8 | } 9 | 10 | public void setEmployeeId(String employeeId) { 11 | this.employeeId = employeeId; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /employeeservice/employeeservice/src/main/java/com/tanthanh/employeeservice/command/event/EmployeeDeletedEvent.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.employeeservice.command.event; 2 | 3 | public class EmployeeDeletedEvent { 4 | private String employeeId; 5 | 6 | public String getEmployeeId() { 7 | return employeeId; 8 | } 9 | 10 | public void setEmployeeId(String employeeId) { 11 | this.employeeId = employeeId; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /borrowingservice/src/main/java/com/tanthanh/borrowingservice/query/queries/GetListBorrowingByEmployeeQuery.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.borrowingservice.query.queries; 2 | 3 | public class GetListBorrowingByEmployeeQuery { 4 | private String employeeId; 5 | 6 | public String getEmployeeId() { 7 | return employeeId; 8 | } 9 | 10 | public void setEmployeeId(String employeeId) { 11 | this.employeeId = employeeId; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /apigateway/src/main/java/com/tanthanh/apigateway/ApigatewayApplication.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.apigateway; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class ApigatewayApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ApigatewayApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /commonservice/src/main/java/com/tanthanh/commonservice/CommonserviceApplication.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.commonservice; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class CommonserviceApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(CommonserviceApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /commonservice/src/main/java/com/tanthanh/commonservice/query/GetDetailsBookQuery.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.commonservice.query; 2 | 3 | public class GetDetailsBookQuery { 4 | private String bookId; 5 | 6 | 7 | 8 | public GetDetailsBookQuery(String bookId) { 9 | super(); 10 | this.bookId = bookId; 11 | } 12 | 13 | public String getBookId() { 14 | return bookId; 15 | } 16 | 17 | public void setBookId(String bookId) { 18 | this.bookId = bookId; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /borrowingservice/src/main/java/com/tanthanh/borrowingservice/command/api/data/BorrowRepository.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.borrowingservice.command.api.data; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | 7 | public interface BorrowRepository extends JpaRepository{ 8 | List findByEmployeeIdAndReturnDateIsNull(String employeeId); 9 | Borrowing findByEmployeeIdAndBookIdAndReturnDateIsNull(String employeeId,String bookId); 10 | } -------------------------------------------------------------------------------- /commonservice/src/main/java/com/tanthanh/commonservice/query/GetDetailsEmployeeQuery.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.commonservice.query; 2 | 3 | public class GetDetailsEmployeeQuery { 4 | private String employeeId; 5 | 6 | 7 | 8 | public GetDetailsEmployeeQuery(String employeeId) { 9 | super(); 10 | this.employeeId = employeeId; 11 | } 12 | 13 | public String getEmployeeId() { 14 | return employeeId; 15 | } 16 | 17 | public void setEmployeeId(String employeeId) { 18 | this.employeeId = employeeId; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /apigateway/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /bookservice/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /userservice/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /borrowingservice/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /commonservice/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /discoveryserver/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /notificationservice/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /discoveryserver/src/main/java/com/tanthanh/discoveryserver/DiscoveryserverApplication.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.discoveryserver; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; 6 | 7 | @SpringBootApplication 8 | @EnableEurekaServer 9 | public class DiscoveryserverApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(DiscoveryserverApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /employeeservice/employeeservice/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /bookservice/src/main/java/com/tanthanh/bookservice/command/command/DeleteBookCommand.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.bookservice.command.command; 2 | 3 | import org.axonframework.modelling.command.TargetAggregateIdentifier; 4 | 5 | public class DeleteBookCommand { 6 | @TargetAggregateIdentifier 7 | private String bookId; 8 | 9 | public DeleteBookCommand(String bookId) { 10 | super(); 11 | this.bookId = bookId; 12 | 13 | } 14 | 15 | public String getBookId() { 16 | return bookId; 17 | } 18 | 19 | public void setBookId(String bookId) { 20 | this.bookId = bookId; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /employeeservice/employeeservice/src/main/java/com/tanthanh/employeeservice/EmployeeserviceApplication.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.employeeservice; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | 7 | @SpringBootApplication 8 | @EnableDiscoveryClient 9 | public class EmployeeserviceApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(EmployeeserviceApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /borrowingservice/src/main/java/com/tanthanh/borrowingservice/command/api/command/DeleteBorrowCommand.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.borrowingservice.command.api.command; 2 | 3 | import org.axonframework.modelling.command.TargetAggregateIdentifier; 4 | 5 | public class DeleteBorrowCommand { 6 | @TargetAggregateIdentifier 7 | private String id; 8 | 9 | 10 | 11 | public DeleteBorrowCommand(String id) { 12 | super(); 13 | this.id = id; 14 | } 15 | 16 | public String getId() { 17 | return id; 18 | } 19 | 20 | public void setId(String id) { 21 | this.id = id; 22 | } 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /bookservice/src/main/java/com/tanthanh/bookservice/config/AxonConfig.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.bookservice.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | import com.thoughtworks.xstream.XStream; 7 | 8 | @Configuration 9 | public class AxonConfig { 10 | 11 | // @Bean 12 | // public XStream xStream() { 13 | // XStream xStream = new XStream(); 14 | // 15 | // xStream.allowTypesByWildcard(new String[] { 16 | // "com.tanthanh.**" 17 | // }); 18 | // return xStream; 19 | // } 20 | } 21 | -------------------------------------------------------------------------------- /bookservice/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name = bookservice 2 | server.port = 9001 3 | eureka.client.service-url.defaultZone = http://localhost:8761/eureka 4 | spring.datasource.url=jdbc:h2:file:~/data/bookDB 5 | spring.datasource.driverClassName=org.h2.Driver 6 | spring.datasource.username=sa 7 | spring.datasource.password= 8 | spring.jpa.database-platform=org.hibernate.dialect.H2Dialect 9 | spring.h2.console.enabled=true 10 | spring.jpa.hibernate.ddl-auto =update 11 | spring.zipkin.base-url=http://localhost:9411 12 | logging.file.name=C:/Users/thando/OneDrive - Capgemini/Desktop/log/logElk.log 13 | -------------------------------------------------------------------------------- /borrowingservice/src/main/java/com/tanthanh/borrowingservice/config/AxonConfig.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.borrowingservice.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | import com.thoughtworks.xstream.XStream; 7 | 8 | @Configuration 9 | public class AxonConfig { 10 | 11 | @Bean 12 | public XStream xStream() { 13 | XStream xStream = new XStream(); 14 | 15 | xStream.allowTypesByWildcard(new String[] { 16 | "com.tanthanh.**" 17 | }); 18 | return xStream; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /employeeservice/employeeservice/src/main/java/com/tanthanh/employeeservice/config/AxonConfig.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.employeeservice.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | import com.thoughtworks.xstream.XStream; 7 | 8 | @Configuration 9 | public class AxonConfig { 10 | 11 | @Bean 12 | public XStream xStream() { 13 | XStream xStream = new XStream(); 14 | 15 | xStream.allowTypesByWildcard(new String[] { 16 | "com.tanthanh.**" 17 | }); 18 | return xStream; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /userservice/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name = userservice 2 | eureka.client.service-url.defaultZone = http://localhost:8761/eureka 3 | server.port = 9004 4 | spring.datasource.url=jdbc:h2:file:~/data/userserviceDB 5 | spring.datasource.driverClassName=org.h2.Driver 6 | spring.datasource.username=sa 7 | spring.datasource.password= 8 | spring.jpa.database-platform=org.hibernate.dialect.H2Dialect 9 | spring.h2.console.enabled=true 10 | spring.jpa.hibernate.ddl-auto =update 11 | spring.h2.console.settings.web-allow-others=true 12 | logging.level.org.springframework.boot.autoconfigure.web.servlet.DispatcherServlet= DEBUG 13 | -------------------------------------------------------------------------------- /userservice/src/test/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name = userservice 2 | eureka.client.service-url.defaultZone = http://localhost:8761/eureka 3 | server.port = 9004 4 | spring.datasource.url=jdbc:h2:file:~/data/userserviceDB 5 | spring.datasource.driverClassName=org.h2.Driver 6 | spring.datasource.username=sa 7 | spring.datasource.password= 8 | spring.jpa.database-platform=org.hibernate.dialect.H2Dialect 9 | spring.h2.console.enabled=true 10 | spring.jpa.hibernate.ddl-auto =update 11 | spring.h2.console.settings.web-allow-others=true 12 | logging.level.org.springframework.boot.autoconfigure.web.servlet.DispatcherServlet= DEBUG 13 | -------------------------------------------------------------------------------- /employeeservice/employeeservice/src/main/java/com/tanthanh/employeeservice/command/command/DeleteEmployeeCommand.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.employeeservice.command.command; 2 | 3 | import org.axonframework.modelling.command.TargetAggregateIdentifier; 4 | 5 | public class DeleteEmployeeCommand { 6 | @TargetAggregateIdentifier 7 | private String employeeId; 8 | 9 | public String getEmployeeId() { 10 | return employeeId; 11 | } 12 | 13 | public void setEmployeeId(String employeeId) { 14 | this.employeeId = employeeId; 15 | } 16 | 17 | public DeleteEmployeeCommand(String employeeId) { 18 | super(); 19 | this.employeeId = employeeId; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /notificationservice/src/main/java/com/tanthanh/notificationservice/Message.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.notificationservice; 2 | 3 | public class Message { 4 | private String employeeId; 5 | private String message; 6 | public String getEmployeeId() { 7 | return employeeId; 8 | } 9 | public void setEmployeeId(String employeeId) { 10 | this.employeeId = employeeId; 11 | } 12 | public String getMessage() { 13 | return message; 14 | } 15 | public void setMessage(String message) { 16 | this.message = message; 17 | } 18 | @Override 19 | public String toString() { 20 | return "Message [employeeId=" + employeeId + ", message=" + message + "]"; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /bookservice/src/main/java/com/tanthanh/bookservice/BookserviceApplication.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.bookservice; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import org.springframework.context.annotation.ComponentScan; 7 | 8 | @SpringBootApplication 9 | @EnableDiscoveryClient 10 | @ComponentScan({"com.tanthanh.bookservice","com.tanthah.commoservice"}) 11 | public class BookserviceApplication { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(BookserviceApplication.class, args); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /userservice/src/main/java/com/tanthanh/userservice/data/User.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.userservice.data; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import javax.persistence.Entity; 8 | import javax.persistence.GeneratedValue; 9 | import javax.persistence.GenerationType; 10 | import javax.persistence.Id; 11 | import javax.persistence.Table; 12 | 13 | @Entity 14 | @Table(name = "users") 15 | @Data 16 | @AllArgsConstructor 17 | @NoArgsConstructor 18 | public class User { 19 | @Id 20 | @GeneratedValue(strategy = GenerationType.IDENTITY) 21 | private Long id; 22 | private String username; 23 | private String password; 24 | private String employeeId; 25 | 26 | } -------------------------------------------------------------------------------- /borrowingservice/src/main/java/com/tanthanh/borrowingservice/BorrowingserviceApplication.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.borrowingservice; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 7 | import org.springframework.context.annotation.Import; 8 | 9 | import com.tanthanh.borrowingservice.config.AxonConfig; 10 | @EnableDiscoveryClient 11 | @SpringBootApplication 12 | @Import({ AxonConfig.class }) 13 | public class BorrowingserviceApplication { 14 | 15 | public static void main(String[] args) { 16 | SpringApplication.run(BorrowingserviceApplication.class, args); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /employeeservice/employeeservice/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name = employeeservice 2 | eureka.client.service-url.defaultZone = http://localhost:8761/eureka 3 | server.port = 9002 4 | spring.datasource.url=jdbc:h2:file:~/data/employeeDB 5 | spring.datasource.driverClassName=org.h2.Driver 6 | spring.datasource.username=sa 7 | spring.datasource.password= 8 | spring.jpa.database-platform=org.hibernate.dialect.H2Dialect 9 | spring.h2.console.enabled=true 10 | spring.jpa.hibernate.ddl-auto =update 11 | spring.h2.console.settings.web-allow-others=true 12 | spring.cloud.stream.bindings.output.destination=tanthanh 13 | spring.cloud.stream.bindings.output.content-type=application/json 14 | spring.zipkin.base-url=http://localhost:9411 15 | logging.file.name=C:/Users/thando/OneDrive - Capgemini/Desktop/log/logElk.log -------------------------------------------------------------------------------- /borrowingservice/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name = borrowservice 2 | eureka.client.service-url.defaultZone = http://localhost:8761/eureka 3 | server.port = 9003 4 | spring.datasource.url=jdbc:h2:file:~/data/borrowingDB 5 | spring.datasource.driverClassName=org.h2.Driver 6 | spring.datasource.username=sa 7 | spring.datasource.password= 8 | spring.jpa.database-platform=org.hibernate.dialect.H2Dialect 9 | spring.h2.console.enabled=true 10 | spring.jpa.hibernate.ddl-auto =update 11 | spring.h2.console.settings.web-allow-others=true 12 | spring.cloud.stream.bindings.output.destination=tanthanh 13 | spring.cloud.stream.bindings.output.content-type=application/json 14 | logging.level.org.springframework.boot.autoconfigure.web.servlet.DispatcherServlet= DEBUG 15 | spring.zipkin.base-url=http://localhost:9411 16 | -------------------------------------------------------------------------------- /borrowingservice/src/main/java/com/tanthanh/borrowingservice/command/api/model/Message.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.borrowingservice.command.api.model; 2 | 3 | public class Message { 4 | private String employeeId; 5 | private String message; 6 | public Message(String employeeId, String message) { 7 | super(); 8 | this.employeeId = employeeId; 9 | this.message = message; 10 | } 11 | public String getEmployeeId() { 12 | return employeeId; 13 | } 14 | public void setEmployeeId(String employeeId) { 15 | this.employeeId = employeeId; 16 | } 17 | public String getMessage() { 18 | return message; 19 | } 20 | public void setMessage(String message) { 21 | this.message = message; 22 | } 23 | @Override 24 | public String toString() { 25 | return "Message [employeeId=" + employeeId + ", message=" + message + "]"; 26 | } 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /userservice/src/main/java/com/tanthanh/userservice/UserserviceApplication.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.userservice; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 8 | import org.springframework.security.crypto.password.PasswordEncoder; 9 | 10 | @SpringBootApplication 11 | @EnableDiscoveryClient 12 | public class UserserviceApplication { 13 | 14 | public static void main(String[] args) { 15 | SpringApplication.run(UserserviceApplication.class, args); 16 | } 17 | @Bean 18 | PasswordEncoder passwordEncoder() { 19 | return new BCryptPasswordEncoder(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /bookservice/src/main/java/com/tanthanh/bookservice/command/event/BookCreatedEvent.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.bookservice.command.event; 2 | 3 | public class BookCreatedEvent { 4 | private String bookId; 5 | private String name; 6 | private String author; 7 | private Boolean isReady; 8 | 9 | public String getBookId() { 10 | return bookId; 11 | } 12 | public void setBookId(String bookId) { 13 | this.bookId = bookId; 14 | } 15 | public String getName() { 16 | return name; 17 | } 18 | public void setName(String name) { 19 | this.name = name; 20 | } 21 | public String getAuthor() { 22 | return author; 23 | } 24 | public void setAuthor(String author) { 25 | this.author = author; 26 | } 27 | public Boolean getIsReady() { 28 | return isReady; 29 | } 30 | public void setIsReady(Boolean isReady) { 31 | this.isReady = isReady; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /bookservice/src/main/java/com/tanthanh/bookservice/command/event/BookUpdatedEvent.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.bookservice.command.event; 2 | 3 | public class BookUpdatedEvent { 4 | private String bookId; 5 | private String name; 6 | private String author; 7 | private Boolean isReady; 8 | 9 | public String getBookId() { 10 | return bookId; 11 | } 12 | public void setBookId(String bookId) { 13 | this.bookId = bookId; 14 | } 15 | public String getName() { 16 | return name; 17 | } 18 | public void setName(String name) { 19 | this.name = name; 20 | } 21 | public String getAuthor() { 22 | return author; 23 | } 24 | public void setAuthor(String author) { 25 | this.author = author; 26 | } 27 | public Boolean getIsReady() { 28 | return isReady; 29 | } 30 | public void setIsReady(Boolean isReady) { 31 | this.isReady = isReady; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /bookservice/src/main/java/com/tanthanh/bookservice/command/model/BookRequestModel.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.bookservice.command.model; 2 | 3 | public class BookRequestModel { 4 | private String bookId; 5 | private String name; 6 | private String author; 7 | private Boolean isReady; 8 | 9 | public String getBookId() { 10 | return bookId; 11 | } 12 | public void setBookId(String bookId) { 13 | this.bookId = bookId; 14 | } 15 | public String getName() { 16 | return name; 17 | } 18 | public void setName(String name) { 19 | this.name = name; 20 | } 21 | public String getAuthor() { 22 | return author; 23 | } 24 | public void setAuthor(String author) { 25 | this.author = author; 26 | } 27 | public Boolean getIsReady() { 28 | return isReady; 29 | } 30 | public void setIsReady(Boolean isReady) { 31 | this.isReady = isReady; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /bookservice/src/main/java/com/tanthanh/bookservice/query/model/BookResponseModel.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.bookservice.query.model; 2 | 3 | public class BookResponseModel { 4 | private String bookId; 5 | private String name; 6 | private String author; 7 | private Boolean isReady; 8 | 9 | public String getBookId() { 10 | return bookId; 11 | } 12 | public void setBookId(String bookId) { 13 | this.bookId = bookId; 14 | } 15 | public String getName() { 16 | return name; 17 | } 18 | public void setName(String name) { 19 | this.name = name; 20 | } 21 | public String getAuthor() { 22 | return author; 23 | } 24 | public void setAuthor(String author) { 25 | this.author = author; 26 | } 27 | public Boolean getIsReady() { 28 | return isReady; 29 | } 30 | public void setIsReady(Boolean isReady) { 31 | this.isReady = isReady; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /commonservice/src/main/java/com/tanthanh/commonservice/model/BookResponseCommonModel.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.commonservice.model; 2 | 3 | public class BookResponseCommonModel { 4 | private String bookId; 5 | private String name; 6 | private String author; 7 | private Boolean isReady; 8 | public String getBookId() { 9 | return bookId; 10 | } 11 | public void setBookId(String bookId) { 12 | this.bookId = bookId; 13 | } 14 | public String getName() { 15 | return name; 16 | } 17 | public void setName(String name) { 18 | this.name = name; 19 | } 20 | public String getAuthor() { 21 | return author; 22 | } 23 | public void setAuthor(String author) { 24 | this.author = author; 25 | } 26 | public Boolean getIsReady() { 27 | return isReady; 28 | } 29 | public void setIsReady(Boolean isReady) { 30 | this.isReady = isReady; 31 | } 32 | 33 | } 34 | 35 | -------------------------------------------------------------------------------- /commonservice/src/main/java/com/tanthanh/commonservice/event/BookUpdateStatusEvent.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.commonservice.event; 2 | 3 | public class BookUpdateStatusEvent { 4 | private String bookId; 5 | private Boolean isReady; 6 | private String employeeId; 7 | private String borrowId; 8 | 9 | 10 | 11 | 12 | public String getBorrowId() { 13 | return borrowId; 14 | } 15 | public void setBorrowId(String borrowId) { 16 | this.borrowId = borrowId; 17 | } 18 | public String getEmployeeId() { 19 | return employeeId; 20 | } 21 | public void setEmployeeId(String employeeId) { 22 | this.employeeId = employeeId; 23 | } 24 | public String getBookId() { 25 | return bookId; 26 | } 27 | public void setBookId(String bookId) { 28 | this.bookId = bookId; 29 | } 30 | public Boolean getIsReady() { 31 | return isReady; 32 | } 33 | public void setIsReady(Boolean isReady) { 34 | this.isReady = isReady; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /commonservice/src/main/java/com/tanthanh/commonservice/event/BookRollBackStatusEvent.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.commonservice.event; 2 | 3 | public class BookRollBackStatusEvent { 4 | private String bookId; 5 | private Boolean isReady; 6 | private String employeeId; 7 | private String borrowId; 8 | 9 | 10 | 11 | 12 | public String getBorrowId() { 13 | return borrowId; 14 | } 15 | public void setBorrowId(String borrowId) { 16 | this.borrowId = borrowId; 17 | } 18 | public String getEmployeeId() { 19 | return employeeId; 20 | } 21 | public void setEmployeeId(String employeeId) { 22 | this.employeeId = employeeId; 23 | } 24 | public String getBookId() { 25 | return bookId; 26 | } 27 | public void setBookId(String bookId) { 28 | this.bookId = bookId; 29 | } 30 | public Boolean getIsReady() { 31 | return isReady; 32 | } 33 | public void setIsReady(Boolean isReady) { 34 | this.isReady = isReady; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /borrowingservice/src/main/java/com/tanthanh/borrowingservice/command/api/events/BorrowingUpdateBookReturnEvent.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.borrowingservice.command.api.events; 2 | 3 | import java.util.Date; 4 | 5 | public class BorrowingUpdateBookReturnEvent { 6 | private String id; 7 | private String bookId; 8 | private String employee; 9 | private Date returnDate; 10 | public String getId() { 11 | return id; 12 | } 13 | public void setId(String id) { 14 | this.id = id; 15 | } 16 | public String getBookId() { 17 | return bookId; 18 | } 19 | public void setBookId(String bookId) { 20 | this.bookId = bookId; 21 | } 22 | public String getEmployee() { 23 | return employee; 24 | } 25 | public void setEmployee(String employee) { 26 | this.employee = employee; 27 | } 28 | public Date getReturnDate() { 29 | return returnDate; 30 | } 31 | public void setReturnDate(Date returnDate) { 32 | this.returnDate = returnDate; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /borrowingservice/src/main/java/com/tanthanh/borrowingservice/command/api/events/BorrowSendMessageEvent.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.borrowingservice.command.api.events; 2 | 3 | public class BorrowSendMessageEvent { 4 | private String id; 5 | 6 | private String employeeId; 7 | private String message; 8 | public BorrowSendMessageEvent(String id, String employeeId, String message) { 9 | super(); 10 | this.id = id; 11 | this.employeeId = employeeId; 12 | this.message = message; 13 | } 14 | public BorrowSendMessageEvent() { 15 | super(); 16 | } 17 | public String getId() { 18 | return id; 19 | } 20 | public void setId(String id) { 21 | this.id = id; 22 | } 23 | public String getEmployeeId() { 24 | return employeeId; 25 | } 26 | public void setEmployeeId(String employeeId) { 27 | this.employeeId = employeeId; 28 | } 29 | public String getMessage() { 30 | return message; 31 | } 32 | public void setMessage(String message) { 33 | this.message = message; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /bookservice/src/main/java/com/tanthanh/bookservice/command/data/Book.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.bookservice.command.data; 2 | 3 | import javax.persistence.Entity; 4 | import javax.persistence.Id; 5 | import javax.persistence.Table; 6 | 7 | @Entity 8 | @Table(name = "books") 9 | public class Book { 10 | @Id 11 | private String bookId; 12 | private String name; 13 | private String author; 14 | private Boolean isReady; 15 | 16 | public String getBookId() { 17 | return bookId; 18 | } 19 | public void setBookId(String bookId) { 20 | this.bookId = bookId; 21 | } 22 | public String getName() { 23 | return name; 24 | } 25 | public void setName(String name) { 26 | this.name = name; 27 | } 28 | public String getAuthor() { 29 | return author; 30 | } 31 | public void setAuthor(String author) { 32 | this.author = author; 33 | } 34 | public Boolean getIsReady() { 35 | return isReady; 36 | } 37 | public void setIsReady(Boolean isReady) { 38 | this.isReady = isReady; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /borrowingservice/src/main/java/com/tanthanh/borrowingservice/command/api/events/BorrowCreatedEvent.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.borrowingservice.command.api.events; 2 | 3 | import java.util.Date; 4 | 5 | public class BorrowCreatedEvent { 6 | private String id; 7 | private String bookId; 8 | private String employeeId; 9 | private Date borrowingDate; 10 | 11 | 12 | 13 | public String getId() { 14 | return id; 15 | } 16 | public void setId(String id) { 17 | this.id = id; 18 | } 19 | public String getBookId() { 20 | return bookId; 21 | } 22 | public void setBookId(String bookId) { 23 | this.bookId = bookId; 24 | } 25 | public String getEmployeeId() { 26 | return employeeId; 27 | } 28 | public void setEmployeeId(String employeeId) { 29 | this.employeeId = employeeId; 30 | } 31 | public Date getBorrowingDate() { 32 | return borrowingDate; 33 | } 34 | public void setBorrowingDate(Date borrowingDate) { 35 | this.borrowingDate = borrowingDate; 36 | } 37 | 38 | 39 | } 40 | -------------------------------------------------------------------------------- /borrowingservice/src/main/java/com/tanthanh/borrowingservice/command/api/command/SendMessageCommand.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.borrowingservice.command.api.command; 2 | 3 | import org.axonframework.modelling.command.TargetAggregateIdentifier; 4 | 5 | public class SendMessageCommand { 6 | @TargetAggregateIdentifier 7 | private String id; 8 | 9 | private String employeeId; 10 | private String message; 11 | public SendMessageCommand(String id, String employeeId, String message) { 12 | super(); 13 | this.id = id; 14 | this.employeeId = employeeId; 15 | this.message = message; 16 | } 17 | public String getId() { 18 | return id; 19 | } 20 | public void setId(String id) { 21 | this.id = id; 22 | } 23 | public String getEmployeeId() { 24 | return employeeId; 25 | } 26 | public void setEmployeeId(String employeeId) { 27 | this.employeeId = employeeId; 28 | } 29 | public String getMessage() { 30 | return message; 31 | } 32 | public void setMessage(String message) { 33 | this.message = message; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /apigateway/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 9000 3 | 4 | spring: 5 | application: 6 | name: api-gateway 7 | cloud: 8 | gateway: 9 | routes: 10 | - id: bookservice 11 | uri: http://localhost:9001 12 | predicates: 13 | - Path=/api/v1/books/** 14 | filters: 15 | - AuthFilter 16 | - id: employeeservice 17 | uri: http://localhost:9002 18 | predicates: 19 | - Path=/api/v1/employees/** 20 | filters: 21 | - AuthFilter 22 | - id: borrowservice 23 | uri: http://localhost:9003 24 | predicates: 25 | - Path=/api/v1/borrowing/** 26 | filters: 27 | - AuthFilter 28 | default-filters: 29 | - DedupeResponseHeader=Access-Control-Allow-Credentials Access-Control-Allow-Origin 30 | globalcors: 31 | corsConfigurations: 32 | '[/**]': 33 | allowedOrigins: "*" 34 | allowedMethods: "*" 35 | allowedHeaders: "*" 36 | 37 | -------------------------------------------------------------------------------- /userservice/src/main/java/com/tanthanh/userservice/model/UserDTO.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.userservice.model; 2 | 3 | import com.tanthanh.userservice.data.User; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | @Data 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | public class UserDTO { 12 | private Long id; 13 | private String username; 14 | private String password; 15 | private String employeeId; 16 | private String token; 17 | private String refreshtoken; 18 | 19 | 20 | public static UserDTO entityToDTO(User user){ 21 | UserDTO userDTO = new UserDTO(); 22 | userDTO.setId(user.getId()); 23 | userDTO.setPassword(user.getPassword()); 24 | userDTO.setUsername(user.getUsername()); 25 | userDTO.setEmployeeId(user.getEmployeeId()); 26 | return userDTO; 27 | } 28 | public static User dtoToEntity(UserDTO dto){ 29 | User user = new User(); 30 | user.setId(dto.getId()); 31 | user.setPassword(dto.getPassword()); 32 | user.setUsername(dto.getUsername()); 33 | user.setEmployeeId(dto.getEmployeeId()); 34 | return user; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /commonservice/src/main/java/com/tanthanh/commonservice/model/EmployeeResponseCommonModel.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.commonservice.model; 2 | 3 | public class EmployeeResponseCommonModel { 4 | private String employeeId; 5 | private String firstName; 6 | private String lastName; 7 | private String kin; 8 | private Boolean isDisciplined; 9 | public String getEmployeeId() { 10 | return employeeId; 11 | } 12 | public void setEmployeeId(String employeeId) { 13 | this.employeeId = employeeId; 14 | } 15 | public String getFirstName() { 16 | return firstName; 17 | } 18 | public void setFirstName(String firstName) { 19 | this.firstName = firstName; 20 | } 21 | public String getLastName() { 22 | return lastName; 23 | } 24 | public void setLastName(String lastName) { 25 | this.lastName = lastName; 26 | } 27 | public String getKin() { 28 | return kin; 29 | } 30 | public void setKin(String kin) { 31 | this.kin = kin; 32 | } 33 | public Boolean getIsDisciplined() { 34 | return isDisciplined; 35 | } 36 | public void setIsDisciplined(Boolean isDisciplined) { 37 | this.isDisciplined = isDisciplined; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /notificationservice/src/main/java/com/tanthanh/notificationservice/EmployeeReponseModel.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.notificationservice; 2 | 3 | public class EmployeeReponseModel { 4 | private String employeeId; 5 | private String firstName; 6 | private String lastName; 7 | private String kin; 8 | private Boolean isDisciplined; 9 | public String getEmployeeId() { 10 | return employeeId; 11 | } 12 | public void setEmployeeId(String employeeId) { 13 | this.employeeId = employeeId; 14 | } 15 | public String getFirstName() { 16 | return firstName; 17 | } 18 | public void setFirstName(String firstName) { 19 | this.firstName = firstName; 20 | } 21 | public String getLastName() { 22 | return lastName; 23 | } 24 | public void setLastName(String lastName) { 25 | this.lastName = lastName; 26 | } 27 | public String getKin() { 28 | return kin; 29 | } 30 | public void setKin(String kin) { 31 | this.kin = kin; 32 | } 33 | public Boolean getIsDisciplined() { 34 | return isDisciplined; 35 | } 36 | public void setIsDisciplined(Boolean isDisciplined) { 37 | this.isDisciplined = isDisciplined; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /employeeservice/employeeservice/src/main/java/com/tanthanh/employeeservice/query/model/EmployeeReponseModel.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.employeeservice.query.model; 2 | 3 | public class EmployeeReponseModel { 4 | private String employeeId; 5 | private String firstName; 6 | private String lastName; 7 | private String kin; 8 | private Boolean isDisciplined; 9 | public String getEmployeeId() { 10 | return employeeId; 11 | } 12 | public void setEmployeeId(String employeeId) { 13 | this.employeeId = employeeId; 14 | } 15 | public String getFirstName() { 16 | return firstName; 17 | } 18 | public void setFirstName(String firstName) { 19 | this.firstName = firstName; 20 | } 21 | public String getLastName() { 22 | return lastName; 23 | } 24 | public void setLastName(String lastName) { 25 | this.lastName = lastName; 26 | } 27 | public String getKin() { 28 | return kin; 29 | } 30 | public void setKin(String kin) { 31 | this.kin = kin; 32 | } 33 | public Boolean getIsDisciplined() { 34 | return isDisciplined; 35 | } 36 | public void setIsDisciplined(Boolean isDisciplined) { 37 | this.isDisciplined = isDisciplined; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /employeeservice/employeeservice/src/main/java/com/tanthanh/employeeservice/command/event/EmployeeUpdatedEvent.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.employeeservice.command.event; 2 | 3 | public class EmployeeUpdatedEvent { 4 | private String employeeId; 5 | private String firstName; 6 | private String lastName; 7 | private String kin; 8 | private Boolean isDisciplined; 9 | public String getEmployeeId() { 10 | return employeeId; 11 | } 12 | public void setEmployeeId(String employeeId) { 13 | this.employeeId = employeeId; 14 | } 15 | public String getFirstName() { 16 | return firstName; 17 | } 18 | public void setFirstName(String firstName) { 19 | this.firstName = firstName; 20 | } 21 | public String getLastName() { 22 | return lastName; 23 | } 24 | public void setLastName(String lastName) { 25 | this.lastName = lastName; 26 | } 27 | public String getKin() { 28 | return kin; 29 | } 30 | public void setKin(String kin) { 31 | this.kin = kin; 32 | } 33 | public Boolean getIsDisciplined() { 34 | return isDisciplined; 35 | } 36 | public void setIsDisciplined(Boolean isDisciplined) { 37 | this.isDisciplined = isDisciplined; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /employeeservice/employeeservice/src/main/java/com/tanthanh/employeeservice/command/event/EmployeeCreatedEvent.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.employeeservice.command.event; 2 | 3 | public class EmployeeCreatedEvent { 4 | private String employeeId; 5 | private String firstName; 6 | private String lastName; 7 | private String kin; 8 | private Boolean isDisciplined; 9 | public String getEmployeeId() { 10 | return employeeId; 11 | } 12 | public void setEmployeeId(String employeeId) { 13 | this.employeeId = employeeId; 14 | } 15 | public String getFirstName() { 16 | return firstName; 17 | } 18 | public void setFirstName(String firstName) { 19 | this.firstName = firstName; 20 | } 21 | public String getLastName() { 22 | return lastName; 23 | } 24 | public void setLastName(String lastName) { 25 | this.lastName = lastName; 26 | } 27 | public String getKin() { 28 | return kin; 29 | } 30 | public void setKin(String kin) { 31 | this.kin = kin; 32 | } 33 | public Boolean getIsDisciplined() { 34 | return isDisciplined; 35 | } 36 | public void setIsDisciplined(Boolean isDisciplined) { 37 | this.isDisciplined = isDisciplined; 38 | } 39 | 40 | 41 | } 42 | -------------------------------------------------------------------------------- /employeeservice/employeeservice/src/main/java/com/tanthanh/employeeservice/command/model/EmployeeRequestModel.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.employeeservice.command.model; 2 | 3 | 4 | public class EmployeeRequestModel { 5 | private String employeeId; 6 | private String firstName; 7 | private String lastName; 8 | private String kin; 9 | private Boolean isDisciplined; 10 | 11 | 12 | public String getKin() { 13 | return kin; 14 | } 15 | public void setKin(String kin) { 16 | this.kin = kin; 17 | } 18 | public String getEmployeeId() { 19 | return employeeId; 20 | } 21 | public void setEmployeeId(String employeeId) { 22 | this.employeeId = employeeId; 23 | } 24 | public String getFirstName() { 25 | return firstName; 26 | } 27 | public void setFirstName(String firstName) { 28 | this.firstName = firstName; 29 | } 30 | public String getLastName() { 31 | return lastName; 32 | } 33 | public void setLastName(String lastName) { 34 | this.lastName = lastName; 35 | } 36 | 37 | public Boolean getIsDisciplined() { 38 | return isDisciplined; 39 | } 40 | public void setIsDisciplined(Boolean isDisciplined) { 41 | this.isDisciplined = isDisciplined; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /borrowingservice/src/main/java/com/tanthanh/borrowingservice/command/api/model/BorrowRequestModel.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.borrowingservice.command.api.model; 2 | 3 | import java.util.Date; 4 | 5 | public class BorrowRequestModel { 6 | private String id; 7 | private String bookId; 8 | private String employeeId; 9 | private Date borrowingDate; 10 | private Date returnDate; 11 | 12 | 13 | public String getId() { 14 | return id; 15 | } 16 | public void setId(String id) { 17 | this.id = id; 18 | } 19 | public String getBookId() { 20 | return bookId; 21 | } 22 | public void setBookId(String bookId) { 23 | this.bookId = bookId; 24 | } 25 | public String getEmployeeId() { 26 | return employeeId; 27 | } 28 | public void setEmployeeId(String employeeId) { 29 | this.employeeId = employeeId; 30 | } 31 | public Date getBorrowingDate() { 32 | return borrowingDate; 33 | } 34 | public void setBorrowingDate(Date borrowingDate) { 35 | this.borrowingDate = borrowingDate; 36 | } 37 | public Date getReturnDate() { 38 | return returnDate; 39 | } 40 | public void setReturnDate(Date returnDate) { 41 | this.returnDate = returnDate; 42 | } 43 | 44 | 45 | 46 | } 47 | -------------------------------------------------------------------------------- /bookservice/src/main/java/com/tanthanh/bookservice/command/command/CreateBookCommand.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.bookservice.command.command; 2 | 3 | import org.axonframework.modelling.command.TargetAggregateIdentifier; 4 | 5 | public class CreateBookCommand { 6 | @TargetAggregateIdentifier 7 | private String bookId; 8 | private String name; 9 | private String author; 10 | private Boolean isReady; 11 | 12 | 13 | 14 | public CreateBookCommand(String bookId, String name, String author, Boolean isReady) { 15 | super(); 16 | this.bookId = bookId; 17 | this.name = name; 18 | this.author = author; 19 | this.isReady = isReady; 20 | } 21 | public String getBookId() { 22 | return bookId; 23 | } 24 | public void setBookId(String bookId) { 25 | this.bookId = bookId; 26 | } 27 | public String getName() { 28 | return name; 29 | } 30 | public void setName(String name) { 31 | this.name = name; 32 | } 33 | public String getAuthor() { 34 | return author; 35 | } 36 | public void setAuthor(String author) { 37 | this.author = author; 38 | } 39 | public Boolean getIsReady() { 40 | return isReady; 41 | } 42 | public void setIsReady(Boolean isReady) { 43 | this.isReady = isReady; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /bookservice/src/main/java/com/tanthanh/bookservice/command/command/UpdateBookCommand.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.bookservice.command.command; 2 | 3 | import org.axonframework.modelling.command.TargetAggregateIdentifier; 4 | 5 | public class UpdateBookCommand { 6 | @TargetAggregateIdentifier 7 | private String bookId; 8 | private String name; 9 | private String author; 10 | private Boolean isReady; 11 | 12 | 13 | 14 | public UpdateBookCommand(String bookId, String name, String author, Boolean isReady) { 15 | super(); 16 | this.bookId = bookId; 17 | this.name = name; 18 | this.author = author; 19 | this.isReady = isReady; 20 | } 21 | public String getBookId() { 22 | return bookId; 23 | } 24 | public void setBookId(String bookId) { 25 | this.bookId = bookId; 26 | } 27 | public String getName() { 28 | return name; 29 | } 30 | public void setName(String name) { 31 | this.name = name; 32 | } 33 | public String getAuthor() { 34 | return author; 35 | } 36 | public void setAuthor(String author) { 37 | this.author = author; 38 | } 39 | public Boolean getIsReady() { 40 | return isReady; 41 | } 42 | public void setIsReady(Boolean isReady) { 43 | this.isReady = isReady; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /userservice/src/main/java/com/tanthanh/userservice/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.userservice.controller; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.PostMapping; 8 | import org.springframework.web.bind.annotation.RequestBody; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RestController; 11 | 12 | import com.tanthanh.userservice.data.User; 13 | import com.tanthanh.userservice.model.UserDTO; 14 | import com.tanthanh.userservice.service.UserService; 15 | 16 | @RestController 17 | @RequestMapping("/api/v1/users") 18 | public class UserController { 19 | 20 | @Autowired 21 | UserService userService; 22 | 23 | @GetMapping("/listUser") 24 | public List getAllUser() { 25 | return userService.getAllUser(); 26 | } 27 | @PostMapping("/addUser") 28 | public UserDTO addUser(@RequestBody UserDTO dto) { 29 | return userService.saveUser(dto); 30 | } 31 | @PostMapping("/login") 32 | public UserDTO login(@RequestBody UserDTO dto) { 33 | return userService.login(dto.getUsername(), dto.getPassword()); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /borrowingservice/src/main/java/com/tanthanh/borrowingservice/command/api/command/UpdateBookReturnCommand.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.borrowingservice.command.api.command; 2 | 3 | import java.util.Date; 4 | 5 | import org.axonframework.modelling.command.TargetAggregateIdentifier; 6 | 7 | public class UpdateBookReturnCommand { 8 | @TargetAggregateIdentifier 9 | private String id; 10 | private String bookId; 11 | private String employee; 12 | private Date returnDate; 13 | public String getId() { 14 | return id; 15 | } 16 | public void setId(String id) { 17 | this.id = id; 18 | } 19 | public String getBookId() { 20 | return bookId; 21 | } 22 | public void setBookId(String bookId) { 23 | this.bookId = bookId; 24 | } 25 | public String getEmployee() { 26 | return employee; 27 | } 28 | public void setEmployee(String employee) { 29 | this.employee = employee; 30 | } 31 | public Date getReturnDate() { 32 | return returnDate; 33 | } 34 | public void setReturnDate(Date returnDate) { 35 | this.returnDate = returnDate; 36 | } 37 | public UpdateBookReturnCommand(String id, String bookId, String employee, Date returnDate) { 38 | super(); 39 | this.id = id; 40 | this.bookId = bookId; 41 | this.employee = employee; 42 | this.returnDate = returnDate; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /employeeservice/employeeservice/src/main/java/com/tanthanh/employeeservice/command/data/Employee.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.employeeservice.command.data; 2 | 3 | import javax.persistence.Entity; 4 | import javax.persistence.Id; 5 | import javax.persistence.Table; 6 | 7 | @Entity 8 | @Table(name = "employees") 9 | public class Employee { 10 | @Id 11 | private String employeeId; 12 | private String firstName; 13 | private String lastName; 14 | private String kin; 15 | private Boolean isDisciplined; 16 | public String getEmployeeId() { 17 | return employeeId; 18 | } 19 | public void setEmployeeId(String employeeId) { 20 | this.employeeId = employeeId; 21 | } 22 | public String getFirstName() { 23 | return firstName; 24 | } 25 | public void setFirstName(String firstName) { 26 | this.firstName = firstName; 27 | } 28 | public String getLastName() { 29 | return lastName; 30 | } 31 | public void setLastName(String lastName) { 32 | this.lastName = lastName; 33 | } 34 | 35 | public String getKin() { 36 | return kin; 37 | } 38 | public void setKin(String kin) { 39 | this.kin = kin; 40 | } 41 | public Boolean getIsDisciplined() { 42 | return isDisciplined; 43 | } 44 | public void setIsDisciplined(Boolean isDisciplined) { 45 | this.isDisciplined = isDisciplined; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /borrowingservice/src/main/java/com/tanthanh/borrowingservice/command/api/data/Borrowing.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.borrowingservice.command.api.data; 2 | 3 | import java.util.Date; 4 | 5 | import javax.persistence.Entity; 6 | import javax.persistence.Id; 7 | import javax.persistence.Table; 8 | 9 | @Entity 10 | @Table(name = "borrowing") 11 | public class Borrowing { 12 | @Id 13 | private String id; 14 | 15 | private String bookId; 16 | 17 | private String employeeId; 18 | private Date borrowingDate; 19 | private Date returnDate; 20 | 21 | 22 | public String getId() { 23 | return id; 24 | } 25 | public void setId(String id) { 26 | this.id = id; 27 | } 28 | public String getBookId() { 29 | return bookId; 30 | } 31 | public void setBookId(String bookId) { 32 | this.bookId = bookId; 33 | } 34 | public String getEmployeeId() { 35 | return employeeId; 36 | } 37 | public void setEmployeeId(String employeeId) { 38 | this.employeeId = employeeId; 39 | } 40 | public Date getBorrowingDate() { 41 | return borrowingDate; 42 | } 43 | public void setBorrowingDate(Date borrowingDate) { 44 | this.borrowingDate = borrowingDate; 45 | } 46 | public Date getReturnDate() { 47 | return returnDate; 48 | } 49 | public void setReturnDate(Date returnDate) { 50 | this.returnDate = returnDate; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /commonservice/src/main/java/com/tanthanh/commonservice/command/RollBackStatusBookCommand.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.commonservice.command; 2 | 3 | import org.axonframework.modelling.command.TargetAggregateIdentifier; 4 | 5 | public class RollBackStatusBookCommand { 6 | @TargetAggregateIdentifier 7 | private String bookId; 8 | private Boolean isReady; 9 | private String employeeId; 10 | private String borrowId; 11 | 12 | public RollBackStatusBookCommand(String bookId, Boolean isReady, String employeeId, String borrowId) { 13 | super(); 14 | this.bookId = bookId; 15 | this.isReady = isReady; 16 | this.employeeId = employeeId; 17 | this.borrowId = borrowId; 18 | } 19 | 20 | public String getBorrowId() { 21 | return borrowId; 22 | } 23 | 24 | public void setBorrowId(String borrowId) { 25 | this.borrowId = borrowId; 26 | } 27 | 28 | public String getEmployeeId() { 29 | return employeeId; 30 | } 31 | 32 | public void setEmployeeId(String employeeId) { 33 | this.employeeId = employeeId; 34 | } 35 | 36 | public String getBookId() { 37 | return bookId; 38 | } 39 | public void setBookId(String bookId) { 40 | this.bookId = bookId; 41 | } 42 | public Boolean getIsReady() { 43 | return isReady; 44 | } 45 | public void setIsReady(Boolean isReady) { 46 | this.isReady = isReady; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /commonservice/src/main/java/com/tanthanh/commonservice/command/UpdateStatusBookCommand.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.commonservice.command; 2 | 3 | import org.axonframework.modelling.command.TargetAggregateIdentifier; 4 | 5 | public class UpdateStatusBookCommand { 6 | 7 | @TargetAggregateIdentifier 8 | private String bookId; 9 | private Boolean isReady; 10 | private String employeeId; 11 | private String borrowId; 12 | 13 | public UpdateStatusBookCommand(String bookId, Boolean isReady, String employeeId, String borrowId) { 14 | super(); 15 | this.bookId = bookId; 16 | this.isReady = isReady; 17 | this.employeeId = employeeId; 18 | this.borrowId = borrowId; 19 | } 20 | 21 | public String getBorrowId() { 22 | return borrowId; 23 | } 24 | 25 | public void setBorrowId(String borrowId) { 26 | this.borrowId = borrowId; 27 | } 28 | 29 | public String getEmployeeId() { 30 | return employeeId; 31 | } 32 | 33 | public void setEmployeeId(String employeeId) { 34 | this.employeeId = employeeId; 35 | } 36 | 37 | public String getBookId() { 38 | return bookId; 39 | } 40 | public void setBookId(String bookId) { 41 | this.bookId = bookId; 42 | } 43 | public Boolean getIsReady() { 44 | return isReady; 45 | } 46 | public void setIsReady(Boolean isReady) { 47 | this.isReady = isReady; 48 | } 49 | 50 | 51 | } 52 | -------------------------------------------------------------------------------- /borrowingservice/src/main/java/com/tanthanh/borrowingservice/command/api/command/CreateBorrowCommand.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.borrowingservice.command.api.command; 2 | 3 | import java.util.Date; 4 | 5 | import org.axonframework.modelling.command.TargetAggregateIdentifier; 6 | 7 | public class CreateBorrowCommand { 8 | 9 | 10 | @TargetAggregateIdentifier 11 | private String id; 12 | 13 | private String bookId; 14 | private String employeeId; 15 | private Date borrowingDate; 16 | 17 | 18 | 19 | public CreateBorrowCommand(String bookId, String employeeId, Date borrowingDate,String id) { 20 | super(); 21 | this.bookId = bookId; 22 | this.employeeId = employeeId; 23 | this.borrowingDate = borrowingDate; 24 | this.id = id; 25 | } 26 | 27 | public String getId() { 28 | return id; 29 | } 30 | 31 | public void setId(String id) { 32 | this.id = id; 33 | } 34 | 35 | public String getBookId() { 36 | return bookId; 37 | } 38 | public void setBookId(String bookId) { 39 | this.bookId = bookId; 40 | } 41 | public String getEmployeeId() { 42 | return employeeId; 43 | } 44 | public void setEmployeeId(String employeeId) { 45 | this.employeeId = employeeId; 46 | } 47 | public Date getBorrowingDate() { 48 | return borrowingDate; 49 | } 50 | public void setBorrowingDate(Date borrowingDate) { 51 | this.borrowingDate = borrowingDate; 52 | } 53 | 54 | 55 | 56 | } 57 | -------------------------------------------------------------------------------- /employeeservice/employeeservice/src/main/java/com/tanthanh/employeeservice/command/event/EmployeeEventsHandler.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.employeeservice.command.event; 2 | 3 | import org.axonframework.eventhandling.EventHandler; 4 | import org.springframework.beans.BeanUtils; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Component; 7 | 8 | import com.tanthanh.employeeservice.command.data.Employee; 9 | import com.tanthanh.employeeservice.command.data.EmployeeRepository; 10 | 11 | @Component 12 | public class EmployeeEventsHandler { 13 | @Autowired 14 | private EmployeeRepository employeeRepository; 15 | 16 | @EventHandler 17 | public void on(EmployeeCreatedEvent event) { 18 | Employee employee = new Employee(); 19 | BeanUtils.copyProperties(event, employee); 20 | employeeRepository.save(employee); 21 | } 22 | @EventHandler 23 | public void on(EmployeeUpdatedEvent event) { 24 | Employee employee = employeeRepository.getById(event.getEmployeeId()); 25 | employee.setFirstName(event.getFirstName()); 26 | employee.setLastName(event.getLastName()); 27 | employee.setKin(event.getKin()); 28 | employee.setIsDisciplined(event.getIsDisciplined()); 29 | employeeRepository.save(employee); 30 | } 31 | @EventHandler 32 | public void on(EmployeeDeletedEvent event) { 33 | try { 34 | employeeRepository.deleteById(event.getEmployeeId()); 35 | } catch (Exception e) { 36 | System.out.print(e.getMessage()); 37 | } 38 | 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /notificationservice/src/main/java/com/tanthanh/notificationservice/configuration/AppConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.notificationservice.configuration; 2 | 3 | import java.time.Duration; 4 | 5 | import org.springframework.cloud.circuitbreaker.resilience4j.Resilience4JCircuitBreakerFactory; 6 | import org.springframework.cloud.circuitbreaker.resilience4j.Resilience4JConfigBuilder; 7 | import org.springframework.cloud.client.circuitbreaker.Customizer; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.web.reactive.function.client.WebClient; 11 | 12 | import io.github.resilience4j.circuitbreaker.CircuitBreakerConfig; 13 | import io.github.resilience4j.timelimiter.TimeLimiterConfig; 14 | 15 | @Configuration 16 | public class AppConfiguration { 17 | @Bean 18 | public WebClient.Builder getWebClientBuilder(){ 19 | return WebClient.builder(); 20 | } 21 | @Bean 22 | public Customizer defaultCustomizer(){ 23 | return factory -> factory.configureDefault(id -> new Resilience4JConfigBuilder(id) 24 | .timeLimiterConfig(TimeLimiterConfig.custom().timeoutDuration(Duration.ofSeconds(3)).build()) 25 | .circuitBreakerConfig(CircuitBreakerConfig.custom() 26 | .slidingWindowSize(10) 27 | .slidingWindowType(CircuitBreakerConfig.SlidingWindowType.TIME_BASED) 28 | .minimumNumberOfCalls(5) 29 | .failureRateThreshold(50) 30 | .build() 31 | ).build() 32 | ); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /borrowingservice/src/main/java/com/tanthanh/borrowingservice/query/model/BorrowingResponseModel.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.borrowingservice.query.model; 2 | 3 | import java.util.Date; 4 | 5 | public class BorrowingResponseModel { 6 | private String id; 7 | private String bookId; 8 | private String employeeId; 9 | private Date borrowingDate; 10 | private Date returnDate; 11 | private String nameBook; 12 | private String nameEmployee; 13 | 14 | 15 | public String getNameBook() { 16 | return nameBook; 17 | } 18 | public void setNameBook(String nameBook) { 19 | this.nameBook = nameBook; 20 | } 21 | public String getNameEmployee() { 22 | return nameEmployee; 23 | } 24 | public void setNameEmployee(String nameEmployee) { 25 | this.nameEmployee = nameEmployee; 26 | } 27 | public String getId() { 28 | return id; 29 | } 30 | public void setId(String id) { 31 | this.id = id; 32 | } 33 | public String getBookId() { 34 | return bookId; 35 | } 36 | public void setBookId(String bookId) { 37 | this.bookId = bookId; 38 | } 39 | public String getEmployeeId() { 40 | return employeeId; 41 | } 42 | public void setEmployeeId(String employeeId) { 43 | this.employeeId = employeeId; 44 | } 45 | public Date getBorrowingDate() { 46 | return borrowingDate; 47 | } 48 | public void setBorrowingDate(Date borrowingDate) { 49 | this.borrowingDate = borrowingDate; 50 | } 51 | public Date getReturnDate() { 52 | return returnDate; 53 | } 54 | public void setReturnDate(Date returnDate) { 55 | this.returnDate = returnDate; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /borrowingservice/src/main/java/com/tanthanh/borrowingservice/command/api/service/BorrowService.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.borrowingservice.command.api.service; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.cloud.stream.annotation.EnableBinding; 5 | import org.springframework.cloud.stream.messaging.Source; 6 | import org.springframework.messaging.MessageChannel; 7 | import org.springframework.messaging.support.MessageBuilder; 8 | import org.springframework.stereotype.Service; 9 | 10 | import com.fasterxml.jackson.core.JsonProcessingException; 11 | import com.fasterxml.jackson.databind.ObjectMapper; 12 | import com.tanthanh.borrowingservice.command.api.data.BorrowRepository; 13 | import com.tanthanh.borrowingservice.command.api.model.Message; 14 | 15 | @Service 16 | @EnableBinding(Source.class) 17 | public class BorrowService { 18 | @Autowired 19 | private BorrowRepository repository; 20 | 21 | @Autowired 22 | private MessageChannel output; 23 | 24 | public void sendMessage(Message message) { 25 | try { 26 | 27 | ObjectMapper mapper = new ObjectMapper(); 28 | String json = mapper.writeValueAsString(message); 29 | output.send(MessageBuilder.withPayload(json).build()); 30 | } catch (JsonProcessingException e) { 31 | // TODO Auto-generated catch block 32 | e.printStackTrace(); 33 | } 34 | 35 | } 36 | 37 | public String findIdBorrowing(String employeeId, String bookId) { 38 | 39 | return repository.findByEmployeeIdAndBookIdAndReturnDateIsNull(employeeId,bookId).getId(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /employeeservice/employeeservice/src/main/java/com/tanthanh/employeeservice/command/command/UpdateEmployeeCommand.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.employeeservice.command.command; 2 | 3 | import org.axonframework.modelling.command.TargetAggregateIdentifier; 4 | 5 | public class UpdateEmployeeCommand { 6 | @TargetAggregateIdentifier 7 | private String employeeId; 8 | private String firstName; 9 | private String lastName; 10 | private String kin; 11 | private Boolean isDisciplined; 12 | public UpdateEmployeeCommand(String employeeId, String firstName, String lastName, String kin, 13 | Boolean isDisciplined) { 14 | super(); 15 | this.employeeId = employeeId; 16 | this.firstName = firstName; 17 | this.lastName = lastName; 18 | this.kin = kin; 19 | this.isDisciplined = isDisciplined; 20 | } 21 | public String getEmployeeId() { 22 | return employeeId; 23 | } 24 | public void setEmployeeId(String employeeId) { 25 | this.employeeId = employeeId; 26 | } 27 | public String getFirstName() { 28 | return firstName; 29 | } 30 | public void setFirstName(String firstName) { 31 | this.firstName = firstName; 32 | } 33 | public String getLastName() { 34 | return lastName; 35 | } 36 | public void setLastName(String lastName) { 37 | this.lastName = lastName; 38 | } 39 | public String getKin() { 40 | return kin; 41 | } 42 | public void setKin(String kin) { 43 | this.kin = kin; 44 | } 45 | public Boolean getIsDisciplined() { 46 | return isDisciplined; 47 | } 48 | public void setIsDisciplined(Boolean isDisciplined) { 49 | this.isDisciplined = isDisciplined; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /employeeservice/employeeservice/src/main/java/com/tanthanh/employeeservice/command/command/CreateEmployeeCommand.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.employeeservice.command.command; 2 | 3 | import org.axonframework.modelling.command.TargetAggregateIdentifier; 4 | 5 | public class CreateEmployeeCommand { 6 | @TargetAggregateIdentifier 7 | private String employeeId; 8 | private String firstName; 9 | private String lastName; 10 | private String kin; 11 | private Boolean isDisciplined; 12 | 13 | 14 | 15 | public CreateEmployeeCommand(String employeeId, String firstName, String lastName, String kin, 16 | Boolean isDisciplined) { 17 | super(); 18 | this.employeeId = employeeId; 19 | this.firstName = firstName; 20 | this.lastName = lastName; 21 | this.kin = kin; 22 | this.isDisciplined = isDisciplined; 23 | } 24 | public String getEmployeeId() { 25 | return employeeId; 26 | } 27 | public void setEmployeeId(String employeeId) { 28 | this.employeeId = employeeId; 29 | } 30 | public String getFirstName() { 31 | return firstName; 32 | } 33 | public void setFirstName(String firstName) { 34 | this.firstName = firstName; 35 | } 36 | public String getLastName() { 37 | return lastName; 38 | } 39 | public void setLastName(String lastName) { 40 | this.lastName = lastName; 41 | } 42 | 43 | public String getKin() { 44 | return kin; 45 | } 46 | public void setKin(String kin) { 47 | this.kin = kin; 48 | } 49 | public Boolean getIsDisciplined() { 50 | return isDisciplined; 51 | } 52 | public void setIsDisciplined(Boolean isDisciplined) { 53 | this.isDisciplined = isDisciplined; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /borrowingservice/src/main/java/com/tanthanh/borrowingservice/command/api/events/BorrowingEventsHandler.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.borrowingservice.command.api.events; 2 | 3 | import org.axonframework.eventhandling.EventHandler; 4 | import org.springframework.beans.BeanUtils; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Component; 7 | 8 | import com.tanthanh.borrowingservice.command.api.data.BorrowRepository; 9 | import com.tanthanh.borrowingservice.command.api.data.Borrowing; 10 | import com.tanthanh.borrowingservice.command.api.model.Message; 11 | import com.tanthanh.borrowingservice.command.api.service.BorrowService; 12 | 13 | @Component 14 | public class BorrowingEventsHandler { 15 | @Autowired 16 | private BorrowRepository borrowRepository; 17 | 18 | @Autowired 19 | private BorrowService borrowService; 20 | 21 | @EventHandler 22 | public void on(BorrowCreatedEvent event) { 23 | Borrowing model = new Borrowing(); 24 | 25 | BeanUtils.copyProperties(event, model); 26 | 27 | borrowRepository.save(model); 28 | } 29 | @EventHandler 30 | public void on(BorrowDeletedEvent event) { 31 | if(borrowRepository.findById(event.getId()).isPresent()) { 32 | borrowRepository.deleteById(event.getId()); 33 | } 34 | else return; 35 | 36 | } 37 | @EventHandler 38 | public void on(BorrowSendMessageEvent event) { 39 | Message message = new Message(event.getEmployeeId(), event.getMessage()); 40 | borrowService.sendMessage(message); 41 | } 42 | @EventHandler 43 | public void on(BorrowingUpdateBookReturnEvent event) { 44 | Borrowing model = borrowRepository.findByEmployeeIdAndBookIdAndReturnDateIsNull(event.getEmployee(), event.getBookId()); 45 | model.setReturnDate(event.getReturnDate()); 46 | borrowRepository.save(model); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /borrowingservice/src/main/java/com/tanthanh/borrowingservice/query/controller/BorrowingQueryController.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.borrowingservice.query.controller; 2 | 3 | import java.util.List; 4 | 5 | import org.axonframework.messaging.responsetypes.ResponseTypes; 6 | import org.axonframework.queryhandling.QueryGateway; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.PathVariable; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | import com.tanthanh.borrowingservice.query.model.BorrowingResponseModel; 14 | import com.tanthanh.borrowingservice.query.queries.GetAllBorrowing; 15 | import com.tanthanh.borrowingservice.query.queries.GetListBorrowingByEmployeeQuery; 16 | 17 | @RestController 18 | @RequestMapping("/api/v1/borrowing") 19 | public class BorrowingQueryController { 20 | @Autowired 21 | private QueryGateway queryGateway; 22 | 23 | @GetMapping("/{employeeId}") 24 | public List getBorrowingByEmployee(@PathVariable String employeeId){ 25 | GetListBorrowingByEmployeeQuery getBorrowingQuery = new GetListBorrowingByEmployeeQuery(); 26 | getBorrowingQuery.setEmployeeId(employeeId); 27 | 28 | List list = 29 | queryGateway.query(getBorrowingQuery, ResponseTypes.multipleInstancesOf(BorrowingResponseModel.class)) 30 | .join(); 31 | 32 | return list; 33 | } 34 | @GetMapping 35 | public List getAllBorrowing(){ 36 | List list = queryGateway.query(new GetAllBorrowing(), ResponseTypes.multipleInstancesOf(BorrowingResponseModel.class)) 37 | .join(); 38 | return list; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /bookservice/src/main/java/com/tanthanh/bookservice/command/event/BookEventsHandler.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.bookservice.command.event; 2 | 3 | import org.axonframework.eventhandling.EventHandler; 4 | import org.springframework.beans.BeanUtils; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Component; 7 | 8 | import com.tanthanh.bookservice.command.data.Book; 9 | import com.tanthanh.bookservice.command.data.BookRepository; 10 | import com.tanthanh.commonservice.event.BookRollBackStatusEvent; 11 | import com.tanthanh.commonservice.event.BookUpdateStatusEvent; 12 | 13 | @Component 14 | public class BookEventsHandler { 15 | 16 | @Autowired 17 | private BookRepository bookRepository; 18 | 19 | @EventHandler 20 | public void on(BookCreatedEvent event) { 21 | Book book = new Book(); 22 | BeanUtils.copyProperties(event,book); 23 | bookRepository.save(book); 24 | } 25 | @EventHandler 26 | public void on(BookUpdatedEvent event) { 27 | Book book = bookRepository.getById(event.getBookId()); 28 | book.setAuthor(event.getAuthor()); 29 | book.setName(event.getName()); 30 | book.setIsReady(event.getIsReady()); 31 | bookRepository.save(book); 32 | } 33 | @EventHandler 34 | public void on(BookDeletedEvent event) { 35 | 36 | bookRepository.deleteById(event.getBookId());; 37 | } 38 | @EventHandler 39 | public void on(BookUpdateStatusEvent event) { 40 | Book book = bookRepository.getById(event.getBookId()); 41 | book.setIsReady(event.getIsReady()); 42 | bookRepository.save(book); 43 | } 44 | @EventHandler 45 | public void on(BookRollBackStatusEvent event) { 46 | Book book = bookRepository.getById(event.getBookId()); 47 | book.setIsReady(event.getIsReady()); 48 | bookRepository.save(book); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /commonservice/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.6.7 9 | 10 | 11 | com.tanthanh 12 | commonservice 13 | 0.0.1-SNAPSHOT 14 | commonservice 15 | Demo project for Spring Boot 16 | 17 | 11 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter 23 | 24 | 25 | org.axonframework 26 | axon-spring-boot-starter 27 | 4.5.9 28 | 29 | 30 | com.h2database 31 | h2 32 | runtime 33 | 34 | 35 | com.google.guava 36 | guava 37 | 31.0.1-jre 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-starter-test 42 | test 43 | 44 | 45 | 46 | 47 | 48 | 49 | org.springframework.boot 50 | spring-boot-maven-plugin 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /bookservice/src/main/java/com/tanthanh/bookservice/query/controller/BookQueryController.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.bookservice.query.controller; 2 | 3 | import java.util.List; 4 | 5 | import com.tanthanh.bookservice.BookserviceApplication; 6 | import org.axonframework.messaging.responsetypes.ResponseTypes; 7 | import org.axonframework.queryhandling.QueryGateway; 8 | import org.slf4j.Logger; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.web.bind.annotation.GetMapping; 11 | import org.springframework.web.bind.annotation.PathVariable; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | import org.springframework.web.bind.annotation.RestController; 14 | 15 | import com.tanthanh.bookservice.query.model.BookResponseModel; 16 | import com.tanthanh.bookservice.query.queries.GetAllBooksQuery; 17 | import com.tanthanh.bookservice.query.queries.GetBookQuery; 18 | 19 | @RestController 20 | @RequestMapping("/api/v1/books") 21 | public class BookQueryController { 22 | 23 | @Autowired 24 | private QueryGateway queryGateway; 25 | 26 | private Logger logger =org.slf4j.LoggerFactory.getLogger(BookserviceApplication.class); 27 | 28 | @GetMapping("/{bookId}") 29 | public BookResponseModel getBookDetail(@PathVariable String bookId) { 30 | GetBookQuery getBooksQuery = new GetBookQuery(); 31 | getBooksQuery.setBookId(bookId); 32 | 33 | BookResponseModel bookResponseModel = 34 | queryGateway.query(getBooksQuery, 35 | ResponseTypes.instanceOf(BookResponseModel.class)) 36 | .join(); 37 | 38 | return bookResponseModel; 39 | } 40 | @GetMapping 41 | public List getAllBooks(){ 42 | GetAllBooksQuery getAllBooksQuery = new GetAllBooksQuery(); 43 | List list = queryGateway.query(getAllBooksQuery, ResponseTypes.multipleInstancesOf(BookResponseModel.class)) 44 | .join(); 45 | logger.info("Danh sach Book "+list.toString()); 46 | return list; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /userservice/src/main/java/com/tanthanh/userservice/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.userservice.service; 2 | 3 | import com.auth0.jwt.JWT; 4 | import com.auth0.jwt.algorithms.Algorithm; 5 | import com.tanthanh.userservice.data.User; 6 | import com.tanthanh.userservice.data.UserRepository; 7 | import com.tanthanh.userservice.model.UserDTO; 8 | import org.springframework.beans.BeanUtils; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.security.crypto.password.PasswordEncoder; 11 | import org.springframework.stereotype.Service; 12 | 13 | import java.util.Date; 14 | import java.util.List; 15 | 16 | @Service 17 | public class UserService { 18 | 19 | @Autowired 20 | private UserRepository userRepository; 21 | 22 | 23 | @Autowired 24 | private PasswordEncoder passwordEncoder; 25 | 26 | 27 | public List getAllUser() { 28 | return userRepository.findAll(); 29 | } 30 | 31 | public UserDTO saveUser(UserDTO userDTO) { 32 | userDTO.setPassword(passwordEncoder.encode(userDTO.getPassword())); 33 | return UserDTO.entityToDTO(userRepository.save(UserDTO.dtoToEntity(userDTO))); 34 | } 35 | public UserDTO login(String username, String password) { 36 | User user = userRepository.findByUsername(username); 37 | UserDTO dto = new UserDTO(); 38 | if(user !=null) { 39 | BeanUtils.copyProperties(user, dto); 40 | if(passwordEncoder.matches(password, dto.getPassword())) { 41 | Algorithm algorithm = Algorithm.HMAC256("secret".getBytes()); 42 | String accessToken = JWT.create() 43 | .withSubject(user.getUsername()) 44 | .withExpiresAt(new Date(System.currentTimeMillis()+ (1 * 60 * 10000))) 45 | .sign(algorithm); 46 | String refreshtoken = JWT.create() 47 | .withSubject(user.getUsername()) 48 | .withExpiresAt(new Date(System.currentTimeMillis()+ (10080 * 60 * 10000))) 49 | .sign(algorithm); 50 | dto.setToken(accessToken); 51 | dto.setRefreshtoken(refreshtoken); 52 | } 53 | } 54 | return dto; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /borrowingservice/src/main/java/com/tanthanh/borrowingservice/command/api/controller/BorrowCommandController.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.borrowingservice.command.api.controller; 2 | 3 | import java.util.Date; 4 | import java.util.UUID; 5 | 6 | import org.axonframework.commandhandling.gateway.CommandGateway; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.PostMapping; 9 | import org.springframework.web.bind.annotation.PutMapping; 10 | import org.springframework.web.bind.annotation.RequestBody; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.RestController; 13 | 14 | import com.tanthanh.borrowingservice.command.api.command.CreateBorrowCommand; 15 | import com.tanthanh.borrowingservice.command.api.command.UpdateBookReturnCommand; 16 | import com.tanthanh.borrowingservice.command.api.model.BorrowRequestModel; 17 | import com.tanthanh.borrowingservice.command.api.service.BorrowService; 18 | 19 | @RestController 20 | @RequestMapping("/api/v1/borrowing") 21 | public class BorrowCommandController { 22 | @Autowired 23 | private CommandGateway commandGateway; 24 | 25 | @Autowired 26 | private BorrowService borrowService; 27 | 28 | @PostMapping 29 | public String addBookBorrowing(@RequestBody BorrowRequestModel model) { 30 | try { 31 | CreateBorrowCommand command = 32 | new CreateBorrowCommand(model.getBookId(), model.getEmployeeId(), new Date(),UUID.randomUUID().toString()); 33 | commandGateway.sendAndWait(command); 34 | } catch (Exception e) { 35 | System.out.println(e.getMessage()); 36 | } 37 | 38 | 39 | return "Book borrowing added"; 40 | } 41 | @PutMapping 42 | public String updateBookReturn(@RequestBody BorrowRequestModel model) { 43 | UpdateBookReturnCommand command = new UpdateBookReturnCommand(borrowService.findIdBorrowing(model.getEmployeeId(), model.getBookId()), model.getBookId(),model.getEmployeeId(),new Date()); 44 | commandGateway.sendAndWait(command); 45 | return "Book returned"; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /bookservice/src/main/java/com/tanthanh/bookservice/query/projection/BookProjection.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.bookservice.query.projection; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.axonframework.queryhandling.QueryHandler; 7 | import org.springframework.beans.BeanUtils; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Component; 10 | 11 | import com.tanthanh.bookservice.command.data.Book; 12 | import com.tanthanh.bookservice.command.data.BookRepository; 13 | import com.tanthanh.bookservice.query.model.BookResponseModel; 14 | import com.tanthanh.bookservice.query.queries.GetAllBooksQuery; 15 | import com.tanthanh.bookservice.query.queries.GetBookQuery; 16 | import com.tanthanh.commonservice.model.BookResponseCommonModel; 17 | import com.tanthanh.commonservice.query.GetDetailsBookQuery; 18 | 19 | @Component 20 | public class BookProjection { 21 | @Autowired 22 | private BookRepository bookRepository; 23 | 24 | @QueryHandler 25 | public BookResponseModel handle(GetBookQuery getBooksQuery) { 26 | BookResponseModel model = new BookResponseModel(); 27 | Book book = bookRepository.getById(getBooksQuery.getBookId()); 28 | BeanUtils.copyProperties(book, model); 29 | 30 | return model; 31 | } 32 | @QueryHandler List handle(GetAllBooksQuery getAllBooksQuery){ 33 | List listEntity = bookRepository.findAll(); 34 | List listbook = new ArrayList<>(); 35 | listEntity.forEach(s -> { 36 | BookResponseModel model = new BookResponseModel(); 37 | BeanUtils.copyProperties(s, model); 38 | listbook.add(model); 39 | }); 40 | return listbook; 41 | } 42 | @QueryHandler 43 | public BookResponseCommonModel handle(GetDetailsBookQuery getDetailsBookQuery) { 44 | BookResponseCommonModel model = new BookResponseCommonModel(); 45 | Book book = bookRepository.getById(getDetailsBookQuery.getBookId()); 46 | BeanUtils.copyProperties(book, model); 47 | 48 | return model; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /bookservice/src/main/java/com/tanthanh/bookservice/command/controller/BookCommandController.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.bookservice.command.controller; 2 | 3 | import java.util.UUID; 4 | 5 | import org.axonframework.commandhandling.gateway.CommandGateway; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.web.bind.annotation.DeleteMapping; 8 | import org.springframework.web.bind.annotation.PathVariable; 9 | import org.springframework.web.bind.annotation.PostMapping; 10 | import org.springframework.web.bind.annotation.PutMapping; 11 | import org.springframework.web.bind.annotation.RequestBody; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | import org.springframework.web.bind.annotation.RestController; 14 | 15 | import com.tanthanh.bookservice.command.command.CreateBookCommand; 16 | import com.tanthanh.bookservice.command.command.DeleteBookCommand; 17 | import com.tanthanh.bookservice.command.command.UpdateBookCommand; 18 | import com.tanthanh.bookservice.command.model.BookRequestModel; 19 | 20 | @RestController 21 | @RequestMapping("/api/v1/books") 22 | public class BookCommandController { 23 | 24 | @Autowired 25 | private CommandGateway commandGateway; 26 | 27 | @PostMapping 28 | public String addBook(@RequestBody BookRequestModel model) { 29 | CreateBookCommand command = 30 | new CreateBookCommand(UUID.randomUUID().toString(),model.getName(), model.getAuthor(), true); 31 | commandGateway.sendAndWait(command); 32 | return "added Book"; 33 | } 34 | @PutMapping 35 | public String updateBook(@RequestBody BookRequestModel model) { 36 | UpdateBookCommand command = 37 | new UpdateBookCommand(model.getBookId(),model.getName(), model.getAuthor(), model.getIsReady()); 38 | commandGateway.sendAndWait(command); 39 | return "updated Book"; 40 | } 41 | @DeleteMapping("/{bookId}") 42 | public String deleteBook(@PathVariable String bookId) { 43 | 44 | DeleteBookCommand command = 45 | new DeleteBookCommand(bookId); 46 | commandGateway.sendAndWait(command); 47 | return "deleted Book"; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /employeeservice/employeeservice/src/main/java/com/tanthanh/employeeservice/query/controller/EmployeeQueryController.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.employeeservice.query.controller; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import com.tanthanh.employeeservice.EmployeeserviceApplication; 7 | import org.axonframework.messaging.responsetypes.ResponseTypes; 8 | import org.axonframework.queryhandling.QueryGateway; 9 | import org.slf4j.Logger; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.web.bind.annotation.GetMapping; 12 | import org.springframework.web.bind.annotation.PathVariable; 13 | import org.springframework.web.bind.annotation.RequestMapping; 14 | import org.springframework.web.bind.annotation.RestController; 15 | 16 | import com.tanthanh.employeeservice.query.model.EmployeeReponseModel; 17 | import com.tanthanh.employeeservice.query.queries.GetAllEmployeeQuery; 18 | import com.tanthanh.employeeservice.query.queries.GetEmployeesQuery; 19 | 20 | @RestController 21 | @RequestMapping("/api/v1/employees") 22 | public class EmployeeQueryController { 23 | private Logger logger =org.slf4j.LoggerFactory.getLogger(EmployeeserviceApplication.class); 24 | @Autowired 25 | private QueryGateway queryGateway; 26 | 27 | @GetMapping("/{employeeId}") 28 | public EmployeeReponseModel getEmployeeDetail(@PathVariable String employeeId) { 29 | GetEmployeesQuery getEmployeesQuery = new GetEmployeesQuery(); 30 | getEmployeesQuery.setEmployeeId(employeeId); 31 | 32 | EmployeeReponseModel employeeReponseModel = 33 | queryGateway.query(getEmployeesQuery, 34 | ResponseTypes.instanceOf(EmployeeReponseModel.class)) 35 | .join(); 36 | 37 | return employeeReponseModel; 38 | } 39 | @GetMapping 40 | public List getAllEmployee(){ 41 | List list = queryGateway.query(new GetAllEmployeeQuery(), ResponseTypes.multipleInstancesOf(EmployeeReponseModel.class)) 42 | .join(); 43 | logger.info("Danh Sach Nhan Vien: "+list.toString()); 44 | return list; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /notificationservice/src/main/java/com/tanthanh/notificationservice/NotificationserviceApplication.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.notificationservice; 2 | 3 | import org.slf4j.Logger; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | import org.springframework.cloud.client.circuitbreaker.CircuitBreakerFactory; 8 | import org.springframework.cloud.stream.annotation.EnableBinding; 9 | import org.springframework.cloud.stream.annotation.StreamListener; 10 | import org.springframework.cloud.stream.messaging.Sink; 11 | import org.springframework.web.bind.annotation.RestController; 12 | import org.springframework.web.reactive.function.client.WebClient; 13 | 14 | @SpringBootApplication 15 | @RestController 16 | @EnableBinding(Sink.class) 17 | public class NotificationserviceApplication { 18 | private Logger logger =org.slf4j.LoggerFactory.getLogger(NotificationserviceApplication.class); 19 | 20 | @Autowired 21 | private WebClient.Builder webClientBuilder; 22 | 23 | @Autowired 24 | private CircuitBreakerFactory circuitBreakerFactory; 25 | 26 | @StreamListener(Sink.INPUT) 27 | public void consumeMessage(Message message) { 28 | 29 | EmployeeReponseModel Employeemodel = circuitBreakerFactory.create("getEmployee").run( 30 | () -> { EmployeeReponseModel model = webClientBuilder.build() 31 | .get() 32 | .uri("http://localhost:9002/api/v1/employees/"+message.getEmployeeId()) 33 | .retrieve() 34 | .bodyToMono(EmployeeReponseModel.class) 35 | .block(); 36 | return model; 37 | }, 38 | t -> { EmployeeReponseModel model = new EmployeeReponseModel(); 39 | model.setFirstName("Anonymous"); 40 | model.setLastName("Employee"); 41 | return model; 42 | } 43 | ); 44 | 45 | if(Employeemodel !=null) { 46 | logger.info("Consume Payload: "+Employeemodel.getFirstName()+ " "+Employeemodel.getLastName()+" "+message.getMessage()); 47 | } 48 | } 49 | public static void main(String[] args) { 50 | SpringApplication.run(NotificationserviceApplication.class, args); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /userservice/src/test/java/com/tanthanh/userservice/UserControllerTest.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.userservice; 2 | 3 | import com.tanthanh.userservice.controller.UserController; 4 | import com.tanthanh.userservice.data.User; 5 | import com.tanthanh.userservice.model.UserDTO; 6 | import com.tanthanh.userservice.service.UserService; 7 | import org.junit.jupiter.api.Assertions; 8 | import org.junit.jupiter.api.BeforeEach; 9 | import org.junit.jupiter.api.Test; 10 | import org.junit.jupiter.api.extension.ExtendWith; 11 | import org.junit.platform.commons.util.ReflectionUtils; 12 | import org.mockito.InjectMocks; 13 | import org.mockito.Mock; 14 | import org.springframework.test.context.junit.jupiter.SpringExtension; 15 | import org.springframework.test.util.ReflectionTestUtils; 16 | 17 | import java.util.ArrayList; 18 | import java.util.List; 19 | 20 | import static org.mockito.ArgumentMatchers.anyString; 21 | import static org.mockito.Mockito.when; 22 | 23 | @ExtendWith(SpringExtension.class) 24 | class UserControllerTest { 25 | @Mock 26 | private UserService userService; 27 | 28 | @InjectMocks 29 | private UserController userController; 30 | 31 | private User user; 32 | private UserDTO userDTO; 33 | 34 | @BeforeEach 35 | public void setUp(){ 36 | user = new User(1L,"dev@gmail.com","123456","employeeID"); 37 | userDTO = new UserDTO(1L,"dev@gmail.com","123456","employeeID","token","refresh"); 38 | ReflectionTestUtils.setField(userController,"userService",userService); 39 | } 40 | 41 | @Test 42 | void getAllUser(){ 43 | List users = new ArrayList<>(); 44 | users.add(user); 45 | when(userService.getAllUser()).thenReturn(users); 46 | Assertions.assertEquals(users,userController.getAllUser()); 47 | } 48 | @Test 49 | void addUser(){ 50 | when(userService.saveUser(userDTO)).thenReturn(userDTO); 51 | Assertions.assertEquals(userDTO,userController.addUser(userDTO)); 52 | } 53 | @Test 54 | void login(){ 55 | when(userService.login(anyString(),anyString())).thenReturn(userDTO); 56 | Assertions.assertEquals(userDTO,userController.login(userDTO)); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /userservice/src/test/java/com/tanthanh/userservice/IntergrationTest.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.userservice; 2 | 3 | import com.google.gson.Gson; 4 | import com.tanthanh.userservice.data.User; 5 | import com.tanthanh.userservice.data.UserRepository; 6 | import org.junit.jupiter.api.Assertions; 7 | import org.junit.jupiter.api.BeforeAll; 8 | import org.junit.jupiter.api.BeforeEach; 9 | import org.junit.jupiter.api.Test; 10 | import org.springframework.boot.test.context.SpringBootTest; 11 | import org.springframework.boot.test.mock.mockito.MockBean; 12 | import org.springframework.boot.test.web.server.LocalServerPort; 13 | import org.springframework.http.*; 14 | import org.springframework.web.client.RestTemplate; 15 | 16 | import java.util.ArrayList; 17 | import java.util.Arrays; 18 | import java.util.List; 19 | 20 | import static org.mockito.Mockito.when; 21 | 22 | @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = "application.properties") 23 | class IntergrationTest { 24 | @LocalServerPort 25 | private int port; 26 | 27 | private static RestTemplate restTemplate; 28 | 29 | @MockBean 30 | UserRepository userRepository; 31 | 32 | private User user; 33 | Gson gson = new Gson(); 34 | private String baseUrl = "http://localhost"; 35 | @BeforeAll 36 | public static void init(){ 37 | restTemplate = new RestTemplate(); 38 | } 39 | @BeforeEach 40 | public void setUp(){ 41 | user = new User(1L,"dev@gmail.com","123456","employeeID"); 42 | baseUrl = baseUrl.concat(":").concat(port+"").concat("/api/v1/users"); 43 | } 44 | @Test 45 | void ShouldGetAllUser(){ 46 | List users = new ArrayList<>(); 47 | users.add(user); 48 | when(userRepository.findAll()).thenReturn(users); 49 | ResponseEntity response = restTemplate.getForEntity(baseUrl.concat("/listUser"),List.class); 50 | System.out.println(gson.toJson(response.getBody())); 51 | System.out.println(response.getStatusCode()); 52 | Assertions.assertEquals(gson.toJson(users),gson.toJson(response.getBody())); 53 | Assertions.assertEquals(HttpStatus.OK,response.getStatusCode()); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /discoveryserver/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.7.2 9 | 10 | 11 | com.tanthanh 12 | discoveryserver 13 | 0.0.1-SNAPSHOT 14 | discoveryserver 15 | Demo project for Spring Boot 16 | 17 | 17 18 | 2021.0.3 19 | 20 | 21 | 22 | org.springframework.boot 23 | spring-boot-starter-actuator 24 | 25 | 26 | org.springframework.cloud 27 | spring-cloud-starter-netflix-eureka-server 28 | 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-devtools 33 | runtime 34 | true 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-starter-test 39 | test 40 | 41 | 42 | 43 | 44 | 45 | org.springframework.cloud 46 | spring-cloud-dependencies 47 | ${spring-cloud.version} 48 | pom 49 | import 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | org.springframework.boot 58 | spring-boot-maven-plugin 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /employeeservice/employeeservice/src/main/java/com/tanthanh/employeeservice/query/projection/EmployeeProjection.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.employeeservice.query.projection; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.axonframework.queryhandling.QueryHandler; 7 | import org.springframework.beans.BeanUtils; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Component; 10 | 11 | import com.tanthanh.commonservice.model.EmployeeResponseCommonModel; 12 | import com.tanthanh.commonservice.query.GetDetailsEmployeeQuery; 13 | import com.tanthanh.employeeservice.command.data.Employee; 14 | import com.tanthanh.employeeservice.command.data.EmployeeRepository; 15 | import com.tanthanh.employeeservice.query.model.EmployeeReponseModel; 16 | import com.tanthanh.employeeservice.query.queries.GetAllEmployeeQuery; 17 | import com.tanthanh.employeeservice.query.queries.GetEmployeesQuery; 18 | 19 | @Component 20 | public class EmployeeProjection { 21 | @Autowired 22 | private EmployeeRepository employeeRepository; 23 | 24 | @QueryHandler 25 | public EmployeeReponseModel handle(GetEmployeesQuery getEmployeesQuery) { 26 | EmployeeReponseModel model = new EmployeeReponseModel(); 27 | Employee employee = employeeRepository.getById(getEmployeesQuery.getEmployeeId()); 28 | BeanUtils.copyProperties(employee, model); 29 | 30 | return model; 31 | } 32 | @QueryHandler 33 | public List handle(GetAllEmployeeQuery getAllEmployeeQuery){ 34 | List listModel = new ArrayList<>(); 35 | List listEntity = employeeRepository.findAll(); 36 | listEntity.stream().forEach(s -> { 37 | EmployeeReponseModel model = new EmployeeReponseModel(); 38 | BeanUtils.copyProperties(s, model); 39 | listModel.add(model); 40 | }); 41 | return listModel; 42 | } 43 | @QueryHandler 44 | public EmployeeResponseCommonModel handle(GetDetailsEmployeeQuery getDetailsEmployeeQuery) { 45 | EmployeeResponseCommonModel model = new EmployeeResponseCommonModel(); 46 | Employee employee = employeeRepository.getById(getDetailsEmployeeQuery.getEmployeeId()); 47 | BeanUtils.copyProperties(employee, model); 48 | 49 | return model; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /apigateway/src/main/java/com/tanthanh/apigateway/configuration/AuthFilter.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.apigateway.configuration; 2 | 3 | import org.springframework.cloud.gateway.filter.GatewayFilter; 4 | import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory; 5 | import org.springframework.http.server.reactive.ServerHttpRequest; 6 | import org.springframework.stereotype.Component; 7 | 8 | import com.auth0.jwt.JWT; 9 | import com.auth0.jwt.algorithms.Algorithm; 10 | import com.auth0.jwt.interfaces.DecodedJWT; 11 | import com.auth0.jwt.interfaces.JWTVerifier; 12 | import com.google.common.net.HttpHeaders; 13 | 14 | @Component 15 | public class AuthFilter extends AbstractGatewayFilterFactory{ 16 | 17 | public static class Config { 18 | // empty class as I don't need any particular configuration 19 | } 20 | 21 | private AuthFilter() { 22 | super(Config.class); 23 | } 24 | @Override 25 | public GatewayFilter apply(Config config) { 26 | return (exchange, chain) -> { 27 | if (!exchange.getRequest().getHeaders().containsKey(HttpHeaders.AUTHORIZATION)) { 28 | throw new RuntimeException("Missing authorization information"); 29 | } 30 | 31 | String authHeader = exchange.getRequest().getHeaders().get(HttpHeaders.AUTHORIZATION).get(0); 32 | 33 | String[] parts = authHeader.split(" "); 34 | 35 | if (parts.length != 2 || !"Bearer".equals(parts[0])) { 36 | throw new RuntimeException("Incorrect authorization structure"); 37 | } 38 | 39 | Algorithm algorithm = Algorithm.HMAC256("secret".getBytes()); 40 | JWTVerifier verifier = JWT.require(algorithm).build(); 41 | DecodedJWT decodedJWT = verifier.verify(parts[1]); 42 | String username = decodedJWT.getSubject(); 43 | if(username == "" || username == null) { 44 | throw new RuntimeException("Athorization error"); 45 | } 46 | ServerHttpRequest request = exchange.getRequest().mutate(). 47 | header("X-auth-username", username). 48 | build(); 49 | return chain.filter(exchange.mutate().request(request).build()); 50 | 51 | 52 | 53 | }; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /apigateway/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.7.0 9 | 10 | 11 | com.tanthanh 12 | apigateway 13 | 0.0.1-SNAPSHOT 14 | apigateway 15 | Demo project for Spring Boot 16 | 17 | 11 18 | 2021.0.3 19 | 20 | 21 | 22 | org.springframework.boot 23 | spring-boot-starter-webflux 24 | 25 | 26 | org.springframework.cloud 27 | spring-cloud-starter-gateway 28 | 29 | 30 | org.springframework.cloud 31 | spring-cloud-starter-netflix-eureka-client 32 | 33 | 34 | com.auth0 35 | java-jwt 36 | 3.19.2 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-devtools 41 | runtime 42 | true 43 | 44 | 45 | org.springframework.boot 46 | spring-boot-starter-test 47 | test 48 | 49 | 50 | io.projectreactor 51 | reactor-test 52 | test 53 | 54 | 55 | 56 | 57 | 58 | org.springframework.cloud 59 | spring-cloud-dependencies 60 | ${spring-cloud.version} 61 | pom 62 | import 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | org.springframework.boot 71 | spring-boot-maven-plugin 72 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /employeeservice/employeeservice/src/main/java/com/tanthanh/employeeservice/command/aggregate/EmployeeAggregate.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.employeeservice.command.aggregate; 2 | 3 | import org.axonframework.commandhandling.CommandHandler; 4 | import org.axonframework.eventsourcing.EventSourcingHandler; 5 | import org.axonframework.modelling.command.AggregateIdentifier; 6 | import org.axonframework.modelling.command.AggregateLifecycle; 7 | import org.axonframework.spring.stereotype.Aggregate; 8 | import org.springframework.beans.BeanUtils; 9 | 10 | import com.tanthanh.employeeservice.command.command.CreateEmployeeCommand; 11 | import com.tanthanh.employeeservice.command.command.DeleteEmployeeCommand; 12 | import com.tanthanh.employeeservice.command.command.UpdateEmployeeCommand; 13 | import com.tanthanh.employeeservice.command.event.EmployeeCreatedEvent; 14 | import com.tanthanh.employeeservice.command.event.EmployeeDeletedEvent; 15 | import com.tanthanh.employeeservice.command.event.EmployeeUpdatedEvent; 16 | 17 | @Aggregate 18 | public class EmployeeAggregate { 19 | 20 | @AggregateIdentifier 21 | private String employeeId; 22 | private String firstName; 23 | private String lastName; 24 | private String kin; 25 | private Boolean isDisciplined; 26 | 27 | public EmployeeAggregate() {} 28 | 29 | @CommandHandler 30 | public EmployeeAggregate(CreateEmployeeCommand command) { 31 | EmployeeCreatedEvent event = new EmployeeCreatedEvent(); 32 | BeanUtils.copyProperties(command, event); 33 | AggregateLifecycle.apply(event); 34 | } 35 | @CommandHandler 36 | public void handle(UpdateEmployeeCommand command) { 37 | EmployeeUpdatedEvent event = new EmployeeUpdatedEvent(); 38 | BeanUtils.copyProperties(command, event); 39 | AggregateLifecycle.apply(event); 40 | } 41 | @CommandHandler 42 | public void handle(DeleteEmployeeCommand command) { 43 | EmployeeDeletedEvent event = new EmployeeDeletedEvent(); 44 | event.setEmployeeId(command.getEmployeeId()); 45 | AggregateLifecycle.apply(event); 46 | } 47 | @EventSourcingHandler 48 | public void on(EmployeeCreatedEvent event) { 49 | this.employeeId = event.getEmployeeId(); 50 | this.firstName = event.getFirstName(); 51 | this.lastName = event.getLastName(); 52 | this.kin = event.getKin(); 53 | this.isDisciplined = event.getIsDisciplined(); 54 | } 55 | @EventSourcingHandler 56 | public void on(EmployeeUpdatedEvent event) { 57 | this.employeeId = event.getEmployeeId(); 58 | this.firstName = event.getFirstName(); 59 | this.lastName = event.getLastName(); 60 | this.kin = event.getKin(); 61 | this.isDisciplined = event.getIsDisciplined(); 62 | } 63 | @EventSourcingHandler 64 | public void on(EmployeeDeletedEvent event) { 65 | this.employeeId = event.getEmployeeId(); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /userservice/src/test/java/com/tanthanh/userservice/UserServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.userservice; 2 | 3 | import com.tanthanh.userservice.data.User; 4 | import com.tanthanh.userservice.data.UserRepository; 5 | import com.tanthanh.userservice.model.UserDTO; 6 | import com.tanthanh.userservice.service.UserService; 7 | import org.junit.jupiter.api.Assertions; 8 | import org.junit.jupiter.api.BeforeEach; 9 | import org.junit.jupiter.api.Test; 10 | import org.junit.jupiter.api.extension.ExtendWith; 11 | import org.mockito.InjectMocks; 12 | import org.mockito.Mock; 13 | import org.springframework.security.crypto.password.PasswordEncoder; 14 | import org.springframework.test.context.junit.jupiter.SpringExtension; 15 | import org.springframework.test.util.ReflectionTestUtils; 16 | 17 | import java.util.ArrayList; 18 | import java.util.List; 19 | 20 | import static org.mockito.ArgumentMatchers.any; 21 | 22 | import static org.mockito.ArgumentMatchers.anyString; 23 | import static org.mockito.Mockito.when; 24 | 25 | @ExtendWith(SpringExtension.class) 26 | class UserServiceTest { 27 | @Mock 28 | private UserRepository userRepository; 29 | 30 | @Mock 31 | private PasswordEncoder passwordEncoder; 32 | @InjectMocks 33 | private UserService userService; 34 | private User user; 35 | private UserDTO userDTO; 36 | @BeforeEach 37 | public void setUp(){ 38 | user = new User(1L,"dev@gmail.com","123456","employeeID"); 39 | userDTO = new UserDTO(1L,"dev@gmail.com","123456","employeeID","token","refresh"); 40 | ReflectionTestUtils.setField(userService,"userRepository",userRepository); 41 | ReflectionTestUtils.setField(userService,"passwordEncoder",passwordEncoder); 42 | } 43 | @Test 44 | void getAllUser(){ 45 | List users = new ArrayList<>(); 46 | users.add(user); 47 | when(userRepository.findAll()).thenReturn(users); 48 | Assertions.assertEquals(users,userService.getAllUser()); 49 | } 50 | @Test 51 | void saveUser() { 52 | when(passwordEncoder.encode(user.getPassword())).thenReturn(user.getPassword()); 53 | when(userRepository.save(any(User.class))).thenReturn(user); 54 | Assertions.assertEquals(userDTO.getId(), userService.saveUser(userDTO).getId()); 55 | } 56 | @Test 57 | void login(){ 58 | when(userRepository.findByUsername(user.getUsername())).thenReturn(user); 59 | when(passwordEncoder.matches(anyString(),anyString())).thenReturn(true); 60 | Assertions.assertNotNull(userService.login(user.getUsername(),user.getPassword())); 61 | } 62 | @Test 63 | void loginWithPasswordNotMatch(){ 64 | when(userRepository.findByUsername(user.getUsername())).thenReturn(user); 65 | when(passwordEncoder.matches(anyString(),anyString())).thenReturn(false); 66 | Assertions.assertNotNull(userService.login(user.getUsername(),user.getPassword())); 67 | } 68 | @Test 69 | void loginWithNotFoundUser(){ 70 | when(userRepository.findByUsername(user.getUsername())).thenReturn(null); 71 | Assertions.assertNotNull(userService.login(user.getUsername(),user.getPassword())); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /borrowingservice/src/main/java/com/tanthanh/borrowingservice/query/projection/BorrowingProjection.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.borrowingservice.query.projection; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.axonframework.messaging.responsetypes.ResponseTypes; 7 | import org.axonframework.queryhandling.QueryGateway; 8 | import org.axonframework.queryhandling.QueryHandler; 9 | import org.springframework.beans.BeanUtils; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Component; 12 | 13 | import com.tanthanh.borrowingservice.command.api.data.BorrowRepository; 14 | import com.tanthanh.borrowingservice.command.api.data.Borrowing; 15 | import com.tanthanh.borrowingservice.query.model.BorrowingResponseModel; 16 | import com.tanthanh.borrowingservice.query.queries.GetAllBorrowing; 17 | import com.tanthanh.borrowingservice.query.queries.GetListBorrowingByEmployeeQuery; 18 | import com.tanthanh.commonservice.model.BookResponseCommonModel; 19 | import com.tanthanh.commonservice.model.EmployeeResponseCommonModel; 20 | import com.tanthanh.commonservice.query.GetDetailsBookQuery; 21 | import com.tanthanh.commonservice.query.GetDetailsEmployeeQuery; 22 | 23 | @Component 24 | public class BorrowingProjection { 25 | @Autowired 26 | private BorrowRepository borrowRepository; 27 | 28 | @Autowired 29 | private QueryGateway queryGateway; 30 | 31 | @QueryHandler 32 | public List handle(GetListBorrowingByEmployeeQuery query){ 33 | List list = new ArrayList<>(); 34 | List listEntity = borrowRepository.findByEmployeeIdAndReturnDateIsNull(query.getEmployeeId()); 35 | listEntity.forEach(s ->{ 36 | BorrowingResponseModel model = new BorrowingResponseModel(); 37 | BeanUtils.copyProperties(s, model); 38 | model.setNameBook(queryGateway.query(new GetDetailsBookQuery(model.getBookId()), ResponseTypes.instanceOf(BookResponseCommonModel.class)).join().getName()); 39 | EmployeeResponseCommonModel employee = queryGateway.query(new GetDetailsEmployeeQuery(model.getEmployeeId()), ResponseTypes.instanceOf(EmployeeResponseCommonModel.class)).join(); 40 | model.setNameEmployee(employee.getFirstName()+" "+employee.getLastName()); 41 | 42 | list.add(model); 43 | }); 44 | return list; 45 | } 46 | 47 | @QueryHandler 48 | public List handle(GetAllBorrowing query){ 49 | List list = new ArrayList<>(); 50 | List listEntity = borrowRepository.findAll(); 51 | listEntity.forEach(s ->{ 52 | BorrowingResponseModel model = new BorrowingResponseModel(); 53 | BeanUtils.copyProperties(s, model); 54 | model.setNameBook(queryGateway.query(new GetDetailsBookQuery(model.getBookId()), ResponseTypes.instanceOf(BookResponseCommonModel.class)).join().getName()); 55 | EmployeeResponseCommonModel employee = queryGateway.query(new GetDetailsEmployeeQuery(model.getEmployeeId()), ResponseTypes.instanceOf(EmployeeResponseCommonModel.class)).join(); 56 | model.setNameEmployee(employee.getFirstName()+" "+employee.getLastName()); 57 | list.add(model); 58 | }); 59 | return list; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /employeeservice/employeeservice/src/main/java/com/tanthanh/employeeservice/command/controller/EmployeeCommandController.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.employeeservice.command.controller; 2 | 3 | import java.util.UUID; 4 | 5 | import org.axonframework.commandhandling.gateway.CommandGateway; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.cloud.stream.annotation.EnableBinding; 8 | import org.springframework.cloud.stream.messaging.Source; 9 | import org.springframework.messaging.MessageChannel; 10 | import org.springframework.messaging.support.MessageBuilder; 11 | import org.springframework.stereotype.Controller; 12 | import org.springframework.web.bind.annotation.DeleteMapping; 13 | import org.springframework.web.bind.annotation.PathVariable; 14 | import org.springframework.web.bind.annotation.PostMapping; 15 | import org.springframework.web.bind.annotation.PutMapping; 16 | import org.springframework.web.bind.annotation.RequestBody; 17 | import org.springframework.web.bind.annotation.RequestMapping; 18 | import org.springframework.web.bind.annotation.RestController; 19 | 20 | import com.fasterxml.jackson.core.JsonProcessingException; 21 | import com.fasterxml.jackson.databind.ObjectMapper; 22 | import com.tanthanh.employeeservice.command.command.CreateEmployeeCommand; 23 | import com.tanthanh.employeeservice.command.command.DeleteEmployeeCommand; 24 | import com.tanthanh.employeeservice.command.command.UpdateEmployeeCommand; 25 | import com.tanthanh.employeeservice.command.model.EmployeeRequestModel; 26 | 27 | @RestController 28 | @RequestMapping("/api/v1/employees") 29 | @EnableBinding(Source.class) 30 | public class EmployeeCommandController { 31 | 32 | @Autowired 33 | private CommandGateway commandGateway; 34 | 35 | @Autowired 36 | private MessageChannel output; 37 | 38 | @PostMapping 39 | public String addEmployee(@RequestBody EmployeeRequestModel model) { 40 | CreateEmployeeCommand command = 41 | new CreateEmployeeCommand(UUID.randomUUID().toString(),model.getFirstName(), model.getLastName(), model.getKin(), false); 42 | 43 | commandGateway.sendAndWait(command); 44 | 45 | return "emmployee added"; 46 | } 47 | @PutMapping 48 | public String updateEmployee(@RequestBody EmployeeRequestModel model) { 49 | UpdateEmployeeCommand command = 50 | new UpdateEmployeeCommand(model.getEmployeeId(),model.getFirstName(),model.getLastName(),model.getKin(),model.getIsDisciplined()); 51 | commandGateway.sendAndWait(command); 52 | return "employee updated"; 53 | } 54 | @DeleteMapping("/{employeeId}") 55 | public String deleteEmployee(@PathVariable String employeeId) { 56 | DeleteEmployeeCommand command = new DeleteEmployeeCommand(employeeId); 57 | commandGateway.sendAndWait(command); 58 | return "emmployee deleted"; 59 | } 60 | @PostMapping("/sendMessage") 61 | public void SendMessage(@RequestBody String message) { 62 | try { 63 | 64 | ObjectMapper mapper = new ObjectMapper(); 65 | String json = mapper.writeValueAsString(message); 66 | output.send(MessageBuilder.withPayload(json).build()); 67 | } catch (JsonProcessingException e) { 68 | // TODO Auto-generated catch block 69 | e.printStackTrace(); 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /borrowingservice/src/main/java/com/tanthanh/borrowingservice/command/api/aggregate/BorrowAggregate.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.borrowingservice.command.api.aggregate; 2 | 3 | import java.util.Date; 4 | 5 | import org.axonframework.commandhandling.CommandHandler; 6 | import org.axonframework.eventsourcing.EventSourcingHandler; 7 | import org.axonframework.modelling.command.AggregateIdentifier; 8 | import org.axonframework.modelling.command.AggregateLifecycle; 9 | import org.axonframework.spring.stereotype.Aggregate; 10 | import org.springframework.beans.BeanUtils; 11 | 12 | import com.tanthanh.borrowingservice.command.api.command.CreateBorrowCommand; 13 | import com.tanthanh.borrowingservice.command.api.command.DeleteBorrowCommand; 14 | import com.tanthanh.borrowingservice.command.api.command.SendMessageCommand; 15 | import com.tanthanh.borrowingservice.command.api.command.UpdateBookReturnCommand; 16 | import com.tanthanh.borrowingservice.command.api.events.BorrowCreatedEvent; 17 | import com.tanthanh.borrowingservice.command.api.events.BorrowDeletedEvent; 18 | import com.tanthanh.borrowingservice.command.api.events.BorrowSendMessageEvent; 19 | import com.tanthanh.borrowingservice.command.api.events.BorrowingUpdateBookReturnEvent; 20 | 21 | @Aggregate 22 | public class BorrowAggregate { 23 | @AggregateIdentifier 24 | private String id; 25 | 26 | private String bookId; 27 | private String employeeId; 28 | private Date borrowingDate; 29 | private Date returnDate; 30 | 31 | private String message; 32 | public BorrowAggregate() {} 33 | 34 | @CommandHandler 35 | public BorrowAggregate(CreateBorrowCommand command) { 36 | BorrowCreatedEvent event = new BorrowCreatedEvent(); 37 | BeanUtils.copyProperties(command, event); 38 | AggregateLifecycle.apply(event); 39 | } 40 | @EventSourcingHandler 41 | public void on(BorrowCreatedEvent event) { 42 | this.bookId = event.getBookId(); 43 | this.borrowingDate = event.getBorrowingDate(); 44 | this.employeeId = event.getEmployeeId(); 45 | this.id = event.getId(); 46 | 47 | } 48 | @CommandHandler 49 | public void handle(DeleteBorrowCommand command) { 50 | BorrowDeletedEvent event = new BorrowDeletedEvent(); 51 | BeanUtils.copyProperties(command, event); 52 | AggregateLifecycle.apply(event); 53 | } 54 | @EventSourcingHandler 55 | public void on(BorrowDeletedEvent event) { 56 | this.id = event.getId(); 57 | } 58 | @CommandHandler 59 | public void handle(SendMessageCommand command) { 60 | BorrowSendMessageEvent event = new BorrowSendMessageEvent(); 61 | BeanUtils.copyProperties(command, event); 62 | AggregateLifecycle.apply(event); 63 | } 64 | @EventSourcingHandler 65 | public void on(BorrowSendMessageEvent event) { 66 | this.id = event.getId(); 67 | this.message = event.getMessage(); 68 | this.employeeId = event.getEmployeeId(); 69 | } 70 | @CommandHandler 71 | public void handle(UpdateBookReturnCommand command) { 72 | BorrowingUpdateBookReturnEvent event = new BorrowingUpdateBookReturnEvent(); 73 | BeanUtils.copyProperties(command, event); 74 | AggregateLifecycle.apply(event); 75 | } 76 | @EventSourcingHandler 77 | public void on(BorrowingUpdateBookReturnEvent event) { 78 | 79 | this.returnDate = event.getReturnDate(); 80 | this.bookId = event.getBookId(); 81 | this.employeeId = event.getEmployee(); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /bookservice/src/main/java/com/tanthanh/bookservice/command/aggregate/BookAggregate.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.bookservice.command.aggregate; 2 | 3 | import org.axonframework.commandhandling.CommandHandler; 4 | import org.axonframework.eventsourcing.EventSourcingHandler; 5 | import org.axonframework.modelling.command.AggregateIdentifier; 6 | import org.axonframework.modelling.command.AggregateLifecycle; 7 | import org.axonframework.spring.stereotype.Aggregate; 8 | import org.springframework.beans.BeanUtils; 9 | 10 | import com.tanthanh.bookservice.command.command.CreateBookCommand; 11 | import com.tanthanh.bookservice.command.command.DeleteBookCommand; 12 | import com.tanthanh.bookservice.command.command.UpdateBookCommand; 13 | import com.tanthanh.bookservice.command.event.BookCreatedEvent; 14 | import com.tanthanh.bookservice.command.event.BookDeletedEvent; 15 | import com.tanthanh.bookservice.command.event.BookUpdatedEvent; 16 | import com.tanthanh.commonservice.command.RollBackStatusBookCommand; 17 | import com.tanthanh.commonservice.command.UpdateStatusBookCommand; 18 | import com.tanthanh.commonservice.event.BookRollBackStatusEvent; 19 | import com.tanthanh.commonservice.event.BookUpdateStatusEvent; 20 | 21 | @Aggregate 22 | public class BookAggregate { 23 | 24 | @AggregateIdentifier 25 | private String bookId; 26 | private String name; 27 | private String author; 28 | private Boolean isReady; 29 | 30 | public BookAggregate() { 31 | 32 | } 33 | @CommandHandler 34 | public BookAggregate(CreateBookCommand createBookCommand) { 35 | 36 | BookCreatedEvent bookCreatedEvent 37 | = new BookCreatedEvent(); 38 | BeanUtils.copyProperties(createBookCommand,bookCreatedEvent); 39 | AggregateLifecycle.apply(bookCreatedEvent); 40 | } 41 | @CommandHandler 42 | public void handle(UpdateBookCommand updateBookCommand) { 43 | 44 | BookUpdatedEvent bookUpdatedEvent 45 | = new BookUpdatedEvent(); 46 | BeanUtils.copyProperties(updateBookCommand,bookUpdatedEvent); 47 | AggregateLifecycle.apply(bookUpdatedEvent); 48 | } 49 | @CommandHandler 50 | public void handle(DeleteBookCommand deleteBookCommand) { 51 | 52 | BookDeletedEvent deletedEvent 53 | = new BookDeletedEvent(); 54 | BeanUtils.copyProperties(deleteBookCommand,deletedEvent); 55 | AggregateLifecycle.apply(deletedEvent); 56 | } 57 | @CommandHandler 58 | public void handle(UpdateStatusBookCommand command) { 59 | BookUpdateStatusEvent event = new BookUpdateStatusEvent(); 60 | BeanUtils.copyProperties(command, event); 61 | AggregateLifecycle.apply(event); 62 | } 63 | @EventSourcingHandler 64 | public void on(BookUpdateStatusEvent event) { 65 | this.bookId = event.getBookId(); 66 | this.isReady = event.getIsReady(); 67 | } 68 | @EventSourcingHandler 69 | public void on(BookCreatedEvent event) { 70 | this.bookId = event.getBookId(); 71 | this.author = event.getAuthor(); 72 | this.isReady = event.getIsReady(); 73 | this.name = event.getName(); 74 | } 75 | @EventSourcingHandler 76 | public void on(BookUpdatedEvent event) { 77 | this.bookId = event.getBookId(); 78 | this.author = event.getAuthor(); 79 | this.isReady = event.getIsReady(); 80 | this.name = event.getName(); 81 | } 82 | @EventSourcingHandler 83 | public void on(BookDeletedEvent event) { 84 | this.bookId = event.getBookId(); 85 | 86 | } 87 | @CommandHandler 88 | public void handle(RollBackStatusBookCommand command) { 89 | BookRollBackStatusEvent event = new BookRollBackStatusEvent(); 90 | BeanUtils.copyProperties(command, event); 91 | AggregateLifecycle.apply(event); 92 | } 93 | @EventSourcingHandler 94 | public void on(BookRollBackStatusEvent event) { 95 | this.bookId = event.getBookId(); 96 | this.isReady = event.getIsReady(); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /notificationservice/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.7.0 9 | 10 | 11 | com.tanthanh 12 | notificationservice 13 | 0.0.1-SNAPSHOT 14 | notificationservice 15 | Demo project for Spring Boot 16 | 17 | 11 18 | 2021.0.3 19 | 20 | 21 | 22 | org.springframework.boot 23 | spring-boot-starter-web 24 | 25 | 26 | org.springframework.cloud 27 | spring-cloud-stream 28 | 29 | 30 | org.springframework.cloud 31 | spring-cloud-starter-sleuth 32 | 33 | 34 | org.springframework.cloud 35 | spring-cloud-sleuth-zipkin 36 | 37 | 38 | org.springframework.cloud 39 | spring-cloud-stream-binder-kafka 40 | 41 | 42 | org.springframework.kafka 43 | spring-kafka 44 | 45 | 46 | 47 | org.springframework.cloud 48 | spring-cloud-starter-circuitbreaker-resilience4j 49 | 50 | 51 | org.springframework.boot 52 | spring-boot-starter-actuator 53 | 54 | 55 | org.springframework.boot 56 | spring-boot-starter-aop 57 | 58 | 59 | 60 | org.springframework.boot 61 | spring-boot-starter-webflux 62 | 63 | 64 | org.springframework.boot 65 | spring-boot-devtools 66 | runtime 67 | true 68 | 69 | 70 | org.springframework.boot 71 | spring-boot-starter-test 72 | test 73 | 74 | 75 | org.springframework.cloud 76 | spring-cloud-stream 77 | test 78 | test-binder 79 | test-jar 80 | 81 | 82 | org.springframework.kafka 83 | spring-kafka-test 84 | test 85 | 86 | 87 | 88 | 89 | 90 | org.springframework.cloud 91 | spring-cloud-dependencies 92 | ${spring-cloud.version} 93 | pom 94 | import 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | org.springframework.boot 103 | spring-boot-maven-plugin 104 | 105 | 106 | 107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /bookservice/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.6.7 9 | 10 | 11 | com.tanthanh 12 | bookservice 13 | 0.0.1-SNAPSHOT 14 | bookservice 15 | Demo project for Spring Boot 16 | 17 | 11 18 | 2021.0.2 19 | 20 | 21 | 22 | com.tanthanh 23 | commonservice 24 | 0.0.1-SNAPSHOT 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter-actuator 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter-data-jpa 33 | 34 | 35 | org.springframework.cloud 36 | spring-cloud-starter-sleuth 37 | 38 | 39 | org.springframework.cloud 40 | spring-cloud-sleuth-zipkin 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-starter-web 45 | 46 | 47 | org.springframework.cloud 48 | spring-cloud-starter-netflix-eureka-client 49 | 50 | 51 | 52 | org.springframework.boot 53 | spring-boot-devtools 54 | runtime 55 | true 56 | 57 | 58 | com.h2database 59 | h2 60 | runtime 61 | 62 | 63 | org.springframework.boot 64 | spring-boot-starter-test 65 | test 66 | 67 | 68 | org.axonframework 69 | axon-spring-boot-starter 70 | 4.5.9 71 | 72 | 73 | com.google.guava 74 | guava 75 | 31.0.1-jre 76 | 77 | 78 | 79 | 80 | 81 | 82 | org.springframework.cloud 83 | spring-cloud-dependencies 84 | ${spring-cloud.version} 85 | pom 86 | import 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | org.springframework.boot 95 | spring-boot-maven-plugin 96 | 97 | 98 | org.jacoco 99 | jacoco-maven-plugin 100 | 0.8.8 101 | 102 | 103 | **/model/** 104 | **/configuration/** 105 | **/BookserviceApplication.* 106 | 107 | 108 | defaultprepare-agentdefault-reportprepare-packagereport 109 | 110 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /userservice/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.7.0 9 | 10 | 11 | com.tanthanh 12 | userservice 13 | 0.0.1-SNAPSHOT 14 | userservice 15 | Demo project for Spring Boot 16 | 17 | 11 18 | 2021.0.3 19 | **/model/*,**/data/**,**/configuration/**,**/UserserviceApplication.* 20 | src/test/**jacocoreuseReports${project.basedir}/../target/jacoco.exec 21 | 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-actuator 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-data-jpa 30 | 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-starter-web 35 | 36 | 37 | org.projectlombok 38 | lombok 39 | true 40 | 41 | 42 | org.springframework.cloud 43 | spring-cloud-starter-netflix-eureka-client 44 | 45 | 46 | com.auth0 47 | java-jwt 48 | 3.19.2 49 | 50 | 51 | org.springframework.boot 52 | spring-boot-devtools 53 | runtime 54 | true 55 | 56 | 57 | com.h2database 58 | h2 59 | runtime 60 | 61 | 62 | org.springframework.boot 63 | spring-boot-starter-test 64 | test 65 | 66 | 67 | 68 | 69 | 70 | 71 | org.springframework.cloud 72 | spring-cloud-dependencies 73 | ${spring-cloud.version} 74 | pom 75 | import 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | org.springframework.boot 84 | spring-boot-maven-plugin 85 | 86 | 87 | 88 | org.projectlombok 89 | lombok 90 | 91 | 92 | 93 | 94 | 95 | org.sonarsource.scanner.maven 96 | sonar-maven-plugin 97 | 3.7.0.1746 98 | 99 | 100 | org.jacoco 101 | jacoco-maven-plugin 102 | 0.8.8 103 | 104 | 105 | **/model/** 106 | **/data/** 107 | **/configuration/** 108 | **/UserserviceApplication.* 109 | 110 | 111 | defaultprepare-agentdefault-reportprepare-packagereport 112 | 113 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /borrowingservice/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.6.7 9 | 10 | 11 | com.tanthanh 12 | borrowingservice 13 | 0.0.1-SNAPSHOT 14 | borrowingservice 15 | Demo project for Spring Boot 16 | 17 | 11 18 | 2021.0.2 19 | 20 | 21 | 22 | org.springframework.boot 23 | spring-boot-starter-actuator 24 | 25 | 26 | org.springframework.boot 27 | spring-boot-starter-web 28 | 29 | 30 | org.springframework.cloud 31 | spring-cloud-starter-sleuth 32 | 33 | 34 | org.springframework.cloud 35 | spring-cloud-sleuth-zipkin 36 | 37 | 38 | org.springframework.cloud 39 | spring-cloud-starter-netflix-eureka-client 40 | 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-devtools 45 | runtime 46 | true 47 | 48 | 49 | org.springframework.boot 50 | spring-boot-starter-test 51 | test 52 | 53 | 54 | com.tanthanh 55 | commonservice 56 | 0.0.1-SNAPSHOT 57 | 58 | 59 | org.axonframework 60 | axon-spring-boot-starter 61 | 4.5.9 62 | 63 | 64 | com.h2database 65 | h2 66 | runtime 67 | 68 | 69 | org.projectlombok 70 | lombok 71 | true 72 | 73 | 74 | org.springframework.boot 75 | spring-boot-starter-data-jpa 76 | 77 | 78 | org.springframework.cloud 79 | spring-cloud-stream 80 | 3.2.4 81 | 82 | 83 | org.springframework.cloud 84 | spring-cloud-stream-binder-kafka 85 | 3.2.4 86 | 87 | 88 | org.springframework.kafka 89 | spring-kafka 90 | 2.8.6 91 | 92 | 93 | org.springframework.cloud 94 | spring-cloud-stream 95 | 3.2.4 96 | test 97 | test-binder 98 | test-jar 99 | 100 | 101 | org.springframework.kafka 102 | spring-kafka-test 103 | 2.8.6 104 | test 105 | 106 | 107 | 108 | 109 | com.google.guava 110 | guava 111 | 31.0.1-jre 112 | 113 | 114 | 115 | 116 | 117 | 118 | org.springframework.cloud 119 | spring-cloud-dependencies 120 | ${spring-cloud.version} 121 | pom 122 | import 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | org.springframework.boot 131 | spring-boot-maven-plugin 132 | 133 | 134 | 135 | 136 | 137 | -------------------------------------------------------------------------------- /employeeservice/employeeservice/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.6.7 9 | 10 | 11 | com.tanthanh 12 | employeeservice 13 | 0.0.1-SNAPSHOT 14 | employeeservice 15 | Demo project for Spring Boot 16 | 17 | 11 18 | 2021.0.2 19 | 20 | 21 | 22 | org.springframework.boot 23 | spring-boot-starter-actuator 24 | 25 | 26 | org.springframework.boot 27 | spring-boot-starter-data-jpa 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-starter-web 32 | 33 | 34 | org.springframework.cloud 35 | spring-cloud-starter-netflix-eureka-client 36 | 37 | 38 | org.springframework.cloud 39 | spring-cloud-stream 40 | 3.2.4 41 | 42 | 43 | org.springframework.cloud 44 | spring-cloud-stream-binder-kafka 45 | 3.2.4 46 | 47 | 48 | org.springframework.cloud 49 | spring-cloud-starter-sleuth 50 | 51 | 52 | org.springframework.cloud 53 | spring-cloud-sleuth-zipkin 54 | 55 | 56 | org.springframework.kafka 57 | spring-kafka 58 | 2.8.6 59 | 60 | 61 | org.springframework.cloud 62 | spring-cloud-stream 63 | 3.2.4 64 | test 65 | test-binder 66 | test-jar 67 | 68 | 69 | org.springframework.kafka 70 | spring-kafka-test 71 | 2.8.6 72 | test 73 | 74 | 75 | com.tanthanh 76 | commonservice 77 | 0.0.1-SNAPSHOT 78 | 79 | 80 | org.springframework.boot 81 | spring-boot-devtools 82 | runtime 83 | true 84 | 85 | 86 | org.axonframework 87 | axon-spring-boot-starter 88 | 4.5.9 89 | 90 | 91 | com.google.guava 92 | guava 93 | 31.0.1-jre 94 | 95 | 96 | com.h2database 97 | h2 98 | runtime 99 | 100 | 101 | org.springframework.boot 102 | spring-boot-starter-test 103 | test 104 | 105 | 106 | 107 | 108 | 109 | org.springframework.cloud 110 | spring-cloud-dependencies 111 | ${spring-cloud.version} 112 | pom 113 | import 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | org.springframework.boot 122 | spring-boot-maven-plugin 123 | 124 | 125 | 126 | 127 | 128 | netflix-candidates 129 | Netflix Candidates 130 | https://artifactory-oss.prod.netflix.net/artifactory/maven-oss-candidates 131 | 132 | false 133 | 134 | 135 | 136 | spring-milestones 137 | Spring Milestones 138 | https://repo.spring.io/milestone 139 | 140 | false 141 | 142 | 143 | 144 | 145 | 146 | -------------------------------------------------------------------------------- /borrowingservice/src/main/java/com/tanthanh/borrowingservice/command/api/saga/BorrowingSaga.java: -------------------------------------------------------------------------------- 1 | package com.tanthanh.borrowingservice.command.api.saga; 2 | 3 | import org.axonframework.commandhandling.gateway.CommandGateway; 4 | import org.axonframework.messaging.responsetypes.ResponseTypes; 5 | import org.axonframework.modelling.saga.EndSaga; 6 | import org.axonframework.modelling.saga.SagaEventHandler; 7 | import org.axonframework.modelling.saga.SagaLifecycle; 8 | import org.axonframework.modelling.saga.StartSaga; 9 | import org.axonframework.queryhandling.QueryGateway; 10 | import org.axonframework.spring.stereotype.Saga; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | 13 | import com.tanthanh.borrowingservice.command.api.command.DeleteBorrowCommand; 14 | import com.tanthanh.borrowingservice.command.api.command.SendMessageCommand; 15 | import com.tanthanh.borrowingservice.command.api.events.BorrowCreatedEvent; 16 | import com.tanthanh.borrowingservice.command.api.events.BorrowDeletedEvent; 17 | import com.tanthanh.borrowingservice.command.api.events.BorrowingUpdateBookReturnEvent; 18 | import com.tanthanh.commonservice.command.RollBackStatusBookCommand; 19 | import com.tanthanh.commonservice.command.UpdateStatusBookCommand; 20 | import com.tanthanh.commonservice.event.BookRollBackStatusEvent; 21 | import com.tanthanh.commonservice.event.BookUpdateStatusEvent; 22 | import com.tanthanh.commonservice.model.BookResponseCommonModel; 23 | import com.tanthanh.commonservice.model.EmployeeResponseCommonModel; 24 | import com.tanthanh.commonservice.query.GetDetailsBookQuery; 25 | import com.tanthanh.commonservice.query.GetDetailsEmployeeQuery; 26 | 27 | @Saga 28 | public class BorrowingSaga { 29 | @Autowired 30 | private transient CommandGateway commandGateway; 31 | 32 | @Autowired 33 | private transient QueryGateway queryGateway; 34 | 35 | @StartSaga 36 | @SagaEventHandler(associationProperty = "id") 37 | private void handle(BorrowCreatedEvent event) { 38 | System.out.println("BorrowCreatedEvent in Saga for BookId : "+event.getBookId()+ " : EmployeeId : "+event.getEmployeeId()); 39 | 40 | try { 41 | SagaLifecycle.associateWith("bookId", event.getBookId()); 42 | 43 | GetDetailsBookQuery getDetailsBookQuery = new GetDetailsBookQuery(event.getBookId()); 44 | 45 | BookResponseCommonModel bookResponseModel = 46 | queryGateway.query(getDetailsBookQuery, 47 | ResponseTypes.instanceOf(BookResponseCommonModel.class)) 48 | .join(); 49 | if(bookResponseModel.getIsReady() == true) { 50 | UpdateStatusBookCommand command = new UpdateStatusBookCommand(event.getBookId(), false,event.getEmployeeId(),event.getId()); 51 | commandGateway.sendAndWait(command); 52 | } 53 | else { 54 | 55 | throw new Exception("Sach Da co nguoi Muon"); 56 | } 57 | 58 | 59 | } catch (Exception e) { 60 | rollBackBorrowRecord(event.getId()); 61 | 62 | System.out.println(e.getMessage()); 63 | } 64 | } 65 | @SagaEventHandler(associationProperty = "bookId") 66 | private void handle(BookUpdateStatusEvent event) { 67 | System.out.println("BookUpdateStatusEvent in Saga for BookId : "+event.getBookId()); 68 | try { 69 | GetDetailsEmployeeQuery getDetailsEmployeeQuery = new GetDetailsEmployeeQuery(event.getEmployeeId()); 70 | 71 | EmployeeResponseCommonModel employeeResponseCommonModel = 72 | queryGateway.query(getDetailsEmployeeQuery, 73 | ResponseTypes.instanceOf(EmployeeResponseCommonModel.class)) 74 | .join(); 75 | if(employeeResponseCommonModel.getIsDisciplined()==true) { 76 | throw new Exception("Nhan vien bi ky luat"); 77 | }else { 78 | commandGateway.sendAndWait(new SendMessageCommand(event.getBorrowId(), event.getEmployeeId(), "Da muon sach thanh cong !")); 79 | SagaLifecycle.end(); 80 | } 81 | } catch (Exception e) { 82 | 83 | System.out.println(e.getMessage()); 84 | rollBackBookStatus(event.getBookId(),event.getEmployeeId(),event.getBorrowId()); 85 | } 86 | } 87 | private void rollBackBookStatus(String bookId,String employeeId,String borrowId) { 88 | SagaLifecycle.associateWith("bookId", bookId); 89 | RollBackStatusBookCommand command = new RollBackStatusBookCommand(bookId, true,employeeId,borrowId); 90 | commandGateway.sendAndWait(command); 91 | } 92 | @SagaEventHandler(associationProperty = "bookId") 93 | public void handleRollBackBookStatus(BookRollBackStatusEvent event) { 94 | System.out.println("BookRollBackStatusEvent in Saga for book Id : {} " + event.getBookId()); 95 | rollBackBorrowRecord(event.getBorrowId()); 96 | } 97 | private void rollBackBorrowRecord(String id) { 98 | commandGateway.sendAndWait(new DeleteBorrowCommand(id)); 99 | } 100 | @SagaEventHandler(associationProperty = "id") 101 | @EndSaga 102 | public void handle(BorrowDeletedEvent event) { 103 | System.out.println("BorrowDeletedEvent in Saga for Borrowing Id : {} " + 104 | event.getId()); 105 | SagaLifecycle.end(); 106 | } 107 | 108 | @StartSaga 109 | @SagaEventHandler(associationProperty = "id") 110 | private void handle(BorrowingUpdateBookReturnEvent event) { 111 | System.out.println("BorrowingUpdateBookReturnEvent in Saga for borrowing Id : "+event.getId()); 112 | try { 113 | UpdateStatusBookCommand command = new UpdateStatusBookCommand(event.getBookId(), true,event.getEmployee(),event.getId()); 114 | commandGateway.sendAndWait(command); 115 | commandGateway.sendAndWait(new SendMessageCommand(event.getId(), event.getEmployee(), "Da tra sach thanh cong !")); 116 | SagaLifecycle.end(); 117 | } catch (Exception e) { 118 | // TODO: handle exception 119 | System.out.println(e.getMessage()); 120 | } 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /apigateway/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* 50 | if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" 124 | 125 | FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% ^ 162 | %JVM_CONFIG_MAVEN_PROPS% ^ 163 | %MAVEN_OPTS% ^ 164 | %MAVEN_DEBUG_OPTS% ^ 165 | -classpath %WRAPPER_JAR% ^ 166 | "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ 167 | %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 168 | if ERRORLEVEL 1 goto error 169 | goto end 170 | 171 | :error 172 | set ERROR_CODE=1 173 | 174 | :end 175 | @endlocal & set ERROR_CODE=%ERROR_CODE% 176 | 177 | if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost 178 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 179 | if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" 180 | if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" 181 | :skipRcPost 182 | 183 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 184 | if "%MAVEN_BATCH_PAUSE%"=="on" pause 185 | 186 | if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% 187 | 188 | cmd /C exit /B %ERROR_CODE% 189 | -------------------------------------------------------------------------------- /bookservice/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* 50 | if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" 124 | 125 | FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% ^ 162 | %JVM_CONFIG_MAVEN_PROPS% ^ 163 | %MAVEN_OPTS% ^ 164 | %MAVEN_DEBUG_OPTS% ^ 165 | -classpath %WRAPPER_JAR% ^ 166 | "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ 167 | %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 168 | if ERRORLEVEL 1 goto error 169 | goto end 170 | 171 | :error 172 | set ERROR_CODE=1 173 | 174 | :end 175 | @endlocal & set ERROR_CODE=%ERROR_CODE% 176 | 177 | if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost 178 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 179 | if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" 180 | if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" 181 | :skipRcPost 182 | 183 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 184 | if "%MAVEN_BATCH_PAUSE%"=="on" pause 185 | 186 | if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% 187 | 188 | cmd /C exit /B %ERROR_CODE% 189 | -------------------------------------------------------------------------------- /commonservice/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* 50 | if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" 124 | 125 | FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% ^ 162 | %JVM_CONFIG_MAVEN_PROPS% ^ 163 | %MAVEN_OPTS% ^ 164 | %MAVEN_DEBUG_OPTS% ^ 165 | -classpath %WRAPPER_JAR% ^ 166 | "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ 167 | %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 168 | if ERRORLEVEL 1 goto error 169 | goto end 170 | 171 | :error 172 | set ERROR_CODE=1 173 | 174 | :end 175 | @endlocal & set ERROR_CODE=%ERROR_CODE% 176 | 177 | if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost 178 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 179 | if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" 180 | if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" 181 | :skipRcPost 182 | 183 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 184 | if "%MAVEN_BATCH_PAUSE%"=="on" pause 185 | 186 | if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% 187 | 188 | cmd /C exit /B %ERROR_CODE% 189 | -------------------------------------------------------------------------------- /discoveryserver/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* 50 | if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" 124 | 125 | FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% ^ 162 | %JVM_CONFIG_MAVEN_PROPS% ^ 163 | %MAVEN_OPTS% ^ 164 | %MAVEN_DEBUG_OPTS% ^ 165 | -classpath %WRAPPER_JAR% ^ 166 | "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ 167 | %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 168 | if ERRORLEVEL 1 goto error 169 | goto end 170 | 171 | :error 172 | set ERROR_CODE=1 173 | 174 | :end 175 | @endlocal & set ERROR_CODE=%ERROR_CODE% 176 | 177 | if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost 178 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 179 | if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" 180 | if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" 181 | :skipRcPost 182 | 183 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 184 | if "%MAVEN_BATCH_PAUSE%"=="on" pause 185 | 186 | if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% 187 | 188 | cmd /C exit /B %ERROR_CODE% 189 | -------------------------------------------------------------------------------- /userservice/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* 50 | if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" 124 | 125 | FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% ^ 162 | %JVM_CONFIG_MAVEN_PROPS% ^ 163 | %MAVEN_OPTS% ^ 164 | %MAVEN_DEBUG_OPTS% ^ 165 | -classpath %WRAPPER_JAR% ^ 166 | "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ 167 | %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 168 | if ERRORLEVEL 1 goto error 169 | goto end 170 | 171 | :error 172 | set ERROR_CODE=1 173 | 174 | :end 175 | @endlocal & set ERROR_CODE=%ERROR_CODE% 176 | 177 | if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost 178 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 179 | if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" 180 | if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" 181 | :skipRcPost 182 | 183 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 184 | if "%MAVEN_BATCH_PAUSE%"=="on" pause 185 | 186 | if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% 187 | 188 | cmd /C exit /B %ERROR_CODE% 189 | -------------------------------------------------------------------------------- /borrowingservice/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* 50 | if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" 124 | 125 | FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% ^ 162 | %JVM_CONFIG_MAVEN_PROPS% ^ 163 | %MAVEN_OPTS% ^ 164 | %MAVEN_DEBUG_OPTS% ^ 165 | -classpath %WRAPPER_JAR% ^ 166 | "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ 167 | %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 168 | if ERRORLEVEL 1 goto error 169 | goto end 170 | 171 | :error 172 | set ERROR_CODE=1 173 | 174 | :end 175 | @endlocal & set ERROR_CODE=%ERROR_CODE% 176 | 177 | if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost 178 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 179 | if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" 180 | if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" 181 | :skipRcPost 182 | 183 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 184 | if "%MAVEN_BATCH_PAUSE%"=="on" pause 185 | 186 | if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% 187 | 188 | cmd /C exit /B %ERROR_CODE% 189 | -------------------------------------------------------------------------------- /notificationservice/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* 50 | if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" 124 | 125 | FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% ^ 162 | %JVM_CONFIG_MAVEN_PROPS% ^ 163 | %MAVEN_OPTS% ^ 164 | %MAVEN_DEBUG_OPTS% ^ 165 | -classpath %WRAPPER_JAR% ^ 166 | "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ 167 | %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 168 | if ERRORLEVEL 1 goto error 169 | goto end 170 | 171 | :error 172 | set ERROR_CODE=1 173 | 174 | :end 175 | @endlocal & set ERROR_CODE=%ERROR_CODE% 176 | 177 | if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost 178 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 179 | if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" 180 | if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" 181 | :skipRcPost 182 | 183 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 184 | if "%MAVEN_BATCH_PAUSE%"=="on" pause 185 | 186 | if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% 187 | 188 | cmd /C exit /B %ERROR_CODE% 189 | --------------------------------------------------------------------------------