Skip to content

Commit

Permalink
Merge pull request #73 from Journey-Together/feature/#71
Browse files Browse the repository at this point in the history
fix : isPublic false로 고정
  • Loading branch information
sycuuui authored Jun 11, 2024
2 parents d904e26 + 16d31bb commit 45613d3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,30 @@
import Journey.Together.domain.member.entity.Member;
import lombok.Builder;

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

@Builder
public record PlanDetailRes(
String title,
LocalDate startDate,
LocalDate endDate,
String remainDate,
Boolean isPublic,
List<String> imageUrls,
List<DailyList> dailyList,
Boolean isWriter,
Long writerId,
String writerNickname
) {
public static PlanDetailRes of(List<String> imageUrls,
List<DailyList> dailyList, Boolean isWriter, Plan plan){
List<DailyList> dailyList, Boolean isWriter, Plan plan,String remainDate){
return PlanDetailRes.builder()
.title(plan.getTitle())
.startDate(plan.getStartDate())
.endDate(plan.getEndDate())
.remainDate(remainDate)
.isPublic(plan.getIsPublic())
.imageUrls(imageUrls)
.dailyList(dailyList)
.isWriter(isWriter)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public void savePlan(Member member, PlanReq planReq){
.title(planReq.title())
.startDate(planReq.startDate())
.endDate(planReq.endDate())
.isPublic(false)
.build();
planRepository.save(plan);
//날짜별 장소 정보 저장
Expand Down Expand Up @@ -129,7 +130,7 @@ public PlanDetailRes findPlanDetail(Member member, Long planId){
if(plan.getEndDate().isAfter(LocalDate.now())){
//imageUrl : 장소 사진
for(Day day : dayList){
if(day.getPlace().getFirstImg()!=null){
if(!day.getPlace().getFirstImg().isEmpty()){
imageUrls.add(day.getPlace().getFirstImg());
}
}
Expand All @@ -139,7 +140,7 @@ public PlanDetailRes findPlanDetail(Member member, Long planId){
if(planReviewImageList == null){
//imageUrl : 장소사진
for(Day day : dayList){
if(day.getPlace().getFirstImg()!=null){
if(!day.getPlace().getFirstImg().isEmpty()){
imageUrls.add(day.getPlace().getFirstImg());
}
}
Expand All @@ -164,9 +165,18 @@ public PlanDetailRes findPlanDetail(Member member, Long planId){
}else {
isWriter = plan.getMember().getMemberId().equals(member.getMemberId());
}

String remainDate = null;
if ((LocalDate.now().isEqual(plan.getStartDate()) || LocalDate.now().isAfter(plan.getStartDate())) && (LocalDate.now().isEqual(plan.getEndDate()) || LocalDate.now().isBefore(plan.getEndDate()))){
remainDate = "D-Day";
}else if (LocalDate.now().isBefore(plan.getStartDate())){
Period period = Period.between(LocalDate.now(),plan.getStartDate());
remainDate = "D-"+ period.getDays();
}

//PlanDetailRes - List<String> imageUrls, List<DailyList> dailyList, Boolean isWriter
//Response
return PlanDetailRes.of(imageUrls,dailyLists,isWriter,plan);
return PlanDetailRes.of(imageUrls,dailyLists,isWriter,plan,remainDate);
}

@Transactional
Expand Down Expand Up @@ -373,7 +383,7 @@ public String getPlanImageUrl(Member member,Plan plan){
public String getPlaceFirstImage(Member member,Plan plan){
List<Day> dayList = dayRepository.findByMemberAndDateAndPlanOrderByCreatedAtDesc(member,plan.getStartDate(),plan);
String placeImageUrl = dayList.get(0).getPlace().getFirstImg();
if(placeImageUrl==null){
if(!placeImageUrl.isEmpty()){
return null;
}
return dayList.get(0).getPlace().getFirstImg();
Expand Down

0 comments on commit 45613d3

Please sign in to comment.