From a593ce006247f02b7ba685de9afaf737ec084deb Mon Sep 17 00:00:00 2001 From: Mingadinga Date: Sun, 28 Aug 2022 12:21:44 +0900 Subject: [PATCH] develop Post Single Read Without Num of Permitted Participants #4 --- .../t4/plan/dto/PlanInfoResponseDto.java | 22 +++++++++---------- .../com/team20/t4/post/PostController.java | 5 ++--- .../java/com/team20/t4/post/PostService.java | 5 +++-- .../team20/t4/post/dto/PostResponseDto.java | 4 +++- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/team20/t4/plan/dto/PlanInfoResponseDto.java b/src/main/java/com/team20/t4/plan/dto/PlanInfoResponseDto.java index c9a8ab0..0942fc2 100644 --- a/src/main/java/com/team20/t4/plan/dto/PlanInfoResponseDto.java +++ b/src/main/java/com/team20/t4/plan/dto/PlanInfoResponseDto.java @@ -1,7 +1,5 @@ package com.team20.t4.plan.dto; - -import com.team20.t4.member.domain.Member; import com.team20.t4.plan.domain.FoodType; import com.team20.t4.plan.domain.Location; import com.team20.t4.plan.domain.Plan; @@ -15,21 +13,21 @@ @Getter public class PlanInfoResponseDto { - private Member lead; + private String leadId; private Integer numOfParticipants; private LocalDateTime appointmentTime; - private FoodType foodType; + private String foodType; private String restaurant; - private Location location; + private String location; @Builder - public PlanInfoResponseDto(Member lead, + public PlanInfoResponseDto(String leadId, Integer numOfParticipants, LocalDateTime appointmentTime, - FoodType foodType, + String foodType, String restaurant, - Location location) { - this.lead = lead; + String location) { + this.leadId = leadId; this.numOfParticipants = numOfParticipants; this.appointmentTime = appointmentTime; this.foodType = foodType; @@ -39,12 +37,12 @@ public PlanInfoResponseDto(Member lead, public static PlanInfoResponseDto of(Plan plan) { return PlanInfoResponseDto.builder() - .lead(plan.getLead()) + .leadId(plan.getLead().getMemberId()) .numOfParticipants(plan.getNumOfParticipants()) .appointmentTime(plan.getAppointmentTime()) - .foodType(plan.getFoodType()) + .foodType(plan.getFoodType().getValue()) .restaurant(plan.getRestaurant()) - .location(plan.getLocation()) + .location(plan.getLocation().getGu().getValue()) .build(); } diff --git a/src/main/java/com/team20/t4/post/PostController.java b/src/main/java/com/team20/t4/post/PostController.java index 077c931..c42be87 100644 --- a/src/main/java/com/team20/t4/post/PostController.java +++ b/src/main/java/com/team20/t4/post/PostController.java @@ -5,6 +5,7 @@ import com.team20.t4.member.domain.Member; import com.team20.t4.plan.PlanService; import com.team20.t4.plan.dto.AppointmentSimpleResponseDto; +import com.team20.t4.plan.dto.ListAppointmentSimpleResponseDto; import com.team20.t4.post.dto.PostResponseDto; import com.team20.t4.post.dto.PostSaveRequestDto; import com.team20.t4.post.dto.PostUpdateRequestDto; @@ -23,8 +24,6 @@ public class PostController { @PostMapping("/post/new") public Long saveNewPost(@RequestBody @Valid PostSaveRequestDto requestDto){ -// Member loginedMember = memberService.getLoginedMember(); -// planService.createPlan(requestDto.getPlan(), loginedMember); return postService.savePost(requestDto); } @@ -45,7 +44,7 @@ public OnlyResponseString deletePost(@PathVariable Long postId){ } @GetMapping("/member/posts") - public List getMyPostList(){ + public ListAppointmentSimpleResponseDto getMyPostList(){ return postService.getPostListWrittenByMe(); } diff --git a/src/main/java/com/team20/t4/post/PostService.java b/src/main/java/com/team20/t4/post/PostService.java index d50968b..ceefbd0 100644 --- a/src/main/java/com/team20/t4/post/PostService.java +++ b/src/main/java/com/team20/t4/post/PostService.java @@ -7,6 +7,7 @@ import com.team20.t4.plan.PlanService; import com.team20.t4.plan.domain.Plan; import com.team20.t4.plan.dto.AppointmentSimpleResponseDto; +import com.team20.t4.plan.dto.ListAppointmentSimpleResponseDto; import com.team20.t4.plan.dto.RegisterHistorySaveRequestDto; import com.team20.t4.post.domain.Post; import com.team20.t4.post.domain.PostRepository; @@ -71,14 +72,14 @@ public void deletePost(Long postId){ } @Transactional - public List getPostListWrittenByMe(){ + public ListAppointmentSimpleResponseDto getPostListWrittenByMe(){ Member loginedMember = memberService.getLoginedMember(); List responseDtoList = new ArrayList<>(); List postList = postRepository.findAllByWriter(loginedMember); for(Post post:postList){ responseDtoList.add(new AppointmentSimpleResponseDto(post, post.getPlan())); } - return responseDtoList; + return new ListAppointmentSimpleResponseDto(responseDtoList); } diff --git a/src/main/java/com/team20/t4/post/dto/PostResponseDto.java b/src/main/java/com/team20/t4/post/dto/PostResponseDto.java index 30bc4aa..6333a07 100644 --- a/src/main/java/com/team20/t4/post/dto/PostResponseDto.java +++ b/src/main/java/com/team20/t4/post/dto/PostResponseDto.java @@ -1,5 +1,6 @@ package com.team20.t4.post.dto; +import com.team20.t4.plan.dto.PlanInfoResponseDto; import com.team20.t4.post.domain.Post; import lombok.AllArgsConstructor; import lombok.Builder; @@ -15,13 +16,14 @@ public class PostResponseDto { private String title; private String content; private String chatRoomLink; - // private PlanResponseDto planInfo; + private PlanInfoResponseDto planInfo; public static PostResponseDto of(Post post) { return PostResponseDto.builder() .title(post.getTitle()) .content(post.getContent()) .chatRoomLink(post.getChatRoomLink()) + .planInfo(PlanInfoResponseDto.of(post.getPlan())) .build(); } }