Skip to content

Commit

Permalink
Merge pull request #47 from ttoklip/feat/#1_home_news_fragment
Browse files Browse the repository at this point in the history
Feat/#1 home news fragment
  • Loading branch information
kyujin0911 authored Feb 17, 2024
2 parents d28c1a5 + 53147ce commit 657b17f
Show file tree
Hide file tree
Showing 83 changed files with 2,353 additions and 691 deletions.
4 changes: 4 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ dependencies {
implementation "com.kakao.sdk:v2-user:2.19.0"
//naver login
implementation 'com.navercorp.nid:oauth:5.1.1'

implementation "androidx.room:room-runtime:2.6.1"
kapt "androidx.room:room-compiler:2.6.1"
implementation "androidx.room:room-ktx:2.6.1"
}
kapt {
correctErrorTypes true
Expand Down
16 changes: 10 additions & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
android:exported="false" />
<activity
android:name=".presentation.news.detail.ArticleActivity"
android:windowSoftInputMode="adjustResize"
android:screenOrientation="portrait"
android:exported="false" />
<activity
Expand Down Expand Up @@ -154,21 +155,19 @@
android:name=".presentation.intro.SplashActivity"
android:screenOrientation="portrait"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:screenOrientation="portrait"
android:name=".presentation.MainActivity"
android:exported="true">
<!--<intent-filter>

<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>-->
</intent-filter>
</activity>


<service
android:name="com.google.android.gms.metadata.ModuleDependencies"
android:enabled="false"
Expand All @@ -187,6 +186,11 @@
android:screenOrientation="portrait"
android:exported="false" />
<activity android:name="com.umc.ttoklip.presentation.honeytip.ImageViewActivity" />

<activity android:name=".presentation.news.detail.PostImageActivity"
android:screenOrientation="portrait"
android:exported="false"/>

<activity android:name=".presentation.honeytip.read.ReadQuestionActivity" />

</application>
Expand Down
60 changes: 59 additions & 1 deletion app/src/main/java/com/umc/ttoklip/data/api/NewsApi.kt
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>>

}
33 changes: 33 additions & 0 deletions app/src/main/java/com/umc/ttoklip/data/api/SearchApi.kt
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>>

}
42 changes: 42 additions & 0 deletions app/src/main/java/com/umc/ttoklip/data/db/DBUtile.kt
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 {

}
}
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
)

This file was deleted.

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>
)

This file was deleted.

This file was deleted.

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>
)
10 changes: 10 additions & 0 deletions app/src/main/java/com/umc/ttoklip/data/model/news/News.kt
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,"","")
}
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
)

This file was deleted.

This file was deleted.

This file was deleted.

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
)
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
)
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
)
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)
}
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
)
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
)
Loading

0 comments on commit 657b17f

Please sign in to comment.