今天实现后端代码
package com.example.controller; import com.example.pojo.Department; import com.example.pojo.Result; import com.example.pojo.Staff; import com.example.service.LogONService; import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.Update; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @RestController @RequestMapping("/user") public class LogONController { @Autowired private LogONService logONService; @GetMapping("/getByUser") public Result getByUser(String username, String password) { return Result.success(logONService.getByUser(username, password)); } @GetMapping("/count") public ResponseEntity<Integer> count() { int re = logONService.count(); return ResponseEntity.ok(re); } @GetMapping("/selectCount") public Result selectCount() { return Result.success(logONService.selectCount()); } @PostMapping("/addStaff") public Result addStaff(@RequestBody Staff staff) { logONService.addStaff(staff); return Result.success(staff); } @PostMapping("/updateStaff") public Result updateStaff(@RequestBody Staff staff) { logONService.updateStaff(staff); return Result.success(staff); } @GetMapping("/getStaff") public Result getStaff() { return Result.success(logONService.getStaff()); } @DeleteMapping("deleteStaff/{id}") public Result deleteStaff(@PathVariable("id") String id) { logONService.deleteStaff(id); return Result.success(); } @GetMapping("/aDep/{id}") public ResponseEntity<Integer> aDep(@PathVariable("id") String id) { int re = logONService.aDep(id); return ResponseEntity.ok(re); } @GetMapping("/bDep/{name}") public ResponseEntity<Integer> bDep(@PathVariable("name") String name) { int re = logONService.bDep(name); return ResponseEntity.ok(re); } @GetMapping("/cDep/{id}") public ResponseEntity<Integer> cDep(@PathVariable("id") String id) { int re = logONService.cDep(id); return ResponseEntity.ok(re); } @GetMapping("/dDep") public ResponseEntity<Integer> dDep() { int re = logONService.dDep(); return ResponseEntity.ok(re); } @PostMapping("/addDep") public Result addDep(@RequestBody Department department) { logONService.addDep(department); return Result.success(department); } @PostMapping("/updateDep") public Result updateDep(@RequestBody Department department) { logONService.updateDep(department); return Result.success(department); } @DeleteMapping("/deleteDep/{id}") public Result deleteDep(@PathVariable("id") String id) { logONService.deleteDep(id); return Result.success(); } @GetMapping("/updateRole/{id}") public Result updateRole(@PathVariable("id") String id) { logONService.updateRole(id); return Result.success(logONService.selectById(id)); } @GetMapping("/selectById/{id}") public Result selectById(@PathVariable("id") String id) { return Result.success(logONService.selectById(id)); } @GetMapping("/update/{id}/{new1}") public Result update(@PathVariable("id") String id,@PathVariable("new1") String password) { logONService.update(id,password); return Result.success(selectById(id)); } }
StaffController
package com.example.controller; import com.example.pojo.Attendance; import com.example.pojo.Result; import com.example.service.StaffService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @RestController @RequestMapping("/staff") public class StaffController { @Autowired private StaffService staffService; @PostMapping("/add") public Result addStaff(@RequestBody Attendance attendance) { staffService.addStaff(attendance); return Result.success(attendance); } @GetMapping("/count") public ResponseEntity<Integer> count() { int re = staffService.count(); return ResponseEntity.ok(re); } @GetMapping("/low") public Result low() { return Result.success(staffService.low()); } @GetMapping("/approve/{name}/{type}/{i}") public Result approve(@PathVariable("name") String name, @PathVariable("type") String type, @PathVariable("i") String i) { staffService.approve(name, type, i); return Result.success(); } }
标签:return,11.17,id,Result,logONService,import,public From: https://www.cnblogs.com/zzqq1314/p/17910881.html