Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIx] GifSimpleDto 필드 추가 #90

Merged
merged 4 commits into from
Dec 1, 2023
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
6 changes: 3 additions & 3 deletions favor/src/main/java/com/favor/favor/friend/FriendService.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public List<GiftSimpleDto> findGiftListByFriendNo(Long friendNo){
List<Gift> giftList = giftRepository.findGiftsByFriendNoListContains(friendNo);
List<GiftSimpleDto> giftResponseDtoList = new ArrayList<>();
for(Gift gift : giftList){
GiftSimpleDto dto = new GiftSimpleDto(gift);
GiftSimpleDto dto = GiftSimpleDto.from(gift);
giftResponseDtoList.add(dto);
}
return giftResponseDtoList;
Expand All @@ -145,7 +145,7 @@ public List<GiftSimpleDto> findGivenGiftList(Long friendNo){
List<GiftSimpleDto> giftResponseDtoList = new ArrayList<>();
for(Gift gift : giftList){
if(gift.getIsGiven()){
GiftSimpleDto dto = new GiftSimpleDto(gift);
GiftSimpleDto dto = GiftSimpleDto.from(gift);
giftResponseDtoList.add(dto);
}
}
Expand All @@ -156,7 +156,7 @@ public List<GiftSimpleDto> findReceivedGiftList(Long friendNo){
List<GiftSimpleDto> giftResponseDtoList = new ArrayList<>();
for(Gift gift : giftList){
if(!gift.getIsGiven()){
GiftSimpleDto dto = new GiftSimpleDto(gift);
GiftSimpleDto dto = GiftSimpleDto.from(gift);
giftResponseDtoList.add(dto);
}
}
Expand Down
29 changes: 21 additions & 8 deletions favor/src/main/java/com/favor/favor/gift/GiftSimpleDto.java
Original file line number Diff line number Diff line change
@@ -1,27 +1,40 @@
package com.favor.favor.gift;

import com.favor.favor.photo.GiftPhoto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;

import java.time.LocalDate;
import java.util.List;

@Getter
@AllArgsConstructor
@Builder
public class GiftSimpleDto {
private Long giftNo;
private String giftName;
private LocalDate giftDate;
private List<GiftPhoto> photoList;
private Boolean isPinned;
private Boolean isGiven;

@Builder
public GiftSimpleDto(Gift gift){
this.giftNo = gift.getGiftNo();
this.giftName = gift.getGiftName();
this.giftDate = gift.getGiftDate();
this.photoList = gift.getGiftPhotoList();
private GiftSimpleDto(Long giftNo, String giftName, LocalDate giftDate, List<GiftPhoto> photoList, Boolean isPinned, Boolean isGiven){
this.giftNo = giftNo;
this.giftName = giftName;
this.giftDate = giftDate;
this.photoList = photoList;
this.isPinned = isPinned;
this.isGiven = isGiven;
}

public static GiftSimpleDto from(Gift gift){
return GiftSimpleDto.builder()
.giftNo(gift.getGiftNo())
.giftName(gift.getGiftName())
.giftDate(gift.getGiftDate())
.photoList(gift.getGiftPhotoList())
.isPinned(gift.getIsPinned())
.isGiven(gift.getIsGiven())
.build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,6 @@ public class ReminderSimpleDto {
private Long userNo;
private FriendSimpleDto friendSimpleDto;

// @Builder
// public ReminderSimpleDto(Reminder reminder){
// this.reminderNo = reminder.getReminderNo();
// this.reminderTitle = reminder.getReminderTitle();
// this.reminderDate = reminder.getReminderDate();
// this.isAlarmSet = reminder.getIsAlarmSet();
// this.userNo = reminder.getUser().getUserNo();
// this.friendSimpleDto = null;
// }
@Builder
public ReminderSimpleDto(Reminder reminder, FriendSimpleDto dto){
this.reminderNo = reminder.getReminderNo();
Expand Down
12 changes: 6 additions & 6 deletions favor/src/main/java/com/favor/favor/user/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,22 +143,22 @@ public List<GiftSimpleDto> readGiftList(Long userNo) {
User user = findUserByUserNo(userNo);

return giftRepository.findGiftsByUser(user).stream()
.map(GiftSimpleDto::new).collect(Collectors.toList());
.map(GiftSimpleDto::from).collect(Collectors.toList());
}

public List<GiftSimpleDto> readGiftListByName(Long userNo, String giftName){
User user = findUserByUserNo(userNo);

return giftRepository.findGiftsByUserAndGiftNameContains(user, giftName).stream()
.map(GiftSimpleDto::new).collect(Collectors.toList());
.map(GiftSimpleDto::from).collect(Collectors.toList());
}

public List<GiftSimpleDto> readGiftListByCategory(Long userNo, GiftCategory giftCategory){
User user = findUserByUserNo(userNo);
Integer categoryNo = giftCategory.getType();

return giftRepository.findGiftsByUserAndCategory(user, categoryNo).stream()
.map(GiftSimpleDto::new)
.map(GiftSimpleDto::from)
.collect(Collectors.toList());
}

Expand All @@ -167,7 +167,7 @@ public List<GiftSimpleDto> readGiftListByEmotion(Long userNo, Emotion emotion){
Integer emotionNo = emotion.getType();

return giftRepository.findGiftsByUserAndEmotion(user, emotionNo).stream()
.map(GiftSimpleDto::new)
.map(GiftSimpleDto::from)
.collect(Collectors.toList());
}

Expand Down Expand Up @@ -265,14 +265,14 @@ public List<Reminder> readReminderListByMonthAndYear(int year, int month){
public List<GiftSimpleDto> readGivenGiftList(Long userNo){
User user = findUserByUserNo(userNo);
return giftRepository.findGiftsByUser(user).stream()
.map(GiftSimpleDto::new)
.map(GiftSimpleDto::from)
.collect(Collectors.toList());
}

public List<GiftSimpleDto> readReceivedGiftList(Long userNo){
User user = findUserByUserNo(userNo);
return giftRepository.findGiftsByUser(user).stream()
.map(GiftSimpleDto::new)
.map(GiftSimpleDto::from)
.collect(Collectors.toList());
}

Expand Down