Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(teams): add jacketNr to team model #132

Merged
merged 3 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 Integer jacketNr;
NuttyShrimp marked this conversation as resolved.
Show resolved Hide resolved

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 integer default 0 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
Loading