-
Notifications
You must be signed in to change notification settings - Fork 0
Feat: [FN-301] 그룹 삭제 API 구현 #5
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package flipnote.group.adapter.in.web; | ||
|
|
||
| public class MemberController { | ||
| //todo 가인 신청 요청 | ||
|
|
||
| //todo 그룹 내 가입 신청한 리스트 조회 | ||
|
|
||
| //todo 가입신청 응답 | ||
|
|
||
| //todo 가입신청 삭제 | ||
|
|
||
| //todo 내가 신청한 가입신청 리스트 조회 | ||
|
|
||
| //todo 초대 | ||
|
|
||
| //todo 그룹 멤버 추방 | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -35,4 +35,9 @@ public Group findById(Long id) { | |||||||||||||||||||||||
| ); | ||||||||||||||||||||||||
| return GroupMapper.toDomain(groupEntity); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| @Override | ||||||||||||||||||||||||
| public void delete(Long groupId) { | ||||||||||||||||||||||||
| groupRepository.deleteById(groupId); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
Comment on lines
+39
to
+42
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. 존재하지 않는 그룹 삭제 시 예외 처리 부재 Spring Data JPA 3.x의 🔧 존재 확인 후 삭제하는 방식 제안 `@Override`
public void delete(Long groupId) {
- groupRepository.deleteById(groupId);
+ if (!groupRepository.existsById(groupId)) {
+ throw new IllegalArgumentException("Group not Exist");
+ }
+ groupRepository.deleteById(groupId);
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package flipnote.group.application.port.in; | ||
|
|
||
| import flipnote.group.application.port.in.command.DeleteGroupCommand; | ||
|
|
||
| public interface DeleteGroupUseCase { | ||
| void deleteGroup(DeleteGroupCommand cmd); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package flipnote.group.application.port.in.command; | ||
|
|
||
| public record DeleteGroupCommand( | ||
| Long userId, | ||
| Long groupId | ||
| ) { | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package flipnote.group.application.service; | ||
|
|
||
| import org.springframework.stereotype.Service; | ||
|
|
||
| import flipnote.group.application.port.in.DeleteGroupUseCase; | ||
| import flipnote.group.application.port.in.command.DeleteGroupCommand; | ||
| import flipnote.group.application.port.out.GroupRepositoryPort; | ||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class DeleteGroupService implements DeleteGroupUseCase { | ||
|
|
||
| private final GroupRepositoryPort groupRepository; | ||
|
|
||
| @Override | ||
| public void deleteGroup(DeleteGroupCommand cmd) { | ||
| groupRepository.delete(cmd.groupId()); | ||
| } | ||
|
Comment on lines
+10
to
+19
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.
두 가지 문제가 있습니다:
🔧 `@Transactional` 추가 및 소유자 검증 제안 package flipnote.group.application.service;
+import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Service;
import flipnote.group.application.port.in.DeleteGroupUseCase;
import flipnote.group.application.port.in.command.DeleteGroupCommand;
import flipnote.group.application.port.out.GroupRepositoryPort;
import lombok.RequiredArgsConstructor;
`@Service`
`@RequiredArgsConstructor`
public class DeleteGroupService implements DeleteGroupUseCase {
private final GroupRepositoryPort groupRepository;
`@Override`
+ `@Transactional`
public void deleteGroup(DeleteGroupCommand cmd) {
+ var group = groupRepository.findById(cmd.groupId());
+ // TODO: group.getOwnerId()와 cmd.userId() 비교하여 권한 검증
groupRepository.delete(cmd.groupId());
}
}🤖 Prompt for AI Agents |
||
|
|
||
| } | ||
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.
엔드포인트 구조는 적절합니다. TODO 코멘트에 오타가 있습니다.
Line 120:
권환→권한(2회 반복). 사소하지만 나중에 TODO를 검색할 때 혼동을 줄 수 있습니다.🤖 Prompt for AI Agents