-
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.
[FEAT] #14-connect full job list api
- Loading branch information
Showing
5 changed files
with
98 additions
and
40 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
app/src/main/java/com/sopt/carrot/data/home/FullListDto.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,34 @@ | ||
package com.sopt.carrot.data.home | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
|
||
@Serializable | ||
data class ResponseFullListDto( | ||
@SerialName("status") | ||
val status: Integer, | ||
@SerialName("success") | ||
val success: Boolean, | ||
@SerialName("message") | ||
val message: String, | ||
@SerialName("status") | ||
val data: Detail | ||
) { | ||
@Serializable | ||
data class Detail( | ||
@SerialName("posts") | ||
val posts: List<Post> | ||
) { | ||
@Serializable | ||
data class Post( | ||
@SerialName("title") | ||
val title: String, | ||
@SerialName("image") | ||
val image: String, | ||
@SerialName("hourlyWage") | ||
val hourlyWage: Int | ||
) | ||
|
||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
app/src/main/java/com/sopt/carrot/data/home/FullListService.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,14 @@ | ||
package com.sopt.carrot.data.home | ||
|
||
import retrofit2.Call | ||
import retrofit2.http.GET | ||
import retrofit2.http.Header | ||
import retrofit2.http.Query | ||
|
||
interface FullListService { | ||
@GET("/posts/list") | ||
fun getFullJobList( | ||
@Header("Authorization") Authorization: Int, | ||
@Query("size") size: Long | ||
): Call<ResponseFullListDto> | ||
} |
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
43 changes: 23 additions & 20 deletions
43
app/src/main/java/com/sopt/carrot/presentation/home/FullJobViewModel.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,29 +1,32 @@ | ||
package com.sopt.carrot.presentation.home | ||
|
||
import androidx.lifecycle.LiveData | ||
import androidx.lifecycle.MutableLiveData | ||
import androidx.lifecycle.ViewModel | ||
import com.sopt.carrot.R | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.sopt.carrot.data.ApiPool | ||
import com.sopt.carrot.data.home.ResponseFullListDto | ||
import com.sopt.carrot.data.home.ResponseRecommendDto | ||
import com.sopt.carrot.util.enqueueUtil | ||
|
||
class FullJobViewModel : ViewModel() { | ||
val mockListLists = listOf( | ||
RecommendedJob( | ||
id = 1, | ||
image = R.drawable.img_test_1, | ||
title = "당근 마켓", | ||
salary = "시급 10,000원" | ||
), | ||
RecommendedJob( | ||
id = 2, | ||
image = R.drawable.img_test_2, | ||
title = "당근 알바", | ||
salary = "시급 20,000원" | ||
private val _fullJobResponse: MutableLiveData<ResponseFullListDto> = MutableLiveData() | ||
val fullJobResponse: LiveData<ResponseFullListDto> = _fullJobResponse | ||
|
||
), | ||
RecommendedJob( | ||
id = 3, | ||
image = R.drawable.img_test_1, | ||
title = "당근 마켓", | ||
salary = "시급 10,000원" | ||
fun getFullJob(size: Long, recyclerView: RecyclerView, message: (String) -> Unit) { | ||
ApiPool.fullListService.getFullJobList(1, size).enqueueUtil( | ||
onSuccess = { | ||
_fullJobResponse.value = it | ||
recyclerView.adapter = FullJobAdapter().apply { submitList(it.data.posts) } | ||
message.invoke(it.message) | ||
|
||
}, | ||
onError = { | ||
message.invoke("error:${it}") | ||
} | ||
) | ||
) | ||
|
||
|
||
} | ||
|
||
} |
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