This API is designed to implement functionality for performing tasks related to the transport company.
Vehicle:
Returns all Vehicles
Returns One Vehicle by id
Adds new Vehicle
Updates Vehicle in db
Returns a filtered list of Vehicles by filters
Category:
Returns all Categories
Returns One Category by id
Type:
Returns all Types
Returns One Type by id
1. Clone repository, and open it in IDE
2. Create database by this file (PostgreSql syntax):
https://github.com/4ubov/transport-catalog-api/blob/main/src/main/resources/transport_catalog_db.sql
3. Fill application.properties fields by your own dataSource
4. Run project in IDE
5. Go to the browser and go to the address: http://localhost:yourPort/
Example link: http://localhost:8080/
On this address will contain the builded version of the frontend client.
path: resources/templates/index.html
⚪ GET /api/vehicle/
Request body: No parameters
Description: Successfully found!
Media type: application/json
Json return: List<VehicleDTO>
Example value:
[
{
"vehicleId": 53,
"brand": "Mercedes",
"model": "E250",
"category": "A",
"stateNumber": "F553RH58",
"type": "Хэтчбек",
"yearOfRealise": 2007,
"hasTrailer": false
},
{
"vehicleId": 54,
"brand": "Mercedes",
"model": "GLS3",
"category": "A",
"stateNumber": "R282AA58",
"type": "Седан",
"yearOfRealise": 2017,
"hasTrailer": false
}
]
⚪ POST /api/vehicle/get-one
Request body: application/json
Example value:
{
"vehicleId" : "56"
}
Description: Vehicle successfully found!
Media type: application/json
Json return: VehicleDTO
Example value:
{
"vehicleId": 56,
"brand": "BMW",
"model": "E3",
"category": "A",
"stateNumber": "A111AA58",
"type": "Хэтчбек",
"yearOfRealise": 2011,
"hasTrailer": false
}
Description: Bad ID format! ("vehicleId" : "56DFE") only Long value
Media type: application/json
Example value:
{
"statusCode": 404,
"message": "Entered vehicleId is incorrect type, it need be a number",
"timestamp": 1679587416465
}
Description: Entity not found! If entered vehicleId dont exist in db.
Media type: application/json
Example value:
{
"statusCode": 404,
"message": "Vehicle Entity with entered id not found!",
"timestamp": 1679587416465
}
⚪ POST /api/vehicle/add
Request body: application/json
Json contain: VehicleDTO
Example value:
{
"brand": "Audi",
"model": "R8",
"category": "A",
"stateNumber": "F287FR777",
"type": "Седан",
"yearOfRealise": 2012,
"hasTrailer": false
}
Description: Vehicle successfully added!
Media type: application/json
Example value:
{
"CREATED"
}
Description: Exceptions that will throws in case bad Validation @Valid!
Media type: application/json
Example value:
{
"statusCode": 400,
"message": "brand - Поле brand не должно быть пустым!;
Поле model не должно быть пустым! Example: M3;
VehicleType Entity with entered name not found!;
VehicleCategory Entity with entered name not found!" ,
"timestamp": 1689438720293
}
Description: State Number is unique field, your request contain same number!
Media type: application/json
Example value:
{
"statusCode": 400,
"message": "stateNumber - Транспорт с таким гос. номером уже есть в БД!; ",
"timestamp": 1689438543459
}
⚪ PUT /api/vehicle/add
Request body: application/json
Example value:
Json contain: VehicleDTO
{
"vehicleId": "5",
"brand": "Audi",
"model": "RX7",
"category": "A",
"stateNumber": "F237FR777",
"type": "Кроссовер",
"yearOfRealise": 2014,
"hasTrailer": false
}
Description: Vehicle successfully updated!
Media type: application/json
Example value:
{
"CREATED"
}
Description: Exceptions that will throws in case bad Validation @Valid!
Media type: application/json
Example value:
{
"statusCode": 400,
"message": "brand - Поле brand не должно быть пустым!;
Поле model не должно быть пустым! Example: M3;
VehicleType Entity with entered name not found!;
VehicleCategory Entity with entered name not found!" ,
"timestamp": 1689438720293
}
Description: State Number is unique field, your request contain same number!
Media type: application/json
Example value:
{
"statusCode": 400,
"message": "stateNumber - Транспорт с таким гос. номером уже есть в БД!; ",
"timestamp": 1689438543459
}
⚪ POST /api/vehicle/filter
Request body: application/json
Json contain: Map<String, String>
Example value:
{
"brand": "Audi",
"type": "Седан"
}
Description: Vehicles successfully filtered!
Media type: application/json
Json return: List<VehicleDTO>
Example value:
[
{
"vehicleId": 67,
"brand": "Audi",
"model": "R8",
"category": "A",
"stateNumber": "F287FR777",
"type": "Седан",
"yearOfRealise": 2012,
"hasTrailer": false
},
{
"vehicleId": 58,
"brand": "Audi",
"model": "Q7",
"category": "A",
"stateNumber": "G283GR777",
"type": "Седан",
"yearOfRealise": 2022,
"hasTrailer": false
}
]
Description: Exceptions that will throws if sended category or type dont exist in db!
Because VehicleCategory and VehicleType data in db added manually.
Media type: application/json
Example value:
{
"statusCode": 400,
"message":
VehicleType Entity with entered name not found!;
VehicleCategory Entity with entered name not found!" ,
"timestamp": 1689438720293
}
⚪ GET /api/type/
Request body: No parameters
Description: Successfully found!
Media type: application/json
Json return: List<VehicleTypeDTO>
Example value:
[
{
"typeId": 1,
"typeName": "Седан"
},
{
"typeId": 2,
"typeName": "Хэтчбек"
},
{
"typeId": 3,
"typeName": "Минивэн"
}
]
⚪ POST /api/type/get-one
Request body: application/json
Request contain: Long id
Example value:
2
Description: Vehicle Type successfully found!
Media type: application/json
Json return: VehicleTypeDTO
Example value:
{
"typeId": 2,
"typeName": "Хэтчбек"
}
Description: VehicleType not Found!
Media type: application/json
Example value:
{
"statusCode": 400,
"message": "VehicleType Entity with entered ID not found!",
"timestamp": 1679587416465
}
⚪ GET /api/category/
Request body: No parameters
Description: Successfully found!
Media type: application/json
Json return: List<VehicleCategoryDTO>
Example value:
[
{
"categoryId": 1,
"categoryName": "A"
},
{
"categoryId": 2,
"categoryName": "B"
},
{
"categoryId": 3,
"categoryName": "C"
}
]
⚪ POST /api/category/get-one
Request body: application/json
Request contain: Long id
Example value:
2
Description: Vehicle Type successfully found!
Media type: application/json
Json return: VehicleTypeDTO
Example value:
{
"categoryId": 2,
"categoryName": "B"
}
Description: VehicleType not Found!
Media type: application/json
Example value:
{
"statusCode": 400,
"message": "VehicleCategory Entity with entered ID not found!",
"timestamp": 1679587413465
}
⚪ vehicleId
type: integer64
⚪ brand
type: string
⚪ model
type: string
⚪ category
type: string
⚪ stateNumber
type: string
⚪ type
type: integer32
⚪ hasTrailer
type: boolean
⚪ typeId
type: integer64
⚪ typeName
type: string
⚪ categoryId
type: integer64
⚪ categoryName
type: string