-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
125 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
app/src/main/java/com/owori/android/data/api/story/StoryApi.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.owori.android.data.api.story | ||
|
||
import com.owori.android.data.model.story.StoryItem | ||
import com.owori.android.data.model.story.StoryListPageResponse | ||
import com.owori.android.data.model.story.StoryResponse | ||
import com.owori.android.module.DataResult | ||
import retrofit2.http.Body | ||
import retrofit2.http.DELETE | ||
import retrofit2.http.GET | ||
import retrofit2.http.POST | ||
import retrofit2.http.Path | ||
import retrofit2.http.Query | ||
|
||
interface StoryApi { | ||
|
||
// 이야기 등록 | ||
@POST("/stories") | ||
fun postStory(@Body data: StoryItem): DataResult<StoryResponse> | ||
|
||
// 이야기 수정 | ||
@POST("/stories/update") | ||
fun editStory(@Body data: StoryItem): DataResult<StoryResponse> | ||
|
||
// 이야기 삭제 | ||
@DELETE("/stories/{storyId}") | ||
fun deleteStory(@Path(value = "storyId") storyId: String): DataResult<Any> | ||
|
||
// 이야기 전체 조회 | ||
@GET("/stories") | ||
fun getAllStories(@Query("sort") sortType: String, @Query("page") page: Int, @Query("size") size: Int): DataResult<StoryListPageResponse> | ||
|
||
// 이야기 상세 조회 | ||
@GET("/stories/{storyId}") | ||
fun getDetailStory(@Path(value = "storyId") storyId: String): DataResult<StoryItem> | ||
|
||
// 이야기 검색 | ||
@GET("/stories/search") | ||
fun searchStory(@Query("keyword") keyword: String): DataResult<List<StoryItem>> | ||
|
||
// 유저가 작성한 이야기 조회 | ||
@GET("/stories/member") | ||
fun getStoryWithMember(@Query("sort") sortType: String, @Query("page") page: Int, @Query("size") size: Int): DataResult<StoryListPageResponse> | ||
|
||
// 유저가 좋아한 이야기 조회 | ||
@GET("/stories/heart") | ||
fun getLikedStoryWithMember(@Query("sort") sortType: String, @Query("page") page: Int, @Query("size") size: Int): DataResult<StoryListPageResponse> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
app/src/main/java/com/owori/android/data/model/story/StoryRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.owori.android.data.model.story | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class StoryItem( | ||
@SerializedName("story_id") | ||
val storyId: String?, | ||
@SerializedName("start_date") | ||
val startDate: String?, | ||
@SerializedName("end_date") | ||
val endDate: String?, | ||
val title: String, | ||
val content: String, | ||
@SerializedName("story_images") | ||
val storyImages: List<String>?, | ||
val writer: String?, | ||
val thumbnail: String?, | ||
val isMultipleImages: Boolean?, | ||
@SerializedName("heart_count") | ||
val heartCount: Int?, | ||
@SerializedName("comment_count") | ||
val commentCount: Int?, | ||
val comments: List<CommentItem>?, | ||
) | ||
|
||
data class CommentItem( | ||
@SerializedName("parent_comment_id") | ||
val parentCommentId: String, | ||
@SerializedName("comment_id") | ||
val commentId: String, | ||
val comment: String, | ||
val writer: String, | ||
@SerializedName("time_before_writing") | ||
val timeBeforeWriting: String, | ||
@SerializedName("delete_comment_check") | ||
val deleteCommentCheck: Boolean, | ||
) | ||
|
||
enum class SortType(val value: String) { | ||
CREATED_AT("created_at"), | ||
START_DATE("start_date") | ||
} |
16 changes: 16 additions & 0 deletions
16
app/src/main/java/com/owori/android/data/model/story/StoryResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.owori.android.data.model.story | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class StoryResponse( | ||
@SerializedName("story_id") | ||
val storyId: String?, | ||
) | ||
|
||
data class StoryListPageResponse( | ||
val stories: List<StoryItem>?, | ||
@SerializedName("next_page") | ||
val nextPage: Int, | ||
@SerializedName("last_page") | ||
val lastPage: Int, | ||
) |