-
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 recommended job api
- Loading branch information
Showing
9 changed files
with
111 additions
and
52 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
41 changes: 41 additions & 0 deletions
41
app/src/main/java/com/sopt/carrot/data/home/RecommendDto.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,41 @@ | ||
package com.sopt.carrot.data.home | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
|
||
@Serializable | ||
data class ResponseRecommendDto( | ||
@SerialName("status") | ||
val status: Integer, | ||
@SerialName("success") | ||
val success: Boolean, | ||
@SerialName("message") | ||
val message: String, | ||
@SerialName("data") | ||
val data: Detail | ||
) { | ||
@Serializable | ||
data class Detail( | ||
@SerialName("nickname") | ||
val nickname: String, | ||
@SerialName("posts") | ||
val posts: List<Post>, | ||
) { | ||
@Serializable | ||
data class Post( | ||
@SerialName("userId") | ||
val userId: Int, | ||
@SerialName("postId") | ||
val postId: Int, | ||
@SerialName("title") | ||
val title: String, | ||
@SerialName("image") | ||
val image: String, | ||
@SerialName("monthlyWage") | ||
val monthlyWage: Int, | ||
) | ||
|
||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
app/src/main/java/com/sopt/carrot/data/home/RecommendService.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 RecommendService { | ||
@GET("/posts/recommend") | ||
fun getRecommendJobList( | ||
@Header("Authorization") Authorization: Int, | ||
@Query("size") size: Long | ||
): Call<ResponseRecommendDto> | ||
} |
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
54 changes: 21 additions & 33 deletions
54
app/src/main/java/com/sopt/carrot/presentation/home/RecommendedViewModel.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,44 +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.ResponseRecommendDto | ||
import com.sopt.carrot.util.enqueueUtil | ||
|
||
class RecommendedViewModel : ViewModel() { | ||
val mockRecommendedJobLists = 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원" | ||
|
||
), | ||
RecommendedJob( | ||
id = 3, | ||
image = R.drawable.img_test_1, | ||
title = "당근 마켓", | ||
salary = "시급 10,000원" | ||
|
||
), | ||
RecommendedJob( | ||
id = 4, | ||
image = R.drawable.img_test_2, | ||
title = "당근 알바", | ||
salary = "시급 20,000원" | ||
|
||
private val _recommendedJobResponse: MutableLiveData<ResponseRecommendDto> = MutableLiveData() | ||
val recommendedJobResponse: LiveData<ResponseRecommendDto> = _recommendedJobResponse | ||
|
||
fun getRecommendedJob(size: Long, recyclerView: RecyclerView, message: (String) -> Unit) { | ||
ApiPool.recommendService.getRecommendJobList(1, size).enqueueUtil( | ||
onSuccess = { | ||
_recommendedJobResponse.value = it | ||
recyclerView.adapter = RecommendedJobAdapter().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