Skip to content

Commit 0b86c23

Browse files
fix: add nullable to application service
1 parent 6c37671 commit 0b86c23

File tree

6 files changed

+21
-13
lines changed

6 files changed

+21
-13
lines changed

src/main/kotlin/application/service/RoomService.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ object RoomService {
3434
class GetRoomEnvironmentalInfo(
3535
private val roomId: RoomData.RoomId,
3636
private val roomRepository: RoomRepository,
37-
) : ApplicationService<Future<Room>> {
37+
) : ApplicationService<Future<Room?>> {
3838

39-
override fun execute(): Future<Room> = roomRepository.getRoomEnvironmentalInfo(roomId)
39+
override fun execute(): Future<Room?> = roomRepository.getRoomEnvironmentalInfo(roomId)
4040
}
4141
}

src/main/kotlin/application/service/SurgeryReportService.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ object SurgeryReportService {
3434
class SurgeryReportInfoService(
3535
private val processId: String,
3636
private val repository: SurgeryReportRepository,
37-
) : ApplicationService<Future<SurgeryReport>> {
37+
) : ApplicationService<Future<SurgeryReport?>> {
3838

39-
override fun execute(): Future<SurgeryReport> = repository.getSurgeryReportInfo(processId)
39+
override fun execute(): Future<SurgeryReport?> = repository.getSurgeryReportInfo(processId)
4040
}
4141
}

src/main/kotlin/infrastructure/api/handlers/ProcessManualEventHandler.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class ProcessManualEventHandler(private val vertx: Vertx) : Handler<RoutingConte
3838
"process-manual-events",
3939
Json.encodeToString(event),
4040
)
41-
routingContext.response().setStatusCode(HttpResponseStatus.OK.code()).end()
41+
routingContext.response().setStatusCode(HttpResponseStatus.NO_CONTENT.code()).end()
4242
}
4343
}
4444
}

src/main/kotlin/infrastructure/webclient/WebClient.kt

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,13 @@ class WebClient(vertx: Vertx) :
9090
}
9191
}
9292

93-
override fun getSurgeryReportInfo(processId: String): Future<SurgeryReport> =
93+
override fun getSurgeryReportInfo(processId: String): Future<SurgeryReport?> =
9494
client.getAbs("$SR_URI/reports/$processId").send().map {
95-
Json.decodeFromString<SurgeryReportApiDto>(it.bodyAsString()).toSurgeryReport()
95+
if (it.statusCode() == HttpResponseStatus.OK.code()) {
96+
Json.decodeFromString<SurgeryReportApiDto>(it.bodyAsString()).toSurgeryReport()
97+
} else {
98+
null
99+
}
96100
}
97101

98102
override fun integrateReport(
@@ -104,11 +108,15 @@ class WebClient(vertx: Vertx) :
104108
it.statusCode() == HttpResponseStatus.NO_CONTENT.code()
105109
}
106110

107-
override fun getRoomEnvironmentalInfo(roomId: RoomData.RoomId): Future<Room> =
111+
override fun getRoomEnvironmentalInfo(roomId: RoomData.RoomId): Future<Room?> =
108112
client.getAbs("$BM_URI/rooms/${roomId.id}").send().map {
109-
Json.decodeFromString<RoomPresentation.RoomDto>(
110-
it.bodyAsString(),
111-
).toRoom()
113+
if (it.statusCode() == HttpResponseStatus.OK.code()) {
114+
Json.decodeFromString<RoomPresentation.RoomDto>(
115+
it.bodyAsString(),
116+
).toRoom()
117+
} else {
118+
null
119+
}
112120
}
113121

114122
override fun getSurgicalProcessInfoByRoomId(

src/main/kotlin/usecase/repository/RoomRepository.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ interface RoomRepository {
2525
/**
2626
* Return the environmental information of a [Room] by its [roomId].
2727
*/
28-
fun getRoomEnvironmentalInfo(roomId: RoomData.RoomId): Future<Room>
28+
fun getRoomEnvironmentalInfo(roomId: RoomData.RoomId): Future<Room?>
2929
}

src/main/kotlin/usecase/repository/SurgeryReportRepository.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ interface SurgeryReportRepository {
2626
/**
2727
* get the surgery report info given the [processId].
2828
*/
29-
fun getSurgeryReportInfo(processId: String): Future<SurgeryReport>
29+
fun getSurgeryReportInfo(processId: String): Future<SurgeryReport?>
3030

3131
/**
3232
* Integrate the surgery report.

0 commit comments

Comments
 (0)