Skip to content

Commit ff3de9d

Browse files
committed
changes
1 parent 5321bfc commit ff3de9d

File tree

5 files changed

+27
-0
lines changed

5 files changed

+27
-0
lines changed

reactive-micro-service/employee-service/src/main/java/com/prs/services/EmployeeApplication.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.springframework.boot.autoconfigure.SpringBootApplication;
99
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
1010
import org.springframework.cloud.openfeign.EnableFeignClients;
11+
import org.springframework.context.annotation.Bean;
1112
import org.springframework.core.io.ClassPathResource;
1213
import org.springframework.data.r2dbc.connectionfactory.init.ConnectionFactoryInitializer;
1314
import org.springframework.data.r2dbc.connectionfactory.init.ResourceDatabasePopulator;

reactive-micro-service/employee-service/src/main/java/com/prs/services/employee/controller/EmployeeController.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
import org.apache.logging.log4j.LogManager;
66
import org.apache.logging.log4j.Logger;
77
import org.springframework.beans.factory.annotation.Autowired;
8+
import org.springframework.http.HttpStatus;
9+
import org.springframework.web.bind.annotation.DeleteMapping;
810
import org.springframework.web.bind.annotation.GetMapping;
911
import org.springframework.web.bind.annotation.PathVariable;
1012
import org.springframework.web.bind.annotation.PostMapping;
1113
import org.springframework.web.bind.annotation.PutMapping;
1214
import org.springframework.web.bind.annotation.RequestBody;
15+
import org.springframework.web.bind.annotation.ResponseStatus;
1316
import org.springframework.web.bind.annotation.RestController;
1417

1518
import com.prs.services.employee.model.Employee;
@@ -50,6 +53,12 @@ public Flux<Employee> findAll() {
5053
return service.findAll();
5154
}*/
5255

56+
@DeleteMapping("/delete/{id}")
57+
@ResponseStatus(HttpStatus.NO_CONTENT)
58+
public Mono<Void> deleteById(@PathVariable("id") Long id){
59+
return service.deleteById(id);
60+
61+
}
5362
@GetMapping("/department/{departmentId}")
5463
public Flux<Employee> findByDepartment(@PathVariable("departmentId") Long departmentId) {
5564
LOGGER.info("Employee find: departmentId={}", departmentId);

reactive-micro-service/employee-service/src/main/java/com/prs/services/employee/service/EmployeeServiceImpl.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ public Flux<Employee> findAll() {
4848
public Mono<Employee> findById(Long id) {
4949
return repository.findById(id).map(entityToVomapper);
5050
}
51+
52+
@Override
53+
public Mono<Void> deleteById(Long id) {
54+
return repository.deleteById(id);
55+
}
5156

5257
@Override
5358
public Flux<Employee> findByCollege(Long collegeId) {

reactive-micro-service/employee-service/src/main/java/com/prs/services/employee/service/IEmployeeService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,7 @@ public interface IEmployeeService {
1919

2020
Flux<Employee> findByDepartment(Long departmentId);
2121

22+
Mono<Void> deleteById(Long id);
23+
2224

2325
}

reactive-micro-service/student-service/src/main/java/com/prs/services/student/controller/StudentController.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
package com.prs.services.student.controller;
22

3+
import java.time.Duration;
4+
import java.time.LocalTime;
5+
36
import org.slf4j.Logger;
47
import org.slf4j.LoggerFactory;
58
import org.springframework.beans.factory.annotation.Autowired;
69
import org.springframework.http.HttpStatus;
10+
import org.springframework.http.MediaType;
711
import org.springframework.web.bind.annotation.DeleteMapping;
812
import org.springframework.web.bind.annotation.GetMapping;
913
import org.springframework.web.bind.annotation.PathVariable;
@@ -75,4 +79,10 @@ public Flux<Student> findByCollege(@PathVariable("collegeId") Long collegeId) {
7579
return service.findByCollege(collegeId);
7680
}
7781

82+
@GetMapping(path = "/stream-flux", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
83+
public Flux<String> streamFlux() {
84+
return Flux.interval(Duration.ofSeconds(1)).limitRequest(5)
85+
.map(sequence -> "Flux - " + LocalTime.now().toString()).log();
86+
}
87+
7888
}

0 commit comments

Comments
 (0)