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..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 @@ -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" @@ -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(); } 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); } } 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));