-
Notifications
You must be signed in to change notification settings - Fork 6
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] Refactor/#406 토픽 권한을 가진 회원 목록 조회 시 공개 여부를 함께 반환하도록 변경 #412
Changes from 14 commits
9dfea1f
afc314c
7be1f71
1613287
6d9b305
b90630c
016496f
5ffb6cb
318228f
bec7adf
fc6ba2f
31f1d06
4232fe2
f21911f
190255f
443b456
e60fa9c
8f71050
f4c5b93
754336d
8a12ba7
4d50edc
17641cd
f54e896
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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
== 즐겨찾기 | ||
|
||
=== 토픽을 유저의 즐겨찾기에 추가 | ||
=== 토픽을 회원의 즐겨찾기에 추가 | ||
|
||
operation::bookmark-controller-test/add-topic-in-bookmark[snippets='http-request,http-response'] | ||
|
||
|
||
=== 유저의 토픽 즐겨찾기 삭제 | ||
=== 회원의 토픽 즐겨찾기 삭제 | ||
|
||
operation::bookmark-controller-test/delete-topic-in-bookmark[snippets='http-request,http-response'] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
== 유저 | ||
== 회원 | ||
|
||
=== 유저 목록 조회 | ||
=== 회원 목록 조회 | ||
|
||
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-my-all-topics[snippets='http-request,http-response'] | ||
|
||
=== 유저의 나의 핀 목록 조회 | ||
=== 회원의 나의 핀 목록 조회 | ||
|
||
operation::member-controller-test/find-my-all-pins[snippets='http-request,http-response'] | ||
|
||
=== 유저의 모아보기 조회 | ||
=== 회원의 모아보기 조회 | ||
|
||
operation::member-controller-test/find-all-topics-in-atlas[snippets='http-request,http-response'] | ||
|
||
=== 유저의 즐겨찾기 조회 | ||
=== 회원의 즐겨찾기 조회 | ||
|
||
operation::member-controller-test/find-all-topics-in-bookmark[snippets='http-request,http-response'] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
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.dto.request.MemberUpdateRequest; | ||
import com.mapbefine.mapbefine.member.exception.MemberErrorCode; | ||
import com.mapbefine.mapbefine.member.exception.MemberException.MemberConflictException; | ||
import java.util.NoSuchElementException; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@Transactional | ||
public class MemberCommandService { | ||
|
||
private final MemberRepository memberRepository; | ||
|
||
public MemberCommandService(MemberRepository memberRepository) { | ||
this.memberRepository = memberRepository; | ||
} | ||
|
||
public void updateInfoById(AuthMember authMember, MemberUpdateRequest request) { | ||
Member member = findMemberById(authMember.getMemberId()); | ||
String nickName = request.nickName(); | ||
|
||
validateNicknameDuplicated(nickName); | ||
|
||
member.update(nickName); | ||
} | ||
|
||
private Member findMemberById(Long memberId) { | ||
return memberRepository.findById(memberId) | ||
.orElseThrow(() -> new NoSuchElementException("findMemberById; memberId=" + memberId)); | ||
} | ||
|
||
private void validateNicknameDuplicated(String nickName) { | ||
if (memberRepository.existsByMemberInfoNickName(nickName)) { | ||
throw new MemberConflictException(MemberErrorCode.ILLEGAL_NICKNAME_ALREADY_EXISTS, nickName); | ||
} | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.mapbefine.mapbefine.member.dto.request; | ||
|
||
public record MemberUpdateRequest( | ||
String nickName | ||
) { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,16 @@ | |
|
||
import com.mapbefine.mapbefine.permission.domain.Permission; | ||
import com.mapbefine.mapbefine.permission.domain.PermissionRepository; | ||
import com.mapbefine.mapbefine.permission.dto.response.PermissionDetailResponse; | ||
import com.mapbefine.mapbefine.permission.dto.response.PermissionResponse; | ||
import com.mapbefine.mapbefine.permission.dto.response.PermissionMemberDetailResponse; | ||
import com.mapbefine.mapbefine.permission.dto.response.PermissionedMemberResponse; | ||
import com.mapbefine.mapbefine.permission.dto.response.TopicAccessDetailResponse; | ||
import com.mapbefine.mapbefine.permission.exception.PermissionException.PermissionNotFoundException; | ||
import com.mapbefine.mapbefine.topic.domain.Publicity; | ||
import com.mapbefine.mapbefine.topic.domain.Topic; | ||
import com.mapbefine.mapbefine.topic.domain.TopicRepository; | ||
import com.mapbefine.mapbefine.topic.domain.TopicStatus; | ||
import com.mapbefine.mapbefine.topic.exception.TopicErrorCode; | ||
import com.mapbefine.mapbefine.topic.exception.TopicException.TopicNotFoundException; | ||
import java.util.List; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
@@ -16,22 +23,35 @@ | |
public class PermissionQueryService { | ||
|
||
private final PermissionRepository permissionRepository; | ||
private final TopicRepository topicRepository; | ||
|
||
public PermissionQueryService(PermissionRepository permissionRepository) { | ||
public PermissionQueryService(PermissionRepository permissionRepository, TopicRepository topicRepository) { | ||
this.permissionRepository = permissionRepository; | ||
this.topicRepository = topicRepository; | ||
} | ||
|
||
public List<PermissionResponse> findAllTopicPermissions(Long topicId) { | ||
return permissionRepository.findAllByTopicId(topicId) | ||
public TopicAccessDetailResponse findTopicAccessDetailById(Long topicId) { | ||
Publicity publicity = findTopicPublicityById(topicId); | ||
/// TODO: 2023/09/15 이럴거면 topic.getPermissions 로 하는 게 나을 수도 있나? TopicController 에서 하는 게 더 자연스러운 것 같기도.. | ||
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. 저도 TODO처럼 생각합니당! 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. 저두요 |
||
List<PermissionedMemberResponse> permissionedMembers = permissionRepository.findAllByTopicId(topicId) | ||
.stream() | ||
.map(PermissionResponse::from) | ||
.map(PermissionedMemberResponse::from) | ||
.toList(); | ||
|
||
return new TopicAccessDetailResponse(publicity, permissionedMembers); | ||
} | ||
|
||
private Publicity findTopicPublicityById(Long topicId) { | ||
return topicRepository.findById(topicId) | ||
.map(Topic::getTopicStatus) | ||
.map(TopicStatus::getPublicity) | ||
.orElseThrow(() -> new TopicNotFoundException(TopicErrorCode.TOPIC_NOT_FOUND, topicId)); | ||
} | ||
|
||
public PermissionDetailResponse findPermissionById(Long permissionId) { | ||
public PermissionMemberDetailResponse findPermissionById(Long permissionId) { | ||
Permission permission = permissionRepository.findById(permissionId) | ||
.orElseThrow(() -> new PermissionNotFoundException(PERMISSION_NOT_FOUND, permissionId)); | ||
|
||
return PermissionDetailResponse.from(permission); | ||
return PermissionMemberDetailResponse.from(permission); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
@Getter | ||
public class Permission extends BaseTimeEntity { | ||
|
||
// TODO 매핑 테이블인데 Id를 가져야 할까? | ||
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. 저도 값타입 컬렉션 - map을 써보는 건 어떨까 생각하긴 했어요 ㅋㅋ |
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
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.
p2. email은 nullable하더라도 unique 하면 더 좋지 않을까요?
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.
아 이 부분은 #408 PR에 해당되는 커밋인데요! 커밋에만 적고 자세히 말씀을 못드렸네용
아래와 같은 이유로 변경했는데 어떻게 생각하시나요??
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.
저는 2번째 경우는 두번째 회원 가입을 막아야한다고 생각하긴 했어요!
아이디가 다중으로 필요한 경우는 보통 어뷰저일 가능성이 높다고 생각해서요 ㅋㅋ
(차단을 당했거나, 여러 아이디로 분란을 조장하거나 등등)
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.
@cpot5620 @kpeel5839 의견은 어떠신가요??
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.
저는 오히려 회원가입을 막게되면 다중 플랫폼을 제공하는 의미가 다소 퇴색될 것 같기도 하다는 생각이 드네용
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.
저도 unique할 필요는 없다고 생각해요 !!!!!!
만약, unique하게 갈거라면 어떤 OAuth로 연동되어있는지도 알려주는 기능이 필요할 것 같아요.