diff --git a/src/main/frontend/src/components/Navbar.tsx b/src/main/frontend/src/components/Navbar.tsx index 58f30e3b..d96506f8 100644 --- a/src/main/frontend/src/components/Navbar.tsx +++ b/src/main/frontend/src/components/Navbar.tsx @@ -6,14 +6,14 @@ import Link from 'next/link'; const NavigationBar = () =>{ const [isAuthenticated, setIsAuthenticated] = useState(false); - // useEffect(() => { - // const fetchAuthStatus = async () => { - // const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/oauth/status`, { credentials: 'include' }); - // const data = await response.json(); - // setIsAuthenticated(data.authenticated); - // }; - // fetchAuthStatus(); - // }, []); + useEffect(() => { + const fetchAuthStatus = async () => { + const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/oauth/status`, { credentials: 'include' }); + const data = await response.json(); + setIsAuthenticated(data.authenticated); + }; + fetchAuthStatus(); + }, []); const handleLogout = async () => { try { diff --git a/src/main/java/com/project/sanhak/card/controller/cardController.java b/src/main/java/com/project/sanhak/card/controller/cardController.java index a8c548a1..4a4b7e5e 100644 --- a/src/main/java/com/project/sanhak/card/controller/cardController.java +++ b/src/main/java/com/project/sanhak/card/controller/cardController.java @@ -88,7 +88,7 @@ public ResponseEntity createAiCard(HttpSession session, } card.setECImageUrl(imageUrl); card.setECPdfUrl(pdfUrl); - String result = cardService.createAiCard(card, pdfFile); + String result = cardService.createAiCard(card, imageUrl); if ("success".equals(result)) { return ResponseEntity.ok("{\"status\":\"success\"}"); } else { @@ -140,9 +140,10 @@ public ResponseEntity updateAiCard(@PathVariable int card_id, if (updatedCardDTO.getReflection() != null) { existingCard.setECReflection(updatedCardDTO.getReflection()); } - if(imageFile != null &&!imageFile.isEmpty()){ + String imageUrl = null; + if (imageFile != null && !imageFile.isEmpty()) { S3FileService.deleteFileFromS3(updatedCardDTO.getImageUrl()); - String imageUrl = null; + imageUrl = null; if (!imageFile.isEmpty()) { try { imageUrl = S3FileService.upload(imageFile); @@ -153,7 +154,7 @@ public ResponseEntity updateAiCard(@PathVariable int card_id, } card.setECImageUrl(imageUrl); } - if(pdfFile != null &&!pdfFile.isEmpty()){ + if (pdfFile != null && !pdfFile.isEmpty()) { S3FileService.deleteFileFromS3(updatedCardDTO.getPdfUrl()); String pdfUrl; try { @@ -167,14 +168,14 @@ public ResponseEntity updateAiCard(@PathVariable int card_id, card.setECPdfUrl(pdfUrl); } else { try { - pdfFile= S3FileService.downloadFileAsMultipartFile(updatedCardDTO.getPdfUrl()); + pdfFile = S3FileService.downloadFileAsMultipartFile(updatedCardDTO.getPdfUrl()); } catch (Exception e) { log.error("PDF 파일 다운로드 실패: {}", e.getMessage()); return ResponseEntity.status(500).body("PDF 파일 다운로드에 실패했습니다."); } } // Call the service to update the card - String result = cardService.updateAiCard(user, card_id, existingCard, imageFile, pdfFile); + String result = cardService.updateAiCard(user, card_id, existingCard, imageFile, imageUrl); if ("success".equals(result)) { return ResponseEntity.ok("{\"status\":\"success\"}"); } else { diff --git a/src/main/java/com/project/sanhak/card/service/cardService.java b/src/main/java/com/project/sanhak/card/service/cardService.java index a06275dc..38246d6a 100644 --- a/src/main/java/com/project/sanhak/card/service/cardService.java +++ b/src/main/java/com/project/sanhak/card/service/cardService.java @@ -55,8 +55,7 @@ public aiCardDTO getTargetCard(int ecId) { .orElse(null); } - public String createAiCard(ExperienceCard card, MultipartFile pdfFile) throws IOException { - String pdfText = extractTextFromPDF(pdfFile); // PDF에서 텍스트 추출 + public String createAiCard(ExperienceCard card, String pdfFileURL) throws IOException { String url = apiBaseUrl + "/createCard"; // 요청 데이터 설정 @@ -67,7 +66,7 @@ public String createAiCard(ExperienceCard card, MultipartFile pdfFile) throws IO requestData.put("tool", toolsList); requestData.put("position", positionList); requestData.put("reflection", card.getECReflection()); - requestData.put("pdfText", pdfText); + requestData.put("pdfURL", pdfFileURL); System.out.println("Request data: " + requestData); @@ -122,8 +121,7 @@ public String extractTextFromPDF(MultipartFile pdfFile) throws IOException { } } - public String updateAiCard(User user, int cardId, ExperienceCard card, MultipartFile imageFile, MultipartFile pdfFile) throws IOException { - String pdfText = extractTextFromPDF(pdfFile); + public String updateAiCard(User user, int cardId, ExperienceCard card, MultipartFile imageFile, String pdfFileURL) throws IOException { // 외부 API 요청으로 요약 생성 String url = apiBaseUrl + "/createCard"; Map requestData = new HashMap<>(); @@ -133,7 +131,7 @@ public String updateAiCard(User user, int cardId, ExperienceCard card, Multipart requestData.put("tool", toolsList); requestData.put("position", positionList); requestData.put("reflection", card.getECReflection()); - requestData.put("pdfText", pdfText); + requestData.put("pdfURL", pdfFileURL); System.out.println("Request data: " + requestData); diff --git a/src/main/java/com/project/sanhak/company/dto/companyDTO.java b/src/main/java/com/project/sanhak/company/dto/companyDTO.java index cb7206b8..398f0860 100644 --- a/src/main/java/com/project/sanhak/company/dto/companyDTO.java +++ b/src/main/java/com/project/sanhak/company/dto/companyDTO.java @@ -1,5 +1,6 @@ package com.project.sanhak.company.dto; +import com.project.sanhak.card.dto.skill; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @@ -19,5 +20,5 @@ public class companyDTO { @Schema(description = "부가 설명") private String description; @Schema(description = "스킬 종류") - private List skill; + private List skill; } diff --git a/src/main/java/com/project/sanhak/company/service/companyService.java b/src/main/java/com/project/sanhak/company/service/companyService.java index 31093cb4..db6a15da 100644 --- a/src/main/java/com/project/sanhak/company/service/companyService.java +++ b/src/main/java/com/project/sanhak/company/service/companyService.java @@ -1,7 +1,9 @@ package com.project.sanhak.company.service; +import com.project.sanhak.card.dto.skill; import com.project.sanhak.company.dto.companyDTO; import com.project.sanhak.company.repository.companyRepository; +import com.project.sanhak.category.repository.categoryRepository; import com.project.sanhak.domain.company.Company; import com.project.sanhak.domain.user.Badge; import com.project.sanhak.domain.user.User; @@ -23,6 +25,9 @@ public class companyService { private companyRepository companyRepository; @Autowired private BadgeRepository badgeRepository; + @Autowired + private categoryRepository categoryRepository; + private final WebClient webClient; public companyService(WebClient webClient) { @@ -54,7 +59,9 @@ public List recommandCompany(User user) { for (Map companyData : companyResponseList) { String comName = companyData.get("company_name").toString(); String comPosition = companyData.get("result").toString(); - List comSkill =(List) companyData.get("extracted_skills"); + List skills = categoryRepository.findByCSNameIn((List) companyData.get("extracted_skills")).stream() + .map(codeSkill -> new skill(codeSkill.getCSId(), codeSkill.getCSName())) + .collect(Collectors.toList()); List companies = companyRepository.findByCOMNameAndCOMPosition(comName, comPosition); for (Company company : companies) { @@ -64,7 +71,7 @@ public List recommandCompany(User user) { dto.setLocation(company.getCOMPlace()); dto.setPosition(company.getCOMPosition()); dto.setDescription(company.getCOMDescription()); - dto.setSkill(comSkill); + dto.setSkill(skills); companyDTOList.add(dto); } }