Skip to content
This repository has been archived by the owner on Dec 21, 2024. It is now read-only.

Commit

Permalink
develop Post List Written By Member #4
Browse files Browse the repository at this point in the history
  • Loading branch information
Mingadinga committed Aug 28, 2022
1 parent 81f05e2 commit 294b94b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main/java/com/team20/t4/post/PostController.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
import com.team20.t4.member.MemberService;
import com.team20.t4.member.domain.Member;
import com.team20.t4.plan.PlanService;
import com.team20.t4.plan.dto.AppointmentSimpleResponseDto;
import com.team20.t4.post.dto.PostResponseDto;
import com.team20.t4.post.dto.PostSaveRequestDto;
import com.team20.t4.post.dto.PostUpdateRequestDto;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@RequiredArgsConstructor
@RestController
Expand Down Expand Up @@ -42,4 +44,9 @@ public OnlyResponseString deletePost(@PathVariable Long postId){
return new OnlyResponseString("Post 삭제에 성공했습니다.");
}

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

}
15 changes: 15 additions & 0 deletions src/main/java/com/team20/t4/post/PostService.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.team20.t4.member.domain.Member;
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.RegisterHistorySaveRequestDto;
import com.team20.t4.post.domain.Post;
import com.team20.t4.post.domain.PostRepository;
Expand All @@ -17,6 +18,9 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

@RequiredArgsConstructor
@Service
public class PostService {
Expand Down Expand Up @@ -66,6 +70,17 @@ public void deletePost(Long postId){
postRepository.deleteById(postId);
}

@Transactional
public List<AppointmentSimpleResponseDto> 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;
}


// 리스트 조회
// 검색 기준 : 위치
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/team20/t4/post/domain/PostRepository.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package com.team20.t4.post.domain;

import com.team20.t4.member.domain.Member;
import com.team20.t4.post.domain.Post;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;

public interface PostRepository extends JpaRepository<Post, Long> {
List<Post> findAllByWriter(Member loginedMember);
}

0 comments on commit 294b94b

Please sign in to comment.