diff --git a/.gitignore b/.gitignore
index 667aaef..8cf54e8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,3 +31,4 @@ build/
### VS Code ###
.vscode/
+.env
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index bbdda38..e7c219c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -38,7 +38,11 @@
org.springframework.boot
spring-boot-starter-webmvc
-
+
+ software.amazon.awssdk
+ s3
+ 2.25.0
+
org.postgresql
postgresql
@@ -49,6 +53,12 @@
lombok
true
+
+ me.paulschwarz
+ spring-dotenv
+ 4.0.0
+
+
org.springframework.boot
spring-boot-starter-webclient-test
diff --git a/src/main/java/net/hackyourfuture/hyfshop/product/B2Config.java b/src/main/java/net/hackyourfuture/hyfshop/product/B2Config.java
new file mode 100644
index 0000000..1ffef8e
--- /dev/null
+++ b/src/main/java/net/hackyourfuture/hyfshop/product/B2Config.java
@@ -0,0 +1,43 @@
+package net.hackyourfuture.hyfshop.product;
+
+import java.net.URI;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
+import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
+import software.amazon.awssdk.regions.Region;
+import software.amazon.awssdk.services.s3.S3Client;
+import software.amazon.awssdk.services.s3.presigner.S3Presigner;
+
+
+@Configuration
+public class B2Config {
+
+ @Value("${b2.endpoint}") private String endpoint;
+ @Value("${b2.region}") private String region;
+ @Value("${b2.access-key}") private String accessKey;
+ @Value("${b2.secret-key}") private String secretKey;
+
+ @Bean
+ public S3Client s3Client() {
+ return S3Client.builder()
+ .credentialsProvider(StaticCredentialsProvider.create(
+ AwsBasicCredentials.create(accessKey, secretKey)))
+ .endpointOverride(URI.create(endpoint))
+ .region(Region.of(region))
+ .build();
+ }
+
+ @Bean
+ public S3Presigner s3Presigner() {
+ return S3Presigner.builder()
+ .credentialsProvider(StaticCredentialsProvider.create(
+ AwsBasicCredentials.create(accessKey, secretKey)))
+ .endpointOverride(URI.create(endpoint))
+ .region(Region.of(region))
+ .build();
+ }
+}
diff --git a/src/main/java/net/hackyourfuture/hyfshop/product/FileService.java b/src/main/java/net/hackyourfuture/hyfshop/product/FileService.java
new file mode 100644
index 0000000..bbd9667
--- /dev/null
+++ b/src/main/java/net/hackyourfuture/hyfshop/product/FileService.java
@@ -0,0 +1,4 @@
+package net.hackyourfuture.hyfshop.product;
+
+public class FileService {
+}
diff --git a/src/main/java/net/hackyourfuture/hyfshop/product/Product.java b/src/main/java/net/hackyourfuture/hyfshop/product/Product.java
index ccc6204..a3108b9 100644
--- a/src/main/java/net/hackyourfuture/hyfshop/product/Product.java
+++ b/src/main/java/net/hackyourfuture/hyfshop/product/Product.java
@@ -6,6 +6,7 @@
import lombok.Setter;
import java.math.BigDecimal;
+import java.util.Map;
@AllArgsConstructor
@NoArgsConstructor
@@ -17,4 +18,5 @@ public class Product {
private BigDecimal price;
private String category;
private String imageUrl;
+ private Map details;
}
diff --git a/src/main/java/net/hackyourfuture/hyfshop/product/ProductRepository.java b/src/main/java/net/hackyourfuture/hyfshop/product/ProductRepository.java
index 2766734..8414a19 100644
--- a/src/main/java/net/hackyourfuture/hyfshop/product/ProductRepository.java
+++ b/src/main/java/net/hackyourfuture/hyfshop/product/ProductRepository.java
@@ -4,12 +4,20 @@
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.simple.JdbcClient;
import org.springframework.stereotype.Repository;
+import tools.jackson.core.type.TypeReference;
+import tools.jackson.databind.ObjectMapper;
+
+import java.lang.reflect.Type;
import java.util.List;
+import java.util.Map;
+
+import static org.springframework.web.servlet.function.RequestPredicates.param;
@Repository
@AllArgsConstructor
public class ProductRepository {
private final JdbcClient jdbcClient;
+ private static final ObjectMapper objectMapper = new ObjectMapper();
public static final RowMapper PRODUCT_ROW_MAPPER = (rs, _) -> {
var product = new Product();
@@ -18,12 +26,23 @@ public class ProductRepository {
product.setPrice(rs.getBigDecimal("price"));
product.setCategory(rs.getString("category"));
product.setImageUrl(rs.getString("image_url"));
+ try {
+ String json = rs.getString("details");
+ if (json != null) {
+ product.setDetails(objectMapper.readValue(json,
+ new TypeReference