-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [#56] feat: 포스트 생성, 수정, 삭제 endpoint prefix로 /manage 설정 * [#56] feat: 기존 블로그 Id 사용 로직을 모두 이름을 사용하도록 변경 * [#56] feat: 내 글 관리 목록 조회 기능 구현 * [#56] feat: 내 관리 글 단일 조회 기능 구현 * test: 각 인수테스트에서 AcceptanceTest 상속받도록 수정
- Loading branch information
1 parent
4595eaa
commit 98b50d3
Showing
65 changed files
with
1,478 additions
and
729 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
src/main/java/com/mallang/post/presentation/PostManageController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package com.mallang.post.presentation; | ||
|
||
import com.mallang.auth.presentation.support.Auth; | ||
import com.mallang.post.application.PostService; | ||
import com.mallang.post.presentation.request.CreatePostRequest; | ||
import com.mallang.post.presentation.request.DeletePostRequest; | ||
import com.mallang.post.presentation.request.UpdatePostRequest; | ||
import com.mallang.post.query.PostManageQueryService; | ||
import com.mallang.post.query.data.PostManageDetailData; | ||
import com.mallang.post.query.data.PostManageSearchCond; | ||
import com.mallang.post.query.data.PostManageSimpleData; | ||
import java.net.URI; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.ModelAttribute; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.PutMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RequiredArgsConstructor | ||
@RequestMapping("/manage/posts") | ||
@RestController | ||
public class PostManageController { | ||
|
||
private final PostService postService; | ||
private final PostManageQueryService postManageQueryService; | ||
|
||
@PostMapping | ||
public ResponseEntity<Void> create( | ||
@Auth Long memberId, | ||
@RequestBody CreatePostRequest request | ||
) { | ||
Long id = postService.create(request.toCommand(memberId)); | ||
return ResponseEntity.created(URI.create("/posts/" + id)).build(); | ||
} | ||
|
||
@PutMapping("/{id}") | ||
public ResponseEntity<Void> update( | ||
@PathVariable(name = "id") Long postId, | ||
@Auth Long memberId, | ||
@RequestBody UpdatePostRequest request | ||
) { | ||
postService.update(request.toCommand(memberId, postId)); | ||
return ResponseEntity.ok().build(); | ||
} | ||
|
||
@DeleteMapping | ||
public ResponseEntity<Void> delete( | ||
@Auth Long memberId, | ||
@RequestBody DeletePostRequest request | ||
) { | ||
postService.delete(request.toCommand(memberId)); | ||
return ResponseEntity.noContent().build(); | ||
} | ||
|
||
@GetMapping("/{id}") | ||
public ResponseEntity<PostManageDetailData> getById( | ||
@PathVariable(name = "id") Long postId, | ||
@Auth Long memberId | ||
) { | ||
return ResponseEntity.ok(postManageQueryService.findById(memberId, postId)); | ||
} | ||
|
||
@GetMapping | ||
public ResponseEntity<List<PostManageSimpleData>> search( | ||
@Auth Long memberId, | ||
@ModelAttribute PostManageSearchCond cond | ||
) { | ||
return ResponseEntity.ok(postManageQueryService.search(memberId, cond)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/main/java/com/mallang/post/query/PostManageQueryService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.mallang.post.query; | ||
|
||
import com.mallang.post.query.dao.PostManageDetailDataDao; | ||
import com.mallang.post.query.dao.PostManageSimpleDataDao; | ||
import com.mallang.post.query.data.PostManageDetailData; | ||
import com.mallang.post.query.data.PostManageSearchCond; | ||
import com.mallang.post.query.data.PostManageSimpleData; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@RequiredArgsConstructor | ||
@Transactional(readOnly = true) | ||
@Service | ||
public class PostManageQueryService { | ||
|
||
private final PostManageDetailDataDao postManageDetailDataDao; | ||
private final PostManageSimpleDataDao postManageSimpleDataDao; | ||
|
||
public PostManageDetailData findById(Long memberId, Long id) { | ||
return postManageDetailDataDao.find(memberId, id); | ||
} | ||
|
||
public List<PostManageSimpleData> search(Long memberId, PostManageSearchCond cond) { | ||
return postManageSimpleDataDao.search(memberId, cond); | ||
} | ||
} |
Oops, something went wrong.