Skip to content

Commit dfef37d

Browse files
authored
Revert "Feat: 프로필 화면 API" (#85)
Reverts #79 -> 코드 에러 난 거 확인 후 다시 pr 올려주세요
2 parents 4397b16 + 1889ae8 commit dfef37d

File tree

11 files changed

+37
-176
lines changed

11 files changed

+37
-176
lines changed

src/main/java/EatPic/spring/domain/card/controller/CardController.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package EatPic.spring.domain.card.controller;
22

33
import EatPic.spring.domain.card.dto.request.CardCreateRequest;
4-
import EatPic.spring.domain.card.dto.response.CardResponse;
54
import EatPic.spring.domain.card.dto.request.CardCreateRequest.CardUpdateRequest;
65
import EatPic.spring.domain.card.dto.response.CardResponse.CardDetailResponse;
76
import EatPic.spring.domain.card.dto.response.CardResponse.CardFeedResponse;
@@ -21,7 +20,14 @@
2120
import java.util.List;
2221
import lombok.RequiredArgsConstructor;
2322
import org.springframework.http.ResponseEntity;
24-
import org.springframework.web.bind.annotation.*;
23+
import org.springframework.web.bind.annotation.DeleteMapping;
24+
import org.springframework.web.bind.annotation.GetMapping;
25+
import org.springframework.web.bind.annotation.PathVariable;
26+
import org.springframework.web.bind.annotation.PostMapping;
27+
import org.springframework.web.bind.annotation.PutMapping;
28+
import org.springframework.web.bind.annotation.RequestBody;
29+
import org.springframework.web.bind.annotation.RequestMapping;
30+
import org.springframework.web.bind.annotation.RestController;
2531

2632
@RestController
2733
@RequiredArgsConstructor
@@ -74,14 +80,6 @@ public ApiResponse<CardFeedResponse> getCardFeed(@PathVariable Long cardId) {
7480
return ApiResponse.onSuccess(cardService.getCardFeed(cardId, userId));
7581
}
7682

77-
78-
@GetMapping("/profile/{userId}/cards")
79-
@Operation(summary = "프로필 화면 피드 미리보기", description = "공유한 카드의 번호와 이미지 url 조회 API")
80-
public ApiResponse<CardResponse.profileCardListDTO> getProfileCardsList(@PathVariable Long userId,
81-
@RequestParam(required = false) Long cursor,
82-
@RequestParam(defaultValue = "15") int size) {
83-
return ApiResponse.onSuccess(cardService.getProfileCardList(userId,size,cursor));
84-
8583
@DeleteMapping("/{cardId}")
8684
@Operation(summary = "카드 삭제", description = "카드를 소프트 삭제 처리합니다.")
8785
public ApiResponse<Void> deleteCard(@PathVariable Long cardId) {

src/main/java/EatPic/spring/domain/card/converter/CardConverter.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
import EatPic.spring.domain.card.mapping.CardHashtag;
1313
import EatPic.spring.domain.reaction.entity.Reaction;
1414
import EatPic.spring.domain.user.entity.User;
15-
import org.springframework.context.annotation.Profile;
16-
import org.springframework.data.domain.Slice;
17-
1815
import java.util.List;
1916
import java.util.stream.Collectors;
2017

@@ -113,23 +110,6 @@ public static CardResponse.CardFeedResponse toFeedResponse(
113110
.build();
114111
}
115112

116-
public static CardResponse.ProfileCardDTO toProfileCardDto(Card card){
117-
return CardResponse.ProfileCardDTO.builder()
118-
.cardId(card.getId())
119-
.cardImageUrl(card.getCardImageUrl())
120-
.build();
121-
}
122-
123-
public static CardResponse.profileCardListDTO toProfileCardList(Long userId, Slice<Card> cardList){
124-
return CardResponse.profileCardListDTO.builder()
125-
.hasNext(cardList.hasNext())
126-
.nextCursor(cardList.hasNext()?cardList.getContent().get(cardList.getContent().size()-1).getId():null)
127-
.userId(userId)
128-
.cardsList(cardList.getContent().stream()
129-
.map(CardConverter::toProfileCardDto)
130-
.toList())
131-
.build();
132-
133113
public static TodayCardResponse toTodayCard(Card card) {
134114
return TodayCardResponse.builder()
135115
.cardId(card.getId())

src/main/java/EatPic/spring/domain/card/dto/response/CardResponse.java

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -188,22 +188,6 @@ public static class CardFeedUserDTO {
188188
@Getter
189189
@NoArgsConstructor
190190
@AllArgsConstructor
191-
public static class profileCardListDTO{
192-
private Long userId;
193-
private boolean hasNext;
194-
private Long nextCursor;
195-
private List<ProfileCardDTO> cardsList;
196-
}
197-
198-
@Builder
199-
@Getter
200-
@NoArgsConstructor
201-
@AllArgsConstructor
202-
public static class ProfileCardDTO {
203-
private Long cardId;
204-
private String cardImageUrl;
205-
}
206-
207191
@Schema(title = "TodayCardResponse: 오늘의 식사(카드) 현황 응답 dto")
208192
public static class TodayCardResponse {
209193
@Schema(description = "카드 ID", example = "12")
@@ -216,4 +200,7 @@ public static class TodayCardResponse {
216200
private Meal meal;
217201
}
218202

203+
204+
205+
219206
}

src/main/java/EatPic/spring/domain/card/repository/CardRepository.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,8 @@ public interface CardRepository extends JpaRepository<Card, Long> {
2525
ORDER BY c.id ASC
2626
""")
2727
Slice<Card> findByCursor(@Param("cursor") Long cursor, Pageable pageable);
28-
2928
boolean existsByUserIdAndMealAndCreatedAtBetween(Long userId, Meal meal, LocalDateTime start, LocalDateTime end);
3029

31-
Long countCardById(Long id);
32-
33-
Slice<Card> findByUserIdAndIsSharedTrueOrderByIdDesc(Long userId, Pageable pageable);
34-
Slice<Card> findByUserIdAndIsSharedTrueAndIdLessThanOrderByIdDesc(Long userId, Long cursor, Pageable pageable);
3530
Optional<Card> findByIdAndIsDeletedFalse(Long id);
3631

3732
List<Card> findAllByUserAndCreatedAtBetween(User user, LocalDateTime start, LocalDateTime end);

src/main/java/EatPic/spring/domain/card/service/CardService.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
public interface CardService {
1313
CardResponse.CreateCardResponse createNewCard(CardCreateRequest.CreateCardRequest request, Long userId);
1414
CardDetailResponse getCardDetail(Long cardId, Long userId);
15-
CardFeedResponse getCardFeed(Long cardId, Long userId)
16-
CardResponse.profileCardListDTO getProfileCardList(Long userId, int size, Long cursor);
15+
CardFeedResponse getCardFeed(Long cardId, Long userId);
1716
void deleteCard(Long cardId, Long userId);
1817
List<TodayCardResponse> getTodayCards(Long userId);
1918
CardDetailResponse updateCard(Long cardId, Long userId, CardUpdateRequest request);

src/main/java/EatPic/spring/domain/card/service/CardServiceImpl.java

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,9 @@
2424
import java.time.LocalTime;
2525
import java.util.Comparator;
2626
import java.util.List;
27-
27+
import java.util.stream.Collectors;
2828
import lombok.RequiredArgsConstructor;
2929
import lombok.extern.slf4j.Slf4j;
30-
import org.springframework.data.domain.PageRequest;
31-
import org.springframework.data.domain.Pageable;
32-
import org.springframework.data.domain.Slice;
3330
import org.springframework.stereotype.Service;
3431
import org.springframework.transaction.annotation.Transactional;
3532

@@ -149,19 +146,6 @@ public CardFeedResponse getCardFeed(Long cardId, Long userId) {
149146
}
150147

151148
@Override
152-
@Transactional(readOnly = true)
153-
public CardResponse.profileCardListDTO getProfileCardList(Long userId, int size, Long cursor) {
154-
155-
Slice<Card> cardSlice;
156-
Pageable pageable = PageRequest.of(0, size);
157-
158-
if (cursor == null) {
159-
cardSlice = cardRepository.findByUserIdAndIsSharedTrueOrderByIdDesc(userId, pageable);
160-
} else {
161-
cardSlice = cardRepository.findByUserIdAndIsSharedTrueAndIdLessThanOrderByIdDesc(userId, cursor, pageable);
162-
}
163-
return CardConverter.toProfileCardList(userId, cardSlice);
164-
165149
@Transactional
166150
public void deleteCard(Long cardId, Long userId) {
167151
Card card = cardRepository.findByIdAndIsDeletedFalse(cardId)

src/main/java/EatPic/spring/domain/user/controller/UserRestController.java

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class UserRestController {
1919
description = "페이지는 1부터 시작하며 total은 전체 항목 수 입니다.")
2020
@GetMapping("/users")
2121
@Tag(name = "User", description = "사용자 관련 API")
22-
public ApiResponse<UserResponseDTO.UserIconListResponseDto> followingUsersIcon(
22+
public ApiResponse<UserResponseDTO.UserIconListResponseDto> followingUsers(
2323
@RequestParam(defaultValue = "1") int page,
2424
@RequestParam(defaultValue = "15") int size) {
2525
//todo : userId -> 본인
@@ -30,7 +30,7 @@ public ApiResponse<UserResponseDTO.UserIconListResponseDto> followingUsersIcon(
3030
summary = "커뮤니티 상단 팔로잉 유저 아이콘(나)")
3131
@GetMapping("/me")
3232
@Tag(name = "User", description = "사용자 관련 API")
33-
public ApiResponse<UserResponseDTO.ProfileIconDto> myIcon() {
33+
public ApiResponse<UserResponseDTO.ProfileDto> myIcon() {
3434
return ApiResponse.onSuccess(userService.getMyIcon());
3535
}
3636

@@ -41,19 +41,4 @@ public ApiResponse<UserResponseDTO.UserBlockResponseDto> blockUser(@PathVariable
4141
return ApiResponse.onSuccess(userService.blockUser(userId));
4242
}
4343

44-
@Operation(summary = "유저 프로필 조회")
45-
@PostMapping("/{userId}/profile")
46-
@Tag(name = "User", description = "사용자 관련 API")
47-
public ApiResponse<UserResponseDTO.DetailProfileDto> getProfile(@PathVariable Long userId) {
48-
return ApiResponse.onSuccess(userService.getProfile(userId));
49-
}
50-
51-
// @Operation(summary = "유저 프로필 조회(이미지)")
52-
// @PostMapping("/{userId}/profile/cards")
53-
// @Tag(name = "User", description = "사용자 관련 API")
54-
// public ApiResponse<UserResponseDTO.DetailProfileDto> getProfile(@PathVariable Long userId) {
55-
// return ApiResponse.onSuccess(userService.getProfile(userId));
56-
// }
57-
58-
5944
}

src/main/java/EatPic/spring/domain/user/converter/UserConverter.java

Lines changed: 19 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,29 @@
1111
import org.springframework.data.domain.Page;
1212

1313
public class UserConverter {
14-
public static UserResponseDTO.ProfileIconDto toProfileIconDto(User user) {
15-
return UserResponseDTO.ProfileIconDto.builder()
14+
15+
public static UserResponseDTO.UserIconListResponseDto toUserIconListResponseDto(Page<UserFollow> followingPage){
16+
return UserResponseDTO.UserIconListResponseDto.builder()
17+
.total((int)followingPage.getTotalElements())
18+
.page(followingPage.getNumber()+1)
19+
.size(followingPage.getSize())
20+
.userIconList(followingPage.stream()
21+
.map(UserFollow::getTargetUser)
22+
.map(UserConverter::toProfileIconDto)
23+
.toList())
24+
.build();
25+
}
26+
27+
public static UserResponseDTO.ProfileDto toProfileIconDto(User user){
28+
return UserResponseDTO.ProfileDto.builder()
1629
.userId(user.getId())
1730
.profileImageUrl(user.getProfileImageUrl())
1831
.nameId(user.getNameId())
19-
.nickname(user.getNickname())
32+
.isFollowing(true)
2033
.build();
2134
}
22-
23-
public static UserResponseDTO.ProfileDto toProfileDto(User user, Boolean isFollowing) {
35+
// todo: 두개 비슷함 -> 합치기
36+
public static UserResponseDTO.ProfileDto toProfileDto(User user, Boolean isFollowing){
2437
return UserResponseDTO.ProfileDto.builder()
2538
.userId(user.getId())
2639
.profileImageUrl(user.getProfileImageUrl())
@@ -29,38 +42,6 @@ public static UserResponseDTO.ProfileDto toProfileDto(User user, Boolean isFollo
2942
.isFollowing(isFollowing)
3043
.build();
3144
}
32-
33-
public static UserResponseDTO.DetailProfileDto toDetailProfileDto(
34-
User user,
35-
Boolean isFollowing,
36-
Long totalCard,
37-
Long totalFollower,
38-
Long totalFollowing) {
39-
40-
return UserResponseDTO.DetailProfileDto.builder()
41-
.userId(user.getId())
42-
.profileImageUrl(user.getProfileImageUrl())
43-
.nameId(user.getNameId())
44-
.nickname(user.getNickname())
45-
.isFollowing(isFollowing)
46-
.introduce(user.getIntroduce())
47-
.totalCard(totalCard)
48-
.totalFollower(totalFollower)
49-
.totalFollowing(totalFollowing)
50-
.build();
51-
}
52-
53-
public static UserResponseDTO.UserIconListResponseDto toUserIconListResponseDto(Page<UserFollow> followingPage){
54-
return UserResponseDTO.UserIconListResponseDto.builder()
55-
.total((int)followingPage.getTotalElements())
56-
.page(followingPage.getNumber()+1)
57-
.size(followingPage.getSize())
58-
.userIconList(followingPage.stream()
59-
.map(UserFollow::getTargetUser)
60-
.map(UserConverter::toProfileIconDto)
61-
.toList())
62-
.build();
63-
}
6445

6546
public static ReactionResponseDTO.CardReactionUserListDto toCardReactionUsersListDto(Long cardId, ReactionType reactionType, Page<UserResponseDTO.ProfileDto> profileList){
6647
return ReactionResponseDTO.CardReactionUserListDto.builder()
@@ -89,4 +70,4 @@ public static UserResponseDTO.UserBlockResponseDto toUserBlockResponseDto(UserBl
8970
.targetUserId(userBlock.getBlockedUser().getId())
9071
.build();
9172
}
92-
}
73+
}

src/main/java/EatPic/spring/domain/user/dto/response/UserResponseDTO.java

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,6 @@
99

1010
public class UserResponseDTO {
1111

12-
@Getter
13-
@Builder
14-
@AllArgsConstructor
15-
@NoArgsConstructor
16-
public static class ProfileIconDto {
17-
private Long userId;
18-
private String profileImageUrl;
19-
private String nameId;
20-
private String nickname;
21-
private Boolean isFollowing;
22-
private String introduce;
23-
}
24-
2512
@Getter
2613
@Builder
2714
@AllArgsConstructor
@@ -34,23 +21,6 @@ public static class ProfileDto {
3421
private Boolean isFollowing;
3522
}
3623

37-
@Getter
38-
@Builder
39-
@AllArgsConstructor
40-
@NoArgsConstructor
41-
public static class DetailProfileDto {
42-
private Long userId;
43-
private String profileImageUrl;
44-
private String nameId;
45-
private String nickname;
46-
private Boolean isFollowing;
47-
private String introduce;
48-
private Long totalCard;
49-
private Long totalFollower;
50-
private Long totalFollowing;
51-
}
52-
53-
5424
@Getter
5525
@Builder
5626
@AllArgsConstructor
@@ -59,7 +29,7 @@ public static class UserIconListResponseDto{
5929
private int page;
6030
private int size;
6131
private int total;
62-
private List<ProfileIconDto> userIconList;
32+
private List<ProfileDto> userIconList;
6333
}
6434

6535
@Getter

src/main/java/EatPic/spring/domain/user/repository/UserFollowRepository.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,4 @@
1212
public interface UserFollowRepository extends JpaRepository<UserFollow,Long> {
1313
Page<UserFollow> findByUser(User user, Pageable pageable);
1414
Boolean existsByUserAndTargetUser(User user, User targetUser);
15-
16-
Long countUserFollowByTargetUser(User targetUser);
17-
Long countUserFollowByUser(User user);
1815
}

0 commit comments

Comments
 (0)