Open
Conversation
kkw01234
reviewed
Aug 24, 2020
|
|
||
| @DeleteMapping("/delete") | ||
| fun deletePostedBlogList( | ||
| @RequestBody id: Int |
Member
There was a problem hiding this comment.
DELETE 메소드는 Body를 사용하는 것이 좋지 않은 방법으로 알고 있습니다.(사실 안되는걸로 알고있음) 대안으로 @PathVariable를 사용하는 것이 좋을 것 같습니다!
| blogDB.blogList.add(content) | ||
| } | ||
| fun updateContent(content: Content){ | ||
| val updateItem = blogDB.blogList.filter { it.id == content.id } |
minkukjo
reviewed
Aug 25, 2020
| // updateItem = content | ||
| } | ||
| fun deleteContent(id : Int){ | ||
| val deleteItem = blogDB.blogList.filter { it.id == id } |
Member
There was a problem hiding this comment.
현재 Service에서 blodgDB에 대한 로직처리를 하고 있는데, 이는 추후에 blogDB에 대한 로직에 변경이 발생했을 때 이를 사용하는 다른 Service 객체에 모든 변경사항을 반영해주어야해서 유지보수가 어렵습니다.
객체지향 관점에서 봤을 때 유지보수하기 쉬운 코드를 짜려면 데이터에 대한 로직은 blogDB가 갖게 하는게 어떨까 싶습니다.
예시 코드를 아래에 남겨둘게요.
@Service
class Service @Autowired constructor(
val blogDB: BlogDB
) {
fun deleteContent(id : Int){
blogDB.remove(id)
}
}@Component
class BlogDB {
val blogList : MutableList<Content> = mutableListOf()
fun remove(id: Int) {
this.blogList.removeIf{ it.id == id}
}
}
kkw01234
reviewed
Aug 25, 2020
| service.addContent(content) | ||
| } | ||
|
|
||
| @GetMapping("/get") |
Member
There was a problem hiding this comment.
제로랑 같은 내용입니다만 참고로 말씀드리면 서버개발할때 주로 RESTful(REST API)를 사용하는데 URI에 동사를 넣지 않아요..
https://gmlwjd9405.github.io/2018/09/21/rest-and-restful.html 이것 참고해보세용..ㅎㅎ
한번 RESTful에 대해서 누군가 설명을 해봐야할 것 같아보이네요!
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.