-
Notifications
You must be signed in to change notification settings - Fork 2
feat: 분실물 게시판 '찾음' 상태 추가 및 관련 API 구현 #2112
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 구현 #2112
Conversation
kih1015
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
분실물 찾은 사람 수 문구로 띄우기 아이디어 좋네요
그럼 초기에는 0명일텐데 그때도 0명으로 띄워지는 건가요..?
어쨋든 고생하셨습니다!
| if (lostItemArticle.getIsFound()) { | ||
| throw CustomException.of(ApiResponseCode.DUPLICATE_FOUND_STATUS); | ||
| } | ||
|
|
||
| lostItemArticle.markAsFound(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C
markAsFound() 메서드 내부에 이미 찾음 처리 된 게시글인지 확인하고 예외를 던지는 로직을 넣는것은 어떤가요?
중복 찾음 처리 책임을 LostItemArticle 클래스에 위임하는 것이 좋다고 생각합니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
좋은 글이네요! 감사합니다~
asa9874
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다.👍
| 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 | ||
| ); |
There was a problem hiding this comment.
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 값을 활용할수있을거같습니다.
| @GetMapping("/lost-item/found/count") | ||
| public ResponseEntity<FoundLostItemArticleCountResponse> getFoundLostItemArticles() { | ||
| FoundLostItemArticleCountResponse response = lostItemFoundService.countFoundArticles(); | ||
| return ResponseEntity.ok().body(response); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getFoundLostItemArticles 메서드명이 분실물개수를 반환하는 메서드동작에 어울리게 수정해야할거같습니다.
🔍 개요
🚀 주요 변경 내용
1. 분실물 "찾음 처리" POST API 추가
API 설명
요청 정보
응답 예시
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 설명
요청 정보
응답 예시(200)
{ "found_count": 2 }3. "찾음" 상태 필드가 포함된 분실물 게시글 동적 조회 GET API 추가
API 설명
분실물 게시글 목록 조회 V2 변경점
요청 정보
4. "찾음" 상태 필드 응답값 추가
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 (완료 조건)