-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
최신 알림 존재 여부 및 읽기 기능 구현 #783
Changes from 11 commits
f371e6f
216401f
1dc8ec2
5ebd675
4cb655b
f75e102
982f08c
8421e31
f4801f4
a2177b6
933b1e8
1a814de
be74d45
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,13 +15,16 @@ public record MemberInfoResponse( | |
@Schema(description = "출생년도", example = "2002") | ||
Integer birthYear, | ||
|
||
@Schema(description = "권한", example = "MEMBER") | ||
Roles roles, | ||
|
||
@Schema(description = "작성한 게시글 수", example = "5") | ||
long postCount, | ||
|
||
@Schema(description = "투표한 수", example = "10") | ||
long voteCount | ||
long voteCount, | ||
|
||
@Schema(description = "권한", example = "MEMBER") | ||
Roles roles, | ||
Comment on lines
+24
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 꼼꼼히 챙겨주셨네요 👍🏻 |
||
|
||
@Schema(description = "최신 알림 존재 여부", example = "false") | ||
boolean hasLatestAlarm | ||
) { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,24 +56,29 @@ public class Member extends BaseEntity { | |
private String socialId; | ||
|
||
@Enumerated(EnumType.STRING) | ||
@Column(nullable = false, length = 20) | ||
@Column(length = 20, nullable = false) | ||
private Roles roles; | ||
|
||
@Column(columnDefinition = "datetime(6)", nullable = false) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 다른 컬럼과 일관성있게 nullable이 앞으로 오면 좋을 것 같아요 😺 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 저희 컨벤션을 정하기로는 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 헉 그런가요 감사합니다 ㅎㅎ |
||
private LocalDateTime alarmCheckedAt; | ||
|
||
@Builder | ||
private Member( | ||
final String nickname, | ||
final Gender gender, | ||
final Integer birthYear, | ||
final SocialType socialType, | ||
final String socialId, | ||
final Roles roles | ||
final Roles roles, | ||
final LocalDateTime alarmCheckedAt | ||
) { | ||
this.nickname = new Nickname(nickname); | ||
this.gender = gender; | ||
this.birthYear = birthYear; | ||
this.socialType = socialType; | ||
this.socialId = socialId; | ||
this.roles = roles; | ||
this.alarmCheckedAt = alarmCheckedAt; | ||
} | ||
|
||
public static Member from(final KakaoMemberResponse response) { | ||
|
@@ -82,6 +87,7 @@ public static Member from(final KakaoMemberResponse response) { | |
.socialType(SocialType.KAKAO) | ||
.socialId(String.valueOf(response.id())) | ||
.roles(Roles.MEMBER) | ||
.alarmCheckedAt(LocalDateTime.now()) | ||
.build(); | ||
} | ||
|
||
|
@@ -117,6 +123,14 @@ public boolean hasEssentialInfo() { | |
return (this.gender != null && this.birthYear != null); | ||
} | ||
|
||
public boolean hasLatestAlarmCompareTo(final LocalDateTime latestAlarmCreatedAt) { | ||
return alarmCheckedAt.isBefore(latestAlarmCreatedAt); | ||
} | ||
|
||
public void checkAlarm() { | ||
alarmCheckedAt = LocalDateTime.now(); | ||
} | ||
Comment on lines
+130
to
+132
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 간결하고 깔끔한 구현 👍🏻 |
||
|
||
public String getNickname() { | ||
return this.nickname.getValue(); | ||
} | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -55,9 +55,10 @@ void findMemberInfo() throws Exception { | |||||||||||
"저문", | ||||||||||||
Gender.MALE, | ||||||||||||
1988, | ||||||||||||
Roles.MEMBER, | ||||||||||||
0, | ||||||||||||
0 | ||||||||||||
0, | ||||||||||||
Roles.MEMBER, | ||||||||||||
false | ||||||||||||
); | ||||||||||||
|
||||||||||||
given(tokenProcessor.resolveToken(anyString())).willReturn("token"); | ||||||||||||
|
@@ -219,6 +220,26 @@ void invalidNullOfBirthYear(Integer birthYear) throws Exception { | |||||||||||
|
||||||||||||
} | ||||||||||||
|
||||||||||||
@Test | ||||||||||||
@DisplayName("최신 알림 읽기에 성공하면 200을 반환한다.") | ||||||||||||
void checkLatestAlarm() throws Exception { | ||||||||||||
// given | ||||||||||||
TokenPayload tokenPayload = new TokenPayload(1L, 1L, 1L); | ||||||||||||
given(tokenProcessor.resolveToken(anyString())).willReturn("token"); | ||||||||||||
given(tokenProcessor.parseToken(anyString())).willReturn(tokenPayload); | ||||||||||||
given(memberService.findById(anyLong())).willReturn(MemberFixtures.FEMALE_20.get()); | ||||||||||||
Comment on lines
+227
to
+230
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
이렇게 바꾸면 어떻게 되나요?? 지금 만드는 기능과 관련은 없지만 혹시나 하고 MemberControllerTest에서 전부 mockingAuthArgumentResolver(); 로 바꾸고 테스트를 실행해봤는데, @Test
@DisplayName("회원 정보를 조회한다.")
void findMemberInfo() throws Exception 이 테스트 제외하고는 전부 성공하더라구요. 그래서 MemberControllerTest 안에서 위 메서드 하나만 제외하고 mockingAuthArgumentResolver(); 로 다 바꿔주시는 것은 어떨까요 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 추후에 member 도메인을 리팩터링 하면서 통일성있게 변경해보는 것은 어떨까요? |
||||||||||||
|
||||||||||||
willDoNothing().given(memberService).checkLatestAlarm(any(Member.class)); | ||||||||||||
|
||||||||||||
// when, then | ||||||||||||
RestAssuredMockMvc | ||||||||||||
.given().log().all() | ||||||||||||
.headers(HttpHeaders.AUTHORIZATION, "Bearer token") | ||||||||||||
.when().patch("/members/me/check-alarm") | ||||||||||||
.then().log().all() | ||||||||||||
.statusCode(HttpStatus.OK.value()); | ||||||||||||
} | ||||||||||||
|
||||||||||||
@Test | ||||||||||||
@DisplayName("회원 탈퇴에 성공하면 204를 반환한다.") | ||||||||||||
void deleteMember() throws Exception { | ||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