Skip to content

[박준용_BackEnd] 7주차 과제 제출합니다.#4

Open
rhldial wants to merge 12 commits into
BCSDLab-Edu:mainfrom
rhldial:main
Open

[박준용_BackEnd] 7주차 과제 제출합니다.#4
rhldial wants to merge 12 commits into
BCSDLab-Edu:mainfrom
rhldial:main

Conversation

@rhldial

@rhldial rhldial commented May 16, 2026

Copy link
Copy Markdown

No description provided.

@dh2906 dh2906 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다!
앞으로는 커밋 작성 시 feat, fix, chore 등 커밋 단위도 작성해주세요.
e.g) feat: POST /article API 추가

<body>
<p>안녕하세요 제 이름은 박준용입니다.</p>
</body>
</html> No newline at end of file

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EOF 체크 부탁드릴게요. Intellij 자체에서 마지막 줄을 추가해주는 기능도 있으니 찾아서 적용해주시면 될 것 같아요
https://hyeon9mak.github.io/github-no-newline-at-a-end-of-file/

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

내용확인하고 기능 적용했습니다.

@@ -0,0 +1,6 @@
package com.example.demo;

public class article {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

클래스 명은 첫 글자가 대문자가 되도록 컨벤션 유지해주세요

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수정했습니다.

Comment on lines +4 to +5
public Long id;
public String description;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public 접근 제어자를 사용한다면 외부에서 누구나 접근이 가능해지므로 객체지향의 특징인 정보 은닉을 만족하지 못하는 것 아닐까요??

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

캡슐화 했습니다.

package com.example.demo;

public class article {
public Long id;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id 멤버 변수는 기본형 long이 아닌 참조형 Long을 사용한 이유가 무엇인가요?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

null값을 사용하기 위해서 참조형을 썼습니다.

Map<Long, article> store = new HashMap<>();
long seq = 1;

@PostMapping("/article")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기 아래부터 한 칸 탭은 불필요해보여요.
앞으로는 코드 작성 후 커밋하기 전 Intellij에서 제공하는 기능인 코드 정렬 기능을 한 번 사용해주세요.
https://carpe08.tistory.com/401

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수정하고, 설정도 완료 했습니다.


@PostMapping("/article")
public article create(@RequestBody article article) {
article.id = seq++;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 코멘트는 심화 내용입니다! 그냥 한 번 보고 생각만 해주세요.
만약 게시글 POST 요청이 여러 사용자에 의해 동시에 들어왔다면 id는 중복될 수 있습니다. 그렇다면 이러한 문제를 해결하기 위해 어떻게 해야할까요?

public article create(@RequestBody article article) {
article.id = seq++;
store.put(article.id, article);
return article;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

나중에 다룰 내용이지만 DTO에 대해서 알아보시는걸 추천드려요.

Comment on lines +14 to +15
Map<Long, article> store = new HashMap<>();
long seq = 1;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 둘의 접근 제어자는 default로 둔 이유가 있나요?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

실수한 것 같습니다.

Comment on lines +39 to +43
if (article == null) {
return null;
}
article.description = req.description;
return article;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (article == null) {
return null;
}
article.description = req.description;
return article;
if (article != null) {
article.description = req.description;
}
return article;

이런 식으로 코드를 정리할 수도 있어 보여요.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

감사합니다.

return article;
}

@GetMapping("/article/{id}")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저번주 과제에서는 /articles로 복수형을 사용하셨는데, 이번엔 단수형을 채택한 이유가 있으실까요??

@dh2906 dh2906 May 21, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아..!! 제가 요구사항에 단수형으로 적어놨네요?!
이 코멘트는 무시하셔도 됩니다!!

import java.util.Map;

@RestController
public class HelloController {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

지금은 Article을 다루고 있으므로 클래스 명이 ArticleController로 변경되어야 할 것 같아요.
그렇게 된다면 기존에 있던 HelloContoller에 있던 코드는 지우지 않아도 사용할 수 있지 않을까요?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수정했습니다.

rhldial added 5 commits May 24, 2026 10:29
- ArticleController, Service, Repository 추가
- PostController, posts.html 추가
- Member, Board, Article 모델 추가

@dh2906 dh2906 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다!

클래스 파일의 경우 패키지를 만들어 계층 별로 정리하는 것이 보기도 깔끔하고 좋습니다!
model, controller, service, repository 와 같은 패키지를 만들고 각 패키지 이름에 맞게 클래스를 넣어주세요.

그리고, 코멘트에서 받은 리뷰는 최대한 모두 적용 부탁드릴게요.

https://kanado2000.tistory.com/119

Comment on lines +18 to +24
public Long getId() {
return id;
}

public Long getMemberId() {
return memberId;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getXXX, setXXX와 같은 메소드는 멤버 변수의 수에 비례하므로 Lombok 라이브러리를 활용하시면 좋을 것 같습니다!
사실상 편의성 측면에서는 필수 라이브러리라서 알아보시는 것을 추천드려요.

Comment on lines +30 to +36
public Article update(Long id, Article req) {
Article article = repository.findById(id);
if (article == null) return null;
article.setTitle(req.getTitle());
article.setContent(req.getContent());
return article;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Article 모델에서 update 변수도 있던데, 게시글을 수정하면 수정된 시각도 변경해야 할 것 같아요

}

@PostMapping("/articles")
public ResponseEntity<Article> create(@RequestBody Article article) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요청과 응답 모두 Article 모델을 사용하고 있는데, DTO를 적용하지 않은 이유가 있으신가요??
만약 DTO를 사용하지 않는다면 무슨 불편함을 겪을까요?

rhldial added 2 commits May 28, 2026 22:25
# Conflicts:
#	src/main/java/com/example/demo/ArticleService.java
@rhldial rhldial changed the title [박준용_BackEnd] 5주차 과제 제출합니다. [박준용_BackEnd] 7주차 과제 제출합니다. May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants