-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 어드민 멤버 수정 api 추가 * feat: 어드민 멤버 수정 request dto 추가 * feat: 정규표현식 상수 클래스 추가 * feat: 어드민 멤버 수정 서비스 추가 * feat: 멤버 수정 메서드 추가 * feat: 존재하지 않는 멤버 예외 추가 * fix: 닉네임 최소 1자 이상이도록 수정 * fix: RegexConstant 수정 * style: 개행 제거 * feat: 검증 메서드 추가 * refactor: update 메서드 수정 * feat: ErrorCode 추가 * feat: 삭제된 멤버 수정 못하도록 검증 추가 * fix: 필드명 변경 * refactor: if문 제거 * refactor: NotBlank로 변경 * feat: dto 검증 예외 처리 메서드 생성 * test: 탈퇴한 회원 정보 수정 시 예외 처리 테스트 추가 * refactor: 탈퇴 여부 확인을 MemberStatus이 처리 * fix: 메서드명 수정 * remove: 중복 null-check 제거 * fix: 메서드명 수정 * refactor: 멤버 상태 검증 시 차단 여부도 확인 * refactor: db에 하이픈 없이 저장하도록 수정 * fix: 메서드명 수정 * refactor: 검증 메서드를 수정 메서드 내부로 이동 * refactor: ErrorCode의 이름을 Response 내에서 처리하도록 수정 * refactor: 수정 로직 수정 * remove: 사용하지 않는 import 제거 * style: spotless apply
- Loading branch information
1 parent
b6197e1
commit f6865b9
Showing
10 changed files
with
137 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/main/java/com/gdschongik/gdsc/domain/member/dto/request/MemberUpdateRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.gdschongik.gdsc.domain.member.dto.request; | ||
|
||
import static com.gdschongik.gdsc.global.common.constant.RegexConstant.*; | ||
|
||
import jakarta.validation.constraints.Email; | ||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.Pattern; | ||
|
||
public record MemberUpdateRequest( | ||
@NotBlank @Pattern(regexp = STUDENT_ID, message = "학번은 " + STUDENT_ID + " 형식이어야 합니다.") String studentId, | ||
@NotBlank String name, | ||
@NotBlank @Pattern(regexp = PHONE, message = "전화번호는 " + PHONE + " 형식이어야 합니다.") String phone, | ||
@NotBlank String department, | ||
@NotBlank @Email String email, | ||
@NotBlank String discordUsername, | ||
@NotBlank @Pattern(regexp = NICKNAME, message = "닉네임은 " + NICKNAME + " 형식이어야 합니다.") String nickname) {} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/gdschongik/gdsc/global/common/constant/RegexConstant.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.gdschongik.gdsc.global.common.constant; | ||
|
||
public class RegexConstant { | ||
public static final String STUDENT_ID = "^[A-C]{1}[0-9]{6}$"; | ||
public static final String PHONE = "^010-[0-9]{4}-[0-9]{4}$"; | ||
public static final String PHONE_WITHOUT_HYPHEN = "^010[0-9]{8}$"; | ||
public static final String NICKNAME = "[ㄱ-ㅣ가-힣]{1,6}$"; | ||
|
||
private RegexConstant() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/test/java/com/gdschongik/gdsc/domain/member/application/MemberServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.gdschongik.gdsc.domain.member.application; | ||
|
||
import static org.assertj.core.api.Assertions.*; | ||
|
||
import com.gdschongik.gdsc.domain.member.dao.MemberRepository; | ||
import com.gdschongik.gdsc.domain.member.domain.Member; | ||
import com.gdschongik.gdsc.domain.member.dto.request.MemberUpdateRequest; | ||
import com.gdschongik.gdsc.global.exception.CustomException; | ||
import com.gdschongik.gdsc.global.exception.ErrorCode; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
|
||
@SpringBootTest | ||
class MemberServiceTest { | ||
@Autowired | ||
private MemberRepository memberRepository; | ||
|
||
@Autowired | ||
private MemberService memberService; | ||
|
||
@Test | ||
void status가_DELETED라면_예외_발생() { | ||
// given | ||
Member member = Member.createGuestMember("oAuthId"); | ||
member.withdraw(); | ||
memberRepository.save(member); | ||
|
||
// when & then | ||
MemberUpdateRequest requestBody = new MemberUpdateRequest( | ||
"A111111", "name", "010-1234-5678", "department", "[email protected]", "discordUsername", "한글"); | ||
assertThatThrownBy(() -> memberService.updateMember(member.getId(), requestBody)) | ||
.isInstanceOf(CustomException.class) | ||
.hasMessage(ErrorCode.MEMBER_DELETED.getMessage()); | ||
} | ||
} |