-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from ttoklip/feat/#1_home_news_fragment
Feat/#1 home news fragment
- Loading branch information
Showing
83 changed files
with
2,353 additions
and
691 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
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
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 |
---|---|---|
@@ -1,14 +1,72 @@ | ||
package com.umc.ttoklip.data.api | ||
|
||
import com.umc.ttoklip.data.model.CommonResponse | ||
import com.umc.ttoklip.data.model.ResponseBody | ||
import com.umc.ttoklip.data.model.TestResponse | ||
import com.umc.ttoklip.data.model.news.MainNewsResponse | ||
import com.umc.ttoklip.data.model.news.ReportRequest | ||
import com.umc.ttoklip.data.model.news.comment.NewsCommentRequest | ||
import com.umc.ttoklip.data.model.news.detail.NewsDetailResponse | ||
import retrofit2.Response | ||
import retrofit2.http.Body | ||
import retrofit2.http.DELETE | ||
import retrofit2.http.GET | ||
import retrofit2.http.PATCH | ||
import retrofit2.http.POST | ||
import retrofit2.http.Path | ||
import retrofit2.http.Query | ||
|
||
interface NewsApi { | ||
|
||
@GET("/api/v1/newsletters/posts") | ||
suspend fun getNewsMainApi(): Response<ResponseBody<MainNewsResponse>> | ||
|
||
@GET("/api/v1/newsletter/posts/{postId}") | ||
suspend fun getDetailNewsApi( | ||
@Path("postId") postId : Int | ||
): Response<ResponseBody<NewsDetailResponse>> | ||
|
||
@POST("/api/v1/newsletter/comment/{postId}") | ||
suspend fun postCommentNewsApi( | ||
@Path("postId") postId: Int, | ||
@Body request : NewsCommentRequest | ||
): Response<ResponseBody<CommonResponse>> | ||
|
||
@POST("/api/v1/newsletter/posts/report/{postId}") | ||
suspend fun postReportNewsApi( | ||
@Path("postId") postId: Int, | ||
@Body request : ReportRequest | ||
): Response<ResponseBody<CommonResponse>> | ||
|
||
@POST("/api/v1/newsletter/comment/report/{commentId}") | ||
suspend fun postReportCommentNewsApi( | ||
@Path("commentId") commentId: Int, | ||
@Body request : ReportRequest | ||
): Response<ResponseBody<CommonResponse>> | ||
|
||
|
||
@DELETE("/api/v1/newsletter/comment/{commentId}") | ||
suspend fun deleteCommentNewsApi( | ||
@Path("commentId") commentId: Int, | ||
): Response<ResponseBody<CommonResponse>> | ||
|
||
@POST("/api/v1/newsletter/posts/like/{postId}") | ||
suspend fun postLikeNewsApi( | ||
@Path("postId") postId: Int, | ||
): Response<ResponseBody<CommonResponse>> | ||
|
||
@DELETE("/api/v1/newsletter/posts/like/{postId}") | ||
suspend fun deleteLikeNewsApi( | ||
@Path("postId") postId: Int, | ||
): Response<ResponseBody<CommonResponse>> | ||
|
||
@POST("/api/v1/newsletter/posts/scrap/{postId}") | ||
suspend fun postScrapNewsApi( | ||
@Path("postId") postId: Int, | ||
): Response<ResponseBody<CommonResponse>> | ||
|
||
@DELETE("/api/v1/newsletter/posts/scrap/{postId}") | ||
suspend fun deleteScrapNewsApi( | ||
@Path("postId") postId: Int, | ||
): Response<ResponseBody<CommonResponse>> | ||
|
||
} |
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,33 @@ | ||
package com.umc.ttoklip.data.api | ||
|
||
import com.umc.ttoklip.data.model.ResponseBody | ||
import com.umc.ttoklip.data.model.news.detail.NewsDetailResponse | ||
import com.umc.ttoklip.data.model.search.NewsSearchResponse | ||
import com.umc.ttoklip.data.model.search.TipSearchResponse | ||
import com.umc.ttoklip.data.model.search.TownSearchResponse | ||
import retrofit2.Response | ||
import retrofit2.http.GET | ||
import retrofit2.http.Query | ||
|
||
interface SearchApi { | ||
|
||
@GET("/api/v1/search/newsletter") | ||
suspend fun getSearchNewsApi( | ||
@Query("title") title : String, | ||
@Query("sort") sort: String | ||
): Response<ResponseBody<NewsSearchResponse>> | ||
|
||
@GET("/api/v1/search/honeytip") | ||
suspend fun getSearchTipApi( | ||
@Query("title") title : String, | ||
@Query("sort") sort: String | ||
): Response<ResponseBody<TipSearchResponse>> | ||
|
||
|
||
@GET("/api/v1/search/our-town") | ||
suspend fun getSearchTownApi( | ||
@Query("title") title : String, | ||
@Query("sort") sort: String | ||
): Response<ResponseBody<TownSearchResponse>> | ||
|
||
} |
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.umc.ttoklip.data.db | ||
|
||
import androidx.room.Dao | ||
import androidx.room.Database | ||
import androidx.room.Entity | ||
import androidx.room.Insert | ||
import androidx.room.OnConflictStrategy | ||
import androidx.room.PrimaryKey | ||
import androidx.room.Query | ||
import androidx.room.RoomDatabase | ||
|
||
@Database( | ||
entities = [HistoryEntity::class], | ||
version = 1, | ||
exportSchema = false | ||
) | ||
abstract class AppDatabase : RoomDatabase() { | ||
abstract fun historyDao(): HistoryDao | ||
} | ||
|
||
@Dao | ||
interface HistoryDao { | ||
|
||
@Insert(onConflict = OnConflictStrategy.REPLACE) | ||
suspend fun addHistory(item: HistoryEntity) | ||
|
||
@Query("SELECT * FROM HistoryEntity") | ||
suspend fun getAll(): List<HistoryEntity> | ||
|
||
@Query("DELETE FROM HistoryEntity") | ||
suspend fun deleteAll() | ||
} | ||
|
||
@Entity | ||
data class HistoryEntity( | ||
@PrimaryKey(autoGenerate = true) val id: Int , | ||
val history: String | ||
) { | ||
companion object { | ||
|
||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
app/src/main/java/com/umc/ttoklip/data/model/CommonResponse.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,5 @@ | ||
package com.umc.ttoklip.data.model | ||
|
||
data class CommonResponse( | ||
val message : String | ||
) |
8 changes: 0 additions & 8 deletions
8
app/src/main/java/com/umc/ttoklip/data/model/news/CategoryResponse.kt
This file was deleted.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
app/src/main/java/com/umc/ttoklip/data/model/news/CategoryResponses.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,8 @@ | ||
package com.umc.ttoklip.data.model.news | ||
|
||
data class CategoryResponses( | ||
val houseWork: List<News>, | ||
val recipe: List<News>, | ||
val safeLiving: List<News>, | ||
val welfarePolicy: List<News> | ||
) |
11 changes: 0 additions & 11 deletions
11
app/src/main/java/com/umc/ttoklip/data/model/news/CookingQuestion.kt
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
app/src/main/java/com/umc/ttoklip/data/model/news/HouseworkQuestion.kt
This file was deleted.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
app/src/main/java/com/umc/ttoklip/data/model/news/MainNewsResponse.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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
package com.umc.ttoklip.data.model.news | ||
|
||
data class MainNewsResponse( | ||
val categoryResponse: CategoryResponse, | ||
val topFiveQuestions: List<TopFiveQuestion> | ||
val categoryResponses: CategoryResponses, | ||
val randomNews: List<Any> | ||
) |
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,10 @@ | ||
package com.umc.ttoklip.data.model.news | ||
|
||
data class News( | ||
val mainImageUrl: String, | ||
val newsletterId: Int, | ||
val title: String, | ||
val writtenTime: String | ||
){ | ||
constructor() : this("",0,"","") | ||
} |
6 changes: 6 additions & 0 deletions
6
app/src/main/java/com/umc/ttoklip/data/model/news/ReportRequest.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,6 @@ | ||
package com.umc.ttoklip.data.model.news | ||
|
||
data class ReportRequest( | ||
val content: String, | ||
val reportType: String | ||
) |
11 changes: 0 additions & 11 deletions
11
app/src/main/java/com/umc/ttoklip/data/model/news/SafeLivingQuestion.kt
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
app/src/main/java/com/umc/ttoklip/data/model/news/TopFiveQuestion.kt
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
app/src/main/java/com/umc/ttoklip/data/model/news/WelfarePolicyQuestion.kt
This file was deleted.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
app/src/main/java/com/umc/ttoklip/data/model/news/comment/NewsCommentRequest.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,6 @@ | ||
package com.umc.ttoklip.data.model.news.comment | ||
|
||
data class NewsCommentRequest( | ||
val comment: String, | ||
val parentCommentId: Int | ||
) |
9 changes: 9 additions & 0 deletions
9
app/src/main/java/com/umc/ttoklip/data/model/news/comment/NewsCommentResponse.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,9 @@ | ||
package com.umc.ttoklip.data.model.news.comment | ||
|
||
data class NewsCommentResponse( | ||
val commentContent: String, | ||
val commentId: Int, | ||
val parentId: Int?, | ||
val writer: String?, | ||
val writtenTime: String | ||
) |
5 changes: 5 additions & 0 deletions
5
app/src/main/java/com/umc/ttoklip/data/model/news/detail/ImageUrl.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,5 @@ | ||
package com.umc.ttoklip.data.model.news.detail | ||
|
||
data class ImageUrl( | ||
val imageUrl : String | ||
) |
21 changes: 21 additions & 0 deletions
21
app/src/main/java/com/umc/ttoklip/data/model/news/detail/NewsDetailResponse.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,21 @@ | ||
package com.umc.ttoklip.data.model.news.detail | ||
|
||
import com.umc.ttoklip.data.model.news.comment.NewsCommentResponse | ||
|
||
data class NewsDetailResponse( | ||
val category: String, | ||
val commentResponses: List<NewsCommentResponse>, | ||
val content: String, | ||
val imageUrlList: List<ImageUrl>, | ||
val newsletterId: Int, | ||
var likeCount: Int, | ||
var scrapCount: Int, | ||
val title: String?, | ||
val urlList: List<Url>, | ||
val writer: String?, | ||
val writtenTime: String, | ||
val likedByCurrentUser: Boolean, | ||
val scrapedByCurrentUser: Boolean | ||
) { | ||
constructor() : this("", listOf(), "", listOf(), 0, 0, 0, "", listOf(), "", "", false, false) | ||
} |
5 changes: 5 additions & 0 deletions
5
app/src/main/java/com/umc/ttoklip/data/model/news/detail/Url.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,5 @@ | ||
package com.umc.ttoklip.data.model.news.detail | ||
|
||
data class Url( | ||
val url: String | ||
) |
9 changes: 9 additions & 0 deletions
9
app/src/main/java/com/umc/ttoklip/data/model/search/NewsSearchResponse.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,9 @@ | ||
package com.umc.ttoklip.data.model.search | ||
|
||
data class NewsSearchResponse( | ||
val isFirst: Boolean, | ||
val isLast: Boolean, | ||
val newsletters: List<SearchResponse>, | ||
val totalElements: Int, | ||
val totalPage: Int | ||
) |
Oops, something went wrong.