remove @springbootTest
Change-Id: Iea186ebd05298d2804b7c6b418581e2cc935fab7
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index e912ce2..6e7d6ce 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -1,6 +1,7 @@
-spring.datasource.password=050301
+spring.datasource.password=12345678
spring.datasource.username=root
spring.datasource.url=jdbc:mysql://localhost:3306/g8backend
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
+spring.sql.init.mode=always
-mybatis-plus.mapper-locations=classpath*:/mapper/**/*.xml
\ No newline at end of file
+mybatis-plus.mapper-locations=classpath*:/mapper/**/*.xml
diff --git a/src/main/resources/mapper/UserMapper.xml b/src/main/resources/mapper/UserMapper.xml
index e8ffb26..314c087 100644
--- a/src/main/resources/mapper/UserMapper.xml
+++ b/src/main/resources/mapper/UserMapper.xml
@@ -4,6 +4,9 @@
<mapper namespace="com.example.g8backend.mapper.UserMapper">
<select id="getUserByName" resultType="com.example.g8backend.entity.User">
- SELECT * FROM user WHERE name = #{name}
+ SELECT * FROM users WHERE user_name = #{userName}
+ </select>
+ <select id="getUserByEmail" resultType="com.example.g8backend.entity.User">
+ SELECT * FROM users WHERE email = #{email}
</select>
</mapper>
\ No newline at end of file
diff --git a/src/main/resources/schema.sql b/src/main/resources/schema.sql
new file mode 100644
index 0000000..2bd7010
--- /dev/null
+++ b/src/main/resources/schema.sql
@@ -0,0 +1,28 @@
+CREATE TABLE IF NOT EXISTS `users` (
+ user_id INT AUTO_INCREMENT PRIMARY KEY,
+ user_name VARCHAR(255) NOT NULL,
+ password VARCHAR(255) NOT NULL,
+ email VARCHAR(255) NOT NULL UNIQUE
+);
+
+CREATE TABLE IF NOT EXISTS `torrents` (
+ torrent_id INT AUTO_INCREMENT PRIMARY KEY,
+ user_id INT NOT NULL,
+ torrent_name VARCHAR(255) NOT NULL,
+ info_hash VARCHAR(255) NOT NULL,
+ file_size FLOAT NOT NULL,
+ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ FOREIGN KEY (user_id) REFERENCES users(user_id)
+);
+
+CREATE TABLE IF NOT EXISTS `peers` (
+ user_id INT NOT NULL,
+ torrent_id INT NOT NULL,
+ peer_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ ip_address VARCHAR(128) NOT NULL,
+ port INT NOT NULL,
+ uploaded FLOAT NOT NULL,
+ downloaded FLOAT NOT NULL,
+ FOREIGN KEY (user_id) REFERENCES users(user_id),
+ FOREIGN KEY (torrent_id) REFERENCES torrents(torrent_id)
+);