Skip to content

Commit

Permalink
Merge pull request #201 from PawWithU/feat/200-social-signup-api
Browse files Browse the repository at this point in the history
[Feature] 소셜 추가 회원가입 API 수정
  • Loading branch information
hojeong2747 authored May 16, 2024
2 parents a213b69 + 6988494 commit b969c7c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
import jakarta.validation.constraints.Size;

public record SocialSignUpRequest(
@NotBlank(message = "이름은 필수 입력 값입니다.")
String name,
@NotBlank(message = "휴대전화 번호는 필수 입력 값입니다.")
@Pattern(regexp = "^010[0-9]{8}$", message = "유효하지 않은 휴대전화 번호입니다.")
String phone,
@Pattern(regexp = "^[가-힣0-9]*$", message = "닉네임은 한글, 숫자만 사용 가능합니다.")
@NotBlank(message = "닉네임은 필수 입력 값입니다.")
@Size(min=2, max=10, message = "닉네임은 2~10자로 입력해 주세요.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,22 @@ public void intermediarySignUp(IntermediarySignUpRequest request, MultipartFile

public void volunteerSocialSignUp(String email, SocialSignUpRequest socialSignUpRequest) {

if (volunteerRepository.existsByPhone(socialSignUpRequest.phone())) {
throw new BadRequestException(ALREADY_EXIST_PHONE);
}
if (volunteerRepository.existsByNickname(socialSignUpRequest.nickname())) {
throw new BadRequestException(ALREADY_EXIST_NICKNAME);
}

Volunteer volunteer = volunteerRepository.findByEmail(email).orElseThrow(() -> new BadRequestException(VOLUNTEER_NOT_FOUND));

// 추가 정보 업데이트
String name = socialSignUpRequest.name();
String phone = socialSignUpRequest.phone();
String nickname = socialSignUpRequest.nickname();
Integer profileImageNum = socialSignUpRequest.profileImageNum();
Boolean isOptionAgr = socialSignUpRequest.isOptionAgr();
volunteer.updateSocialVolunteer(nickname, VolunteerRole.VOLUNTEER, profileImageNum, isOptionAgr); // GUEST -> VOLUNTEER
volunteer.updateSocialVolunteer(name, phone, nickname, VolunteerRole.VOLUNTEER, profileImageNum, isOptionAgr); // GUEST -> VOLUNTEER
}

public void volunteersLogout(HttpServletRequest request, String email) {
Expand Down Expand Up @@ -141,7 +146,7 @@ public IntermediaryPhoneResponse isIntermediaryPhoneDuplicated(IntermediaryPhone
Intermediary intermediary = intermediaryRepository.findByPhone(request.phone()).orElseThrow(() -> new BadRequestException(INTERMEDIARY_NOT_FOUND));
email = intermediary.getEmail();
}

IntermediaryPhoneResponse response = IntermediaryPhoneResponse.of(isDuplicated, email);
return response;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ public void passwordEncode(PasswordEncoder passwordEncoder) {
this.password = passwordEncoder.encode(this.password);
}

public void updateSocialVolunteer(String nickname, VolunteerRole role, Integer profileImageNum, Boolean isOptionAgr) {
public void updateSocialVolunteer(String name, String phone, String nickname, VolunteerRole role, Integer profileImageNum, Boolean isOptionAgr) {
this.name = name;
this.phone = phone;
this.nickname = nickname;
this.role = role;
this.profileImageNum = profileImageNum;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/import.sql
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ INSERT INTO volunteer (id, email, password, nickname, profile_image_num, name, p
INSERT INTO application (id, status, volunteer_name, phone, content, post_id, intermediary_id, volunteer_id, created_date, modified_date) VALUES (1, 'COMPLETED', '민경혁', '01047391908', '이동봉사 신청합니다1!', 11, 2, 2, now(), now());
INSERT INTO application (id, status, volunteer_name, phone, content, post_id, intermediary_id, volunteer_id, created_date, modified_date) VALUES (2, 'COMPLETED', '민경혁', '01047391908', '이동봉사 신청합니다2!', 12, 2, 2, now(), now());
INSERT INTO application (id, status, volunteer_name, phone, content, post_id, intermediary_id, volunteer_id, created_date, modified_date) VALUES (3, 'COMPLETED', '민경혁', '01047391908', '이동봉사 신청합니다3!', 13, 2, 2, now(), now());
INSERT INTO application (id, status, volunteer_name, phone, content, post_id, intermediary_id, volunteer_id, created_date, modified_date) VALUES (4, 'COMPLETED', '민경혁', '01047391908', '이동봉사 신청합니다4!', 14, 2, 2, now(), now());
INSERT INTO application (id, status, volunteer_name, phone, content, post_id, intermediary_id, volunteer_id, created_date, modified_date) VALUES (4, 'PROGRESSING', '민경혁', '01047391908', '이동봉사 신청합니다4!', 14, 2, 2, now(), now());
INSERT INTO application (id, status, volunteer_name, phone, content, post_id, intermediary_id, volunteer_id, created_date, modified_date) VALUES (5, 'COMPLETED', '민경혁', '01047391908', '이동봉사 신청합니다5!', 15, 2, 2, now(), now());
INSERT INTO application (id, status, volunteer_name, phone, content, post_id, intermediary_id, volunteer_id, created_date, modified_date) VALUES (6, 'COMPLETED', '한호정', '01047391908', '이동봉사 신청합니다6!', 16, 3, 1, now(), now());

Expand Down

0 comments on commit b969c7c

Please sign in to comment.