Skip to content

Commit

Permalink
develop Post Single Read Without Num of Permitted Participants #4
Browse files Browse the repository at this point in the history
  • Loading branch information
Mingadinga committed Aug 28, 2022
1 parent 294b94b commit a593ce0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
22 changes: 10 additions & 12 deletions src/main/java/com/team20/t4/plan/dto/PlanInfoResponseDto.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -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();

}
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/com/team20/t4/post/PostController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}

Expand All @@ -45,7 +44,7 @@ public OnlyResponseString deletePost(@PathVariable Long postId){
}

@GetMapping("/member/posts")
public List<AppointmentSimpleResponseDto> getMyPostList(){
public ListAppointmentSimpleResponseDto getMyPostList(){
return postService.getPostListWrittenByMe();
}

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/team20/t4/post/PostService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -71,14 +72,14 @@ public void deletePost(Long postId){
}

@Transactional
public List<AppointmentSimpleResponseDto> getPostListWrittenByMe(){
public ListAppointmentSimpleResponseDto getPostListWrittenByMe(){
Member loginedMember = memberService.getLoginedMember();
List<AppointmentSimpleResponseDto> responseDtoList = new ArrayList<>();
List<Post> postList = postRepository.findAllByWriter(loginedMember);
for(Post post:postList){
responseDtoList.add(new AppointmentSimpleResponseDto(post, post.getPlan()));
}
return responseDtoList;
return new ListAppointmentSimpleResponseDto(responseDtoList);
}


Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/team20/t4/post/dto/PostResponseDto.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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();
}
}

0 comments on commit a593ce0

Please sign in to comment.