This is a Medicine Pharmacy API developed using Spring Boot, Java, and MySQL. It allows you to manage medicines in a pharmacy system by providing endpoints for adding new medicines and updating existing ones.
- A SpringBoot REST API built for its Client
Before you start using this API, make sure you have the following installed:
- Java Development Kit (JDK)
- Spring Boot
- MySQL Database
- Postman (for testing)
- Clone the repository:
bash git clone https://github.com/RachamallaYeswanthReddy/Medicine-Controller.git cd Medicine-Controller
-
Configure the MySQL database by editing the application.properties file in the src/main/resources directory. Update the database URL, username, and password according to your MySQL setup.
-
Build and run the application:
bash ./mvnw spring-boot:run
The API will be accessible at http://localhost:8080.
-
Endpoint: POST /medicines
-
Request Body: json { "medicineName": "Paracetamol", "price": 5.99, "quantity": 200, "description": "Common pain and fever medication" }
-
Response: Returns "true" if the medicine is successfully added, otherwise false.
-
Endpoint: PUT /medicines/{medicineId}
-
Request Body: json { "medicineName": "Paracetamol", "price": 5.99, "quantity": 200, "description": "Common pain and fever medication" }
-
Response: Returns the updated Medicine object.
You can use Postman or any other API testing tool to interact with the endpoints.
-
Open Postman.
-
Create a new collection and add new request.
-
Set the request method (POST or PUT), URL (e.g., http://localhost:8080/medicines), and add the request body as described above.
-
Send the request to test the API.
- Clone this repository
- Create a MySql database with the name medicine
- You can create the database with any name you like. Make sure to update the datasource url in application.properties
- If your datasource username and password are not the defaults username(root) and password(" ") , then update their values inapplication.properties
- Run the code given in the textfile mysql in the MYSQL Workbench
This project is licensed under the MIT License - see the LICENSE file for details.
Please make sure to update your repository link in the clone URL and any other specific details in the README according to your project's requirements.