diff --git a/api/api-health-check/build.gradle b/api/api-health-check/build.gradle index 83a4fd8..e5b3daf 100644 --- a/api/api-health-check/build.gradle +++ b/api/api-health-check/build.gradle @@ -3,5 +3,6 @@ jar {enabled = true} dependencies { implementation project(':domain:domain-rds') + implementation project(':infra:infra-redis') implementation 'org.springframework.boot:spring-boot-starter-actuator' } diff --git a/api/api-health-check/src/main/java/com/drinkhere/apihealthcheck/presentations/HealthCheckController.java b/api/api-health-check/src/main/java/com/drinkhere/apihealthcheck/presentations/HealthCheckController.java index bb6ac38..03f74ee 100644 --- a/api/api-health-check/src/main/java/com/drinkhere/apihealthcheck/presentations/HealthCheckController.java +++ b/api/api-health-check/src/main/java/com/drinkhere/apihealthcheck/presentations/HealthCheckController.java @@ -1,16 +1,32 @@ package com.drinkhere.apihealthcheck.presentations; +import com.drinkhere.infraredis.util.RedisUtil; +import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("/api/v1/health-check") +@RequiredArgsConstructor public class HealthCheckController { + private final RedisUtil redisUtil; @GetMapping public String healthCheck() { return "This Turn is Blue!"; } + @GetMapping("redis") + public String redisConnectionCheck() { + // Redis에서 'id1' 키로 값을 가져옵니다. + String value = (String) redisUtil.getValue("id1"); + + // Redis에서 가져온 값이 있을 경우 반환, 없으면 기본 메시지 반환 + if (value != null) { + return "value"; + } else { + return "No value found for key 'id1'"; + } + } }