Add getShop to DAO, preparing to refactor shop loading

This commit is contained in:
P0nk
2023-03-29 21:14:19 +02:00
parent c71ca7f4d5
commit 2139147dcd
4 changed files with 55 additions and 8 deletions

View File

@@ -7,21 +7,32 @@ import database.maker.MakerReagentRowMapper;
import database.maker.MakerRecipeRowMapper;
import database.note.NoteRowMapper;
import database.shop.ShopItemRowMapper;
import database.shop.ShopRowMapper;
import org.jdbi.v3.core.Jdbi;
import org.jdbi.v3.core.mapper.RowMapper;
import javax.sql.DataSource;
import java.util.List;
public final class JdbiConfig {
private JdbiConfig() {}
public static Jdbi createConfigured(DataSource dataSource) {
return Jdbi.create(dataSource)
.registerRowMapper(new NoteRowMapper())
.registerRowMapper(new MakerReagentRowMapper())
.registerRowMapper(new MakerRecipeRowMapper())
.registerRowMapper(new MakerIngredientRowMapper())
.registerRowMapper(new MonsterDropRowMapper())
.registerRowMapper(new GlobalMonsterDropRowMapper())
.registerRowMapper(new ShopItemRowMapper());
final Jdbi jdbi = Jdbi.create(dataSource);
rowMappers().forEach(jdbi::registerRowMapper);
return jdbi;
}
private static List<RowMapper<?>> rowMappers() {
return List.of(
new NoteRowMapper(),
new MakerReagentRowMapper(),
new MakerRecipeRowMapper(),
new MakerIngredientRowMapper(),
new MonsterDropRowMapper(),
new GlobalMonsterDropRowMapper(),
new ShopRowMapper(),
new ShopItemRowMapper()
);
}
}