Skip to content

Conversation

@DHkimgit
Copy link
Collaborator

@DHkimgit DHkimgit commented Dec 23, 2025

🔍 개요

  • 스프린트 목표: 분실물 기능 실질적 활성화
image

🚀 주요 변경 내용

1. 분실물 "찾음 처리" POST API 추가

API 설명

  • 분실물 게시글의 작성자가 자신의 게시글을 “찾음” 상태로 변경할 수 있는 API
  • 게시글 상태를 is_found = true로 업데이트하며, 동시에 찾은 시각(found_at)을 기록
    • 작성자 본인만 해당 게시글을 찾음 처리할 수 있음.
    • 이미 찾음 처리된 게시글에 대해 다시 요청하면 오류를 반환.

요청 정보

  • Method: POST
  • URL: /articles/lost-item/{id}/found
  • Path Variable: articleId (Long) – 찾음 처리할 분실물 게시글 ID
  • Request Body: 없음
  • Authorization: Bearer Token (로그인 필수)

응답 예시

1. 게시글 작성자가 아닌 경우

{
  "code": "FORBIDDEN_AUTHOR",
  "message": "게시글 접근 권한이 없습니다.",
  "errorTraceId": "123e4567-e89b-12d3-a456-426614174000"
}

2. 이미 찾음 처리된 게시글인 경우

{
  "code": "DUPLICATE_FOUND_STATUS",
  "message": "이미 찾음 처리된 분실물 게시글입니다.",
  "errorTraceId": "123e4567-e89b-12d3-a456-426614174000"
}

3. 로그인 상태가 아닌 경우

{
  "code": "",
  "message": "올바르지 않은 인증정보입니다. userId is null",
  "errorTraceId": "decfb393-3a2c-4b6e-9605-74c044dcea1f"
}

4. 게시글이 존재하지 않는 경우

{
  "code": "",
  "message": "게시글이 존재하지 않습니다. articleId: 20000",
  "errorTraceId": "718e7fcf-c8da-42e9-9daf-84d0818d1f4e"
}

2. "찾음 처리" 된 분실물 게시글 개수 반환 GET API 추가

API 설명

  • 분실물 게시판에서 현재까지 “찾음” 처리된 게시글의 총 개수를 조회하는 API
  • 인증 없이도 조회 가능
  • 삭제된 게시글은 제외됨

요청 정보

  • Method: GET
  • URL: /articles/lost-item/found/count
  • Path Variable: 없음
  • Request Body: 없음
  • Authorization: 없음

응답 예시(200)

{
  "found_count": 2
}

3. "찾음" 상태 필드가 포함된 분실물 게시글 동적 조회 GET API 추가

API 설명

image
  • "찾음" 상태 필드 조건에 따라 동적으로 분실물 게시글을 조회하는 API

분실물 게시글 목록 조회 V2 변경점

  • Request Param 추가: foundStatus (ALL, FOUND, NOT_FOUND)
    • ALL : 모든 분실물 게시글 조회 (Default)
    • FOUND : '주인 찾음' 상태인 게시글 조회
    • NOT_FOUND : '찾는 중' 상태인 게시글 조회

요청 정보

  • Method: GET
  • URL: /articles/lost-item/v2
  • Path Variable: type(FOUND, LOST), foundStatus(ALL, FOUND, NOT_FOUND), page, limit
  • Request Body: 없음
  • Authorization: 없음

4. "찾음" 상태 필드 응답값 추가

  • 기존 전체 조회 API (GET /articles/lost-item, GET /articles/lost-item/{id}, GET /articles/lost-item/search) 응답값에 is_found 필드 추가
{
      "id": 17884,
      "board_id": 14,
      "type": "FOUND",
      "category": "카드",
      "found_place": "우리집 앞",
      "found_date": "2025-12-22",
      "content": "잃어버린 카드",
      "author": "김두현4",
      "registered_at": "2025-12-23",
      "is_reported": false,
      "is_found": true // 필드 추가
    }

💬 참고 사항


✅ Checklist (완료 조건)

  • 코드 스타일 가이드 준수
  • 테스트 코드 포함됨
  • Reviewers / Assignees / Labels 지정 완료
  • 보안 및 민감 정보 검증 (API 키, 환경 변수, 개인정보 등)

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

github-actions bot commented Dec 23, 2025

Unit Test Results

672 tests   671 ✔️  1m 13s ⏱️
165 suites      1 💤
165 files        0

Results for commit a31ddc3.

♻️ This comment has been updated with latest results.

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.

분실물 찾은 사람 수 문구로 띄우기 아이디어 좋네요

그럼 초기에는 0명일텐데 그때도 0명으로 띄워지는 건가요..?

어쨋든 고생하셨습니다!

Comment on lines 26 to 30
if (lostItemArticle.getIsFound()) {
throw CustomException.of(ApiResponseCode.DUPLICATE_FOUND_STATUS);
}

lostItemArticle.markAsFound();
Copy link
Contributor

Choose a reason for hiding this comment

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

C

markAsFound() 메서드 내부에 이미 찾음 처리 된 게시글인지 확인하고 예외를 던지는 로직을 넣는것은 어떤가요?

중복 찾음 처리 책임을 LostItemArticle 클래스에 위임하는 것이 좋다고 생각합니다.

디미터의 법칙

Copy link
Collaborator Author

@DHkimgit DHkimgit Dec 23, 2025

Choose a reason for hiding this comment

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

좋은 글이네요! 감사합니다~

Copy link
Member

@asa9874 asa9874 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 208 to 214
Long total = lostItemArticleRepository.countLostItemArticlesWithFilters(type, foundStatusFilter, LOST_ITEM_BOARD_ID);
Criteria criteria = Criteria.of(page, limit, total.intValue());
PageRequest pageRequest = PageRequest.of(criteria.getPage(), criteria.getLimit(), ARTICLES_SORT);

Page<Article> articles = lostItemArticleRepository.findLostItemArticlesWithFilters(
LOST_ITEM_BOARD_ID, type, foundStatusFilter, pageRequest
);
Copy link
Member

Choose a reason for hiding this comment

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

countLostItemArticlesWithFilters 로 count 쿼리가 실행된뒤 동일한 조건의 쿼리가 findLostItemArticlesWithFilters 내부에도 사용되는거같습니다.

findLostItemArticlesWithFilters 메서드에서 Page객체를 반환하지않고 List<Article> 로 반환한뒤에 기존 total 값을 활용할수있을거같습니다.

Comment on lines 162 to 166
@GetMapping("/lost-item/found/count")
public ResponseEntity<FoundLostItemArticleCountResponse> getFoundLostItemArticles() {
FoundLostItemArticleCountResponse response = lostItemFoundService.countFoundArticles();
return ResponseEntity.ok().body(response);
}
Copy link
Member

Choose a reason for hiding this comment

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

getFoundLostItemArticles 메서드명이 분실물개수를 반환하는 메서드동작에 어울리게 수정해야할거같습니다.

@DHkimgit DHkimgit merged commit a690edf into develop Dec 24, 2025
5 checks passed
@DHkimgit DHkimgit deleted the feat/2111-add-lost-item-article-found-status branch December 24, 2025 05:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Team Campus 캠퍼스 팀에서 작업할 이슈입니다 기능 새로운 기능을 개발합니다.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[캠퍼스] 분실물 게시글 '찾음' 상태 추가 및 관련 API 구현

4 participants