From 3204c52cc5d0086f57788ecaa391a21a56522599 Mon Sep 17 00:00:00 2001 From: Wales Yu Date: Sat, 17 Jul 2021 17:00:04 +0800 Subject: [PATCH] =?UTF-8?q?fixed:=20=E5=AE=8C=E5=96=84=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../swpu/controller/SwpuUserController.java | 79 ++++++++++++++++++- 1 file changed, 78 insertions(+), 1 deletion(-) diff --git a/swpu-spring-projects-boot/src/main/java/com/swpu/controller/SwpuUserController.java b/swpu-spring-projects-boot/src/main/java/com/swpu/controller/SwpuUserController.java index ea6adc9..8a516fe 100644 --- a/swpu-spring-projects-boot/src/main/java/com/swpu/controller/SwpuUserController.java +++ b/swpu-spring-projects-boot/src/main/java/com/swpu/controller/SwpuUserController.java @@ -7,16 +7,93 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.List; +/** + * @author wales + *

+ * 用户表相关接口功能对外暴露 + */ @RestController @RequestMapping(value = "/swpu/user") public class SwpuUserController { + /** + * 自动帮助我们 new SwpuUserDao + */ @Resource private SwpuUserDao swpuUserDao; + /** + * 查询用户表中的所有数据 + * + * @return Object + */ @GetMapping(value = "/findAll") public Object findAll() { - List list = swpuUserDao.findAll(); + List list = swpuUserDao.findAll(); return list; } + + /** + *

+ * + * @param id id + * @return {@link Object} + */ + @GetMapping(value = "/findById") + public Object findById(@RequestParam(value = "id") String id) { + return swpuUserDao.findById(id); + } + + /** + * 增加 + * + * @param swpuUserEntity {@link SwpuUserEntity} + * @return {@link Object} + */ + @PostMapping(value = "/insert") + public Object insert(@RequestBody SwpuUserEntity swpuUserEntity) { + int flag = swpuUserDao.insert(swpuUserEntity); + if (flag > 0) { + return "插入成功: " + flag + " 条"; + } else { + return "插入失败"; + } + } + + /** + * 更新操作 + * + * @param swpuUserEntity {@link SwpuUserEntity} + * @return {@link Object} + */ + @PutMapping(value = "/update") + public Object update(@RequestBody SwpuUserEntity swpuUserEntity) { + int flag = swpuUserDao.update(swpuUserEntity); + if (flag > 0) { + return "更新成功: " + flag + " 条"; + } else { + return "更新失败"; + } + } + + /** + * Delete + * + * @param id id + * @return {@link Object} + */ + @DeleteMapping(value = "/del") + public Object del(@RequestParam(value = "id") String id) { + int flag = swpuUserDao.delete(id); + if (flag > 0) { + return "删除成功: " + flag + " 条"; + } else { + return "删除失败"; + } + } + + } -- Gitee