Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
32 changes: 32 additions & 0 deletions src/main/java/flipnote/group/adapter/in/web/GroupController.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -32,6 +35,7 @@ public class GroupController {
private final CreateGroupUseCase createGroupUseCase;
private final ChangeGroupUseCase changeGroupUseCase;
private final FindGroupUseCase findGroupUseCase;
private final DeleteGroupUseCase deleteGroupUseCase;

/**
* 그룹 생성 API
Expand Down Expand Up @@ -111,4 +115,32 @@ public ResponseEntity<FindGroupResponseDto> findGroup(
return ResponseEntity.ok(res);
}

/**
* 그룹 삭제
* todo 추후 권한 체크 후 권한 확인 후 삭제
* @param userId
* @param groupId
* @return
*/
@DeleteMapping("/{groupId}")
public ResponseEntity<Void> 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 내가 생성한 그룹 전체 조회

}
18 changes: 18 additions & 0 deletions src/main/java/flipnote/group/adapter/in/web/MemberController.java
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
Expand Up @@ -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);
}
}
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
Expand Up @@ -6,4 +6,6 @@ public interface GroupRepositoryPort {
Long saveNewGroup(Group group);

Group findById(Long id);

void delete(Long id);
}
Original file line number Diff line number Diff line change
@@ -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());
}

}