From f95caa6877fb2acf7055ae4e42e533b3af6c33cf Mon Sep 17 00:00:00 2001 From: seungtaekhong Date: Wed, 14 Feb 2024 14:59:59 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20HTTP=20controller=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/HttpClientInferenceController.java | 51 +++++++++---------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/src/main/java/solution/gdsc/PathPal/domain/inference/api/HttpClientInferenceController.java b/src/main/java/solution/gdsc/PathPal/domain/inference/api/HttpClientInferenceController.java index cd98f7a..d165477 100644 --- a/src/main/java/solution/gdsc/PathPal/domain/inference/api/HttpClientInferenceController.java +++ b/src/main/java/solution/gdsc/PathPal/domain/inference/api/HttpClientInferenceController.java @@ -7,29 +7,23 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; -import solution.gdsc.PathPal.domain.client.domain.Client; -import solution.gdsc.PathPal.domain.client.domain.ImageInference; import solution.gdsc.PathPal.domain.client.repository.ClientRepository; import solution.gdsc.PathPal.domain.client.repository.ImageInferenceRepository; -import solution.gdsc.PathPal.domain.inference.domain.Inference; import solution.gdsc.PathPal.domain.inference.service.InferenceService; import solution.gdsc.PathPal.domain.inference.service.SocketClient; -import javax.imageio.stream.FileImageOutputStream; -import java.io.File; import java.util.HashMap; -import java.util.List; import java.util.Map; @RestController @RequiredArgsConstructor public class HttpClientInferenceController { - private final SocketClient socketClient = new SocketClient("127.0.0.1", 9999, 2000); - private final InferenceService inferenceService; - private final ImageInferenceRepository imageInferenceRepository; - private final ClientRepository clientRepository; - private final int savePeriodMilliSeconds = 5000; +// private final SocketClient socketClient = new SocketClient("127.0.0.1", 9999, 2000); +// private final InferenceService inferenceService; +// private final ImageInferenceRepository imageInferenceRepository; +// private final ClientRepository clientRepository; + //private final int savePeriodMilliSeconds = 5000; private String path = "/home/hsk4991149/static/image/"; //private String path = "/Users/hongseungtaeg/Desktop/project/GDSC-PathPal/PathPal/src/main/resources/static/"; @@ -39,22 +33,22 @@ public class HttpClientInferenceController { public String inference(@RequestParam(name = "image") MultipartFile file, @RequestParam(name = "time") Integer time, HttpServletRequest request) throws Exception { - HttpSession session = request.getSession(); - - SessionInfo sessionInfo = sessionMap.get(session); - if (sessionInfo == null) { - int expectedSeconds = time == null ? 500 : time; - Client client = new Client(expectedSeconds); - clientRepository.save(client); - - long currentTimeMillis = System.currentTimeMillis(); - sessionInfo = new SessionInfo(client, currentTimeMillis, expectedSeconds); - sessionMap.put(session, sessionInfo); - } - - byte[] bytes = file.getBytes(); - List inferences = socketClient.inferenceImage(bytes); - String responseMessage = inferenceService.convertInference2(inferences); +// HttpSession session = request.getSession(); +// +// SessionInfo sessionInfo = sessionMap.get(session); +// if (sessionInfo == null) { +// int expectedSeconds = time == null ? 500 : time; +// Client client = new Client(expectedSeconds); +// clientRepository.save(client); +// +// long currentTimeMillis = System.currentTimeMillis(); +// sessionInfo = new SessionInfo(client, currentTimeMillis, expectedSeconds); +// sessionMap.put(session, sessionInfo); +// } +// +// byte[] bytes = file.getBytes(); +// List inferences = socketClient.inferenceImage(bytes); +// String responseMessage = inferenceService.convertInference2(inferences); // long currentTimeMillis = System.currentTimeMillis(); // if (currentTimeMillis - sessionInfo.recentlySaveTime > savePeriodMilliSeconds) { @@ -72,6 +66,7 @@ public String inference(@RequestParam(name = "image") MultipartFile file, // System.err.println("이미지 저장 실패"); // } // } - return responseMessage; + // return responseMessage; + return "test"; } }