This comprehensive RESTful API facilitates the management of tournaments, players, teams, referees, and other essential components.
Note: For PUT and POST operations, ensure that all required information is provided.
- JSON Web Token
- Operator
- Department
- Player
- Teacher
- Team Manager
- Team
- Tournament
- Referee
- Match
- Starting Eleven
- Individual Punishment
- Individual Score
- Tiebreaker
- Setting up the backend
GET /api/token/generate/{userEmail}
- Generate tokenGET /api/token/validate
- Validate token
POST /api/operator/login
- Operator loginGET /api/operator/{email}
- Get operator info (password will be null)
Note: to login as operator only email and password is required.
A JSON sample for operator
{
"email": "YourEmail",
"password": "YourPassword",
"name": "YourName",
"office": "YourOffice"
}
POST /api/dept
- Insert a new departmentPUT /api/dept/{deptCode}
- Update a departmentGET /api/depts
- Get all departmentsGET /api/dept/{deptCode}
- Get a specific departmentDELETE /api/dept/{deptCode}
- Delete a department
A JSON sample for department
{
"deptCode": 1,
"deptName": "Department Name",
"deptHeadName": "Department Head Name",
"deptShortName": "DeptShortName"
}
POST /api/player
- Insert a new playerPOST /api/player/login
- Login a playerPUT /api/player/{playerRegNo}
- Update a playerGET /api/player/{playerRegNo}
- Get a specific playerGET /api/dept/players/{deptCode}
- Get all players of a departmentDELETE /api/player/{playerRegNo}
- Delete a player
Note: to login as player only email and password is required.
A JSON sample for player
{
"playerRegNo": 1,
"playerName": "Player Name",
"playerDeptCode": 1,
"playerEmail": "abc@student.sust.edu",
"playerPassword": "***",
"playerImage": "local loc"
}
POST /api/techer
- Insert a new teacherGET /api/teacher/{email}
- Get a teacherGET /api/teachers/{deptCode}
- Get all the teachers of a dept
A JSON sample for teacher
{
"email": "teacher email",
"name": "teacher name",
"deptCode": 1,
"title": "lecturer"
}
POST /api/teammanager
- Insert a new team manager in a tournamentGET /api/teammanager/{tournamentId}/{email}
- Get a team manager of a tournamentGET /api/teammanagers/{tournamentId}
- Get all team managers of a tournamentDELETE /api/tournament/teammanager/{tournamentId}/{teamManagerEmail}
- Delete a team manager of a tournament
A JSON sample for team manager
{
"email": "Manager email",
"TournamentId": "TournamentID"
}
POST /api/team
- Insert a new teamPUT /api/tournament/team/{tournamentId}/{deptCode}
- Update a teamGET /api/tournament/team/{tournamentId}/{deptCode}
- Get a teamGET /api/tournament/teams/{tournamentId}
- Get all teams of a tournamentDELETE /api/tournament/team/{tournamentId}/{deptCode}
- Delete a team
A JSON sample for team
{
"tournamentId": "Tournament ID",
"teamSubmissionDate": "Submission Date",
"deptCode": 1,
"teamManagerEmail": "Team Manager",
"teamCaptainRegID": 1,
"playerRegNo": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],
"isKnockedOut": false
}
POST /api/tournament
- Insert a new tournamentPUT /api/tournament/{tournamentId}
- Update a tournamentGET /api/tournaments
- Get all tournamentsGET /api/tournament/{tournamentId}
- Get a specific tournamentDELETE /api/tournament/{tournamentId}
- Delete a tournament
A JSON sample for tournament
{
"tournamentId": "Tournament ID",
"tournamentName": "Tournament Name",
"startingDate": "Starting Date",
"endingDate": "Ending Date"
}
POST /api/referee
- Insert a new refereePUT /api/referee/{refereeId}
- Update a refereeGET /api/referees
- Get all refereesGET /api/referee/{refereeId}
- Get a specific refereeDELETE /api/referee/{refereeId}
- Delete a specific referee
A JSON sample for referee
{
"refereeID": 1,
"refereeName": "Referee Name",
"refereeInstitute": "Referee Institute"
}
POST /api/match
- Insert a new matchPUT /api/match/{tournamentId}/{matchId}
- Update a matchGET /api/tournament/matches/{tournamentId}
- Get all matches of a tournamentGET /api/tournament/match/{tournamentId}/{matchId}
- Get a specific match in a tournamentDELETE /api/match/{tournamentId}/{matchId}
- Delete a match
Note: For POST, everything can be nill except tournamentId and matchId.
A JSON sample for match
{
"tournamentId": "Tournament ID",
"matchId": "Match ID",
"matchDate": "Match Date",
"team1DeptCode": 1,
"team2DeptCode": 2,
"team1Score": 3,
"team2Score": 4,
"winnerTeamDeptCode": 1,
"matchRefereeID": 5,
"matchLinesman1ID": 6,
"matchLinesman2ID": 7,
"matchFourthRefereeID": 8,
"venue": "SUST Central Field"
}
POST /api/match/startingeleven
- Insert a new starting elevenPUT /api/match/startingeleven/{tournamentId}/{matchId}/{teamDeptCode}
- Update a starting elevenGET /api/match/startingeleven/{tournamentId}/{matchId}/{deptCode}
- Get the starting eleven of a team in a matchDELETE /api/match/startingeleven/{tournamentId}/{matchId}/{teamDeptCode}
- Delete a starting eleven
A JSON sample for starting eleven
{
"tournamentId": "Tournament ID",
"matchId": "Match ID",
"teamDeptCode": 1,
"startingPlayerRegNo": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
"substitutePlayerRegNo": [12, 13, 14],
"substituedPlayerRegNo": [1, 2, 3]
}
POST /api/individualpunishment
- Insert a new individual punishmentPUT /api/individualpunishment/{tournamentId}/{matchId}/{playerRegNo}
- Update an individual punishmentGET /api/tournament/individualpunishments/{tournamentId}
- Get all individual punishments (all players) of a tournamentGET /api/tournament/match/team/individualpunishments/{tournamentId}/{matchId}/{teamDeptCode}
- Get all individual punishments of a match by a teamGET /api/tournament/player/individualpunishments/{tournamentId}/{playerRegNo}
- Get all individual punishments of a player in a tournamentDELETE /api/individualpunishment/{tournamentId}/{matchId}/{playerRegNo}
- Delete an individual punishment
A JSON sample for individual punishment
{
"tournamentId": "Tournament ID",
"matchId": "Match ID",
"playerRegNo": 1,
"teamDeptCode": 1,
"punishmentType": "Punishment Type"
}
POST /api/individualscore
- Insert a new individual scorePUT /api/individualscore/{tournamentId}/{matchId}/{playerRegNo}
- Update an individual scoreGET /api/tournament/individualscores/{tournamentId}
- Get all individual scores (all players) of a tournamentGET /api/tournament/player/individualscores/{tournamentId}/{playerRegNo}
- Get all individual scores of a player in a tournamentGET /api/tournament/match/team/individualscores/{tournamentId}/{matchId}/{teamDeptCode}
- Get all individual scores of a match by a teamDELETE /api/individualscore/{tournamentId}/{matchId}/{playerRegNo}
- Delete an individual score
A JSON sample for individual score
{
"tournamentId": "Tournament ID",
"matchId": "Match ID",
"playerRegNo": 1,
"teamDeptCode": 1,
"goals": 2
}
POST /api/tiebreaker
- Insert a new tiebreakerPUT /api/tiebreaker/{tournamentId}/{matchId}
- Update a tiebreakerGET /api/tournament/tiebreakers/{tournamentId}
- Get all tiebreakers of a tournamentGET /api/tournament/tiebreaker/{tournamentId}/{matchId}
- Get a tiebreaker of a match of a tournamentDELETE /api/tiebreaker/{tournamentId}/{matchId}
- Delete a tiebreaker
A JSON sample for tiebreaker
{
"tournamentId": "Tournament ID",
"matchId": "Match ID",
"team1DeptCode": 1,
"team2DeptCode": 2,
"team1TieBreakerScore": 3,
"team2TieBreakerScore": 4
}
1. Database Setup
- Create a database named
ftms
in MySQL (XAAMP).
2. Table Creation
- Copy the codes inside
allTables.txt
file from theDatabase
folder. - Paste the contents of
allTables.txt
into your MySQL client (XAAMP) and execute the script to create the necessary tables.
3. Running the Backend
- Open the project in VS Code.
- Run the
main.go
file to start the backend server.
Congratulations! You're now ready to work with the backend.
Thank you for reviewing the documentation for My RESTful API. This API is designed to provide a comprehensive and user-friendly interface for managing tournaments, players, teams, referees, and other essential components for the SUST Football Tournament Management System.