Build API Restful for a phonelines company using Spring MVC, JPA y Mysql.
1. Clone the application
git clone https://github.com/abelacu95/UTNPhones.git
2. Create Mysql database
create database utn_phones
- run
src/main/resources/schema/mysql/utn-phones.sql
3. Change mysql username and password as per your installation
- open
src/main/resources/application.properties
- change
spring.datasource.username
andspring.datasource.password
as per your mysql installation
The app will start running at http://localhost:8080
The app defines following CRUD APIs.
Method | Url | Decription | Sample Valid Request Body |
---|---|---|---|
POST | /api/login | Login | JSON |
POST | /api/logout | Logout |
Method | Url | Description | Sample Valid Request Body |
---|---|---|---|
GET | /api/backoffice/clients | Get all clients | |
GET | /api/backoffice/clients/{dni} | Get client by dni | |
POST | /api/backoffice/clients | Add client | JSON |
PUT | /api/backoffice/clients/{dni} | Update client by dni | JSON |
DELETE | /api/backoffice/clients/{dni} | Delete client by dni |
Method | Url | Description | Sample Valid Request Body |
---|---|---|---|
GET | /api/backoffice/phone-lines | Get all phone lines | |
GET | /api/backoffice/phone-lines/{dni} | Get phone lines by dni | |
POST | /api/backoffice/clients/{dni}/phone-lines | Add phone line by client dni | JSON |
PUT | /api/backoffice/phone-lines/{id} | Enabled phone lines by id | |
DELETE | /api/backoffice/phone-lines/{id} | Diabled phone lines by id |
Method | Url | Description | Sample Valid Request Body |
---|---|---|---|
POST | /api/backoffice/tariffs | Add tariff | JSON |
GET | /api/backoffice/tariffs | Get all tariffs |
Method | Url | Description | Sample Valid Request Body |
---|---|---|---|
GET | /api/backoffice/clients/{dni}/calls | Get calls by client dni | |
GET | /api/backoffice/clients/{dni}/bills | Get bills by client dni |
Method | Url | Description | Sample Valid Request Body |
---|---|---|---|
POST | /api/calls | Add call | JSON |
Method | Url | Description | Sample Valid Request Body |
---|---|---|---|
GET | /api/web/calls?from=05/12/2019&to=26/06/2020 | Get calls by dates range | |
GET | /api/web/bills?from=01/05/2020&to=30/06/2020 | Get bills by dates range | |
GET | /api/web/cities/top-10/calls | Get TOP 10 destination most called |
Test them using postman or any other rest client.
{
"dni": "123456789",
"password": "1234pwd"
}
{
"cityId" : 32,
"firstname" : "Name",
"lastname" : "LastName",
"dni" : "123456789",
"password": "1234pwd",
"typeLine" : "mobile"
}
{
"cityId" : 4,
"firstname" : "Name",
"lastname" : "LastName"
}
{
"dni":"12345678",
"typeLine":"mobile"
}
{
"costPrice": 3.5,
"price": 7.3,
"cityOriginId":4,
"cityDestinationId":32
}
{
"numberOrigin":"02234919872",
"numberDestination":"22678263806",
"duration":19,
"date":"03/05/2020"
}