-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Players are stored individually in club_player with existing ID checks
- Loading branch information
1 parent
ea9bb2f
commit e51756f
Showing
6 changed files
with
79 additions
and
5 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
backend/src/main/java/com/sg/backend/repositories/ClubRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.sg.backend.repositories; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.jdbc.core.JdbcTemplate; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import com.sg.backend.models.Club; | ||
|
||
@Repository | ||
public class ClubRepository { | ||
|
||
@Autowired | ||
private JdbcTemplate template; | ||
|
||
public void insert(Club player) { | ||
/* | ||
// check for existing entries | ||
// shifted this logic into a new method and @ClubService | ||
List<String> ids = template.queryForList(Queries.SQL_ID_CLUB_PLAYER, String.class); | ||
if (ids.contains(player.getId())) { | ||
System.out.println("Player ID already exists in database."); | ||
return; | ||
} | ||
*/ | ||
|
||
Object[] params = new Object[] { | ||
player.getId(), | ||
player.getName() | ||
}; | ||
template.update(Queries.SQL_INSERT_CLUB_PLAYER, params); | ||
} | ||
|
||
// return list of IDs in mySQL | ||
public List<String> getPlayerIds() { | ||
|
||
List<String> ids = template.queryForList(Queries.SQL_ID_CLUB_PLAYER, String.class); | ||
return ids; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters