-
Notifications
You must be signed in to change notification settings - Fork 0
[CHORE] Swagger @Tag로 API 그룹핑 #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
744d32d
feat(device): 유도등 방향 명령 API 및 웹소켓 신호 구현 - #44
kyeonG0210 992c513
fix(test): AiAnalysisClient 빈 생성 시 필요한 ai-service base-url 테스트 프로퍼티 누…
kyeonG0210 ac5d997
docs(websocket): TrainingEventPublisher의 낡은 주석 정리 - #40
kyeonG0210 a357c16
fix(config): aws.dynamodb.table-name 프로퍼티 위치 오류 수정
kyeonG0210 153e3e0
docs(swagger): 컨트롤러별 @Tag 추가로 API 그룹핑 - #46
kyeonG0210 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
src/main/java/com/saferoute/domain/analysis/controller/AnalysisController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/main/java/com/saferoute/domain/device/client/IoTLightPiClient.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| package com.saferoute.domain.device.client; | ||
|
|
||
| import com.saferoute.domain.device.entity.IoTLightDirection; | ||
| import com.saferoute.global.api.error.IoTLightErrorCode; | ||
| import com.saferoute.global.api.exception.ApiException; | ||
| import java.time.Duration; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.stereotype.Component; | ||
| import org.springframework.web.reactive.function.client.WebClient; | ||
|
|
||
| // Spring 서버가 라즈베리파이(Pi Flask 서버)에 유도등 방향 명령을 전달하는 책임을 전담한다. | ||
| // Pi 쪽 API 스펙: POST {piEndpoint}/lights/direction, body { lightCode, direction } | ||
| // 하드웨어(Pi) 구현은 아직 없어 실제 통신은 검증되지 않았다 - 스펙만 정의된 상태이며 | ||
| // 로컬 Flask 스텁 서버로 대신 검증한다. | ||
| @Slf4j | ||
| @Component | ||
| public class IoTLightPiClient { | ||
|
|
||
| private static final Duration TIMEOUT = Duration.ofSeconds(3); | ||
| private static final String DIRECTION_PATH = "/lights/direction"; | ||
|
|
||
| private final WebClient webClient; | ||
|
|
||
| public IoTLightPiClient(WebClient.Builder webClientBuilder) { | ||
| this.webClient = webClientBuilder.build(); | ||
| } | ||
|
|
||
| public void sendDirection(String piEndpoint, String lightCode, IoTLightDirection direction) { | ||
| try { | ||
| webClient.post() | ||
| .uri(piEndpoint + DIRECTION_PATH) | ||
| .bodyValue(new PiLightDirectionRequest(lightCode, direction)) | ||
| .retrieve() | ||
| .toBodilessEntity() | ||
| .block(TIMEOUT); | ||
| } catch (RuntimeException exception) { | ||
| log.warn("라즈베리파이 통신 실패: piEndpoint={}, lightCode={}", piEndpoint, lightCode, exception); | ||
| throw new ApiException(IoTLightErrorCode.DEVICE_UNREACHABLE, exception); | ||
| } | ||
| } | ||
| } |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/saferoute/domain/device/client/PiLightDirectionRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package com.saferoute.domain.device.client; | ||
|
|
||
| import com.saferoute.domain.device.entity.IoTLightDirection; | ||
|
|
||
| // 라즈베리파이(Pi Flask 서버)로 전달하는 방향 명령 요청 body. | ||
| // lightCode는 IoTLight.code를 그대로 사용한다 - Pi 한 대가 릴레이 2대(분기점 2곳)를 담당하므로 | ||
| // 어느 분기점에 대한 명령인지 Pi 쪽이 이 값으로 식별한다. | ||
| public record PiLightDirectionRequest( | ||
| String lightCode, | ||
| IoTLightDirection direction | ||
| ) {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/main/java/com/saferoute/domain/device/dto/request/ChangeLightDirectionRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package com.saferoute.domain.device.dto.request; | ||
|
|
||
| import com.saferoute.domain.device.entity.IoTLightDirection; | ||
| import jakarta.validation.constraints.NotNull; | ||
|
|
||
| public record ChangeLightDirectionRequest( | ||
| @NotNull IoTLightDirection direction | ||
| ) {} |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/saferoute/domain/device/dto/request/UpdatePiEndpointRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package com.saferoute.domain.device.dto.request; | ||
|
|
||
| import jakarta.validation.constraints.NotBlank; | ||
|
|
||
| public record UpdatePiEndpointRequest( | ||
| @NotBlank String piEndpoint | ||
| ) {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/main/java/com/saferoute/domain/device/dto/response/LightDirectionResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package com.saferoute.domain.device.dto.response; | ||
|
|
||
| import com.saferoute.domain.device.entity.IoTLightDirection; | ||
| import java.time.Instant; | ||
| import java.util.UUID; | ||
|
|
||
| public record LightDirectionResponse( | ||
| UUID lightId, | ||
| IoTLightDirection direction, | ||
| Instant updatedAt | ||
| ) {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/java/com/saferoute/domain/device/service/IoTLightDirectionStore.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package com.saferoute.domain.device.service; | ||
|
|
||
| import com.saferoute.domain.device.entity.IoTLightDirection; | ||
| import java.util.Map; | ||
| import java.util.UUID; | ||
| import java.util.concurrent.ConcurrentHashMap; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| // 유도등의 실시간 방향 상태를 보관한다. 훈련별로 바뀌는 동적 상태라 IoTLight 엔티티(DB)에는 | ||
| // 저장하지 않고 서버 메모리에서만 관리한다 (IoTLight 클래스 상단 주석 참고). | ||
| // 서버가 재시작되면 초기화되는 것을 의도한 동작으로 본다 - 재시작 후에는 관리자가 방향을 다시 지정해야 한다. | ||
| @Component | ||
| public class IoTLightDirectionStore { | ||
|
|
||
| private final Map<UUID, IoTLightDirection> directions = new ConcurrentHashMap<>(); | ||
|
|
||
| public void update(UUID lightId, IoTLightDirection direction) { | ||
| directions.put(lightId, direction); | ||
| } | ||
|
|
||
| public IoTLightDirection get(UUID lightId) { | ||
| return directions.getOrDefault(lightId, IoTLightDirection.OFF); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
유도등별 명령 순서를 직렬화하세요.
동일
lightId에 대한 두 요청은 동시에 Pi 호출을 수행할 수 있습니다. 이전 요청의 Pi 응답이 늦게 도착하면 최신 요청이 저장한 방향을 이전 방향으로 덮어쓰고, 오래된 상태 이벤트를 발행할 수 있습니다. Pi의 실제 방향과 메모리 상태 및 WebSocket 이벤트가 불일치합니다.Pi 응답 수신, 상태 저장, 이벤트 등록을 유도등별 단일 명령 큐 또는 순서 보장 가능한 버전 처리로 직렬화하세요.
🤖 Prompt for AI Agents