From 11665aa7025f964c182ba086a99205f10e109196 Mon Sep 17 00:00:00 2001
From: jjyu <jjyu@ahnu.edu.cn>
Date: Mon, 23 Sep 2024 11:36:03 +0800
Subject: [PATCH 1/3] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=B8=AA?=
 =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=8E=A5=E5=8F=A3=EF=BC=8C=E5=AE=9E=E7=8E=B0?=
 =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=BF=99=E8=BE=B9=E7=9A=84service=E5=B1=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/main/java/com/jjyu/controller/UserController.java | 11 +++++++++++
 src/main/java/com/jjyu/service/UserService.java       |  3 ++-
 .../java/com/jjyu/service/impl/UserServiceImpl.java   |  3 ++-
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/main/java/com/jjyu/controller/UserController.java b/src/main/java/com/jjyu/controller/UserController.java
index 1e73f1d1d..2bd9968e5 100644
--- a/src/main/java/com/jjyu/controller/UserController.java
+++ b/src/main/java/com/jjyu/controller/UserController.java
@@ -4,16 +4,27 @@ import com.jjyu.entity.Result;
 import com.jjyu.entity.User;
 import com.jjyu.service.UserService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.List;
+
 @RestController
 @RequestMapping("/user")
 public class UserController {
     @Autowired
     private UserService userService;
 
+    @GetMapping("/list")
+    public Result list() {
+        List<User> userList = userService.list();
+        // 打印所有的用户
+        userList.stream().toList().forEach(System.out::println);
+        return Result.success();
+    }
+
     @PostMapping("/register")
     public Result register(String name, String email, String password) {
         //查询用户
diff --git a/src/main/java/com/jjyu/service/UserService.java b/src/main/java/com/jjyu/service/UserService.java
index e1d1ca921..30861a4c6 100644
--- a/src/main/java/com/jjyu/service/UserService.java
+++ b/src/main/java/com/jjyu/service/UserService.java
@@ -1,8 +1,9 @@
 package com.jjyu.service;
 
+import com.baomidou.mybatisplus.extension.service.IService;
 import com.jjyu.entity.User;
 
-public interface UserService {
+public interface UserService extends IService<User> {
     User findByUserName(String userName);
 
     User register(String name, String email, String password);
diff --git a/src/main/java/com/jjyu/service/impl/UserServiceImpl.java b/src/main/java/com/jjyu/service/impl/UserServiceImpl.java
index fcf68014e..86bc14a8b 100644
--- a/src/main/java/com/jjyu/service/impl/UserServiceImpl.java
+++ b/src/main/java/com/jjyu/service/impl/UserServiceImpl.java
@@ -1,5 +1,6 @@
 package com.jjyu.service.impl;
 
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.jjyu.dao.UserMapper;
 import com.jjyu.entity.User;
 import com.jjyu.service.UserService;
@@ -8,7 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 @Service
-public class UserServiceImpl implements UserService {
+public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
     @Autowired
     private UserMapper userMapper;
 
-- 
Gitee


From 158640f5f3b6b17868f1e89a52c0425998e2e380 Mon Sep 17 00:00:00 2001
From: jjyu <jjyu@ahnu.edu.cn>
Date: Mon, 23 Sep 2024 11:36:41 +0800
Subject: [PATCH 2/3] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=B8=AA?=
 =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=8E=A5=E5=8F=A3=EF=BC=8C=E5=AE=9E=E7=8E=B0?=
 =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=BF=99=E8=BE=B9=E7=9A=84service=E5=B1=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/main/java/com/jjyu/controller/UserController.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/com/jjyu/controller/UserController.java b/src/main/java/com/jjyu/controller/UserController.java
index 2bd9968e5..126b62b06 100644
--- a/src/main/java/com/jjyu/controller/UserController.java
+++ b/src/main/java/com/jjyu/controller/UserController.java
@@ -22,7 +22,7 @@ public class UserController {
         List<User> userList = userService.list();
         // 打印所有的用户
         userList.stream().toList().forEach(System.out::println);
-        return Result.success();
+        return Result.success(userList);
     }
 
     @PostMapping("/register")
-- 
Gitee


From be443c628b110e31bfed35973baaca7e0cdcd78f Mon Sep 17 00:00:00 2001
From: jjyu <jjyu@ahnu.edu.cn>
Date: Mon, 23 Sep 2024 11:43:46 +0800
Subject: [PATCH 3/3] =?UTF-8?q?=E5=AE=8C=E5=96=84controller=20=E6=8E=A5?=
 =?UTF-8?q?=E5=8F=A3=EF=BC=8C=E6=96=B0=E5=A2=9E=E5=88=A0=E9=99=A4=E5=8A=9F?=
 =?UTF-8?q?=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../com/jjyu/controller/UserController.java     | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/main/java/com/jjyu/controller/UserController.java b/src/main/java/com/jjyu/controller/UserController.java
index 126b62b06..8e89505a4 100644
--- a/src/main/java/com/jjyu/controller/UserController.java
+++ b/src/main/java/com/jjyu/controller/UserController.java
@@ -4,12 +4,10 @@ import com.jjyu.entity.Result;
 import com.jjyu.entity.User;
 import com.jjyu.service.UserService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
+import java.util.Map;
 
 @RestController
 @RequestMapping("/user")
@@ -25,6 +23,17 @@ public class UserController {
         return Result.success(userList);
     }
 
+    @DeleteMapping("/delete")
+    public Result delete(String name) {
+        // 删除用户
+        Map<String, Object> nameMap = Map.of("name", name);
+        boolean remove = userService.removeByMap(nameMap);
+        if (remove) {
+            return Result.success("删除成功");
+        }
+        return Result.error("删除失败");
+    }
+
     @PostMapping("/register")
     public Result register(String name, String email, String password) {
         //查询用户
-- 
Gitee