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
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,4 @@ public ResponseEntity<JoinRespondResponseDto> respondToJoinRequest(
return ResponseEntity.ok(res);
}

//todo 내가 신청한 가입신청 리스트 조회
}
36 changes: 36 additions & 0 deletions src/main/java/flipnote/group/adapter/in/web/MeController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package flipnote.group.adapter.in.web;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import flipnote.group.api.dto.response.FindMyJoinListResponseDto;
import flipnote.group.application.port.in.FindMyJoinListUseCase;
import flipnote.group.application.port.in.result.FindMyJoinListResult;
import lombok.RequiredArgsConstructor;

@RestController
@RequestMapping("/v1")
@RequiredArgsConstructor
public class MeController {

private final FindMyJoinListUseCase findMyJoinListUseCase;

/**
* 내가 신청한 가입신청 리스트 조회
* @param userId
* @return
*/
@GetMapping("/joins/me")
public ResponseEntity<FindMyJoinListResponseDto> findGroupJoinMe(
@RequestHeader("X-USER-ID") Long userId
) {
FindMyJoinListResult result = findMyJoinListUseCase.findMyJoinList(userId);

FindMyJoinListResponseDto res = FindMyJoinListResponseDto.from(result);

return ResponseEntity.ok(res);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,11 @@ public JoinEntity findJoin(Long joinId) {
public JoinEntity updateJoin(JoinEntity join) {
return joinRepository.save(join);
}

@Override
public List<JoinEntity> findMyJoinList(Long userId) {
List<JoinEntity> joinList = joinRepository.findAllByUserId(userId);

return joinList;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package flipnote.group.api.dto.response;

import java.util.List;

import flipnote.group.application.port.in.result.FindMyJoinListResult;
import flipnote.group.domain.model.join.JoinInfo;

public record FindMyJoinListResponseDto(
List<JoinInfo> joinList
) {
public static FindMyJoinListResponseDto from(FindMyJoinListResult result) {

return new FindMyJoinListResponseDto(result.joinList());
}
}
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.result.FindMyJoinListResult;

public interface FindMyJoinListUseCase {
FindMyJoinListResult findMyJoinList(Long userId);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package flipnote.group.application.port.in.result;

import java.util.List;

import flipnote.group.adapter.out.entity.JoinEntity;
import flipnote.group.domain.model.join.JoinInfo;

public record FindMyJoinListResult(
List<JoinInfo> joinList
) {
public static FindMyJoinListResult of(List<JoinEntity> joinList) {
List<JoinInfo> joinInfoList = joinList.stream()
.map(JoinInfo::of)
.toList();
return new FindMyJoinListResult(joinInfoList);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ public interface JoinRepositoryPort {
JoinEntity findJoin(Long joinId);

JoinEntity updateJoin(JoinEntity join);

List<JoinEntity> findMyJoinList(Long userId);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package flipnote.group.application.service;

import java.util.List;

import org.springframework.stereotype.Service;

import flipnote.group.adapter.out.entity.JoinEntity;
import flipnote.group.application.port.in.FindMyJoinListUseCase;
import flipnote.group.application.port.in.result.FindMyJoinListResult;
import flipnote.group.application.port.out.JoinRepositoryPort;
import lombok.RequiredArgsConstructor;

@Service
@RequiredArgsConstructor
public class FindMyJoinListService implements FindMyJoinListUseCase {

private final JoinRepositoryPort joinRepository;

@Override
public FindMyJoinListResult findMyJoinList(Long userId) {

List<JoinEntity> joinList = joinRepository.findMyJoinList(userId);

return FindMyJoinListResult.of(joinList);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ public interface JoinRepository extends JpaRepository<JoinEntity, Long> {
boolean existsByUserIdAndGroupId(Long userId, Long groupId);

List<JoinEntity> findAllByGroupId(Long groupId);

List<JoinEntity> findAllByUserId(Long userId);
}