This is a Spring Boot application for a lottery system where guests can select a pre-populated lottery ticket, register their details, and participate in a lottery draw. The application calculates winnings based on predefined rules.
- Registration of guest details, including name and mobile number.
- Dynamic lottery draw with random number and letter generation.
- Calculation of winnings based on matching numbers and letters.
- Storage of participant details for future reference.
- Spring Boot
- Java
- Maven
- H2 Database
- Endpoint:
POST /api/tickets
- Description: Registers a guest with their selected ticket and calculates the winnings.
{
"name": "YSanj98",
"mobile": "0771234567",
"ticket": "4 6 2 7 U"
}
- Success (200 OK):
{
"guestId": 1,
"name": "YSanj98",
"mobile": "0771234567",
"ticket": "4 6 2 7 U",
"amountWon": 200.0,
"percentageWon": 20,
}
- Endpoint:
GET /api/lotteries
- Description: Retrieves all lottery draws and guest details.
- Success (200 OK):
[
{
"lotteryId": 1,
"lotterySequence": "4 6 2 7 U",
"drawnSequence": "2 4 6 7 X",
"jackpot": 1000.0,
"guests": [
{
"guestId": 1,
"name": "YSanj98",
"mobile": "0771234567",
"ticket": "4 6 2 7 U",
"amountWon": 200.0,
"percentageWon": 20
}
]
}
]
-
Clone the repository:
git clone https://github.com/YSanj98/lottery-application.git cd lottery-application
-
Build the application using Maven:
mvn clean install
-
Run the application:
mvn spring-boot:run
-
Access the API at
http://localhost:8080/api
.