-
Notifications
You must be signed in to change notification settings - Fork 0
[feat/#22] 게시물 작성 API 연동 #23
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
Changes from all commits
dd7aaa4
42faa09
6b4bb66
636f1a1
79cf665
0450997
54a8b93
08c9af7
cbde8fe
99dbad3
3566d32
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| package com.hsLink.hslink.data.dto | ||
|
|
||
| class DummyDto { | ||
| } | ||
|
Comment on lines
+3
to
+4
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❓ Verification inconclusiveRemove unused empty class or implement with proper DTO properties. This empty
Run the following script to verify whether this class is referenced elsewhere: 🏁 Script executed: #!/bin/bash
# Description: Check if DummyDto is referenced anywhere in the codebase
# Search for DummyDto usage across the codebase
rg -nP '\bDummyDto\b' -g '!**/DummyDto.kt'Length of output: 0 Remove the unused The class is empty and has no references anywhere in the codebase. It appears to be leftover placeholder code that should be deleted. 🧰 Tools🪛 detekt (1.23.8)[warning] 3-4: The class or object DummyDto is empty. (detekt.empty-blocks.EmptyClassBlock) 🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,14 @@ | ||
| package com.hsLink.hslink.data.dto.request | ||
|
|
||
| class PostRequestDto { | ||
| } | ||
| import kotlinx.serialization.SerialName | ||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class PostRequestDto ( | ||
| @SerialName("postType") | ||
| val postType: String, | ||
| @SerialName("title") | ||
| val title : String, | ||
| @SerialName("body") | ||
| val body : String | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package com.hsLink.hslink.data.dto.response | ||
|
|
||
| import com.hsLink.hslink.domain.model.community.CommunityPostResponseEntity | ||
| import kotlinx.serialization.SerialName | ||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class CommunityPostResponseDto ( | ||
| @SerialName("postId") | ||
| val postId: Int, | ||
| ) | ||
|
|
||
|
|
||
| fun CommunityPostResponseDto.toEntity(): CommunityPostResponseEntity { | ||
| return CommunityPostResponseEntity( | ||
| postId = this.postId, | ||
| ) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package com.hsLink.hslink.data.remote.datasource | ||
|
|
||
| import com.hsLink.hslink.core.network.BaseResponse | ||
| import com.hsLink.hslink.data.dto.request.PostRequestDto | ||
| import com.hsLink.hslink.data.dto.response.CommunityPostResponseDto | ||
|
|
||
| interface CommunityPostDataSource { | ||
| suspend fun createCommunityPost( | ||
| request : PostRequestDto | ||
| ): BaseResponse<CommunityPostResponseDto> | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| package com.hsLink.hslink.data.remote.datasourceimpl | ||
|
|
||
| import com.hsLink.hslink.core.network.BaseResponse | ||
| import com.hsLink.hslink.data.dto.request.PostRequestDto | ||
| import com.hsLink.hslink.data.dto.response.CommunityPostResponseDto | ||
| import com.hsLink.hslink.data.remote.datasource.CommunityPostDataSource | ||
| import com.hsLink.hslink.data.service.commuunity.CommunityPostService | ||
| import javax.inject.Inject | ||
|
|
||
| class CommunityPostDataSourceImpl @Inject constructor( | ||
| private val communityPostService: CommunityPostService | ||
| ) : CommunityPostDataSource { | ||
| override suspend fun createCommunityPost( | ||
| request : PostRequestDto | ||
| ) : BaseResponse<CommunityPostResponseDto> { | ||
| // TODO: Replace dummy token with real access token | ||
| return communityPostService.postCommunity(token = "", requestBody = request) | ||
| } | ||
|
Comment on lines
+13
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pass the real auth token to the API call Right now Line 17 hardcodes -class CommunityPostDataSourceImpl @Inject constructor(
- private val communityPostService: CommunityPostService
-) : CommunityPostDataSource {
+class CommunityPostDataSourceImpl @Inject constructor(
+ private val communityPostService: CommunityPostService,
+ private val tokenProvider: TokenProvider,
+) : CommunityPostDataSource {
override suspend fun createCommunityPost(
request : PostRequestDto
) : BaseResponse<CommunityPostResponseDto> {
- // TODO: Replace dummy token with real access token
- return communityPostService.postCommunity(token = "", requestBody = request)
+ val accessToken = tokenProvider.requireAccessToken()
+ return communityPostService.postCommunity(
+ token = "Bearer $accessToken",
+ requestBody = request
+ )
}
}
🤖 Prompt for AI Agents |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package com.hsLink.hslink.data.repositoryimpl | ||
|
|
||
| import com.hsLink.hslink.data.dto.request.PostRequestDto | ||
| import com.hsLink.hslink.data.dto.response.CommunityPostResponseDto | ||
| import com.hsLink.hslink.data.remote.datasourceimpl.CommunityPostDataSourceImpl | ||
| import com.hsLink.hslink.domain.repository.community.CommunityRepository | ||
| import javax.inject.Inject | ||
|
|
||
| class CommunityRepositoryImpl @Inject constructor( | ||
| private val communityPostDataSourceImpl: CommunityPostDataSourceImpl, | ||
| ) : CommunityRepository { | ||
| override suspend fun createCommunityPost(communityRequestDto: PostRequestDto): Result<CommunityPostResponseDto> = runCatching { | ||
| val response = communityPostDataSourceImpl.createCommunityPost(communityRequestDto) | ||
| if (response.isSuccess) { | ||
| response.result | ||
| } else { | ||
| throw Exception(response.message) | ||
| } | ||
| } | ||
|
Comment on lines
+12
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Map the response to the domain model before returning Lines 12-16 still hand out - override suspend fun createCommunityPost(communityRequestDto: PostRequestDto): Result<CommunityPostResponseDto> = runCatching {
- val response = communityPostDataSourceImpl.createCommunityPost(communityRequestDto)
- if (response.isSuccess) {
- response.result
- } else {
- throw Exception(response.message)
- }
- }
+ override suspend fun createCommunityPost(communityRequestDto: PostRequestDto): Result<CommunityPostResponseEntity> =
+ runCatching {
+ val response = communityPostDataSource.createCommunityPost(communityRequestDto)
+ if (!response.isSuccess) {
+ throw IllegalStateException(response.message ?: "Failed to create community post")
+ }
+ val body = response.result ?: throw IllegalStateException("Create community post returned no body")
+ body.toEntity()
+ }
🤖 Prompt for AI Agents |
||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,17 @@ | ||||||
| package com.hsLink.hslink.data.service.commuunity | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix package name typo. The package name contains a typo: "commuunity" should be "community" (remove the extra 'u'). This affects the file location and all imports referencing this service. Apply this fix: -package com.hsLink.hslink.data.service.commuunity
+package com.hsLink.hslink.data.service.communityNote: You'll also need to move the file from 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
|
|
||||||
| import com.hsLink.hslink.core.network.BaseResponse | ||||||
| import com.hsLink.hslink.data.dto.request.PostRequestDto | ||||||
| import com.hsLink.hslink.data.dto.response.CommunityPostResponseDto | ||||||
| import retrofit2.http.Body | ||||||
| import retrofit2.http.Header | ||||||
| import retrofit2.http.POST | ||||||
|
|
||||||
|
|
||||||
| interface CommunityPostService { | ||||||
| @POST("posts") | ||||||
| suspend fun postCommunity( | ||||||
| @Header("Authorization") token: String, | ||||||
| @Body requestBody: PostRequestDto, | ||||||
| ): BaseResponse<CommunityPostResponseDto> | ||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| package com.hsLink.hslink.domain.model.community | ||
|
|
||
| data class CommunityPostResponseEntity( | ||
| val postId: Int, | ||
| ) |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package com.hsLink.hslink.domain.repository.community | ||
|
|
||
| import com.hsLink.hslink.data.dto.request.PostRequestDto | ||
| import com.hsLink.hslink.data.dto.response.CommunityPostResponseDto | ||
|
|
||
| interface CommunityRepository { | ||
| suspend fun createCommunityPost(communityRequestDto: PostRequestDto): Result<CommunityPostResponseDto> | ||
|
Comment on lines
+3
to
+7
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keep the domain contract free of data-layer DTOs Line 7 exposes -import com.hsLink.hslink.data.dto.request.PostRequestDto
-import com.hsLink.hslink.data.dto.response.CommunityPostResponseDto
+import com.hsLink.hslink.domain.model.community.CommunityPostRequestEntity
+import com.hsLink.hslink.domain.model.community.CommunityPostResponseEntity
@@
-interface CommunityRepository {
- suspend fun createCommunityPost(communityRequestDto: PostRequestDto): Result<CommunityPostResponseDto>
-}
+interface CommunityRepository {
+ suspend fun createCommunityPost(request: CommunityPostRequestEntity): Result<CommunityPostResponseEntity>
+}
🤖 Prompt for AI Agents |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package com.hsLink.hslink.domain.repository.home | ||
|
|
||
| import com.hsLink.hslink.domain.model.home.PostPopularEntity | ||
| import com.hsLink.hslink.domain.model.home.PostPromotionEntity | ||
|
|
||
| interface PostRepository { | ||
| suspend fun getPopularPost(): Result<List<PostPopularEntity>> | ||
| suspend fun getPromotionPost(): Result<List<PostPromotionEntity>> | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package com.hsLink.hslink.presentation.community.state | ||
|
|
||
| import androidx.compose.runtime.Immutable | ||
| import com.hsLink.hslink.domain.model.community.CommunityPostResponseEntity | ||
|
|
||
| @Immutable | ||
| data class CommunityContract ( | ||
| val isLoading: Boolean = false, | ||
| val error: String? = null, | ||
| val communityEntity: CommunityPostResponseEntity ? = null | ||
| ) |
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.
🧩 Analysis chain
Fix package name typo.
The package name contains a typo:
commuunityshould becommunity(has three 'u's instead of two). This should be corrected in both the package structure and all import statements.Verify the extent of this typo across the codebase:
🏁 Script executed:
Length of output: 26
🏁 Script executed:
Length of output: 434
🏁 Script executed:
Length of output: 11323
Fix package name typo in data service layer.
The package
com.hsLink.hslink.data.service.commuunitycontains a typo:commuunityshould becommunity(three 'u's instead of two). This typo exists in the package definition and is imported in two locations:Rename the package directory from
commuunitytocommunity, update the package declaration, and update both import statements accordingly.🤖 Prompt for AI Agents