File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed
springboot_cache/src/main/java/com/hand/springboot_cache Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change 4
4
import com .hand .springboot_cache .service .EmployeeService ;
5
5
import org .springframework .beans .factory .annotation .Autowired ;
6
6
import org .springframework .cache .annotation .Cacheable ;
7
+ import org .springframework .web .bind .annotation .DeleteMapping ;
7
8
import org .springframework .web .bind .annotation .PathVariable ;
8
9
import org .springframework .web .bind .annotation .PutMapping ;
9
10
import org .springframework .web .bind .annotation .RequestBody ;
@@ -31,4 +32,9 @@ public Employee getEmpById(@PathVariable("id") Integer id) {
31
32
public Employee updateEmp (@ RequestBody Employee employee ) {
32
33
return employeeService .updateEmp (employee );
33
34
}
35
+
36
+ @ DeleteMapping ("/emp/{id}" )
37
+ public void delEmp (@ PathVariable ("id" ) Integer id ) {
38
+ employeeService .deleteEmp (id );
39
+ }
34
40
}
Original file line number Diff line number Diff line change 3
3
import com .hand .springboot_cache .entity .Employee ;
4
4
import com .hand .springboot_cache .mapper .EmployeeMapper ;
5
5
import org .springframework .beans .factory .annotation .Autowired ;
6
+ import org .springframework .cache .annotation .CacheEvict ;
6
7
import org .springframework .cache .annotation .CachePut ;
7
8
import org .springframework .cache .annotation .Cacheable ;
8
9
import org .springframework .stereotype .Service ;
@@ -46,4 +47,10 @@ public Employee updateEmp(Employee employee) {
46
47
}
47
48
48
49
50
+ @ CacheEvict (cacheNames = {"emp" }, key = "#id" , beforeInvocation = true )
51
+ public void deleteEmp (int id ) {
52
+ employeeMapper .deleteEmpById (id );
53
+ }
54
+
55
+
49
56
}
You can’t perform that action at this time.
0 commit comments