Skip to content
This repository has been archived by the owner on Apr 27, 2023. It is now read-only.

Commit

Permalink
Feature/inflate ranking (#62)
Browse files Browse the repository at this point in the history
* feat: Ranking Response data class 작성

feature/inflate-ranking

* feat: Ranking 서비스 인터페이스 작성

feature/inflate-ranking

* feat: Rank Data 모듈 모델 작성

feature/inflate-ranking

* feat: Rank Domain 모듈 작성

feature/inflate-ranking

* feat: 모듈의 모델간 데이터 Mapping 함수 작성

feature/inflate-ranking

* feat: 랭킹 Ui 모델 변경

서버 통신으로 받는 값 추가

feature/inflate-ranking

* feat: 랭킹 DataSource 작성

feature/inflate-ranking

* feat: 랭킹 Repository 작성

feature/inflate-ranking

* feat: 미션 Repository 접근자 수정

feature/inflate-ranking

* feat: RankDataSource Injection 추가

feature/inflate-ranking

* feat: RankRepository Injection 추가

feature/inflate-ranking

* feat: Ranking Service 주입 모듈 추가

* feat: StampFloating Button 에 없던 클릭 리스너 추가

* feat: 랭킹 기능 완성

* feat: MissionScreen 변경사항 적용

* feat: 미사용 datasource 코드 삭제

feature/inflate-ranking

* feat: 미사용 datasource 변경으로 인한 레포지터리 코드 변경

전체 조회에서 필터를 거는 방식으로 변경

feature/inflate-ranking

* feat: 자신의 랭킹 표시 추가

feature/inflate-ranking

* feat: 미션 수정 및 destination 시도끝에 실패;;

feature/inflate-ranking

* feat: 줄바꿈 이상한거 변경

feature/inflate-ranking

* feat: 완료 미션 로티 기본 인자 수정

feature/inflate-ranking

* feat: 미션 레벨 표시 이상하던 것 수정

feature/inflate-ranking

* feat: 이전에 Destination 안되서 주석처리 한거 해제

feature/inflate-ranking

* feat: 미션컴포넌트 수정

미션 컴포넌트 자체 크기가 이상한 것 수정
미션 텍스트 줄바꿈 안되는 부분 수정

feature/inflate-ranking

* feat: 졸려 죽것다 나눠서 커밋이고 나발이고 미안하다...

feature/inflate-ranking

* feat: 이상한거 적어둔거 컷

feature/inflate-ranking

* style: 린트 수정

* style: 린트 수정
  • Loading branch information
jinsu4755 authored Jan 29, 2023
1 parent 66fdc6f commit 343a5fa
Show file tree
Hide file tree
Showing 109 changed files with 1,141 additions and 326 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ class ExampleInstrumentedTest {
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("org.sopt.stamp", appContext.packageName)
}
}
}
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET" />

