-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from APP-Android2/21-feature-펫시터-후기-작성-기능-구현
[#21] feature 펫시터 후기 작성 기능 구현
- Loading branch information
Showing
8 changed files
with
235 additions
and
18 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
22 changes: 22 additions & 0 deletions
22
MungNolZa/app/src/main/java/kr/co/lion/mungnolza/model/PetsitterReviewModel.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,22 @@ | ||
package kr.co.lion.mungnolza.model | ||
|
||
data class PetsitterReviewModel( | ||
// 후기글번호 → reviewIdx | ||
// 펫시터 번호 → petsitterIdx | ||
// 사용자(작성자) 번호 → reviewWriterIdx | ||
// 사용자 이름 → reviewWriterName | ||
// 작성날짜 → reviewWriteDate | ||
// 별점 → reviewStarCount | ||
// 후기내용 → reviewText | ||
|
||
var reviewIdx: Int, | ||
/*var petsitterIdx : Int, | ||
var reviewWriterIdx : Int, | ||
var reviewWriterName : String,*/ | ||
var reviewWriteDate : String, | ||
var reviewStarCount: Float?, | ||
var reviewText: String | ||
) | ||
|
||
|
||
|
65 changes: 65 additions & 0 deletions
65
MungNolZa/app/src/main/java/kr/co/lion/mungnolza/repository/PetsitterReviewRepository.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,65 @@ | ||
package kr.co.lion.mungnolza.repository | ||
|
||
import com.google.firebase.Firebase | ||
import com.google.firebase.firestore.firestore | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.launch | ||
import kotlinx.coroutines.tasks.await | ||
import kr.co.lion.mungnolza.model.PetsitterReviewModel | ||
|
||
class PetsitterReviewRepository { | ||
|
||
companion object{ | ||
// 후기글 번호 시퀀스값을 가져온다. | ||
suspend fun getReviewIdx() : Int{ | ||
|
||
var reviewIdxSequence = 0 | ||
|
||
val job1 = CoroutineScope(Dispatchers.IO).launch { | ||
// 컬렉션에 접근할 수 있는 객체를 가져온다 | ||
val collectionReference = Firebase.firestore.collection("petsitterReviewModel") | ||
// 후기글 번호 시퀀스값을 가지고 있는 문서에 접근할 수 있는 객체를 가져온다. | ||
val documentReference = collectionReference.document("reviewIdxSequence") | ||
// 문서내에 있는 데이터를 가져올 수 있는 객체를 가져온다. | ||
val documentSnapShot = documentReference.get().await() | ||
//reviewIdxSequence = documentSnapShot.getLong("petsitterIdx")?.toInt()!! | ||
reviewIdxSequence = documentSnapShot.getLong("reviewIdx")?.toInt() ?: 0 | ||
|
||
} | ||
job1.join() | ||
|
||
return reviewIdxSequence | ||
} | ||
|
||
// 후기글번호 시퀀스값을 업데이트 한다. | ||
suspend fun updateReviewIdx(reviewIdxSequence:Int){ | ||
val job1 = CoroutineScope(Dispatchers.IO).launch { | ||
// 컬렉션에 접근할 수 있는 객체를 가져온다. | ||
val collectionReference = Firebase.firestore.collection("petsitterReviewModel") | ||
// 후기글 번호 시퀀스값을 가지고 있는 문서에 접근할 수 있는 객체를 가져온다. | ||
val documentReference = collectionReference.document("reviewIdxSequence") | ||
// 저장할 데이터를 담을 HaskMap을 만들어준다. | ||
val map = mutableMapOf<String, Long>() | ||
map["reviewIdx"] = reviewIdxSequence.toLong() | ||
// 저장한다 | ||
documentReference.set(map) | ||
} | ||
job1.join() | ||
} | ||
|
||
// 펫시터후기 정보를 저장한다. | ||
suspend fun insertPetsitterReviewData(petsitterReviewModel: PetsitterReviewModel){ | ||
val job1 = CoroutineScope(Dispatchers.IO).launch { | ||
// 컬렉션에 접근할 수 있는 객체를 가져온다. | ||
val collectionReference = Firebase.firestore.collection("petsitterReviewModel") | ||
// 컬렉션에 문서를 추가한다. | ||
// 문서를 추가할 때 객체나 맵을 지정한다. | ||
// 추가된 문서 내부의 필드는 객체가 가진 프로퍼티의 이름이나 맵에 있는 데이터의 이름과 동일하게 결정된다. | ||
collectionReference.add(petsitterReviewModel) | ||
} | ||
job1.join() | ||
} | ||
} | ||
|
||
} |
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
13 changes: 13 additions & 0 deletions
13
.../java/kr/co/lion/mungnolza/ui/reservation_list/viewmodel/PetSitterReviewWriteViewModel.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,13 @@ | ||
package kr.co.lion.mungnolza.ui.reservation_list.viewmodel | ||
|
||
import androidx.lifecycle.MutableLiveData | ||
import androidx.lifecycle.ViewModel | ||
|
||
// 펫시터 후기 작성 | ||
|
||
class PetSitterReviewWriteViewModel : ViewModel() { | ||
// 별점 → starCount | ||
val ratingBar2 = MutableLiveData<Float>() | ||
// 후기내용 → ReviewText | ||
val textfieldPetsitterReviewWrite = MutableLiveData<String>() | ||
} |
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