Skip to content

[임현희_BackEnd] 11주차 과제 제출합니다.#19

Open
bajirakhyeonhee wants to merge 11 commits intoBCSDLab-Edu:mainfrom
bajirakhyeonhee:main
Open

[임현희_BackEnd] 11주차 과제 제출합니다.#19
bajirakhyeonhee wants to merge 11 commits intoBCSDLab-Edu:mainfrom
bajirakhyeonhee:main

Conversation

@bajirakhyeonhee
Copy link

No description provided.

/introduce?name=이름 으로 요청했을때 안녕하세요 제 이름은 {이름}입니다!  텍스트가 반환되도록 하기
Copy link

@seongjae6751 seongjae6751 left a comment

Choose a reason for hiding this comment

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

한주동안 고생하셨습니다! 다음 과제도 화이팅!


public String getContent() { return content; }
public void setContent(String content) { this.content = content; }
} No newline at end of file

Choose a reason for hiding this comment

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

빨간색 경고 같은 표시가 왜 뜬걸까요?
다음 자료 확인하시고 적용해주세요!

this.content = content;
}

public Long getPostId() { return postId; }

Choose a reason for hiding this comment

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

setter는 보통 사용을 지양한답니다! 그 이유를 한번 찾아보시면 좋을 것 같아요

Comment on lines +16 to +24
public Long getPostId() { return postId; }
public void setPostId(Long postId) { this.postId = postId; }

public String getTitle() { return title; }
public void setTitle(String title) { this.title = title; }

public String getContent() { return content; }
public void setContent(String content) { this.content = content; }
} No newline at end of file

Choose a reason for hiding this comment

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

getter setter 직접 다 구현하셨는데
spring의 lombok이라는 library를 사용하면 @Getter @Setter와 같이 더 간단하게 구현 가능해요!
학습 단계에서는 이렇게 직접 다 구현해보는 것도 물론 괜찮을 것 같긴 하지만요 :)

Copy link
Author

Choose a reason for hiding this comment

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

넵 7주차 과제에 적용해봤습니다

private String title;
private String content;

public Article() {}

Choose a reason for hiding this comment

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

지금과 같은 경우에서는 아니지만 자바는 생성자를 정의하지 않았을 때 기본 생성자를 자동으로 추가해준답니다!

Choose a reason for hiding this comment

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

이런 entity들은 반드시 기본 생성자가 있어야 합니다! 그 이유도 나중에 찾아보시면 좋을 것 같아요

Copy link
Author

Choose a reason for hiding this comment

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

넵!

Comment on lines +8 to +14
public Article() {}

public Article(Long postId, String title, String content) {
this.postId = postId;
this.title = title;
this.content = content;
}

Choose a reason for hiding this comment

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

역시 lombok을 사용하면
각각 @All/NoArgsConstructor로 할 수 있겠죠?

Copy link
Author

Choose a reason for hiding this comment

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

7주차 과제에 적용했습니다 감사합니다

Comment on lines +8 to +14

@GetMapping("/json")
public Person getJson() {
return new Person("임현희", 22);
}

