Skip to content

Commit

Permalink
Merge branch 'develop' into feature/setting-keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
huiwoo-jo authored Feb 28, 2024
2 parents a4ae28c + 9d0a0a6 commit 954abff
Show file tree
Hide file tree
Showing 42 changed files with 487 additions and 1,093 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ android {
}
buildFeatures {
dataBinding true
viewBinding true
}
namespace 'com.dongyang.android.youdongknowme'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,12 @@ package com.dongyang.android.youdongknowme.data.remote.entity
import com.google.gson.annotations.SerializedName

data class Notice(
@SerializedName("num")
var num: Int,
@SerializedName("title")
var title: String,
@SerializedName("writer")
var writer: String,
val title: String,
@SerializedName("author")
val author: String,
@SerializedName("date")
var date: String,
)

data class NoticeDetail(
@SerializedName("num")
var num: Int,
@SerializedName("title")
var title: String,
@SerializedName("writer")
var writer: String,
@SerializedName("date")
var date: String,
@SerializedName("content")
var content: String,
@SerializedName("img_url")
var imgUrl : List<String>,
@SerializedName("file_url")
var fileUrl : List<NoticeFileUrl>
)

data class NoticeFileUrl(
val date: String,
@SerializedName("url")
var url: String,
@SerializedName("name")
var name: String
val url: String,
)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
package com.dongyang.android.youdongknowme.data.remote.service

import com.dongyang.android.youdongknowme.data.remote.entity.Notice
import com.dongyang.android.youdongknowme.data.remote.entity.NoticeDetail
import retrofit2.Response
import retrofit2.http.GET
import retrofit2.http.Path
import retrofit2.http.Query

interface NoticeService {
@GET("/notice/{code}")
suspend fun getList(
@Path("code") code : Int
) : List<Notice>

@GET("/notice/{code}/search")
suspend fun getSearchList(
@Path("code") code : Int,
@Query("keyword") keyword : String
) : List<Notice>
@GET("api/v1/dmu/universityNotice")
suspend fun getUniversityNotice(
@Query("page") page: Int,
@Query("size") size: Int
): List<Notice>

@GET("api/v1/dmu/departmentNotice/{department}")
suspend fun getDepartmentNotice(
@Path("department") department: String,
@Query("page") page: Int,
@Query("size") size: Int
): List<Notice>
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,54 +1,38 @@
package com.dongyang.android.youdongknowme.data.repository

import com.dongyang.android.youdongknowme.data.local.SharedPreference
import com.dongyang.android.youdongknowme.data.local.dao.AlarmDao
import com.dongyang.android.youdongknowme.data.remote.entity.Notice
import com.dongyang.android.youdongknowme.data.remote.service.NoticeService
import com.dongyang.android.youdongknowme.standard.network.ErrorResponseHandler
import com.dongyang.android.youdongknowme.standard.network.NetworkResult
import com.dongyang.android.youdongknowme.standard.network.RetrofitObject
import kotlinx.coroutines.flow.Flow
import retrofit2.Response

class NoticeRepository(
private val alarmDao: AlarmDao,
private val errorResponseHandler: ErrorResponseHandler
) {
suspend fun fetchAllNotices(): NetworkResult<Map<String,List<Notice>>> {
suspend fun fetchUniversityNotices(page: Int): NetworkResult<List<Notice>> {
return try {
val departNotices = RetrofitObject.getNetwork().create(NoticeService::class.java).getList(SharedPreference.getCode())
val schoolNotices = RetrofitObject.getNetwork().create(NoticeService::class.java).getList(CODE.SCHOOL_CODE)
val universityNotices = RetrofitObject.getNetwork().create(NoticeService::class.java)
.getUniversityNotice(page, DEFAULT_SIZE)

val result : Map<String,List<Notice>> = mapOf("school" to schoolNotices, "depart" to departNotices)

NetworkResult.Success(result)
NetworkResult.Success(universityNotices)
} catch (exception: Exception) {
val error = errorResponseHandler.getError(exception)
NetworkResult.Error(error)
}
}

suspend fun fetchNotices(code: Int): NetworkResult<List<Notice>> {
suspend fun fetchDepartmentNotices(department: String, page: Int): NetworkResult<List<Notice>> {
return try {
val response = RetrofitObject.getNetwork().create(NoticeService::class.java).getList(code)
NetworkResult.Success(response)
val departmentNotices = RetrofitObject.getNetwork().create(NoticeService::class.java)
.getDepartmentNotice(department, page, DEFAULT_SIZE)
NetworkResult.Success(departmentNotices)
} catch (exception: Exception) {
val error = errorResponseHandler.getError(exception)
NetworkResult.Error(error)
}
}

suspend fun fetchSearchNotices(code: Int, keyword: String): NetworkResult<List<Notice>> {
return try {
val response = RetrofitObject.getNetwork().create(NoticeService::class.java).getSearchList(code, keyword)
NetworkResult.Success(response)
} catch (exception: Exception) {
val error = errorResponseHandler.getError(exception)
NetworkResult.Error(error)
}
companion object {
private const val DEFAULT_SIZE = 20
}

fun getUnVisitedAlarmCount(): Flow<Int> = alarmDao.getUnVisitedAlarmCount()

fun getDepartmentCode(): Int = SharedPreference.getCode()
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import com.dongyang.android.youdongknowme.data.local.entity.KeywordEntity
import com.dongyang.android.youdongknowme.data.repository.AlarmRepository
import com.dongyang.android.youdongknowme.data.repository.CafeteriaRepository
import com.dongyang.android.youdongknowme.data.repository.DepartRepository
import com.dongyang.android.youdongknowme.data.repository.DetailRepository
import com.dongyang.android.youdongknowme.data.repository.KeywordRepository
import com.dongyang.android.youdongknowme.data.repository.NoticeRepository
import com.dongyang.android.youdongknowme.data.repository.ScheduleRepository
Expand All @@ -32,6 +31,7 @@ import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.launch
import org.koin.android.ext.koin.androidContext
import org.koin.androidx.viewmodel.dsl.viewModel
import org.koin.core.scope.get
import org.koin.dsl.module

val databaseModule = module {
Expand Down Expand Up @@ -76,7 +76,7 @@ val viewModelModule = module {
SettingViewModel(get())
}
viewModel {
DetailViewModel(get())
DetailViewModel()
}
viewModel {
SplashViewModel(get())
Expand All @@ -103,10 +103,7 @@ val viewModelModule = module {

val repositoryModule = module {
single {
NoticeRepository(get(), get())
}
single {
DetailRepository(get())
NoticeRepository(get())
}
single {
SplashRepository()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ object RetrofitObject {

fun getNetwork(): Retrofit {

val baseUrl = "http://3.38.118.184:8000"
val baseUrl = "https://triphub.kr/"

val baseInterceptor = Interceptor { chain ->
val request = chain.request().newBuilder()
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 954abff

Please sign in to comment.