From 9d8ba610f9f15edf8e1b15777b805d38fade793d Mon Sep 17 00:00:00 2001 From: hojeong2747 Date: Wed, 15 May 2024 20:24:03 +0900 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=EB=AA=A8=EC=A7=91=EC=9E=90=20?= =?UTF-8?q?=ED=94=84=EB=A1=9C=ED=95=84=20=EC=88=98=EC=A0=95=20API=20?= =?UTF-8?q?=EB=B0=98=ED=99=98=EA=B0=92=20=EC=88=98=EC=A0=95=20(#197)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../intermediary/controller/IntermediaryController.java | 4 ++-- .../dto/request/IntermediaryMyProfileRequest.java | 4 ++++ .../connectdog/domain/intermediary/entity/Intermediary.java | 6 ++++-- .../domain/intermediary/service/IntermediaryService.java | 5 +++-- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/pawwithu/connectdog/domain/intermediary/controller/IntermediaryController.java b/src/main/java/com/pawwithu/connectdog/domain/intermediary/controller/IntermediaryController.java index f9d024fe..58041f36 100644 --- a/src/main/java/com/pawwithu/connectdog/domain/intermediary/controller/IntermediaryController.java +++ b/src/main/java/com/pawwithu/connectdog/domain/intermediary/controller/IntermediaryController.java @@ -125,7 +125,7 @@ public ResponseEntity> getIntermediaryD return ResponseEntity.ok(response); } - @Operation(summary = "이동봉사 중개 - 홈 화면 정보 조회", description = "홈 화면 정보를 조회합니다.", + @Operation(summary = "모집자 - 홈 화면 정보 조회", description = "홈 화면 정보를 조회합니다.", security = { @SecurityRequirement(name = "bearer-key") }, responses = {@ApiResponse(responseCode = "200", description = "이동봉사 중개 홈 화면 정보 조회 성공") , @ApiResponse(responseCode = "400" @@ -138,7 +138,7 @@ public ResponseEntity getIntermediaryHome(@Authenti return ResponseEntity.ok(response); } - @Operation(summary = "이동봉사 중개 - 마이페이지 프로필 수정", description = "마이페이지 프로필을 수정합니다.", + @Operation(summary = "모집자 - 마이페이지 프로필 수정", description = "마이페이지 프로필을 수정합니다.", security = { @SecurityRequirement(name = "bearer-key") }, responses = {@ApiResponse(responseCode = "204", description = "마이페이지 프로필 수정 성공") , @ApiResponse(responseCode = "400" diff --git a/src/main/java/com/pawwithu/connectdog/domain/intermediary/dto/request/IntermediaryMyProfileRequest.java b/src/main/java/com/pawwithu/connectdog/domain/intermediary/dto/request/IntermediaryMyProfileRequest.java index 0cd8ce07..75f0f2c2 100644 --- a/src/main/java/com/pawwithu/connectdog/domain/intermediary/dto/request/IntermediaryMyProfileRequest.java +++ b/src/main/java/com/pawwithu/connectdog/domain/intermediary/dto/request/IntermediaryMyProfileRequest.java @@ -1,8 +1,12 @@ package com.pawwithu.connectdog.domain.intermediary.dto.request; +import jakarta.validation.constraints.Pattern; import jakarta.validation.constraints.Size; public record IntermediaryMyProfileRequest( + @Pattern(regexp = "^(http|https)://[a-zA-Z0-9-.]+\\.[a-zA-Z]{2,}(/\\S*)?$", + message = "url 형식을 입력해 주세요.") + String url, @Size(max=50, message = "한줄 소개는 50자 이하로 입력해 주세요.") String intro, @Size(max=50, message = "문의 받을 연락처는 50자 이하로 입력해 주세요.") diff --git a/src/main/java/com/pawwithu/connectdog/domain/intermediary/entity/Intermediary.java b/src/main/java/com/pawwithu/connectdog/domain/intermediary/entity/Intermediary.java index 844162eb..bbee08b1 100644 --- a/src/main/java/com/pawwithu/connectdog/domain/intermediary/entity/Intermediary.java +++ b/src/main/java/com/pawwithu/connectdog/domain/intermediary/entity/Intermediary.java @@ -55,14 +55,16 @@ public void passwordEncode(PasswordEncoder passwordEncoder) { this.password = passwordEncoder.encode(this.password); } - public void updateProfile(String profileImage, String intro, String contact, String guide) { + public void updateProfile(String profileImage, String url, String intro, String contact, String guide) { this.profileImage = profileImage; + this.url = url; this.intro = intro; this.contact = contact; this.guide = guide; } - public void updateProfileWithoutImage(String intro, String contact, String guide) { + public void updateProfileWithoutImage(String url, String intro, String contact, String guide) { + this.url = url; this.intro = intro; this.contact = contact; this.guide = guide; diff --git a/src/main/java/com/pawwithu/connectdog/domain/intermediary/service/IntermediaryService.java b/src/main/java/com/pawwithu/connectdog/domain/intermediary/service/IntermediaryService.java index 7a42d289..db5d77ac 100644 --- a/src/main/java/com/pawwithu/connectdog/domain/intermediary/service/IntermediaryService.java +++ b/src/main/java/com/pawwithu/connectdog/domain/intermediary/service/IntermediaryService.java @@ -128,15 +128,16 @@ public IntermediaryGetHomeResponse getIntermediaryHome(String email) { public void intermediaryMyProfile(String email, IntermediaryMyProfileRequest intermediaryMyProfileRequest, MultipartFile profileFile) { Intermediary intermediary = intermediaryRepository.findByEmail(email).orElseThrow(() -> new BadRequestException(INTERMEDIARY_NOT_FOUND)); + String url = intermediaryMyProfileRequest.url(); String intro = intermediaryMyProfileRequest.intro(); String contact = intermediaryMyProfileRequest.contact(); String guide = intermediaryMyProfileRequest.guide(); String profileImage = fileService.uploadFile(profileFile, "intermediary/profileImage"); if (profileImage != null) { - intermediary.updateProfile(profileImage, intro, contact, guide); + intermediary.updateProfile(profileImage, url, intro, contact, guide); } else { - intermediary.updateProfileWithoutImage(intro, contact, guide); + intermediary.updateProfileWithoutImage(url, intro, contact, guide); } } From acba390991a26bac293384cb371b94157252dcef Mon Sep 17 00:00:00 2001 From: hojeong2747 Date: Wed, 15 May 2024 20:24:21 +0900 Subject: [PATCH 2/3] =?UTF-8?q?test:=20=EB=AA=A8=EC=A7=91=EC=9E=90=20?= =?UTF-8?q?=ED=94=84=EB=A1=9C=ED=95=84=20=EC=88=98=EC=A0=95=20API=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=BD=94=EB=93=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20(#197)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/IntermediaryControllerTest.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/test/java/com/pawwithu/connectdog/domain/intermediary/controller/IntermediaryControllerTest.java b/src/test/java/com/pawwithu/connectdog/domain/intermediary/controller/IntermediaryControllerTest.java index 7756bf4f..ffa5e67b 100644 --- a/src/test/java/com/pawwithu/connectdog/domain/intermediary/controller/IntermediaryControllerTest.java +++ b/src/test/java/com/pawwithu/connectdog/domain/intermediary/controller/IntermediaryControllerTest.java @@ -1,6 +1,7 @@ package com.pawwithu.connectdog.domain.intermediary.controller; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.pawwithu.connectdog.domain.dog.entity.DogSize; import com.pawwithu.connectdog.domain.intermediary.dto.request.IntermediaryMyProfileRequest; import com.pawwithu.connectdog.domain.intermediary.dto.request.IntermediaryPasswordRequest; @@ -264,17 +265,18 @@ void setUp() { } @Test - void 이동봉사_중개_마이페이지_프로필_수정() throws Exception { + void 모집자_마이페이지_프로필_수정() throws Exception { // given - IntermediaryMyProfileRequest request = new IntermediaryMyProfileRequest("한줄 소개 변경", "문의 받을 연락처 변경", "안내사항 변경"); - MockMultipartFile profileImage = new MockMultipartFile("profileImage", "profileImage.png", "multipart/form-data", "uploadFile".getBytes(StandardCharsets.UTF_8)); - MockMultipartFile intermediaryMyProfileRequest = new MockMultipartFile("request", null, "application/json", objectMapper.writeValueAsString(request).getBytes(StandardCharsets.UTF_8)); + IntermediaryMyProfileRequest intermediaryMyProfileRequest = new IntermediaryMyProfileRequest("https://connectdog2.site", "한줄 소개 변경", "문의 받을 연락처 변경", "안내사항 변경"); + + MockMultipartFile files = new MockMultipartFile("files", "image1.png", "multipart/form-data", "uploadFile".getBytes(StandardCharsets.UTF_8)); + MockMultipartFile request = new MockMultipartFile("request", "", "application/json", objectMapper.registerModule(new JavaTimeModule()).writeValueAsString(intermediaryMyProfileRequest).getBytes(StandardCharsets.UTF_8)); // when ResultActions result = mockMvc.perform(MockMvcRequestBuilders .multipart(HttpMethod.PATCH, "/intermediaries/my/profile") - .file(profileImage) - .file(intermediaryMyProfileRequest) + .file(request) + .file(files) .accept(MediaType.APPLICATION_JSON) .contentType(MediaType.MULTIPART_FORM_DATA)); From 2458b1d5b64d15c40f811f65113b487d11551ebd Mon Sep 17 00:00:00 2001 From: hojeong2747 Date: Wed, 15 May 2024 20:37:05 +0900 Subject: [PATCH 3/3] =?UTF-8?q?chore:=20=EB=AA=A8=EC=A7=91=EC=9E=90=20?= =?UTF-8?q?=ED=94=84=EB=A1=9C=ED=95=84=20=EC=88=98=EC=A0=95=20API=20form-d?= =?UTF-8?q?ata=20param=20=EC=88=98=EC=A0=95=20(#197)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/intermediary/controller/IntermediaryController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/pawwithu/connectdog/domain/intermediary/controller/IntermediaryController.java b/src/main/java/com/pawwithu/connectdog/domain/intermediary/controller/IntermediaryController.java index 58041f36..874dd1fc 100644 --- a/src/main/java/com/pawwithu/connectdog/domain/intermediary/controller/IntermediaryController.java +++ b/src/main/java/com/pawwithu/connectdog/domain/intermediary/controller/IntermediaryController.java @@ -148,7 +148,7 @@ public ResponseEntity getIntermediaryHome(@Authenti @PatchMapping("/intermediaries/my/profile") public ResponseEntity intermediaryMyProfile(@AuthenticationPrincipal UserDetails loginUser, @RequestPart @Valid IntermediaryMyProfileRequest request, - @RequestPart(name = "profileImage", required = false) MultipartFile profileImage) { + @RequestPart(name = "files", required = false) MultipartFile profileImage) { intermediaryService.intermediaryMyProfile(loginUser.getUsername(), request, profileImage); return ResponseEntity.noContent().build(); }