From 984e781b6dd8a81580f26d7bba3788d4d61bd44a Mon Sep 17 00:00:00 2001 From: kyeong-hyeok Date: Thu, 6 Jun 2024 16:18:33 +0900 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20=EB=B4=89=EC=82=AC=EC=9E=90,=20?= =?UTF-8?q?=EB=AA=A8=EC=A7=91=EC=9E=90=20=ED=9A=8C=EC=9B=90=EA=B0=80?= =?UTF-8?q?=EC=9E=85=20=EC=8B=9C=20=EC=9D=B4=EB=A9=94=EC=9D=BC=20=EC=A4=91?= =?UTF-8?q?=EB=B3=B5=20=ED=99=95=EC=9D=B8=20=EB=A1=9C=EC=A7=81=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC=20(#238)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/auth/controller/SignUpController.java | 3 ++- .../connectdog/domain/auth/service/AuthService.java | 7 ++----- src/main/java/com/pawwithu/connectdog/error/ErrorCode.java | 1 + 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/pawwithu/connectdog/domain/auth/controller/SignUpController.java b/src/main/java/com/pawwithu/connectdog/domain/auth/controller/SignUpController.java index bd4244a2..9e71fe14 100644 --- a/src/main/java/com/pawwithu/connectdog/domain/auth/controller/SignUpController.java +++ b/src/main/java/com/pawwithu/connectdog/domain/auth/controller/SignUpController.java @@ -51,7 +51,8 @@ public ResponseEntity volunteerSignUp(@RequestBody @Valid VolunteerSignUpR , description = "V1, 이름은 필수 입력 값입니다 \t\n V1, 휴대전화 번호는 필수 입력 값입니다. \t\n V1, 유효하지 않은 휴대전화 번호입니다. \t\n " + "V1, 이메일 형식에 맞지 않습니다. \t\n V1, 이메일은 필수 입력 값입니다. \t\n V1 문의 받을 연락처는 100자 이하로 입력해 주세요. \t\n " + "V1, 영문+숫자 10자 이상 또는 영문+숫자+특수기호 8자 이상을 입력해 주세요. \t\n V1, 모집자명은 필수 입력 값입니다. \t\n " + - "V1, 한줄 소개는 50자 이하로 입력해 주세요. \t\n A1, 이미 등록된 이메일입니다. \t\n F1, 파일이 존재하지 않습니다. \t\n F2, 파일 업로드에 실패했습니다." + "V1, 한줄 소개는 50자 이하로 입력해 주세요. \t\n A1, 이미 등록된 이메일입니다. \t\n F1, 파일이 존재하지 않습니다. \t\n F2, 파일 업로드에 실패했습니다. \t\n " + + "A9, 이미 등록된 모집자명입니다." , content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) @PostMapping(value = "/intermediaries/sign-up", consumes = {MediaType.APPLICATION_JSON_VALUE, MediaType.MULTIPART_FORM_DATA_VALUE}) diff --git a/src/main/java/com/pawwithu/connectdog/domain/auth/service/AuthService.java b/src/main/java/com/pawwithu/connectdog/domain/auth/service/AuthService.java index cdb0b9fc..829115de 100644 --- a/src/main/java/com/pawwithu/connectdog/domain/auth/service/AuthService.java +++ b/src/main/java/com/pawwithu/connectdog/domain/auth/service/AuthService.java @@ -72,9 +72,6 @@ public void volunteerSignUp(VolunteerSignUpRequest request) { if (volunteerRepository.existsByEmail(request.email())) { throw new BadRequestException(ALREADY_EXIST_EMAIL); } - if (intermediaryRepository.existsByEmail(request.email())) { - throw new BadRequestException(ALREADY_EXIST_EMAIL); - } if (volunteerRepository.existsByNickname(request.nickname())) { throw new BadRequestException(ALREADY_EXIST_NICKNAME); } @@ -92,8 +89,8 @@ public void intermediarySignUp(IntermediarySignUpRequest request, MultipartFile if (intermediaryRepository.existsByEmail(request.email())) { throw new BadRequestException(ALREADY_EXIST_EMAIL); } - if (volunteerRepository.existsByEmail(request.email())) { - throw new BadRequestException(ALREADY_EXIST_EMAIL); + if (intermediaryRepository.existsByName(request.name())) { + throw new BadRequestException(ALREADY_EXIST_NAME); } String profileImage = fileService.uploadFile(profileFile, "intermediary/profileImage"); if (profileImage == null) { diff --git a/src/main/java/com/pawwithu/connectdog/error/ErrorCode.java b/src/main/java/com/pawwithu/connectdog/error/ErrorCode.java index 4bbdce60..c1aaefed 100644 --- a/src/main/java/com/pawwithu/connectdog/error/ErrorCode.java +++ b/src/main/java/com/pawwithu/connectdog/error/ErrorCode.java @@ -15,6 +15,7 @@ public enum ErrorCode { NOT_ALLOWED_MEMBER("A6", "해당 요청에 대한 권한이 없습니다."), NOT_AUTHENTICATED_REQUEST("A7", "유효한 JWT 토큰이 없습니다."), ALREADY_EXIST_PHONE("A8", "이미 등록된 전화번호입니다."), + ALREADY_EXIST_NAME("A9", "이미 등록된 모집자명입니다."), VOLUNTEER_NOT_FOUND("M1", "해당 이동봉사자를 찾을 수 없습니다."), // Member -> M (이동봉사자, 이동봉사 중개 통일) From 27b1157ffdd5ba9441e8825ce5937d49dc97fb5f Mon Sep 17 00:00:00 2001 From: kyeong-hyeok Date: Thu, 6 Jun 2024 16:21:59 +0900 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20=EB=B4=89=EC=82=AC=EC=9E=90=20?= =?UTF-8?q?=EB=AA=A8=EC=A7=91=EC=9E=90=20=EC=9D=B4=EB=A9=94=EC=9D=BC=20?= =?UTF-8?q?=EC=A0=84=EC=86=A1=20api=20=EB=B6=84=EB=A6=AC=20(#238)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/controller/SignUpController.java | 22 +++++++++++++++---- .../domain/auth/service/EmailService.java | 19 +++++++++++++--- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/pawwithu/connectdog/domain/auth/controller/SignUpController.java b/src/main/java/com/pawwithu/connectdog/domain/auth/controller/SignUpController.java index 9e71fe14..7748d8b6 100644 --- a/src/main/java/com/pawwithu/connectdog/domain/auth/controller/SignUpController.java +++ b/src/main/java/com/pawwithu/connectdog/domain/auth/controller/SignUpController.java @@ -62,18 +62,32 @@ public ResponseEntity intermediarySignUp(@RequestPart @Valid IntermediaryS return ResponseEntity.noContent().build(); } - @Operation(summary = "이메일 인증번호 전송", description = "입력한 이메일로 인증번호를 전송합니다.", + @Operation(summary = "봉사자 - 이메일 인증번호 전송", description = "입력한 이메일로 인증번호를 전송합니다.", responses = {@ApiResponse(responseCode = "200", description = "이메일 인증번호 전송 성공") , @ApiResponse(responseCode = "400" , description = "V1, 이메일 형식에 맞지 않습니다. \t\n V1, 이메일은 필수 입력 값입니다. \t\n A1, 이미 존재하는 이메일입니다. \t\n A4, 이메일 인증 코드 전송을 실패했습니다." , content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) - @PostMapping(value = {"/volunteers/sign-up/email", "/intermediaries/sign-up/email"}) - public ResponseEntity mailConfirm(@RequestBody @Valid EmailRequest request){ - EmailResponse emailResponse = emailService.sendEmail(request); + @PostMapping("/volunteers/sign-up/email") + public ResponseEntity sendEmailToVolunteer(@RequestBody @Valid EmailRequest request){ + EmailResponse emailResponse = emailService.sendEmailToVolunteer(request); return ResponseEntity.ok(emailResponse); } + @Operation(summary = "모집자 - 이메일 인증번호 전송", description = "입력한 이메일로 인증번호를 전송합니다.", + responses = {@ApiResponse(responseCode = "200", description = "이메일 인증번호 전송 성공") + , @ApiResponse(responseCode = "400" + , description = "V1, 이메일 형식에 맞지 않습니다. \t\n V1, 이메일은 필수 입력 값입니다. \t\n A1, 이미 존재하는 이메일입니다. \t\n A4, 이메일 인증 코드 전송을 실패했습니다." + , content = @Content(schema = @Schema(implementation = ErrorResponse.class))) + }) + @PostMapping("/intermediaries/sign-up/email") + public ResponseEntity sendEmailToIntermediary(@RequestBody @Valid EmailRequest request){ + EmailResponse emailResponse = emailService.sendEmailToIntermediary(request); + return ResponseEntity.ok(emailResponse); + } + + + @Operation(summary = "이동봉사자 소셜 로그인 추가 회원가입", description = "소셜 로그인하는 이동봉사자 추가 회원가입을 합니다.", security = { @SecurityRequirement(name = "bearer-key") }, responses = {@ApiResponse(responseCode = "204", description = "이동봉사자 소셜 로그인 추가 회원가입 성공") diff --git a/src/main/java/com/pawwithu/connectdog/domain/auth/service/EmailService.java b/src/main/java/com/pawwithu/connectdog/domain/auth/service/EmailService.java index fd9a55cd..3f4743b9 100644 --- a/src/main/java/com/pawwithu/connectdog/domain/auth/service/EmailService.java +++ b/src/main/java/com/pawwithu/connectdog/domain/auth/service/EmailService.java @@ -81,20 +81,33 @@ private MimeMessage createEmailForm(String email) throws MessagingException, Uns /** * 메일 전송 */ - public EmailResponse sendEmail(EmailRequest request) throws BadRequestException { + public EmailResponse sendEmailToVolunteer(EmailRequest request) throws BadRequestException { // 이메일 중복 검사 if (volunteerRepository.existsByEmail(request.email())) { throw new BadRequestException(ALREADY_EXIST_EMAIL); } + try { + // 메일전송에 필요한 정보 설정 + MimeMessage emailForm = createEmailForm(request.email()); + emailSender.send(emailForm); + return new EmailResponse(authNum); + } catch (UnsupportedEncodingException | MessagingException e){ + throw new BadRequestException(EMAIL_SEND_ERROR); + } + + } + + public EmailResponse sendEmailToIntermediary(EmailRequest request) { + // 이메일 중복 검사 if (intermediaryRepository.existsByEmail(request.email())) { throw new BadRequestException(ALREADY_EXIST_EMAIL); } - try{ + try { // 메일전송에 필요한 정보 설정 MimeMessage emailForm = createEmailForm(request.email()); emailSender.send(emailForm); return new EmailResponse(authNum); - }catch (UnsupportedEncodingException | MessagingException e){ + } catch (UnsupportedEncodingException | MessagingException e){ throw new BadRequestException(EMAIL_SEND_ERROR); } From ce9b470591738fa80e12ecc0fab8d47ac8e877d3 Mon Sep 17 00:00:00 2001 From: kyeong-hyeok Date: Thu, 6 Jun 2024 16:23:49 +0900 Subject: [PATCH 3/4] =?UTF-8?q?test:=20=EB=B4=89=EC=82=AC=EC=9E=90,=20?= =?UTF-8?q?=EB=AA=A8=EC=A7=91=EC=9E=90=20=EC=9D=B4=EB=A9=94=EC=9D=BC=20?= =?UTF-8?q?=EC=A0=84=EC=86=A1=20API=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95=20(#238)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/controller/SignUpControllerTest.java | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/pawwithu/connectdog/domain/auth/controller/SignUpControllerTest.java b/src/test/java/com/pawwithu/connectdog/domain/auth/controller/SignUpControllerTest.java index 3763e2b0..24199087 100644 --- a/src/test/java/com/pawwithu/connectdog/domain/auth/controller/SignUpControllerTest.java +++ b/src/test/java/com/pawwithu/connectdog/domain/auth/controller/SignUpControllerTest.java @@ -50,13 +50,13 @@ void setUp() { .build(); } @Test - void 이메일_인증번호_전송() throws Exception{ + void 봉사자_이메일_인증번호_전송() throws Exception{ //given EmailRequest request = new EmailRequest("email@naver.com"); EmailResponse response = new EmailResponse("authCode123"); //when - when(emailService.sendEmail(any())).thenReturn(response); + when(emailService.sendEmailToVolunteer(any())).thenReturn(response); ResultActions result = mockMvc.perform( post("/volunteers/sign-up/email") .contentType(MediaType.APPLICATION_JSON) @@ -64,7 +64,25 @@ void setUp() { ); //then result.andExpect(status().isOk()); - verify(emailService, times(1)).sendEmail(any()); + verify(emailService, times(1)).sendEmailToVolunteer(any()); + } + + @Test + void 모집자_이메일_인증번호_전송() throws Exception{ + //given + EmailRequest request = new EmailRequest("email@naver.com"); + EmailResponse response = new EmailResponse("authCode123"); + + //when + when(emailService.sendEmailToIntermediary(any())).thenReturn(response); + ResultActions result = mockMvc.perform( + post("/intermediaries/sign-up/email") + .contentType(MediaType.APPLICATION_JSON) + .content(objectMapper.writeValueAsString(request)) + ); + //then + result.andExpect(status().isOk()); + verify(emailService, times(1)).sendEmailToIntermediary(any()); } From 1f01674c94ec8c4044e52731fe59dc33bc6be9e0 Mon Sep 17 00:00:00 2001 From: kyeong-hyeok Date: Thu, 6 Jun 2024 16:33:02 +0900 Subject: [PATCH 4/4] =?UTF-8?q?feat:=20=EC=86=8C=EC=85=9C=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=9D=B8=20=EC=B6=94=EA=B0=80=20=ED=9A=8C=EC=9B=90?= =?UTF-8?q?=EA=B0=80=EC=9E=85=20=EC=8B=9C=20=EC=95=8C=EB=A6=BC=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20=EC=B6=94=EA=B0=80=20(#238)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pawwithu/connectdog/domain/volunteer/entity/Volunteer.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/pawwithu/connectdog/domain/volunteer/entity/Volunteer.java b/src/main/java/com/pawwithu/connectdog/domain/volunteer/entity/Volunteer.java index 76ac1965..caa916a4 100644 --- a/src/main/java/com/pawwithu/connectdog/domain/volunteer/entity/Volunteer.java +++ b/src/main/java/com/pawwithu/connectdog/domain/volunteer/entity/Volunteer.java @@ -61,6 +61,7 @@ public void updateSocialVolunteer(String name, String phone, String nickname, Vo this.role = role; this.profileImageNum = profileImageNum; this.isOptionAgr = isOptionAgr; + this.notification = true; } public void updateNameAndPhone(String name, String phone) {