add TorrentServiceTest and add new data table in schema.sql
Change-Id: I9d250db866e1c771db60e45e050ab23d1320f000
diff --git a/src/main/java/com/example/g8backend/util/TorrentUtil.java b/src/main/java/com/example/g8backend/util/TorrentUtil.java
index e6c1f3b..e8360bc 100644
--- a/src/main/java/com/example/g8backend/util/TorrentUtil.java
+++ b/src/main/java/com/example/g8backend/util/TorrentUtil.java
@@ -54,7 +54,7 @@
}
}
- private static byte[] readBytes(File file) throws IOException {
+ public static byte[] readBytes(File file) throws IOException {
try (InputStream in = new FileInputStream(file)) {
return in.readAllBytes();
}
diff --git a/src/main/resources/data.sql b/src/main/resources/data.sql
new file mode 100644
index 0000000..0907033
--- /dev/null
+++ b/src/main/resources/data.sql
@@ -0,0 +1 @@
+# 后面统一数据库数据用
\ No newline at end of file
diff --git a/src/main/resources/schema.sql b/src/main/resources/schema.sql
index e88ff07..952313e 100644
--- a/src/main/resources/schema.sql
+++ b/src/main/resources/schema.sql
@@ -41,6 +41,21 @@
FOREIGN KEY (user_id) REFERENCES users(user_id)
);
+CREATE TABLE IF NOT EXISTS `tags`(
+ tag_id INT AUTO_INCREMENT PRIMARY KEY,
+ tag_name VARCHAR(255) NOT NULL UNIQUE,
+ parent_id INT DEFAULT NULL,
+ FOREIGN KEY (parent_id) REFERENCES tags(tag_id)
+);
+
+CREATE TABLE IF NOT EXISTS `post_tag` (
+ post_id INT NOT NULL,
+ tag_id INT NOT NULL,
+ FOREIGN KEY (post_id) REFERENCES posts(post_id),
+ FOREIGN KEY (tag_id) REFERENCES tags(tag_id),
+ PRIMARY KEY (post_id, tag_id)
+);
+
CREATE TABLE IF NOT EXISTS `post_likes` (
user_id INT NOT NULL,
post_id INT NOT NULL,