diff --git a/src/main/java/flipnote/group/adapter/in/web/GroupController.java b/src/main/java/flipnote/group/adapter/in/web/GroupController.java index fd56c2f..8856c06 100644 --- a/src/main/java/flipnote/group/adapter/in/web/GroupController.java +++ b/src/main/java/flipnote/group/adapter/in/web/GroupController.java @@ -1,6 +1,7 @@ package flipnote.group.adapter.in.web; import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; @@ -17,9 +18,11 @@ import flipnote.group.api.dto.response.FindGroupResponseDto; import flipnote.group.application.port.in.ChangeGroupUseCase; import flipnote.group.application.port.in.CreateGroupUseCase; +import flipnote.group.application.port.in.DeleteGroupUseCase; import flipnote.group.application.port.in.FindGroupUseCase; import flipnote.group.application.port.in.command.ChangeGroupCommand; import flipnote.group.application.port.in.command.CreateGroupCommand; +import flipnote.group.application.port.in.command.DeleteGroupCommand; import flipnote.group.application.port.in.command.FindGroupCommand; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; @@ -32,6 +35,7 @@ public class GroupController { private final CreateGroupUseCase createGroupUseCase; private final ChangeGroupUseCase changeGroupUseCase; private final FindGroupUseCase findGroupUseCase; + private final DeleteGroupUseCase deleteGroupUseCase; /** * 그룹 생성 API @@ -111,4 +115,32 @@ public ResponseEntity findGroup( return ResponseEntity.ok(res); } + /** + * 그룹 삭제 + * todo 추후 권한 체크 후 권한 확인 후 삭제 + * @param userId + * @param groupId + * @return + */ + @DeleteMapping("/{groupId}") + public ResponseEntity deleteGroup( + @RequestHeader("X-USER-ID") Long userId, + @PathVariable("groupId") Long groupId + ) { + + DeleteGroupCommand cmd = new DeleteGroupCommand(userId, groupId); + + deleteGroupUseCase.deleteGroup(cmd); + + return ResponseEntity.noContent().build(); + } + + //todo 그룹 내 멤버 조회 + + //todo 그룹 전체 조회 + + //todo 내 그룹 전체 조회 + + //todo 내가 생성한 그룹 전체 조회 + } diff --git a/src/main/java/flipnote/group/adapter/in/web/MemberController.java b/src/main/java/flipnote/group/adapter/in/web/MemberController.java new file mode 100644 index 0000000..8023df8 --- /dev/null +++ b/src/main/java/flipnote/group/adapter/in/web/MemberController.java @@ -0,0 +1,18 @@ +package flipnote.group.adapter.in.web; + +public class MemberController { + //todo 가인 신청 요청 + + //todo 그룹 내 가입 신청한 리스트 조회 + + //todo 가입신청 응답 + + //todo 가입신청 삭제 + + //todo 내가 신청한 가입신청 리스트 조회 + + //todo 초대 + + //todo 그룹 멤버 추방 + +} diff --git a/src/main/java/flipnote/group/adapter/out/persistence/GroupRepositoryAdapter.java b/src/main/java/flipnote/group/adapter/out/persistence/GroupRepositoryAdapter.java index dcba394..03aec29 100644 --- a/src/main/java/flipnote/group/adapter/out/persistence/GroupRepositoryAdapter.java +++ b/src/main/java/flipnote/group/adapter/out/persistence/GroupRepositoryAdapter.java @@ -35,4 +35,12 @@ public Group findById(Long id) { ); return GroupMapper.toDomain(groupEntity); } + + @Override + public void delete(Long groupId) { + if (!groupRepository.existsById(groupId)) { + throw new IllegalArgumentException("Group not Exist"); + } + groupRepository.deleteById(groupId); + } } diff --git a/src/main/java/flipnote/group/application/port/in/DeleteGroupUseCase.java b/src/main/java/flipnote/group/application/port/in/DeleteGroupUseCase.java new file mode 100644 index 0000000..1cc63a6 --- /dev/null +++ b/src/main/java/flipnote/group/application/port/in/DeleteGroupUseCase.java @@ -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); +} diff --git a/src/main/java/flipnote/group/application/port/in/command/DeleteGroupCommand.java b/src/main/java/flipnote/group/application/port/in/command/DeleteGroupCommand.java new file mode 100644 index 0000000..4be2351 --- /dev/null +++ b/src/main/java/flipnote/group/application/port/in/command/DeleteGroupCommand.java @@ -0,0 +1,7 @@ +package flipnote.group.application.port.in.command; + +public record DeleteGroupCommand( + Long userId, + Long groupId +) { +} diff --git a/src/main/java/flipnote/group/application/port/out/GroupRepositoryPort.java b/src/main/java/flipnote/group/application/port/out/GroupRepositoryPort.java index cc7ad54..432b6c0 100644 --- a/src/main/java/flipnote/group/application/port/out/GroupRepositoryPort.java +++ b/src/main/java/flipnote/group/application/port/out/GroupRepositoryPort.java @@ -6,4 +6,6 @@ public interface GroupRepositoryPort { Long saveNewGroup(Group group); Group findById(Long id); + + void delete(Long id); } diff --git a/src/main/java/flipnote/group/application/service/DeleteGroupService.java b/src/main/java/flipnote/group/application/service/DeleteGroupService.java new file mode 100644 index 0000000..41af347 --- /dev/null +++ b/src/main/java/flipnote/group/application/service/DeleteGroupService.java @@ -0,0 +1,23 @@ +package flipnote.group.application.service; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +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) { + groupRepository.delete(cmd.groupId()); + } + +}