Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 분실물 API 2차 기능 추가(습득물, 학생 작성) #1224

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

Choon0414
Copy link
Contributor

@Choon0414 Choon0414 commented Feb 6, 2025

🔥 연관 이슈

  • close #이슈번호

🚀 작업 내용

  1. 분실물 API에 2차 기능을 추가하였습니다.
    • 습득물 게시글 타입 추가
    • 일반 학생도 게시글 작성/수정/삭제 가능
      • 분실물 게시글 단건 조회에 사용자 토큰이 헤더로 추가되었습니다.
    • 분실물/습득물 별 필터링

💬 리뷰 중점사항

참고) 분실물 API 2차 명세

@Choon0414 Choon0414 added 기능 새로운 기능을 개발합니다. Team Campus 캠퍼스 팀에서 작업할 이슈입니다 labels Feb 6, 2025
@Choon0414 Choon0414 self-assigned this Feb 6, 2025
Copy link

github-actions bot commented Feb 6, 2025

Unit Test Results

353 tests   349 ✔️  1m 33s ⏱️
  45 suites      1 💤
  45 files        3

For more details on these failures, see this check.

Results for commit c7da3fb.

Copy link
Contributor

@kih1015 kih1015 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 103 to +115
@PostMapping("/lost-item")
public ResponseEntity<LostItemArticleResponse> createLostItemArticle(
@Auth(permit = {COUNCIL}) Integer councilId,
@Auth(permit = {STUDENT, COUNCIL}) Integer studentId,
@RequestBody @Valid LostItemArticlesRequest lostItemArticlesRequest
) {
LostItemArticleResponse response = articleService.createLostItemArticle(councilId, lostItemArticlesRequest);
LostItemArticleResponse response = articleService.createLostItemArticle(studentId, lostItemArticlesRequest);
return ResponseEntity.status(HttpStatus.CREATED).body(response);
}

@DeleteMapping("/lost-item/{id}")
public ResponseEntity<Void> deleteLostItemArticle(
@PathVariable("id") Integer articleId,
@Auth(permit = {COUNCIL}) Integer councilId
@Auth(permit = {STUDENT, COUNCIL}) Integer userId
Copy link
Contributor

Choose a reason for hiding this comment

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

C
studentId or userId 한 가지로 통일하면 좋을 것 같아요

Comment on lines +18 to +20
@NotNull(message = "게시글 타입은 필수로 입력해야 합니다.")
@Schema(description = "게시글 타입", example = "LOST", requiredMode = NOT_REQUIRED)
String type,
Copy link
Contributor

Choose a reason for hiding this comment

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

C
requireMode = REQUIRED 이어야 하지 않나요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

type 필드가 없는 기존 버전의 하위호환성을 위해 null 처리를 추가해서, 해당 필드의 requireMode를 NOT_REQUIRED로 지정했습니다!

@@ -42,6 +44,13 @@ default Article getById(Integer articleId) {
return found;
}

@Query(
value = "SELECT a.* FROM new_articles a JOIN lost_item_articles la ON a.id = la.article_id WHERE la.type = :type",
Copy link
Contributor

Choose a reason for hiding this comment

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

A
page 쿼리 시 네이티브 쿼리를 사용하는 이유가 있나요? 몰라서 여쭤봅니다!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Page 쿼리 시 반드시 사용해야 할 이유는 없습니다!

전 두 테이블의 조인을 위해 네이티브 쿼리를 썼어요.
분실물/습득물 필터링에서는 LostItemArticletype필드를 통해 필터링된 Article을 받아야 하기 때문입니다.

또, naticeQuery 속성은 제 쿼리에는 필수가 아니었지만,
Page는 필터링과 함께 하는 경우가 많고, 필터링을 위한 쿼리에는 MATCH와 같이 특정 DB에서 사용하는 단어가 포함되는 경우가 많아서 Page에 네이티브 쿼리가 자주 보이는 것 같습니다!

Copy link
Contributor

@DHkimgit DHkimgit 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 +97 to +98
@PathVariable("id") Integer articleId,
@Auth(permit = {STUDENT, COUNCIL}, anonymous = true) Integer userId
Copy link
Contributor

Choose a reason for hiding this comment

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

토큰을 받는다면 로그인 하지 않은 사용자는 게시글을 볼 수 없지 않나요?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team Campus 캠퍼스 팀에서 작업할 이슈입니다 기능 새로운 기능을 개발합니다.
Projects
Status: In progress
Development

Successfully merging this pull request may close these issues.

3 participants