[MODIFY] EdgeSW 등록 로직에 sw_type 분기 추가, 외부 API URL 구분 및 메서드 파라미터 수정

main
bjkim 8 months ago
parent 6e9282c350
commit c8757c2877

@ -192,6 +192,10 @@ public class ExternalAuthController {
@RequestParam("user_id")
@Schema(description = "사용자 ID", example = "admin", required = true) String userId,
@RequestParam("sw_type")
@Schema(description = "0 = sw 1= edge로 db전송", example = "1", required = true) int sw_type,
@RequestParam("creation_datetime")
@Schema(
description = "생성 일시 (ISO-8601 형식, UTC)",
@ -227,7 +231,7 @@ public class ExternalAuthController {
}
// DB 등록 (파일 업로드 성공 후)
String result = edgeSWUploadService.registerMetadata(edgeSWVO);
String result = edgeSWUploadService.registerMetadata(edgeSWVO, sw_type);
return ResponseEntity.ok(result);

@ -112,7 +112,6 @@ public class DynamicMinioAttachmentService {
)) {
return is.readAllBytes();
} catch (io.minio.errors.ErrorResponseException e) {
// statusCode() 제거, 필요한 정보만 출력
throw new RuntimeException(
"MinIO 서버가 요청을 거부했습니다: " + objectName +
", 코드=" + e.errorResponse().code() +
@ -132,8 +131,6 @@ public class DynamicMinioAttachmentService {
}
}
/** YAML 텍스트 읽기 */
public String readYamlText(String objectName, String type) {
MinioClient client = getClientByType(type);

@ -27,7 +27,9 @@ public class EdgeSWUploadService {
private final S3Client s3Client;
private final RestTemplate restTemplate;
private final String s3Bucket = "etri-advehicle-s3-bucket"; // S3 버킷 이름
private final String externalApiUrl = "https://a659120d3e2ff43ff94087b29396fd96-1057696791.ap-northeast-2.elb.amazonaws.com/api/datamanager/edge-sw/add-db";
private final String externalApiUrl_edge = "https://a659120d3e2ff43ff94087b29396fd96-1057696791.ap-northeast-2.elb.amazonaws.com/api/datamanager/edge-sw/add-db";
private final String externalApiUrl_sw = "https://a659120d3e2ff43ff94087b29396fd96-1057696791.ap-northeast-2.elb.amazonaws.com/api/datamanager/advehicle-sw/add-db";
public EdgeSWUploadService(S3Client s3Client, RestTemplate restTemplate) {
this.s3Client = s3Client;
@ -64,10 +66,14 @@ public class EdgeSWUploadService {
public String registerMetadata(EdgeSWVO edgeSWVO) {
//sw_type 0 = sw
// sw_type 1 = edge
public String registerMetadata(EdgeSWVO edgeSWVO, int sw_type) {
log.info("registerMetadata : " + edgeSWVO.toString());
String result_url = "";
// JSON Body 구성
Map<String, Object> jsonBody = new HashMap<>();
jsonBody.put("creation_datetime", edgeSWVO.getCreation_datetime());
@ -99,7 +105,13 @@ public class EdgeSWUploadService {
HttpEntity<Map<String, Object>> requestEntity = new HttpEntity<>(jsonBody, headers);
ResponseEntity<String> response = restTemplate.postForEntity(externalApiUrl, requestEntity, String.class);
if(sw_type ==0) {
result_url = externalApiUrl_sw;
}
else {
result_url = externalApiUrl_edge;
}
ResponseEntity<String> response = restTemplate.postForEntity(result_url, requestEntity, String.class);
return response.getBody();
}

Loading…
Cancel
Save