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 ea6adc961bfbfe7b9be3f959c19fd3b6a964c813..8a516fedc30b4a9ffee299a9c3f8b5f6b20661a2 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
+ *
+ *
+ * @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 "删除失败";
+ }
+ }
+
+
}