Skip to content

Commit bdd25aa

Browse files
committed
[test] merge (#268)
2 parents d83c8a7 + 4985f53 commit bdd25aa

4 files changed

Lines changed: 15 additions & 5 deletions

File tree

src/main/java/konkuk/thip/user/adapter/in/web/response/UserFollowersResponse.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ public record FollowerDto(
1818
String profileImageUrl,
1919
String aliasName,
2020
String aliasColor,
21-
Integer followerCount
21+
Integer followerCount,
22+
boolean isMyself
2223
){
2324

2425
}

src/main/java/konkuk/thip/user/application/mapper/FollowQueryMapper.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,22 @@
33
import konkuk.thip.user.adapter.in.web.response.UserFollowersResponse;
44
import konkuk.thip.user.adapter.in.web.response.UserFollowingResponse;
55
import konkuk.thip.user.application.port.out.dto.UserQueryDto;
6+
import org.mapstruct.Context;
67
import org.mapstruct.Mapper;
78
import org.mapstruct.Mapping;
9+
import org.mapstruct.Named;
810

911
@Mapper(componentModel = "spring")
1012
public interface FollowQueryMapper {
1113

12-
UserFollowersResponse.FollowerDto toFollowerDto(UserQueryDto dto);
14+
// UserQueryDto의 userId와 Context로 넘어온 userId를 비교해서 true,false를 isMyself 필드에 주입
15+
@Mapping(target = "isMyself", source = "dto.userId", qualifiedByName = "isMyself")
16+
UserFollowersResponse.FollowerDto toFollowerDto(UserQueryDto dto, @Context Long loginUserId);
17+
18+
@Named("isMyself")
19+
default boolean isMyself(Long userId, @Context Long loginUserId) {
20+
return userId != null && userId.equals(loginUserId);
21+
}
1322

1423
@Mapping(target = "isFollowing", constant = "true")
1524
UserFollowingResponse.FollowingDto toFollowingDto(UserQueryDto dto);

src/main/java/konkuk/thip/user/application/service/following/UserGetFollowService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public UserFollowersResponse getUserFollowers(Long userId, String cursor, int si
3636
);
3737

3838
var followers = result.contents().stream()
39-
.map(followQueryMapper::toFollowerDto)
39+
.map(dto -> followQueryMapper.toFollowerDto(dto, userId))
4040
.toList();
4141

4242
return UserFollowersResponse.builder()

src/test/java/konkuk/thip/feed/adapter/in/web/FeedRelatedWithBookApiTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ void getFeedsByBook_cursor_paging_success() throws Exception {
263263
}
264264

265265
@Test
266-
@DisplayName("비공개 피드 제외 및 자기 자신 피드 제외 검증")
266+
@DisplayName("비공개 피드 제외 검증")
267267
void getFeedsByBook_visibility_and_self_filter() throws Exception {
268268
// given
269269
AliasJpaEntity alias = aliasJpaRepository.save(TestEntityFactory.createLiteratureAlias());
@@ -304,7 +304,7 @@ void getFeedsByBook_visibility_and_self_filter() throws Exception {
304304
JsonNode feeds = root.path("data").path("feeds");
305305

306306
// 자기 자신 글 제외 비공개 제외로 인해 only othersPublic 만 남아야 함
307-
assertThat(feeds.size()).isEqualTo(1);
307+
assertThat(feeds.size()).isEqualTo(2);
308308
assertThat(feeds.get(0).path("creatorId").asLong()).isEqualTo(other.getUserId());
309309
assertThat(feeds.get(0).path("isWriter").asBoolean()).isFalse();
310310
}

0 commit comments

Comments
 (0)