Skip to content

MorozovArYu/SprotDataStorage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lider IT REST API

Storage of sports team and players data

Version: 0.0.1

Get Started

With Docker

  1. Install Docker

  2. Download deploy file

  3. Execute the command

    "docker compose -f ^path to downloaded file^ up"

Manualy

  1. Install JRE 8

  2. Install PostgresQL

  3. Download LiderIt.jar

  4. Excecute:

    "java -jar LiderIt.jar ^user^ ^password^>"

if you don't want automatically generated bd:

  1. Execute createUser.sql

  2. Execute createDB.sql

  3. Execute:

    "java -jar LiderIt.jar"

REST API doc

Swagger: https://app.swaggerhub.com/apis/MOROZOWAU/REST/1.0.0

Alternative:

Table of Contents

TEAMS:

PLAYERS:

SERVER:

http://localhost:8080

Get list of teams

GET /sports/teams
  • Responses:
Index Code Response Body
1 200 application/json
2 204 empty
  • Response example{1}:
id name sportKind creationDate
1 Barcelona Football 1899-11-29
2 Avangard Hockey 1950-11-07

Table of Contents

Get list of teams and filtered by sportKind

GET /sport/teams/filters/sport-kinds
  • Parameters:
Name Type Required Description Example
sportKind String(query) True Kind of sport Football
  • Responses:
Index Code Response Body
1 200 application/json
2 204 empty
  • Response example{1}:
id name sportKind creationDate
1 Barcelona Football 1899-11-29
2 Manchester United Football 1879-01-01

Table of Contents

Get list of teams and filtered by date.

GET /sport/teams/filters/dates
  • Description:

    Get teams created between startDate and endDate

  • Parameters:

Name Type Required Description Example Format
startDate String(query) True From date 1800-01-01 'yyyy-MM-dd'
endDate String(query) True To date 2000-01-01 'yyyy-MM-dd'
  • Responses:
Index Code Response Body
1 200 application/json
2 204 empty
3 400 application/json
4 400 application/json
  • Response example{1}:
id name sportKind creationDate
1 Barcelona Football 1899-11-29
2 Manchester United Football 1879-01-01
3 Avangard Hockey 1950-11-07
  • Response example{3}:
message date
The endDate cannot be earlier than the startDate [2100-01-01, 2200-01-01] 2023-03-21T02:56:20.368
  • Response example{4}:
message date description
Failed to convert value of type 'java.lang.String' to required type 'java.time.LocalDate'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [@org.springframework.web.bind.annotation.RequestParam @org.springframework.format.annotation.DateTimeFormat java.time.LocalDate] for value '220-01-01'; nested exception is java.lang.IllegalArgumentException: Parse attempt failed for value [220-01-01] 2023-03-21T03:38:00.79 220-01-01: incorrect format. Format must be 'yyyy-MM-dd'

Table of Contents

Post a team

POST /sports/teams
  • Request body:
name sportKind creationDate
Barcelona Football 1899-11-29
  • Responses:
Index Code Response Body
1 201 application/json
2 400 empty
  • Response example{1}:
id name sportKind creationDate
1 Barcelona Football 1899-11-29

Table of Contents

Put a team by teamId

PUT /sports/teams/{teamId}
  • Description:

    Add team if teamId not found or change team info

  • Parameters:

Name Type Required Description Example
teamId Integer(path) True Numeric id of the team to get 1
  • Request body:
name sportKind creationDate
Barcelona Football 1899-11-29
  • Responses:
Index Code Response Body
1 200 application/json
2 201 application/json
3 400 empty
  • Response example{1}:
id name sportKind creationDate
1 Barcelona Football 1899-11-29
  • Response example{2}:
id name sportKind creationDate
2 Barcelona Football 1899-11-29

Table of Contents

Delete a team by teamId

DELETE /sports/teams/{teamId}
  • Parameters:
Name Type Required Description Example
teamId Integer(path) True Numeric id of the team to get 1
  • Responses:
Index Code Response Body
1 204 empty
2 404 application/json
  • Response example{2}:
message date
Team with id:1 not found 2023-03-21T02:56:20.368

Table of Contents

Get players of team by teamId

GET /sports/players/{teamId}
  • Description:

    If team found, return list of players in team

  • Parameters:

Name Type Required Description Example
teamId Integer(path) True Numeric ID of the team to get 1
  • Responses:
Index Code Response Body
1 200 application/json
2 204 empty
3 404 application/json
  • Response example{1}:
id name surname birthDate role
1 Ander Astralaga 2004-03-03 Goalkeeper
2 Arnau Tenas 2001-05-30 Goalkeeper
  • Response example{3}:
message date
Team with id:100 not found 2023-03-21T04:24:28.745

Table of Contents

Get list of players from team by role

GET /sports/players/{teamId}/filters/roles
  • Description:

    If team found get all players and filters them by role

  • Parameters:

Name Type Required Description Example
role String(query) True Name of role Goalkeeper
teamId Integer(path) True Numeric ID of the team to get 1
  • Request body:
name surname birthDate role
Ander Astralaga 2004-03-03 Goalkeeper
  • Responses:
Index Code Response Body
1 201 application/json
2 404 application/json
  • Response example{1}:
id name surname birthDate role
1 Ander Astralaga 2004-03-03 Goalkeeper
  • Response example{2}:
message date
Team with id:1 not found 2023-03-21T02:56:20.368

Table of Contents

Post players to team

POST /sports/players/{playerId}
  • Description:

    If team found, post player to it.

  • Request body:

name surname birthDate role
Ander Astralaga 2004-03-03 Goalkeeper
  • Parameters:
Name Type Required Description Example
teamId Integer(path) True Numeric ID of the team to get 1
  • Responses:
Index Code Response Body
1 201 application/json
2 404 application/json
  • Response example{1}:
id name surname birthDate role
1 Ander Astralaga 2004-03-03 Goalkeeper
  • Response example{2}:
message date
Team with id:1 not found 2023-03-21T02:56:20.368

Table of Contents

Change player team

PATCH /sports/players/{playerId}
  • Description:

    If team found and player found changes player team.

  • Parameters:

Name Type Required Description Example
newTeamId Integer(query) True Numeric ID of new team to player 2
playerId Integer(path) True Numeric ID of the player to get 1
  • Responses:
Index Code Response Body
1 200 application/json
2 400 application/json
  • Response example{1}:
id name sportKind creationDate
2 Manchester United Football 1879-01-01
  • Response example{2}:
message date
Team with id:1 not found 2023-03-21T02:56:20.368

Table of Contents

Put new data to the player by teamId

PUT /sports/players/{playerId}
  • Description:

    Change player information. Don't create player, if not found by id

  • Parameters:

Name Type Required Description Example
playerId Integer(path) True Numeric ID of the player to get 1
  • Request body:
name surname birthDate role
Ander Astralaga 2004-03-03 Goalkeeper
  • Responses:
Index Code Response Body
1 200 application/json
2 404 application/json
  • Response example{1}:
id name surname birthDate role
1 Ander Astralaga 2004-03-03 Goalkeeper
  • Response example{2}:
message date
Player with id:1 not found 2023-03-21T02:56:20.368

Table of Contents

Delete a player by playerId

DELETE /sports/players/{playerId}
  • Parameters:
Name Type Required Description Example
playerId Integer(path) True Numeric ID of the player to get 1
  • Responses:
Index Code Response Body
1 204 empty
2 404 application/json
  • Response example{2}:
message date
Player with id:1 not found 2023-03-21T02:56:20.368

Table of Contents

Releases

No releases published

Packages

No packages published