Skip to content

Comments

[Feat] inquiry api#103

Merged
nasohee merged 4 commits intodevelopfrom
feat-inquiry-api
Nov 5, 2025
Merged

[Feat] inquiry api#103
nasohee merged 4 commits intodevelopfrom
feat-inquiry-api

Conversation

@nasohee
Copy link
Collaborator

@nasohee nasohee commented Oct 27, 2025

Related issue 🛠

Work Description 📝

  • 문의하기 api를 작성하였습니다.

Screenshot 📸

2025-10-28.05.20.38.mov

Uncompleted Tasks 😅

To Reviewers 📢

서버 쪽이랑 연락을 늦게 해버려 늦게 올립니다 죄송합니다 ㅠㅠ

Summary by CodeRabbit

  • 새로운 기능
    • 문의 작성 및 제출 기능 추가: 제목, 내용, 카테고리 선택으로 서버에 문의 전송 가능
    • 제출 후 성공 시 자동으로 화면 전환(네비게이션) 처리
  • 개선
    • 입력 검증 강화: 제목·내용 최소 5자, 최소 1개 카테고리 필수
    • 사용자 피드백 개선: 로딩 표시 및 오류 메시지 안내 추가
    • 제출 로직 및 상태 관리 추가로 안정적인 전송 및 결과 처리 제공

@coderabbitai
Copy link

coderabbitai bot commented Oct 27, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

문의 제출 기능을 계층별로 추가: DTO, Retrofit 서비스, 원격 데이터소스(인터페이스 + 구현), 저장소 구현, 유스케이스, 뷰모델, DI 바인딩, MyInquireFragment 패키지 이동·뷰모델 통합 및 네비게이션 경로 업데이트.

Changes

