Skip to content

Commit

Permalink
feat(teams): add jacketNr to team model (#132)
Browse files Browse the repository at this point in the history
* feat(teams): add jacketNr to team model

* refactor(teams): use string for jacketNr

* fix: update default value
  • Loading branch information
NuttyShrimp authored Apr 4, 2024
1 parent a653a57 commit 2306e50
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/main/java/telraam/database/daos/TeamDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public interface TeamDAO extends DAO<Team> {
List<Team> getAll();

@Override
@SqlUpdate("INSERT INTO team (name, baton_id) VALUES (:name, :batonId)")
@SqlUpdate("INSERT INTO team (name, baton_id, jacket_nr) VALUES (:name, :batonId, :jacketNr)")
@GetGeneratedKeys({"id"})
int insert(@BindBean Team team);

Expand All @@ -33,9 +33,6 @@ public interface TeamDAO extends DAO<Team> {
int deleteById(@Bind("id") int id);

@Override
@SqlUpdate("UPDATE team SET " +
"name = :name," +
"baton_id = :batonId " +
"WHERE id = :id")
@SqlUpdate("UPDATE team SET name = :name, baton_id = :batonId, jacket_nr = :jacketNr WHERE id = :id")
int update(@Bind("id") int id, @BindBean Team modelObj);
}
1 change: 1 addition & 0 deletions src/main/java/telraam/database/models/Team.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class Team {
private Integer id;
private String name;
private Integer batonId;
private String jacketNr = "INVALID";

public Team(String name) {
this.name = name;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table team add jacket_nr varchar(255) default 'INVALID' not null;
2 changes: 2 additions & 0 deletions src/test/java/telraam/database/daos/TeamDAOTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,14 @@ void testUpdateDoesUpdate() {
int testid = teamDAO.insert(testTeam);
testTeam.setId(testid);
testTeam.setName("postupdate");
testTeam.setJacketNr("10");
int updatedRows = teamDAO.update(testid, testTeam);
assertEquals(1, updatedRows);

Optional<Team> dbTeam = teamDAO.getById(testid);
assertFalse(dbTeam.isEmpty());
assertEquals("postupdate", dbTeam.get().getName());
assertEquals("10", dbTeam.get().getJacketNr());
}

@Test
Expand Down

0 comments on commit 2306e50

Please sign in to comment.