diff --git a/.idea/httpRequests/http-client.cookies b/.idea/httpRequests/http-client.cookies
index e69de29..edfe326 100644
--- a/.idea/httpRequests/http-client.cookies
+++ b/.idea/httpRequests/http-client.cookies
@@ -0,0 +1 @@
+# domain path name value date
diff --git a/.idea/httpRequests/http-requests-log.http b/.idea/httpRequests/http-requests-log.http
index e69de29..edd12c2 100644
--- a/.idea/httpRequests/http-requests-log.http
+++ b/.idea/httpRequests/http-requests-log.http
@@ -0,0 +1,80 @@
+POST http://127.0.0.1:3156/user/add?user_name=user1&email=user1@example.com
+User-Agent: IntelliJ HTTP Client/IntelliJ IDEA 2024.1.4
+Accept-Encoding: br, deflate, gzip, x-gzip
+Accept: */*
+content-length: 0
+
+<> 2026-01-01T214247.200.txt
+
+###
+
+POST http://127.0.0.1:3156/user/add?user_name=user1&email=user1@example.com
+User-Agent: IntelliJ HTTP Client/IntelliJ IDEA 2024.1.4
+Accept-Encoding: br, deflate, gzip, x-gzip
+Accept: */*
+content-length: 0
+
+<> 2026-01-01T214239.200.txt
+
+###
+
+POST http://127.0.0.1:3156/user/add?user_name=user1&email=user1@example.com
+User-Agent: IntelliJ HTTP Client/IntelliJ IDEA 2024.1.4
+Accept-Encoding: br, deflate, gzip, x-gzip
+Accept: */*
+content-length: 0
+
+<> 2026-01-01T214228.200.txt
+
+###
+
+POST http://127.0.0.1:3156/user/add?user_name=user1&email=user1@example.com
+User-Agent: IntelliJ HTTP Client/IntelliJ IDEA 2024.1.4
+Accept-Encoding: br, deflate, gzip, x-gzip
+Accept: */*
+content-length: 0
+
+<> 2026-01-01T213204.200.txt
+
+###
+
+GET http://127.0.0.1:3156/user/add?user_name=test&email=test@example.com
+User-Agent: IntelliJ HTTP Client/IntelliJ IDEA 2024.1.4
+Accept-Encoding: br, deflate, gzip, x-gzip
+Accept: */*
+content-length: 0
+
+<> 2026-01-01T213055.200.txt
+
+###
+
+POST http://127.0.0.1:3156/user/add?user_name=test&email=test@example.com
+User-Agent: IntelliJ HTTP Client/IntelliJ IDEA 2024.1.4
+Accept-Encoding: br, deflate, gzip, x-gzip
+Accept: */*
+content-length: 0
+
+<> 2026-01-01T213022.200.txt
+
+###
+
+POST http://127.0.0.1:3156/user/add?user_name=test&email=test@example.com
+User-Agent: IntelliJ HTTP Client/IntelliJ IDEA 2024.1.4
+Accept-Encoding: br, deflate, gzip, x-gzip
+Accept: */*
+content-length: 0
+
+<> 2026-01-01T213000.200.txt
+
+###
+
+POST http://127.0.0.1:3156/user/add
+User-Agent: IntelliJ HTTP Client/IntelliJ IDEA 2024.1.4
+Accept-Encoding: br, deflate, gzip, x-gzip
+Accept: */*
+content-length: 0
+
+<> 2026-01-01T212548.200.txt
+
+###
+
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
index 3b8e8ce..abfbb28 100644
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -4,5 +4,14 @@
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index e9078de..277eb3f 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,7 +4,20 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -17,6 +30,7 @@
@@ -26,6 +40,9 @@
+
+
+
+
+
+
@@ -54,6 +74,9 @@
"associatedIndex": 0
}]]>
+
+
+
@@ -63,11 +86,14 @@
+
+
+
+
+
+
@@ -130,11 +162,15 @@
+
+
+
+
@@ -147,13 +183,16 @@
1767189220570
-
+
+
+
+
false
true
diff --git a/src/main/java/top/gtb520/java/backend/apibackserver/api/p/product.java b/src/main/java/top/gtb520/java/backend/apibackserver/api/p/product.java
new file mode 100644
index 0000000..070cc15
--- /dev/null
+++ b/src/main/java/top/gtb520/java/backend/apibackserver/api/p/product.java
@@ -0,0 +1,4 @@
+package top.gtb520.java.backend.apibackserver.api.p;
+
+public class product {
+}
diff --git a/src/main/java/top/gtb520/java/backend/apibackserver/api/u/user.java b/src/main/java/top/gtb520/java/backend/apibackserver/api/u/user.java
index 42baa55..805cad0 100644
--- a/src/main/java/top/gtb520/java/backend/apibackserver/api/u/user.java
+++ b/src/main/java/top/gtb520/java/backend/apibackserver/api/u/user.java
@@ -2,6 +2,7 @@ package top.gtb520.java.backend.apibackserver.api.u;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import top.gtb520.java.backend.apibackserver.db.mysql;
@@ -61,8 +62,49 @@ public class user {
} finally {
db.close();
}
+
+ if (usersID.isEmpty()) {
+ usersID.add(Map.of("message", "用户不存在"));
+ }
+
System.out.println(usersID);
return usersID;
}
+ /*
+ 添加用户
+ 路径为:/user/add,协议为POST
+ 接收POST参数:user_name, email
+ 返回:[{"message": "用户添加成功"}], 如果用户已存在则返回[{"message": "用户已存在"}]
+ */
+
+ @PostMapping("/user/add")
+ public String AddUser(String user_name, String email) throws SQLException {
+ String status;
+
+ String INFO = "UserName: " + user_name + " Email: " + email;
+ echo(BLUE, "url: /user/add " + INFO);
+
+ mysql db = new mysql();
+ try {
+ ResultSet rs = db.query("SELECT * FROM user WHERE user_name = '" + user_name + "'");
+ if (rs.next()) {
+ status = "用户已存在";
+ } else {
+ db.update("INSERT INTO user (user_name, email) VALUES ('" + user_name + "', '" + email + "')");
+ status = "用户添加成功";
+ }
+ db.close();
+ } catch (SQLException e) {
+ throw new RuntimeException(e);
+ }
+ return status;
+ }
+
+ @GetMapping("/user/add")
+ public String AddUser() throws SQLException {
+ echo(BLUE, "url: /user/add");
+ return "添加用户";
+ }
+
}
diff --git a/target/api-back-server-0.0.1-SNAPSHOT.jar b/target/api-back-server-0.0.1-SNAPSHOT.jar
index 1cf1a9d..bdfb588 100644
Binary files a/target/api-back-server-0.0.1-SNAPSHOT.jar and b/target/api-back-server-0.0.1-SNAPSHOT.jar differ
diff --git a/target/api-back-server-0.0.1-SNAPSHOT.jar.original b/target/api-back-server-0.0.1-SNAPSHOT.jar.original
index aff0cdf..40ae974 100644
Binary files a/target/api-back-server-0.0.1-SNAPSHOT.jar.original and b/target/api-back-server-0.0.1-SNAPSHOT.jar.original differ
diff --git a/target/classes/top/gtb520/java/backend/apibackserver/api/p/product.class b/target/classes/top/gtb520/java/backend/apibackserver/api/p/product.class
new file mode 100644
index 0000000..f929cd4
Binary files /dev/null and b/target/classes/top/gtb520/java/backend/apibackserver/api/p/product.class differ
diff --git a/target/classes/top/gtb520/java/backend/apibackserver/api/u/user.class b/target/classes/top/gtb520/java/backend/apibackserver/api/u/user.class
index a08e6fc..3082828 100644
Binary files a/target/classes/top/gtb520/java/backend/apibackserver/api/u/user.class and b/target/classes/top/gtb520/java/backend/apibackserver/api/u/user.class differ
diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
index f12c86f..036d074 100644
--- a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
+++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
@@ -1,4 +1,5 @@
top\gtb520\java\backend\apibackserver\db\mysql$DbConfig.class
+top\gtb520\java\backend\apibackserver\api\p\product.class
top\gtb520\java\backend\apibackserver\db\mysql.class
top\gtb520\java\backend\apibackserver\utils\YamlFile_Utils.class
top\gtb520\java\backend\apibackserver\utils\tools.class
diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
index 65f4dd1..ba82685 100644
--- a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
+++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
@@ -1,3 +1,4 @@
+G:\Project\Java\api-back-server\src\main\java\top\gtb520\java\backend\apibackserver\api\p\product.java
G:\Project\Java\api-back-server\src\main\java\top\gtb520\java\backend\apibackserver\api\u\user.java
G:\Project\Java\api-back-server\src\main\java\top\gtb520\java\backend\apibackserver\db\mysql.java
G:\Project\Java\api-back-server\src\main\java\top\gtb520\java\backend\apibackserver\Main.java