Skip to content
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

[BE] Member 관련 기능 개발 #237

Merged
merged 99 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
8646b1a
[Docs] GitHub Issue 및 PR Template 설정 (#37)
junpakPark Jul 18, 2023
5b153cc
[Docs] GitHub Issue Template 파일명 오류 수정 (#39)
junpakPark Jul 18, 2023
c54a142
Merge branch 'develop' of https://github.com/woowacourse-teams/2023-m…
kpeel5839 Jul 25, 2023
1397964
Merge branch 'develop' of https://github.com/woowacourse-teams/2023-m…
kpeel5839 Jul 25, 2023
4efef6e
Merge branch 'develop' of https://github.com/woowacourse-teams/2023-m…
kpeel5839 Jul 26, 2023
29997b1
feat: member 구현 중
junpakPark Jul 27, 2023
82233e0
Merge branch 'feature/member' of https://github.com/woowacourse-teams…
kpeel5839 Jul 27, 2023
70f351f
feat: 패키지 분리, AuthMember 구현
junpakPark Jul 28, 2023
b98ce02
feat: MemberArgumentResolver 구현
kpeel5839 Jul 28, 2023
bd32df0
Merge branch 'feature/member' of https://github.com/woowacourse-teams…
kpeel5839 Jul 28, 2023
69268ee
feat: AuthTopic 구현
kpeel5839 Jul 28, 2023
f6faad0
Merge branch 'feature/member' of https://github.com/woowacourse-teams…
kpeel5839 Jul 28, 2023
960b9b3
Merge branch 'feature/junepark-member' into feature/junjun
kpeel5839 Jul 28, 2023
68838dc
feat: MemberArgumentResolver 구현
kpeel5839 Jul 28, 2023
5bda12f
refactor: API 명세 수정을 위한 임의 커밋
junpakPark Jul 28, 2023
83f79ff
feat: Publicity, Permission 정적 팩토리 및 Converter 추가
kpeel5839 Jul 28, 2023
27a0738
refactor: Topic 에 Publicity, Permission 추가로 인한 테스트 수정
kpeel5839 Jul 28, 2023
41ee4ef
refactor: 모든 테스트가 통과하도록 수정
kpeel5839 Jul 28, 2023
b0850af
refactor: 모든 테스트가 통과하도록 수정
kpeel5839 Jul 28, 2023
9ffcefd
feat: Topic 에 관한 CRUD 에 권한 적용 완료
kpeel5839 Jul 29, 2023
471a826
fix: Converter 반환값 이상으로 인한 오류 해결
kpeel5839 Jul 29, 2023
5075d4b
feat: Pin 기능에 권한 설정 추가
kpeel5839 Jul 29, 2023
30a97f7
style: 사용하지 않는 import 문 제거 및 접근 제어자 조정
kpeel5839 Jul 29, 2023
470fcb5
refactor: .. 지송;;^^
junpakPark Jul 31, 2023
9b58830
refactor: TopicStatus 로직 오류 수정 LocationController 오타 수정
junpakPark Jul 31, 2023
80d7e9f
refactor: 불필요 상수 제거
junpakPark Jul 31, 2023
939964c
refactor: PinResponse 자료형 변경
junpakPark Jul 31, 2023
12e83b4
feat: Image 클래스 구현
junpakPark Jul 31, 2023
8c869a1
feat: LocationRepository에 하버사인을 이용한 find 메서드 구현
junpakPark Jul 31, 2023
7bdea8a
refactor: LocationController의 메서드명 변경
junpakPark Jul 31, 2023
5cf4318
refactor: getTopicsWithPermission의 반환값 변경
junpakPark Jul 31, 2023
cc4c0c4
style: 불필요 공백 제거
junpakPark Jul 31, 2023
b45f3b1
refactor: 로직 오류 수정 및 테스트 추가
junpakPark Jul 31, 2023
0dec766
test: Topic 패키지 테스트 추가
junpakPark Jul 31, 2023
c451958
refactor: Auth 관련 리팩터링 및 TopicIntegrationTest
junpakPark Aug 1, 2023
2433935
refactor: auth 어노테이션 제거
junpakPark Aug 1, 2023
4383f25
test: AddressTest 추가
junpakPark Aug 1, 2023
209a4e2
test: Pin 관련 테스트 추가
junpakPark Aug 1, 2023
d6e4e7a
refactor: Coordinate BigDecimal -> Double 로 수정
kpeel5839 Aug 1, 2023
712a289
refactor: 모든 테스트가 성공하도록 수정
kpeel5839 Aug 1, 2023
846490a
refactor: LocationRepositoryTest 수정
kpeel5839 Aug 1, 2023
cd57810
refactor: Git Conflict Merge 해결
junpakPark Aug 1, 2023
6626b7e
feat: 멤버 단일 조회 기능 추가
kpeel5839 Aug 1, 2023
02979b3
feat: 멤버 목록 조회 기능 구현
kpeel5839 Aug 1, 2023
be59142
feat : Member 를 Create 하는 기능 추가
kpeel5839 Aug 2, 2023
1d81886
feat : Member 가 만든 Topic 들을 조회하는 기능 추가
kpeel5839 Aug 2, 2023
2dccd5f
feat : Member 가 본인이 만든 Pin 을 조회하는 기능 추가
kpeel5839 Aug 2, 2023
975fffd
feat : 토픽을 생성한 자가 특정 멤버에게 권한을 주는 기능 추가
kpeel5839 Aug 2, 2023
6cc09a4
feat : 토픽을 생성한자가 특정 멤버의 권한을 삭제하는 기능 추가
kpeel5839 Aug 2, 2023
dc90aa5
feat : 해당 토픽에 권한을 가진 모든 유저를 조회
kpeel5839 Aug 2, 2023
a78a348
feat : 권한을 가진 유저를 ID 로 조회하는 기능 추가
kpeel5839 Aug 2, 2023
426ad35
refactor: AuthTopic 객체 제거
junpakPark Aug 2, 2023
1a825b5
feat : Topic, Pin, Member 에 연관관계 편의 메서드 추가
kpeel5839 Aug 2, 2023
f8370c3
refactor: RestDocs를 위한 Interceptor 조건문 추가
junpakPark Aug 2, 2023
1520467
test : Permission 추가와 관련된 Domain Test 작성
kpeel5839 Aug 2, 2023
2f48f41
test : 다른 유저에게 권한을 주는 기능 테스트 추가
kpeel5839 Aug 2, 2023
9e97c05
chore : Auth 관련 기능들 Pull 받은 후 충돌 해결
kpeel5839 Aug 2, 2023
b9a18fc
test : 권한 부여 인수테스트 추가
kpeel5839 Aug 2, 2023
d6188c4
docs : 권한 부여 API 명세 작성
kpeel5839 Aug 2, 2023
8ffb1f3
test : 권한 삭제 Service Test 작성
kpeel5839 Aug 2, 2023
9a8a019
test : 권한 삭제 인수테스트 작성
kpeel5839 Aug 2, 2023
fa6d7fe
docs : 권한 삭제 API 명세 작성
kpeel5839 Aug 2, 2023
0dad751
test : memberResponse 정적 팩토리 메서드 테스트 작성
kpeel5839 Aug 2, 2023
bb84223
test : 권한이 있는 멤버 전체를 조회하는 기능 Service Test 작성
kpeel5839 Aug 2, 2023
71e970a
test : 해당 토픽에 권한을 가진 자들을 모두 조회하는 기능 인수테스트 작성
kpeel5839 Aug 2, 2023
d5128c6
docs : 해당 토픽에 권한을 가진 유저의 목록을 조회하는 API 명세 작성
kpeel5839 Aug 2, 2023
c5423ad
test : MemberDetailResponse 생성 테스트 추가
kpeel5839 Aug 3, 2023
37a79a8
test : 권한을 가진 유저를 조회하는 기능 Service Test 추가
kpeel5839 Aug 3, 2023
36ac58e
test : 권한을 가진 유저를 조회하는 기능 인수테스트 추가
kpeel5839 Aug 3, 2023
342f35e
docs : 권한을 가진 유저를 조회하는 기능 API 명세 추가
kpeel5839 Aug 3, 2023
864b851
test : 유저를 저장하는 기능 Service Test 작성
kpeel5839 Aug 3, 2023
3fa28bc
test : 유저를 저장하는 기능 인수테스트 작성
kpeel5839 Aug 3, 2023
6b3696f
docs : 유저를 저장하는 기능 API 명세 작성
kpeel5839 Aug 3, 2023
9192536
test : 유저를 목록 조회하는 기능 Service Test 작성
kpeel5839 Aug 3, 2023
522708f
test : 유저를 목록 조회하는 기능 인수테스트 작성
kpeel5839 Aug 3, 2023
0815ff7
docs : 유저를 목록 조회하는 기능 API 명세 작성
kpeel5839 Aug 3, 2023
7fcc517
refactor : AuthInterceptor mocking 을 RestDocs 에서 실행
kpeel5839 Aug 3, 2023
2ea4a21
test : 유저 단일 조회 Service Test 작성
kpeel5839 Aug 3, 2023
e521b2c
test : 유저 단일 조회 인수테스트 작성
kpeel5839 Aug 3, 2023
e2bb58e
docs : 유저 단일 조회 API 명세 작성
kpeel5839 Aug 3, 2023
9d04afb
test : 유저가 만든 토픽, 핀 조회 Service Test 작성
kpeel5839 Aug 3, 2023
96d3512
test : 유저가 만든 토픽, 핀 조회 인수테스트 작성
kpeel5839 Aug 3, 2023
019f330
docs : 유저가 만든 토픽, 핀 조회 API 명세 작성
kpeel5839 Aug 3, 2023
ec9060c
refactor : MemberInfoTest Role 검증 수정
kpeel5839 Aug 7, 2023
fd70f24
refactor : MemberTest 수정
kpeel5839 Aug 7, 2023
459248e
refactor : ServiceTest 내에서 데이터 준비과정을 Repository 로만 하도록 수정
kpeel5839 Aug 7, 2023
8e192c2
refactor : Integeration 테스트에서도 Repository 를 통해 데이터를 준비할 수 있도록 수정
kpeel5839 Aug 7, 2023
6424bde
style : 개행 및 사용하지 않는 import 문 제거
kpeel5839 Aug 7, 2023
a17a621
refactor : 권한 조회시 권한에 대한 ID 값도 반환할 수 있도록 수정
kpeel5839 Aug 8, 2023
a560db6
chore : git pull 이후 충돌 해결
kpeel5839 Aug 8, 2023
e6846a4
fix : ignoringFields 에 createdAt, updatedAt 추가
kpeel5839 Aug 8, 2023
f623a60
fix : github action test 에서 깨지는 테스트 수정
kpeel5839 Aug 8, 2023
0b32101
refactor : MemberDetailResponse updateAt -> updatedAt 로 수정
kpeel5839 Aug 9, 2023
50888d3
refactor : Member name -> nickName 으로 수정
kpeel5839 Aug 9, 2023
67ba9d9
style : 개행 수정
kpeel5839 Aug 9, 2023
6ba447f
refactor : Objects.isNull 을 사용하여 null 을 검사하도록 통일 및 Repository 매개변수 수정
kpeel5839 Aug 9, 2023
f97ac2d
refactor : 부정 조건문 수정
kpeel5839 Aug 9, 2023
9a0b57f
refactor : MemberInfo Update 삭제
kpeel5839 Aug 9, 2023
4da72dc
style : 개행 조정
kpeel5839 Aug 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions backend/src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ toc::[]

include::topic.adoc[]
include::pin.adoc[]
include::member.adoc[]
37 changes: 37 additions & 0 deletions backend/src/docs/asciidoc/member.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
== 유저

=== 유저 권한 부여

operation::member-controller-test/add-member-topic-permission[snippets='http-request,http-response']

=== 유저 권한 삭제

operation::member-controller-test/delete-member-topic-permission[snippets='http-request,http-response']

=== 토픽에 권한을 가진 유저 목록 조회

operation::member-controller-test/find-member-topic-permission-all[snippets='http-request,http-response']

=== 토픽에 권한을 가진 유저 단일 조회

operation::member-controller-test/find-member-topic-permission-by-id[snippets='http-request,http-response']

=== 유저 생성

operation::member-controller-test/add[snippets='http-request,http-response']

=== 유저 목록 조회

operation::member-controller-test/find-all-member[snippets='http-request,http-response']

=== 유저 단일 조회

operation::member-controller-test/find-member-by-id[snippets='http-request,http-response']

=== 유저가 만든 핀 조회

operation::member-controller-test/find-pins-by-member[snippets='http-request,http-response']

=== 유저가 만든 토픽 조회

operation::member-controller-test/find-topics-by-member[snippets='http-request,http-response']
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ public AuthService(MemberRepository memberRepository) {
}

public boolean isMember(AuthInfo authInfo) {
return memberRepository.existsByEmail(authInfo.email());
return memberRepository.existsByMemberInfoEmail(authInfo.email());
}

public AuthMember findAuthMemberByEmail(AuthInfo authInfo) {
return memberRepository.findByEmail(authInfo.email())
return memberRepository.findByMemberInfoEmail(authInfo.email())
.map(this::convertToAuthMember)
.orElseGet(Guest::new);
}
Expand All @@ -45,14 +45,14 @@ private AuthMember convertToAuthMember(Member member) {
}

private List<Long> getTopicsWithPermission(Member member) {
return member.getTopicsWithPermission()
return member.getTopicsWithPermissions()
.stream()
.map(Topic::getId)
.toList();
}

private List<Long> getCreatedTopics(Member member) {
return member.getCreatedTopic()
return member.getCreatedTopics()
.stream()
.map(Topic::getId)
.toList();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.mapbefine.mapbefine.auth.domain;

import com.mapbefine.mapbefine.member.domain.Member;
import com.mapbefine.mapbefine.topic.domain.Topic;
import java.util.List;

Expand All @@ -20,20 +19,6 @@ protected AuthMember(
this.topicsWithPermission = topicsWithPermission;
}

private static List<Long> getTopicsWithPermission(Member member) {
return member.getTopicsWithPermission()
.stream()
.map(Topic::getId)
.toList();
}

private static List<Long> getCreatedTopics(Member member) {
return member.getCreatedTopic()
.stream()
.map(Topic::getId)
.toList();
}

public abstract boolean canRead(Topic topic);

public abstract boolean canDelete(Topic topic);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
package com.mapbefine.mapbefine.member.application;

import com.mapbefine.mapbefine.auth.domain.AuthMember;
import com.mapbefine.mapbefine.member.domain.Member;
import com.mapbefine.mapbefine.member.domain.MemberRepository;
import com.mapbefine.mapbefine.member.domain.MemberTopicPermission;
import com.mapbefine.mapbefine.member.domain.MemberTopicPermissionRepository;
import com.mapbefine.mapbefine.member.dto.request.MemberCreateRequest;
import com.mapbefine.mapbefine.member.dto.request.MemberTopicPermissionCreateRequest;
import com.mapbefine.mapbefine.topic.domain.Topic;
import com.mapbefine.mapbefine.topic.domain.TopicRepository;
import java.util.NoSuchElementException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

Expand All @@ -9,8 +18,101 @@
public class MemberCommandService {

private final MemberRepository memberRepository;
private final TopicRepository topicRepository;
private final MemberTopicPermissionRepository memberTopicPermissionRepository;

public MemberCommandService(MemberRepository memberRepository) {
public MemberCommandService(
MemberRepository memberRepository,
TopicRepository topicRepository,
MemberTopicPermissionRepository memberTopicPermissionRepository
) {
this.memberRepository = memberRepository;
this.topicRepository = topicRepository;
this.memberTopicPermissionRepository = memberTopicPermissionRepository;
}

public Long save(MemberCreateRequest request) {
validateUniqueNickName(request.nickName());
validateUniqueEmail(request.email());

Member member = Member.of(
request.nickName(),
request.email(),
request.imageUrl(),
request.role()
);

return memberRepository.save(member)
.getId();
Comment on lines +45 to +46
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

기준이 애매하긴 한데, 이 정도는 한 줄에 써도 괜찮지 않을까요 ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저 부분 할 때 강박이 도져서..

}

private void validateUniqueNickName(String nickName) {
if (memberRepository.existsByMemberInfoNickName(nickName)) {
throw new IllegalArgumentException("이미 존재하는 닉네임입니다.");
}
}

private void validateUniqueEmail(String email) {
if (memberRepository.existsByMemberInfoEmail(email)) {
throw new IllegalArgumentException("이미 존재하는 이메일입니다.");
}
}

public Long saveMemberTopicPermission(AuthMember authMember, MemberTopicPermissionCreateRequest request) {
Member member = memberRepository.findById(request.memberId())
.orElseThrow(NoSuchElementException::new);
Topic topic = topicRepository.findById(request.topicId())
.orElseThrow(NoSuchElementException::new);

validateSaveMemberTopicPermission(authMember, request, member, topic);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

짧더라도 컨벤션이니 개행해주시면 더 좋을 것 같습니다!


MemberTopicPermission memberTopicPermission =
MemberTopicPermission.createPermissionAssociatedWithTopicAndMember(topic, member);
Comment on lines +69 to +70
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MemberTopicPermission가 매핑 테이블 역할을 하는 것이 맞나요?

그렇다면, 해당 테이블의 데이터를 직접 save 해주기 보다는 cascade와 orphanRemoval 설정을 활용해보는 편이 어떨까요 ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

음.. 이 부분은 저도 처음에 쥬니 말씀처럼 하려다가 애매해서 MemberTopicPermission 을 저장하도록 했는데요.

이유는 2가지가 정도가 있었습니다.

  1. Member 와 Topic 중 어떤 것을 이용하여 저장할까?? (물론 Member 쪽에 쏠리긴하지만 찝찝해버령)
  2. 이걸 생명주기라고 해야할까요? Member 와 Topic 은 이미 생성되어 있고, 수정된 정보가 MemberTopicPermission 이외에는 없었습니다.

위와 같은 2가지 이유로 쥬니가 말씀하신 사안을 선택하지 않았는데요!

이에 대한 쥬니의 의견도 말씀해주시면 반영해보도록 할게요! 쥬니짜응짜응

Copy link
Collaborator

@cpot5620 cpot5620 Aug 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Member 와 Topic 중 어떤 것을 이용하여 저장할까?? (물론 Member 쪽에 쏠리긴하지만 찝찝해버령)

Member 소유로 가지고 있는 Topic이기 때문에 Member를 이용하면 될 것 같아요.

이걸 생명주기라고 해야할까요? Member 와 Topic 은 이미 생성되어 있고, 수정된 정보가 MemberTopicPermission 이외에는 없었습니다.

멤버에게 토픽 권한이 추가되었다는 것은 멤버의 정보가 업데이트 된 것이겠죠 ?
그렇다면, 멤버의 업데이트된 정보가 저장 되면서 MemberTopicPermission가 저장되는 것이 흐름이나, 객체적인 측면에서 자연스러워 보여요.

의견 부탁드립니다 !


return memberTopicPermissionRepository.save(memberTopicPermission).getId();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

개행 !

}

private void validateSaveMemberTopicPermission(
AuthMember authMember,
MemberTopicPermissionCreateRequest request,
Member member,
Topic topic
) {
validateMemberCanTopicUpdate(authMember, topic);
validateSelfPermission(authMember, request);
validateDuplicatePermission(topic.getId(), member.getId());
}

private void validateMemberCanTopicUpdate(AuthMember authMember, Topic topic) {
if (authMember.canTopicUpdate(topic)) {
return;
}

throw new IllegalArgumentException("해당 유저는 해당 토픽에서 다른 유저에게 권한을 줄 수 없습니다.");
}

private void validateSelfPermission(
AuthMember authMember,
MemberTopicPermissionCreateRequest request
) {
if (authMember.getMemberId().equals(request.memberId())) {
throw new IllegalArgumentException("본인에게 권한을 줄 수 없습니다.");
}
}

private void validateDuplicatePermission(Long topicId, Long memberId) {
if (memberTopicPermissionRepository.existsByTopicIdAndMemberId(topicId, memberId)) {
throw new IllegalArgumentException("권한은 중복으로 줄 수 없습니다.");
}
}

public void deleteMemberTopicPermission(AuthMember authMember, Long permissionId) {
MemberTopicPermission memberTopicPermission = memberTopicPermissionRepository.findById(permissionId)
.orElseThrow(NoSuchElementException::new);

validateMemberCanTopicUpdate(authMember, memberTopicPermission.getTopic());

memberTopicPermissionRepository.delete(memberTopicPermission);
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
package com.mapbefine.mapbefine.member.application;

import com.mapbefine.mapbefine.auth.domain.AuthMember;
import com.mapbefine.mapbefine.member.domain.Member;
import com.mapbefine.mapbefine.member.domain.MemberRepository;
import com.mapbefine.mapbefine.member.domain.MemberTopicPermission;
import com.mapbefine.mapbefine.member.domain.MemberTopicPermissionRepository;
import com.mapbefine.mapbefine.member.dto.response.MemberDetailResponse;
import com.mapbefine.mapbefine.member.dto.response.MemberResponse;
import com.mapbefine.mapbefine.member.dto.response.MemberTopicPermissionDetailResponse;
import com.mapbefine.mapbefine.member.dto.response.MemberTopicPermissionResponse;
import com.mapbefine.mapbefine.pin.domain.Pin;
import com.mapbefine.mapbefine.pin.domain.PinRepository;
import com.mapbefine.mapbefine.pin.dto.response.PinResponse;
import com.mapbefine.mapbefine.topic.domain.Topic;
import com.mapbefine.mapbefine.topic.domain.TopicRepository;
import com.mapbefine.mapbefine.topic.dto.response.TopicResponse;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Objects;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

Expand All @@ -9,8 +26,75 @@
public class MemberQueryService {

private final MemberRepository memberRepository;
private final TopicRepository topicRepository;
private final PinRepository pinRepository;
private final MemberTopicPermissionRepository memberTopicPermissionRepository;

public MemberQueryService(MemberRepository memberRepository) {
public MemberQueryService(
MemberRepository memberRepository,
TopicRepository topicRepository,
PinRepository pinRepository,
MemberTopicPermissionRepository memberTopicPermissionRepository
) {
this.memberRepository = memberRepository;
this.topicRepository = topicRepository;
this.pinRepository = pinRepository;
this.memberTopicPermissionRepository = memberTopicPermissionRepository;
}

public MemberDetailResponse findById(Long id) {
Member member = memberRepository.findById(id)
.orElseThrow(NoSuchElementException::new);

return MemberDetailResponse.from(member);
}

public List<MemberResponse> findAll() {
return memberRepository.findAll()
.stream()
.map(MemberResponse::from)
.toList();
}
Comment on lines +52 to +57
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.stream 정도야 한 줄에 써도 되겠지 했었는데, 제가 컨벤션을 잘못 알고 있었네요 ㅎㅎ
매튜 짱 👍


public List<TopicResponse> findTopicsByMember(AuthMember authMember) {
validateNonExistsMember(authMember.getMemberId());
List<Topic> topicsByCreator = topicRepository.findByCreatorId(authMember.getMemberId());

return topicsByCreator.stream()
.map(TopicResponse::from)
.toList();
}

public List<PinResponse> findPinsByMember(AuthMember authMember) {
validateNonExistsMember(authMember.getMemberId());
List<Pin> pinsByCreator = pinRepository.findByCreatorId(authMember.getMemberId());

return pinsByCreator.stream()
.map(PinResponse::from)
.toList();
}

public void validateNonExistsMember(Long memberId) {
if (Objects.isNull(memberId)) {
throw new IllegalArgumentException("존재하지 않는 유저입니다.");
}
}

public List<MemberTopicPermissionResponse> findAllWithPermission(Long topicId) {
Topic topic = topicRepository.findById(topicId)
.orElseThrow(NoSuchElementException::new);

return memberTopicPermissionRepository.findAllByTopic(topic)
.stream()
.map(MemberTopicPermissionResponse::from)
.toList();
}

public MemberTopicPermissionDetailResponse findMemberTopicPermissionById(Long permissionId) {
MemberTopicPermission memberTopicPermission = memberTopicPermissionRepository.findById(permissionId)
.orElseThrow(NoSuchElementException::new);

return MemberTopicPermissionDetailResponse.from(memberTopicPermission);
}

}
Loading
Loading