diff --git a/src/main/java/team18/team18_be/apply/service/ApplyService.java b/src/main/java/team18/team18_be/apply/service/ApplyService.java index 804fd73..1930816 100644 --- a/src/main/java/team18/team18_be/apply/service/ApplyService.java +++ b/src/main/java/team18/team18_be/apply/service/ApplyService.java @@ -74,7 +74,7 @@ public ApplicationFormResponse findApplicationForm(Long applyId) { return applicationFormResponse; } - + //(고용주입장)구인글에 지원한 지원자 확인 public List searchApplicant(Long recruitmentId, User user) { Recruitment recruitment = findRecruitment(recruitmentId); @@ -94,6 +94,7 @@ private ApplierPerRecruitmentResponse createApplierPerRecruitmentResponse(Apply ); } + //(지원자 입장) 자신이 지원한 곳들 확인하는 메서드 public List searchMyAppliedRecruitments(User user) { return applyRepository.findByUser(user) .orElseThrow(() -> new NoSuchElementException("해당하는 지원이 없습니다.")) diff --git a/src/main/java/team18/team18_be/userInformation/controller/UserInformationController.java b/src/main/java/team18/team18_be/userInformation/controller/UserInformationController.java index 3b9870c..6810765 100644 --- a/src/main/java/team18/team18_be/userInformation/controller/UserInformationController.java +++ b/src/main/java/team18/team18_be/userInformation/controller/UserInformationController.java @@ -9,6 +9,7 @@ import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -87,8 +88,8 @@ public ResponseEntity fillInVisa(@RequestBody VisaRequest visaRequest, } @Operation(summary = "비자 정보 가져오기") - @GetMapping("/visa") - public ResponseEntity findVisa(@RequestParam("userId") Long userId) { + @GetMapping("/visa/{userId}") + public ResponseEntity findVisa(@PathVariable("userId") Long userId) { VisaResponse visaResponse = userInformationService.findVisa(userId); return ResponseEntity.ok(visaResponse); } diff --git a/src/main/java/team18/team18_be/userInformation/service/UserInformationService.java b/src/main/java/team18/team18_be/userInformation/service/UserInformationService.java index f88a9ac..c6f9052 100644 --- a/src/main/java/team18/team18_be/userInformation/service/UserInformationService.java +++ b/src/main/java/team18/team18_be/userInformation/service/UserInformationService.java @@ -49,23 +49,34 @@ public UserInformationService(ForeignerInformationRepository foreignerInformatio this.fileUtil = fileUtil; } + public Long createCompany(CompanyRequest companyRequest, MultipartFile logoImage, User user) { - byte[] imageFile = null; - String storedFileName = null; + String storedFileName = getStoredFileName(logoImage, user); + Company company = createCompanyEntity(companyRequest, storedFileName, user); + return companyRepository.save(company).getId(); + } + private String getStoredFileName(MultipartFile logoImage, User user) { if (logoImage == null) { - storedFileName = defaultLogoUrl; - } else { - imageFile = fileUtil.safelyGetBytes(logoImage) - .orElseThrow(() -> new IllegalArgumentException("multipart 파일을 읽지 못하였습니다.")); - storedFileName = gcsUploader.upload(imageFile, "companyLogo", - user.getId().toString() + "Real" + logoImage.getOriginalFilename()) - .orElseThrow(() -> new NoSuchElementException("파일 업로드에 실패했습니다.")); + return defaultLogoUrl; } - Company company = new Company(companyRequest.name(), companyRequest.industryOccupation(), - companyRequest.brand(), companyRequest.revenuePerYear(), storedFileName, user); - Company savedCompany = companyRepository.save(company); - return savedCompany.getId(); + byte[] imageFile = fileUtil.safelyGetBytes(logoImage) + .orElseThrow(() -> new IllegalArgumentException("multipart 파일을 읽지 못하였습니다.")); + + return gcsUploader.upload(imageFile, "companyLogo", + user.getId() + "Real" + logoImage.getOriginalFilename()) + .orElseThrow(() -> new NoSuchElementException("파일 업로드에 실패했습니다.")); + } + + private Company createCompanyEntity(CompanyRequest request, String logoUrl, User user) { + return new Company( + request.name(), + request.industryOccupation(), + request.brand(), + request.revenuePerYear(), + logoUrl, + user + ); } public List findCompany(User user) {