static class Person {

Choose a reason for hiding this comment

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

이렇게 내부 클래스로 정의 하면 재사용성, 테스트성 매우 낮을 것 같은데 이렇게 하신 이유가 있을까요?

Copy link
Author

Choose a reason for hiding this comment

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

구글링해서 찾아본 예시에서 이렇게 나와있어서 그대로 해봤습니닷..ㅠ 다음부터 고려해서 해보겠습니다

Comment on lines +38 to +47
@PutMapping("/{id}")
public ResponseEntity<Article> updateArticle(@PathVariable Long id, @RequestBody Article updatedData) {
Article article = articleStore.get(id);
if (article == null) {
return ResponseEntity.notFound().build();
}
article.setTitle(updatedData.getTitle());
article.setContent(updatedData.getContent());
return ResponseEntity.ok(article);
}

Choose a reason for hiding this comment

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

컨트롤러에 이렇게 모든 코드가 다 있으면 보기가 힘들겠죠? 그래서 MVC라는 패턴을 사용하는 거랍니다!

public class ArticleController {

private final Map<Long, Article> articleStore = new HashMap<>();
private long nextId = 1;

Choose a reason for hiding this comment

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

여기서는 AtomicLong이라는 것을 쓰는게 좋을 것 같아요 AtomicLong과 Long의 차이는 뭐고 AtomicLong을 쓰면 장점이 뭘까요? 한번 알아보시면 좋을 것 같아요

public ResponseEntity<Article> createArticle(@RequestBody Article article) {
article.setPostId(nextId++);
articleStore.put(article.getPostId(), article);
return ResponseEntity.ok(article);

Choose a reason for hiding this comment

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

여기서 200을 반환하는게 적절할까요? 다른 어떤 상태를 반환 할 수 있을까요?

Comment on lines +38 to +47
@PutMapping("/{id}")
public ResponseEntity<Article> updateArticle(@PathVariable Long id, @RequestBody Article updatedData) {
Article article = articleStore.get(id);
if (article == null) {
return ResponseEntity.notFound().build();
}
article.setTitle(updatedData.getTitle());
article.setContent(updatedData.getContent());
return ResponseEntity.ok(article);
}

Choose a reason for hiding this comment

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

여기서는 put이 적절할까요 patch가 적절할까요?

@bajirakhyeonhee bajirakhyeonhee changed the title [임현희_BackEnd] 5주차 과제 제출합니다. [임현희_BackEnd] 7주차 과제 제출합니다. May 19, 2025
Copy link
Contributor

@dradnats1012 dradnats1012 left a comment

Choose a reason for hiding this comment

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

누락된 기능들이 있는것 같아서 해당 기능들 추가해주세요!
그리고 패키지 구조를 분리해보면 좋을 것 같아요!

Comment on lines +23 to +24
compileOnly 'org.projectlombok:lombok:1.18.28'
annotationProcessor 'org.projectlombok:lombok:1.18.28'
Copy link
Contributor

Choose a reason for hiding this comment

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

lombok이 뭘까요?

Copy link
Author

Choose a reason for hiding this comment

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

@Getter, @Setter 같은 애노테이션을 쓸 수 있는 라이브러리로 알고 있습니다

Comment on lines +9 to +10
@Getter
@Setter
Copy link
Contributor

Choose a reason for hiding this comment

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

사용하는건 좋지만 이렇게 되면 사용하지 않는 getter나 setter 메서드가 생길수도 있습니다!
부작용이 있다는걸 인지하면 좋을 것 같아요

Comment on lines +12 to +14
public ArticleController(ArticleService articleService) {
this.articleService = articleService;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

생성자 주입 방법을 사용하셨는데 해당 방법의 장점은 무엇일까요?
또 다른 주입 방법은 뭐가 있는지 알아보면 좋을 것 같아요~!

Copy link
Author

@bajirakhyeonhee bajirakhyeonhee Jun 2, 2025

Choose a reason for hiding this comment

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

생성자에서만 값을 설정해서 안정성이 높다고 알고 있습니다.

}

@PostMapping
public void create(@RequestBody Article article) {
Copy link
Contributor

Choose a reason for hiding this comment

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

RequestDTO 에 대해 알아보면 좋을 것 같아요!
적용도 한번 해보세용

public void delete(@PathVariable Long id) {
articleService.deleteArticle(id);
}
} No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

EOF에 대해 알아보면 좋을 것 같아요!
참고 : https://velog.io/@junho5336/No-newline-at-end-of-file

Copy link
Author

@bajirakhyeonhee bajirakhyeonhee Jun 2, 2025

Choose a reason for hiding this comment

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

개행 처리 했습니다 감사합니다

this.jdbc = jdbc;
}

public List<ArticleDto> findAllByBoardId(Long boardId) {
Copy link
Contributor

Choose a reason for hiding this comment

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

이 부분은 DTO 를 사용하셨네요 👍

Comment on lines +9 to +12
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
Copy link
Contributor

Choose a reason for hiding this comment

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

모두 필요한 어노테이션일까요?
각각의 역할에 대해 알아보고 꼭 필요한것만 적용하면 좋을 것 같아요!

Comment on lines +16 to +18
public List<ArticleDto> getAllByBoardId(Long boardId) {
return articleDao.findAllByBoardId(boardId);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

boardId 기준으로 가져오는 기능 말고도 다른 CRUD 메서드들도 구현해주세요!

@bajirakhyeonhee bajirakhyeonhee changed the title [임현희_BackEnd] 7주차 과제 제출합니다. [임현희_BackEnd] 8주차 과제 제출합니다. May 26, 2025
@bajirakhyeonhee bajirakhyeonhee changed the title [임현희_BackEnd] 8주차 과제 제출합니다. [임현희_BackEnd] 9주차 과제 제출합니다. Jun 2, 2025
@bajirakhyeonhee bajirakhyeonhee changed the title [임현희_BackEnd] 9주차 과제 제출합니다. [임현희_BackEnd] 10주차 과제 제출합니다. Jun 23, 2025
@bajirakhyeonhee bajirakhyeonhee changed the title [임현희_BackEnd] 10주차 과제 제출합니다. [임현희_BackEnd] 11주차 과제 제출합니다. Jun 30, 2025
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.

3 participants