Cohort / File(s) 변경 요약
원격 데이터 계층
app/src/main/java/com/example/findu/data/dataremote/service/InquiryService.kt, app/src/main/java/com/example/findu/data/dataremote/datasource/InquiryRemoteDataSource.kt, app/src/main/java/com/example/findu/data/dataremote/datasourceimpl/InquiryRemoteDataSourceImpl.kt, app/src/main/java/com/example/findu/data/dataremote/model/request/InquiryRequestDto.kt
PostInquiryRequestDto DTO(@Serializable) 추가, Retrofit InquiryService(@POST "/api/v2/inquiries") 추가, InquiryRemoteDataSource 인터페이스 및 InquiryRemoteDataSourceImpl 구현 추가
저장소 계층
app/src/main/java/com/example/findu/domain/repository/InquiryRepository.kt, app/src/main/java/com/example/findu/data/repositoryimpl/InquiryRepositoryImpl.kt
InquiryRepository 인터페이스 및 InquiryRepositoryImpl 추가. DTO 생성, 원격 데이터소스 호출, handleBaseResponse 적용하여 Result<Unit> 반환
유스케이스 계층
app/src/main/java/com/example/findu/domain/usecase/PostInquiryUseCase.kt
PostInquiryUseCase 추가 — 저장소의 postInquiry 위임
DI 설정
app/src/main/java/com/example/findu/di/ServiceModule.kt, app/src/main/java/com/example/findu/di/DataSourceModule.kt, app/src/main/java/com/example/findu/di/RepositoryModule.kt
InquiryService 제공자 추가, InquiryRemoteDataSourceInquiryRepository 바인딩 추가
뷰모델 계층
app/src/main/java/com/example/findu/presentation/ui/my/viewmodel/InquiryViewModel.kt, app/src/main/java/com/example/findu/presentation/ui/my/viewmodel/MyViewModel.kt
InquiryViewModel 추가(상태: postInquirySuccess, errorMessage, loadingState; postInquiry, resetInquiryState) 및 MyViewModel 패키지 경로 변경
UI 및 네비게이션
app/src/main/java/com/example/findu/presentation/ui/my/inquiry/MyInquireFragment.kt, app/src/main/java/com/example/findu/presentation/ui/my/*.kt, app/src/main/res/navigation/nav_graph.xml
MyInquireFragment...my.inquiry 패키지로 이동, @AndroidEntryPoint 추가, InquiryViewModel 통합, 입력 유효성(제목/내용 5자 이상, 최소 1개 카테고리) 적용, nav_graph.xml fragment android:name 업데이트 및 여러 Fragment import 정리

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Fragment as MyInquireFragment
    participant ViewModel as InquiryViewModel
    participant UseCase as PostInquiryUseCase
    participant Repo as InquiryRepositoryImpl
    participant DataSource as InquiryRemoteDataSourceImpl
    participant Service as InquiryService
    participant API as API_Server

    User->>Fragment: 제목/내용/카테고리 입력 후 제출
    Fragment->>Fragment: 유효성 검사(제목/내용 >=5, 카테고리 >=1)
    Fragment->>ViewModel: postInquiry(title, content, categories)

    rect rgb(230, 245, 255)
    Note over ViewModel: 로딩 시작
    end

    ViewModel->>UseCase: invoke(...)
    UseCase->>Repo: postInquiry(...)
    Repo->>Repo: PostInquiryRequestDto 생성
    Repo->>DataSource: postInquiry(request)
    DataSource->>Service: postInquiry(body)
    Service->>API: POST /api/v2/inquiries

    alt 성공
        API-->>Service: 200 OK
        Service-->>DataSource: NullableBaseResponse<Unit>
        DataSource-->>Repo: NullableBaseResponse<Unit>
        Repo-->>UseCase: Result.success(Unit)
        UseCase-->>ViewModel: success
        ViewModel->>Fragment: 성공 처리 (이동/메시지)
    else 실패
        API-->>Service: Error
        Service-->>DataSource: Error/예외
        DataSource-->>Repo: 예외 전달
        Repo-->>UseCase: Result.failure
        UseCase-->>ViewModel: failure
        ViewModel->>Fragment: errorMessage 표시
    end

    rect rgb(230, 255, 230)
    Note over ViewModel: 로딩 종료
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–25 minutes

검토 시 주의 사항:

  • InquiryViewModel의 StateFlow 전이와 에러 메시지 할당/초기화
  • MyInquireFragment의 유효성 검사 및 UI 상태(로딩, 에러, 네비게이션) 반영
  • DI 바인딩(Service/RemoteDataSource/Repository) 일관성 및 모듈 제공 범위
  • Retrofit 인터페이스(@POST 경로)와 DTO의 직렬화 필드명이 API 사양과 일치하는지 확인

Possibly related PRs

  • [Feat] inquiry api #103 — 동일한 문의하기 API 기능(서비스/DTO/리포지토리/뷰모델/프래그먼트) 변경과 직접적 관련

Suggested labels

feat, 🐶소희

Suggested reviewers

  • ikseong00
  • t1nm1ksun

Poem

🐾 작은 질문, 레이어를 타고 올라가네
DTO로 포장해 Service에 전하고
ViewModel은 흐름을 지켜보다가
성공이면 이동, 실패면 메시지로 속삭여
Hilt로 엮인 코드는 오늘도 chill ✨

Pre-merge checks and finishing touches

✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목 '[Feat] inquiry api'는 주요 변경사항인 문의 API 구현을 명확하게 요약하고 있습니다.
Description check ✅ Passed PR 설명은 템플릿의 주요 섹션(관련 이슈, 작업 내용, 스크린샷, 검토자에게 전하는 말)을 포함하고 있습니다.
Linked Issues check ✅ Passed PR 변경사항은 #98의 문의하기 API 구현 요구사항을 충족하는 완전한 API 레이어 구현을 제공합니다.
Out of Scope Changes check ✅ Passed 모든 변경사항은 문의 API 구현과 관련된 범위 내에 있으며, 불필요한 수정은 포함되지 않습니다.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d0dca53 and f4d0d0c.

📒 Files selected for processing (3)
  • app/src/main/java/com/example/findu/di/DataSourceModule.kt (3 hunks)
  • app/src/main/java/com/example/findu/di/RepositoryModule.kt (4 hunks)
  • app/src/main/java/com/example/findu/di/ServiceModule.kt (2 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (5)
app/src/main/java/com/example/findu/data/dataremote/datasource/InquiryRemoteDataSource.kt (1)

6-8: 인터페이스 구조는 좋습니다. 작은 포맷팅 제안이 있어요.

suspend function 선언부에 불필요한 공백이 있네요 (postInquiry( request 부분).

다음과 같이 정리할 수 있습니다:

 interface InquiryRemoteDataSource {
-    suspend fun postInquiry( request: PostInquiryRequestDto): NullableBaseResponse<Unit>
+    suspend fun postInquiry(request: PostInquiryRequestDto): NullableBaseResponse<Unit>
 }
app/src/main/java/com/example/findu/data/dataremote/model/request/InquiryRequestDto.kt (1)

7-14: 프로퍼티 이름과 직렬화 이름 간의 불일치를 확인해주세요.

코드에서는 category(단수)로 선언했지만, 서버로 전송될 때는 categories(복수)로 매핑됩니다. 프로퍼티가 List<String> 타입이므로 복수형 이름이 더 자연스러울 것 같아요.

일관성을 위해 프로퍼티 이름도 복수형으로 변경하는 것을 고려해보세요:

 @Serializable
 data class PostInquiryRequestDto(
     @SerialName("title")
     val title: String,
     @SerialName("content")
     val content: String,
     @SerialName("categories")
-    val category: List<String>
+    val categories: List<String>
 )
app/src/main/java/com/example/findu/presentation/ui/my/viewmodel/InquiryViewModel.kt (1)

26-41: 입력 값 검증을 추가하면 더 좋을 것 같아요.

현재 postInquiry 메서드는 title, content, categories의 유효성을 확인하지 않고 바로 API를 호출합니다. 빈 문자열이나 빈 리스트가 전달될 경우 불필요한 네트워크 요청이 발생할 수 있어요.

다음과 같이 입력 검증을 추가하는 것을 고려해보세요:

 fun postInquiry(title: String, content: String, categories: List<String>) {
     viewModelScope.launch {
+        if (title.isBlank() || content.isBlank() || categories.isEmpty()) {
+            _postInquirySuccess.value = false
+            _errorMessage.value = "모든 필드를 입력해주세요."
+            return@launch
+        }
+
         _loadingState.value = true

         postInquiryUseCase(title, content, categories)
app/src/main/java/com/example/findu/data/dataremote/service/InquiryService.kt (1)

6-6: 사용하지 않는 import 제거 필요

retrofit2.http.Header가 import되어 있지만 코드에서 사용되지 않고 있어요. 제거해주시면 좋을 것 같습니다.

-import retrofit2.http.Header
app/src/main/java/com/example/findu/data/dataremote/datasourceimpl/InquiryRemoteDataSourceImpl.kt (1)

4-4: 사용하지 않는 import들 정리 필요

다음 import들이 코드에서 사용되지 않고 있어요:

  • Line 4: BaseResponse
  • Line 8: handleBaseResponse
  • Line 9: InquiryRepository

제거해주시면 코드가 더 깔끔해질 것 같습니다.

-import com.example.findu.data.dataremote.model.base.BaseResponse
-import com.example.findu.data.dataremote.util.handleBaseResponse
-import com.example.findu.domain.repository.InquiryRepository

Also applies to: 8-9

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e96b457 and 042d3d6.

📒 Files selected for processing (18)
  • app/src/main/java/com/example/findu/data/dataremote/datasource/InquiryRemoteDataSource.kt (1 hunks)
  • app/src/main/java/com/example/findu/data/dataremote/datasourceimpl/InquiryRemoteDataSourceImpl.kt (1 hunks)
  • app/src/main/java/com/example/findu/data/dataremote/model/request/InquiryRequestDto.kt (1 hunks)
  • app/src/main/java/com/example/findu/data/dataremote/service/InquiryService.kt (1 hunks)
  • app/src/main/java/com/example/findu/data/repositoryimpl/InquiryRepositoryImpl.kt (1 hunks)
  • app/src/main/java/com/example/findu/di/DataSourceModule.kt (3 hunks)
  • app/src/main/java/com/example/findu/di/RepositoryModule.kt (4 hunks)
  • app/src/main/java/com/example/findu/di/ServiceModule.kt (2 hunks)
  • app/src/main/java/com/example/findu/domain/repository/InquiryRepository.kt (1 hunks)
  • app/src/main/java/com/example/findu/domain/usecase/PostInquiryUseCase.kt (1 hunks)
  • app/src/main/java/com/example/findu/presentation/ui/my/MyFragment.kt (1 hunks)
  • app/src/main/java/com/example/findu/presentation/ui/my/MyInterestFragment.kt (1 hunks)
  • app/src/main/java/com/example/findu/presentation/ui/my/MyReportHistoryFragment.kt (1 hunks)
  • app/src/main/java/com/example/findu/presentation/ui/my/MyViewedAnimalFragment.kt (1 hunks)
  • app/src/main/java/com/example/findu/presentation/ui/my/inquiry/MyInquireFragment.kt (6 hunks)
  • app/src/main/java/com/example/findu/presentation/ui/my/viewmodel/InquiryViewModel.kt (1 hunks)
  • app/src/main/java/com/example/findu/presentation/ui/my/viewmodel/MyViewModel.kt (1 hunks)
  • app/src/main/res/navigation/nav_graph.xml (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
app/src/main/java/com/example/findu/presentation/ui/my/inquiry/MyInquireFragment.kt (4)
app/src/main/java/com/example/findu/presentation/ui/my/MyFragment.kt (1)
  • observeViewModel (205-266)
app/src/main/java/com/example/findu/presentation/ui/my/MyInterestFragment.kt (1)
  • observeViewModel (89-110)
app/src/main/java/com/example/findu/presentation/ui/my/MyReportHistoryFragment.kt (1)
  • observeViewModel (83-94)
app/src/main/java/com/example/findu/presentation/ui/my/MyViewedAnimalFragment.kt (1)
  • observeViewModel (88-101)
🔇 Additional comments (19)
app/src/main/java/com/example/findu/presentation/ui/my/MyInterestFragment.kt (1)

17-17: 패키지 재구성에 맞춘 import 업데이트, 깔끔합니다!

MyViewModel의 새 패키지 경로로 import가 정확하게 업데이트되었습니다.

app/src/main/java/com/example/findu/presentation/ui/my/viewmodel/InquiryViewModel.kt (1)

43-47: 상태 초기화 메서드, 좋습니다!

UI 상태를 깔끔하게 초기화하는 메서드가 있어서 좋네요. 다이얼로그 닫기나 화면 재진입 시 유용하게 쓰일 것 같습니다.

app/src/main/java/com/example/findu/presentation/ui/my/MyFragment.kt (1)

32-32: Import 추가 완료!

MyViewModel의 새 패키지 경로를 정확하게 import했습니다.

app/src/main/java/com/example/findu/presentation/ui/my/MyViewedAnimalFragment.kt (1)

15-15: Import 정리 완료!

MyViewModel의 새 패키지로 import가 업데이트되었고, 사용하지 않는 import도 정리된 것 같습니다.

app/src/main/java/com/example/findu/di/ServiceModule.kt (1)

10-10: DI 설정이 깔끔하게 추가되었습니다!

InquiryService의 의존성 주입 설정이 다른 서비스들과 동일한 패턴으로 잘 구현되었습니다. Singleton 스코프도 적절하게 적용되었어요.

Also applies to: 107-111

app/src/main/java/com/example/findu/presentation/ui/my/MyReportHistoryFragment.kt (1)

16-16: Import 업데이트 완료!

MyViewModel의 새 위치로 import가 정확하게 변경되었습니다.

app/src/main/java/com/example/findu/presentation/ui/my/viewmodel/MyViewModel.kt (1)

1-1: 패키지 구조 개선 👍

ViewModel을 별도의 viewmodel 패키지로 분리한 것 좋네요. 코드 구조가 더 명확해졌습니다.

app/src/main/java/com/example/findu/di/RepositoryModule.kt (1)

80-82: InquiryRepository DI 바인딩 잘 추가되었습니다

Dagger Hilt 바인딩이 올바르게 구성되어 있고, 다른 Repository 바인딩들과 일관된 패턴을 따르고 있네요.

app/src/main/java/com/example/findu/di/DataSourceModule.kt (1)

100-102: DataSource 바인딩 깔끔합니다

InquiryRemoteDataSource의 DI 설정이 잘 되어 있고, 기존 패턴과 일관성 있게 구현되었네요.

app/src/main/res/navigation/nav_graph.xml (1)

230-230: 네비게이션 경로 업데이트 확인

MyInquireFragment의 패키지 경로가 정확하게 업데이트되었습니다.

app/src/main/java/com/example/findu/domain/repository/InquiryRepository.kt (1)

4-10: 도메인 인터페이스 깔끔하게 정의되었습니다

Result<Unit>을 사용한 에러 핸들링이 좋고, 파라미터 구조도 명확하네요.

app/src/main/java/com/example/findu/data/dataremote/service/InquiryService.kt (1)

9-14: Retrofit 서비스 정의 잘 되어 있습니다

POST 엔드포인트와 요청 DTO 설정이 올바르게 구성되어 있네요.

app/src/main/java/com/example/findu/data/repositoryimpl/InquiryRepositoryImpl.kt (1)

10-23: Repository 구현 깔끔합니다

runCatchinghandleBaseResponse를 활용한 에러 핸들링이 잘 되어 있고, DTO 생성 로직도 명확하네요.

app/src/main/java/com/example/findu/data/dataremote/datasourceimpl/InquiryRemoteDataSourceImpl.kt (1)

13-18: DataSource 구현 깔끔합니다

Service로의 위임 로직이 간단명료하게 구현되어 있네요.

app/src/main/java/com/example/findu/domain/usecase/PostInquiryUseCase.kt (1)

6-14: 깔끔한 유즈케이스 구현입니다!

의존성 주입과 레포지토리 위임이 잘 구현되어 있네요. 아키텍처 레이어 분리가 명확합니다.

app/src/main/java/com/example/findu/presentation/ui/my/inquiry/MyInquireFragment.kt (4)

1-1: Hilt 통합이 올바르게 구성되었습니다!

패키지 재구성, 의존성 주입 설정, ViewModel 연결이 잘 되어 있네요.

Also applies to: 14-15, 18-19, 21-23, 25-25, 30-30


39-39: 카테고리 처리 로직이 개선되었습니다!

리스트를 사용한 카테고리 수집 방식이 더 깔끔하고 확장 가능하네요. 타입 체크도 안전하게 처리되었습니다.

Also applies to: 54-54, 61-65, 69-69


74-79: 최소 길이 검증 로직이 추가되었습니다.

5자 이상 검증으로 유효성을 강화했네요. 스팸성 문의를 방지할 수 있겠습니다.


158-180: Chip 초기화 로직이 깔끔하게 개선되었습니다!

인라인 확장 함수와 listOf 사용으로 코드가 더 읽기 쉬워졌네요. 스타일링도 일관성 있게 적용되었습니다.

@nasohee nasohee merged commit 22e8cc4 into develop Nov 5, 2025
1 check was pending
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.

[feat] 문의하기 api

1 participant