<application
android:name=".App"
android:allowBackup="true"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/org/sopt/stamp/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ class App : Application() {
companion object {
val networkFlipperPlugin = NetworkFlipperPlugin()
}
}
}
2 changes: 1 addition & 1 deletion app/src/main/java/org/sopt/stamp/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ class MainActivity : ComponentActivity() {
DestinationsNavHost(navGraph = NavGraphs.root)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ class MavericksInitializer : Initializer<Unit> {
override fun dependencies(): MutableList<Class<out Initializer<*>>> {
return mutableListOf()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class TimberInitializer : Initializer<Unit> {
}

private class SOPTDebugTree : Timber.DebugTree() {
override fun createStackElementTag(element: StackTraceElement): String? {
override fun createStackElementTag(element: StackTraceElement): String {
return "SOPT://${element.fileName}:${element.lineNumber}#${element.methodName}"
}
}
Expand All @@ -27,6 +27,7 @@ class TimberInitializer : Initializer<Unit> {
}
FirebaseCrashlytics.getInstance().recordException(newThrowable)
}

else -> FirebaseCrashlytics.getInstance().log("$tag | $message")
}
}
Expand All @@ -35,4 +36,4 @@ class TimberInitializer : Initializer<Unit> {
override fun dependencies(): MutableList<Class<out Initializer<*>>> {
return mutableListOf()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ annotation class LoginNavGraph(
@NavGraph
annotation class SignUpNavGraph(
val start: Boolean = false
)
)
2 changes: 1 addition & 1 deletion app/src/main/java/org/sopt/stamp/data/error/ErrorData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ sealed class ErrorData(
override val cause: Throwable? = null
) : Exception(message, cause) {
object NetworkUnavailable : ErrorData()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ import kotlinx.coroutines.flow.map
import java.io.IOException
import javax.inject.Inject

private val Context.dataStore by preferencesDataStore(name = "pref")

class SoptampDataStore @Inject constructor(
@ApplicationContext private val context: Context
) {
private val Context.dataStore by preferencesDataStore(name = "pref")

/** USER_ID */
private val USER_ID = intPreferencesKey("user_id")
Expand Down Expand Up @@ -57,4 +58,4 @@ class SoptampDataStore @Inject constructor(
pref[PROFILE_MESSAGE] = profileMessage
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ import org.sopt.stamp.domain.error.Error

internal fun ErrorData.toDomain(): Error = when (this) {
ErrorData.NetworkUnavailable -> Error.NetworkUnavailable
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ internal fun MissionData.toDomain(): Mission = Mission(
level = this.level,
profileImage = this.profileImage,
isCompleted = this.isCompleted
)
)
16 changes: 16 additions & 0 deletions app/src/main/java/org/sopt/stamp/data/mapper/RankMapper.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.sopt.stamp.data.mapper // ktlint-disable filename

import org.sopt.stamp.data.remote.model.RankData
import org.sopt.stamp.domain.model.Rank

internal fun List<RankData>.toDomain(): List<Rank> = this.map {
it.toDomain()
}

internal fun RankData.toDomain(): Rank = Rank(
rank,
userId,
nickname,
point,
profileMessage
)
13 changes: 13 additions & 0 deletions app/src/main/java/org/sopt/stamp/data/remote/api/RankService.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.sopt.stamp.data.remote.api

import org.sopt.stamp.data.remote.model.response.RankResponse
import retrofit2.http.GET

internal interface RankService {

@GET("rank")
suspend fun getRanking(): List<RankResponse>

@GET("rank/detail")
suspend fun getRankDetail(): List<RankResponse>
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ internal interface SoptampService {

@GET("mission/incomplete")
suspend fun getIncompleteMissions(@Header("userId") userId: Int): List<MissionResponse>
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ interface StampService {
suspend fun modifyStamp(
@Path("missionId") missionId: Int,
@Part stampContent: RequestBody,
@Part imageUrl: List<MultipartBody.Part>? = null,
@Part imageUrl: List<MultipartBody.Part>? = null
): ModifyStampResponse

@Multipart
@POST("stamp/{missionId}")
suspend fun registerStamp(
@Path("missionId") missionId: Int,
@Part stampContent: RequestBody,
@Part imageUrl: List<MultipartBody.Part>? = null,
@Part imageUrl: List<MultipartBody.Part>? = null
): StampResponse
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ interface UserService {
// 비밀번호 변경
// 닉네임 변경
// 탈퇴하기
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ internal fun MissionResponse.toData(): MissionData = MissionData(
)

internal fun List<MissionResponse>.toData(): List<MissionData> =
this.map { it.toData() }
this.map { it.toData() }
16 changes: 16 additions & 0 deletions app/src/main/java/org/sopt/stamp/data/remote/mapper/RankMapper.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.sopt.stamp.data.remote.mapper // ktlint-disable filename

import org.sopt.stamp.data.remote.model.RankData
import org.sopt.stamp.data.remote.model.response.RankResponse

internal fun List<RankResponse>.toData(): List<RankData> = this.map {
it.toData()
}

internal fun RankResponse.toData(): RankData = RankData(
rank,
userId,
nickname,
point,
profileMessage
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ data class MissionData(
val level: Int,
val profileImage: List<String>?,
val isCompleted: Boolean
)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.sopt.stamp.data.remote.model

data class RankData(
val rank: Int,
val userId: Int,
val nickname: String,
val point: Int,
val profileMessage: String?
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ import kotlinx.serialization.Serializable
data class LoginRequest(
val email: String,
val password: String
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ import kotlinx.serialization.Serializable
data class SignUpRequest(
val nickname: String,
val email: String,
val password: String,
)
val password: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ data class MissionResponse(
val level: Int,
val profileImage: List<String>?,
val isCompleted: Boolean
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import kotlinx.serialization.Serializable

@Serializable
data class ModifyStampResponse(
val stampId: Int,
)
val stampId: Int
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.sopt.stamp.data.remote.model.response

@kotlinx.serialization.Serializable
data class RankResponse(
val rank: Int,
val userId: Int,
val nickname: String,
val point: Int,
val profileMessage: String?
)
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ data class StampResponse(
val contents: String,
val images: List<String>? = null,
val userId: Int,
val missionId: Int,
val missionId: Int
) {
fun toDomain() = Archive(
createdAt = createdAt,
Expand All @@ -20,6 +20,6 @@ data class StampResponse(
contents = contents,
images = images ?: emptyList(),
userId = userId,
missionId = missionId,
missionId = missionId
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ data class UserResponse(
val profileMessage: String? = ""
) {
fun toUser() = User(userId, message, statusCode, profileMessage)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,4 @@ internal class RemoteMissionsDataSource @Inject constructor(
else -> Result.failure(exception)
}
}

override suspend fun getCompleteMission(userId: Int): Result<List<MissionData>> {
val result = kotlin.runCatching { soptampService.getCompleteMissions(userId).toData() }
return when (val exception = result.exceptionOrNull()) {
null -> result
is UnknownHostException -> return Result.failure(ErrorData.NetworkUnavailable)
else -> Result.failure(exception)
}
}

override suspend fun getIncompleteMissions(userId: Int): Result<List<MissionData>> {
val result = kotlin.runCatching { soptampService.getIncompleteMissions(userId).toData() }
return when (val exception = result.exceptionOrNull()) {
null -> result
is UnknownHostException -> return Result.failure(ErrorData.NetworkUnavailable)
else -> Result.failure(exception)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.sopt.stamp.data.remote.source

import org.sopt.stamp.data.error.ErrorData
import org.sopt.stamp.data.remote.api.RankService
import org.sopt.stamp.data.remote.mapper.toData
import org.sopt.stamp.data.remote.model.RankData
import org.sopt.stamp.data.source.RankingDataSource
import java.net.UnknownHostException
import javax.inject.Inject

internal class RemoteRankingDataSource @Inject constructor(
private val rankService: RankService
) : RankingDataSource {
override suspend fun getRanking(): Result<List<RankData>> {
val result = kotlin.runCatching {
rankService.getRanking().toData()
}
return when (val exception = result.exceptionOrNull()) {
null -> result
is UnknownHostException -> Result.failure(ErrorData.NetworkUnavailable)
else -> Result.failure(exception)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ class RemoteUserDataSource @Inject constructor(
): UserResponse {
val response = userService.signup(
SignUpRequest(
nickname, email, password
nickname,
email,
password
)
)
return UserResponse(
Expand Down Expand Up @@ -57,4 +59,4 @@ class RemoteUserDataSource @Inject constructor(
response.code()
)
}
}
}
Loading

0 comments on commit 343a5fa

Please sign in to comment.