|
|
|
@ -1,11 +1,15 @@
|
|
|
|
package kr.re.etri.autoflow.controllers;
|
|
|
|
package kr.re.etri.autoflow.controllers;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
|
|
|
|
|
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
import kr.re.etri.autoflow.payload.request.EdgePkgInfoRequest;
|
|
|
|
import kr.re.etri.autoflow.payload.request.EdgePkgInfoRequest;
|
|
|
|
import kr.re.etri.autoflow.service.ExternalAuthService;
|
|
|
|
import kr.re.etri.autoflow.service.ExternalAuthService;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
|
|
|
import org.springframework.http.MediaType;
|
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
@ -46,20 +50,28 @@ public class ExternalAuthController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "외부 Edge 패키지 등록", description = "외부 서버로 Edge 패키지 정보를 파일과 함께 전송하여 등록합니다.")
|
|
|
|
@Operation(
|
|
|
|
@PostMapping(value = "/add", consumes = {"multipart/form-data"})
|
|
|
|
summary = "외부 Edge 패키지 등록",
|
|
|
|
|
|
|
|
description = "외부 서버로 Edge 패키지 정보를 파일과 함께 전송하여 등록합니다.",
|
|
|
|
|
|
|
|
security = @SecurityRequirement(name = "bearerAuth")
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
@PostMapping(value = "/add", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
|
|
|
public ResponseEntity<?> addEdgePackage(
|
|
|
|
public ResponseEntity<?> addEdgePackage(
|
|
|
|
@Parameter(description = "로그인 시 발급받은 Bearer 토큰") @RequestHeader("Authorization") String bearerToken,
|
|
|
|
@RequestHeader("Authorization") String bearerToken,
|
|
|
|
@Parameter(description = "Edge 패키지 등록 요청 데이터") @RequestPart("edgePkgInfoVO") EdgePkgInfoRequest edgePkgInfoRequest,
|
|
|
|
@RequestPart("edgePkgInfoVO") String edgePkgInfoJson,
|
|
|
|
@Parameter(description = "업로드할 패키지 파일") @RequestPart(value = "file", required = false) MultipartFile file
|
|
|
|
@RequestPart(value = "file", required = false) MultipartFile file
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
|
|
|
|
|
|
EdgePkgInfoRequest edgePkgInfoRequest = mapper.readValue(edgePkgInfoJson, EdgePkgInfoRequest.class);
|
|
|
|
|
|
|
|
|
|
|
|
Object response = externalAuthService.uploadEdgePackage(bearerToken, edgePkgInfoRequest, file);
|
|
|
|
Object response = externalAuthService.uploadEdgePackage(bearerToken, edgePkgInfoRequest, file);
|
|
|
|
return ResponseEntity.ok(response);
|
|
|
|
return ResponseEntity.ok(response);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (JsonProcessingException e) {
|
|
|
|
|
|
|
|
return ResponseEntity.badRequest().body("잘못된 JSON 형식: " + e.getMessage());
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
return ResponseEntity.internalServerError().body(
|
|
|
|
return ResponseEntity.internalServerError().body("파일 업로드 실패: " + e.getMessage());
|
|
|
|
String.format("파일 업로드 실패: %s", e.getMessage())
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|