Skip to content

Commit

Permalink
feat: 공고 저장 api 연결
Browse files Browse the repository at this point in the history
  • Loading branch information
kang9366 committed Nov 23, 2023
1 parent 964246f commit c01e4f9
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.kusitms.connectdog.feature.home

import android.util.Log
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
Expand All @@ -10,6 +11,8 @@ import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import javax.inject.Inject

private const val TAG = "DetailViewModel"

@HiltViewModel
class DetailViewModel @Inject constructor(
private val detailRepository: DetailRepository
Expand All @@ -23,4 +26,26 @@ class DetailViewModel @Inject constructor(
_detail.postValue(response)
}
}

fun postBookmark(postId: Long) {
viewModelScope.launch {
try {
val response = detailRepository.postBookmark(postId)
Log.d(TAG, response.toString())
} catch (e: Exception) {
Log.d(TAG, e.message.toString())
}
}
}

fun deleteBookmark(postId: Long) {
viewModelScope.launch {
try {
val response = detailRepository.deleteBookmark(postId)
Log.d(TAG, response.toString())
} catch (e: Exception) {
Log.d(TAG, e.message.toString())
}
}
}
}

0 comments on commit c01e4f9

Please sign in to comment.