-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0c162ac
commit 9488a0e
Showing
22 changed files
with
195 additions
and
83 deletions.
There are no files selected for viewing
24 changes: 0 additions & 24 deletions
24
src/main/java/aromanticcat/umcproject/controller/AddressBookController.java
This file was deleted.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
src/main/java/aromanticcat/umcproject/converter/FriendConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package aromanticcat.umcproject.converter; | ||
|
||
import aromanticcat.umcproject.web.dto.Friend.FriendResponseDTO; | ||
import aromanticcat.umcproject.entity.Friend; | ||
import org.springframework.data.domain.Page; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public class FriendConverter { | ||
|
||
// Friend 엔티티 -> DTO 생성 | ||
public static FriendResponseDTO.FriendDTO toFriendDTO(Friend friend){ | ||
|
||
return FriendResponseDTO.FriendDTO.builder() | ||
.friend_id(friend.getId()) | ||
.friend_name(friend.getFriend_name()) | ||
.are_we_friend(friend.isAre_we_friend()) | ||
.are_we_close(friend.isAre_we_close()) | ||
.build(); | ||
} | ||
|
||
} |
5 changes: 0 additions & 5 deletions
5
src/main/java/aromanticcat/umcproject/dto/AddressBook/AddressBookRequestDTO.java
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
src/main/java/aromanticcat/umcproject/dto/AddressBook/AddressBookRespondDTO.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/main/java/aromanticcat/umcproject/repository/FriendRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package aromanticcat.umcproject.repository; | ||
|
||
import aromanticcat.umcproject.entity.Friend; | ||
import aromanticcat.umcproject.entity.Member; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.PageRequest; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface FriendRepository extends JpaRepository<Friend, Long> { | ||
|
||
Page<Friend> findByMember(Member member, Pageable pageable); | ||
} |
4 changes: 0 additions & 4 deletions
4
...ain/java/aromanticcat/umcproject/service/AdressBookService/AddressBookCommandService.java
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
...java/aromanticcat/umcproject/service/AdressBookService/AddressBookCommandServiceImpl.java
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
src/main/java/aromanticcat/umcproject/service/AdressBookService/AddressBookQueryService.java
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
...n/java/aromanticcat/umcproject/service/AdressBookService/AddressBookQueryServiceImpl.java
This file was deleted.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
src/main/java/aromanticcat/umcproject/service/FriendService/FriendCommandService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package aromanticcat.umcproject.service.FriendService; | ||
|
||
public interface FriendCommandService { | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/aromanticcat/umcproject/service/FriendService/FriendCommandServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package aromanticcat.umcproject.service.FriendService; | ||
|
||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class FriendCommandServiceImpl implements FriendCommandService { | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/aromanticcat/umcproject/service/FriendService/FriendQueryService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package aromanticcat.umcproject.service.FriendService; | ||
|
||
import aromanticcat.umcproject.entity.Friend; | ||
import aromanticcat.umcproject.entity.Member; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
|
||
import java.util.Optional; | ||
|
||
public interface FriendQueryService { | ||
|
||
Optional<Member> findMember(Long id); | ||
|
||
Page<Friend> getFriendList(Long MemberId, Integer page); | ||
|
||
|
||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/aromanticcat/umcproject/service/FriendService/FriendQueryServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package aromanticcat.umcproject.service.FriendService; | ||
|
||
import aromanticcat.umcproject.entity.Friend; | ||
import aromanticcat.umcproject.entity.Member; | ||
import aromanticcat.umcproject.repository.FriendRepository; | ||
import aromanticcat.umcproject.repository.MemberRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.PageRequest; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.Optional; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Transactional | ||
public class FriendQueryServiceImpl implements FriendQueryService { | ||
|
||
private final MemberRepository memberRepository; | ||
private final FriendRepository friendRepository; | ||
|
||
@Override | ||
public Optional<Member> findMember(Long memberId) { | ||
Optional<Member> member = memberRepository.findById(memberId); | ||
return member; | ||
} | ||
|
||
@Override | ||
public Page<Friend> getFriendList(Long MemberId, Integer page) { | ||
|
||
// page는 페이지의 번호, 12는 한 페이지에 보여줄 친구의 수 | ||
Pageable pageable = PageRequest.of(page,12); | ||
|
||
Member member = memberRepository.findById(MemberId).get(); | ||
|
||
Page<Friend> friendList = friendRepository.findByMember(member, pageable); | ||
|
||
return friendList; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
src/main/java/aromanticcat/umcproject/service/NangmanLetterService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/java/aromanticcat/umcproject/service/NangmanLetterServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/main/java/aromanticcat/umcproject/web/controller/FriendController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package aromanticcat.umcproject.web.controller; | ||
|
||
|
||
import aromanticcat.umcproject.apiPayload.ApiResponse; | ||
import aromanticcat.umcproject.converter.FriendConverter; | ||
import aromanticcat.umcproject.entity.Friend; | ||
import aromanticcat.umcproject.web.dto.Friend.FriendResponseDTO; | ||
import aromanticcat.umcproject.service.FriendService.FriendQueryService; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.Parameters; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@RestController | ||
@RequestMapping("/address-book") | ||
@RequiredArgsConstructor | ||
public class FriendController { | ||
|
||
private final FriendQueryService friendQueryService; | ||
|
||
@GetMapping("/{member_id}") | ||
@Operation(summary = "사용자의 주소록에 있는 친구들 조회 API", description = "페이징 포함을 포함합니다, query String으로 page 번호를 주세요.") | ||
// @ApiResponses(value = { | ||
// @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200", description = "OK, 성공"), | ||
// @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "AUTH003", description = "access 토큰을 주세요!", content = @Content(schema = @Schema(implementation = ApiResponse.class))), | ||
// @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "AUTH004", description = "access 토큰 만료", content = @Content(schema = @Schema(implementation = ApiResponse.class))), | ||
// @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "AUTH006", description = "access 토큰 모양이 이상함", content = @Content(schema = @Schema(implementation = ApiResponse.class))), | ||
// }) | ||
@Parameters({ | ||
@Parameter(name = "memberId", description = "사용자의 아이디, path variable 입니다!"), | ||
@Parameter(name = "page", description = "페이지 번호, 0번이 1번 페이지 입니다.") | ||
}) | ||
public ApiResponse<List<FriendResponseDTO.FriendDTO>> getFriendList(@PathVariable(name = "member_id") Long memberId, | ||
@RequestParam(value = "page", defaultValue = "0") Integer page){ | ||
try{ | ||
// 페이지별 친구 목록 조회 | ||
Page<Friend> friendList = friendQueryService.getFriendList(memberId, page); | ||
|
||
// 친구 내용을 간략하게 변환 | ||
List<FriendResponseDTO.FriendDTO> friendDTOList = friendList.stream() | ||
.map(FriendConverter::toFriendDTO) | ||
.collect(Collectors.toList()); | ||
|
||
// 성공 응답 생성 | ||
return ApiResponse.onSuccess(friendDTOList); | ||
|
||
}catch (Exception e){ | ||
return ApiResponse.onFailure(HttpStatus.INTERNAL_SERVER_ERROR.toString(), e.getMessage(), null); | ||
} | ||
} | ||
|
||
|
||
} |
4 changes: 2 additions & 2 deletions
4
...t/controller/NangmanLetterController.java → ...b/controller/NangmanLetterController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/main/java/aromanticcat/umcproject/web/dto/Friend/FriendRequestDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package aromanticcat.umcproject.web.dto.Friend; | ||
|
||
|
||
public class FriendRequestDTO { | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/aromanticcat/umcproject/web/dto/Friend/FriendResponseDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package aromanticcat.umcproject.web.dto.Friend; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
import java.util.List; | ||
|
||
public class FriendResponseDTO { | ||
|
||
@Getter | ||
@Builder | ||
public static class FriendDTO{ | ||
Long friend_id; | ||
String friend_name; | ||
boolean are_we_friend; | ||
boolean are_we_close; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...ccat/umcproject/dto/NangmanLetterDTO.java → .../umcproject/web/dto/NangmanLetterDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters