From 1bbc98fa69b81813b0a7f91b7dccd311efd5377e Mon Sep 17 00:00:00 2001 From: test1 Date: Wed, 13 Nov 2024 13:56:06 +0900 Subject: [PATCH 1/4] =?UTF-8?q?refacotor=20:=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81=20=EB=B0=8F=20=EC=97=94?= =?UTF-8?q?=EB=93=9C=ED=8F=AC=EC=9D=B8=ED=8A=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apply/controller/ApplyController.java | 2 +- .../team18_be/apply/service/ApplyService.java | 3 +- .../service/UserInformationService.java | 36 ++++++++++++------- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/src/main/java/team18/team18_be/apply/controller/ApplyController.java b/src/main/java/team18/team18_be/apply/controller/ApplyController.java index 08350bf..1c41897 100644 --- a/src/main/java/team18/team18_be/apply/controller/ApplyController.java +++ b/src/main/java/team18/team18_be/apply/controller/ApplyController.java @@ -22,7 +22,7 @@ @RestController -@RequestMapping("/api/application") +@RequestMapping("/api") @Tag(name = "지원 API") public class ApplyController { 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/service/UserInformationService.java b/src/main/java/team18/team18_be/userInformation/service/UserInformationService.java index f88a9ac..7facc9a 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,33 @@ 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) { From b6b89ec08cb39366df7735cf0b868e7969721e03 Mon Sep 17 00:00:00 2001 From: test1 Date: Wed, 13 Nov 2024 13:57:58 +0900 Subject: [PATCH 2/4] =?UTF-8?q?refacotor=20:=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=A0=95=EB=A0=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../userInformation/service/UserInformationService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 7facc9a..c6f9052 100644 --- a/src/main/java/team18/team18_be/userInformation/service/UserInformationService.java +++ b/src/main/java/team18/team18_be/userInformation/service/UserInformationService.java @@ -63,7 +63,8 @@ private String getStoredFileName(MultipartFile logoImage, User user) { byte[] imageFile = fileUtil.safelyGetBytes(logoImage) .orElseThrow(() -> new IllegalArgumentException("multipart 파일을 읽지 못하였습니다.")); - return gcsUploader.upload(imageFile, "companyLogo", user.getId() + "Real" + logoImage.getOriginalFilename()) + return gcsUploader.upload(imageFile, "companyLogo", + user.getId() + "Real" + logoImage.getOriginalFilename()) .orElseThrow(() -> new NoSuchElementException("파일 업로드에 실패했습니다.")); } From 142e4f7fead83f4d3907450f1f36d6e6863445d6 Mon Sep 17 00:00:00 2001 From: test1 Date: Wed, 13 Nov 2024 18:39:57 +0900 Subject: [PATCH 3/4] =?UTF-8?q?feat=20:=20=EC=97=94=EB=93=9C=ED=8F=AC?= =?UTF-8?q?=EC=9D=B8=ED=8A=B8=20=EB=B3=B5=EA=B5=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/team18/team18_be/apply/controller/ApplyController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/team18/team18_be/apply/controller/ApplyController.java b/src/main/java/team18/team18_be/apply/controller/ApplyController.java index 1c41897..08350bf 100644 --- a/src/main/java/team18/team18_be/apply/controller/ApplyController.java +++ b/src/main/java/team18/team18_be/apply/controller/ApplyController.java @@ -22,7 +22,7 @@ @RestController -@RequestMapping("/api") +@RequestMapping("/api/application") @Tag(name = "지원 API") public class ApplyController { From 72c229497830c96868b8d3d6e06f4935880d27a6 Mon Sep 17 00:00:00 2001 From: test1 Date: Wed, 13 Nov 2024 21:06:17 +0900 Subject: [PATCH 4/4] =?UTF-8?q?fix=20:=20=EB=B9=84=EC=9E=90=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EA=B0=80=EC=A0=B8=EC=98=A4=EA=B8=B0=20pathVariable?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/UserInformationController.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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); }