Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/mz 193 received envelope add #99

Merged
merged 32 commits into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
f4f3f3b
feat: ReceivedEnvelopeAddContract.kt, ReceivedEnvelopeAddViewModel
jinukeu Jan 21, 2024
9290564
Merge branch 'develop' into feature/MZ-193-received-envelope-add
jinukeu Jan 21, 2024
6aace07
feat: ReceivedEnvelopeAdd Contract, ViewModel μΆ”κ°€
jinukeu Jan 21, 2024
088cd76
feat: λ³΄λ‚΄μš” 리슀트 μ„œλ²„ 톡신 μ„ΈνŒ…
syb8200 Jan 20, 2024
1b4b0bb
feat: RelationShip Api 연동
jinukeu Jan 21, 2024
57067ac
feat: 받은 λ΄‰νˆ¬ 생성 - κΈˆμ•‘ μž…λ ₯ κΈ°λŠ₯ κ΅¬ν˜„
jinukeu Jan 22, 2024
6a06549
feat: 받은 λ΄‰νˆ¬ 생성 - 이름 μž…λ ₯ κΈ°λŠ₯ κ΅¬ν˜„
jinukeu Jan 22, 2024
58ac133
feat: 받은 λ΄‰νˆ¬ 생성 - 관계 선택 κΈ°λŠ₯ κ΅¬ν˜„
jinukeu Jan 22, 2024
0ad6b71
feat: 받은 λ΄‰νˆ¬ 생성 - 더 기둝할 λ‚΄μš© κΈ°λŠ₯ κ΅¬ν˜„
jinukeu Jan 22, 2024
419856d
feat: 받은 λ΄‰νˆ¬ 생성 - λ°©λ¬Έ μ—¬λΆ€ κΈ°λŠ₯ κ΅¬ν˜„
jinukeu Jan 22, 2024
c13905d
feat: 받은 λ΄‰νˆ¬ 생성 - μ„ λ¬Ό, μ—°λ½μ²˜, λ©”λͺ¨ κΈ°λŠ₯ κ΅¬ν˜„
jinukeu Jan 22, 2024
553fbf0
Merge branch 'develop' into feature/MZ-193-received-envelope-add
jinukeu Jan 23, 2024
8727b53
fix: μž₯λΆ€ 생성, μ‚­μ œ μ‹œ μž₯λΆ€ μ—†μŒ 화면이 μ œλŒ€λ‘œ ν‘œκΈ°λ˜μ§€ μ•Šλ˜ 문제 ν•΄κ²°
jinukeu Jan 23, 2024
87f3cb4
feat: Category style μΆ”κ°€
jinukeu Jan 23, 2024
925970c
feat: Friend Service μΆ”κ°€
jinukeu Jan 23, 2024
bceb087
fix: ν•„ν„° 쑰건 λ³€κ²½
jinukeu Jan 24, 2024
bcddb8b
feat: CreateFriendUseCase, SearchFriendUseCase μΆ”κ°€
jinukeu Jan 24, 2024
e5cf031
feat: CreateReceivedEnvelopeUseCase μΆ”κ°€
jinukeu Jan 24, 2024
f1a94f6
remove: CreateFriendUseCase.kt
jinukeu Jan 24, 2024
5379a8a
feat: μž₯λΆ€ μΆ”κ°€ νŒŒλΌλ―Έν„° LedgerId μΆ”κ°€
jinukeu Jan 24, 2024
f14b05f
feat: λ΄‰νˆ¬ μΆ”κ°€ - 친ꡬ 검색 κΈ°λŠ₯ κ΅¬ν˜„
jinukeu Jan 24, 2024
8563daf
feat: λ΄‰νˆ¬ μΆ”κ°€ - 친ꡬ 검색 κΈ°λŠ₯ κ΅¬ν˜„
jinukeu Jan 24, 2024
c850805
Merge remote-tracking branch 'origin/feature/MZ-193-received-envelope…
jinukeu Jan 24, 2024
6999694
chore: 쀑볡 μ½”λ“œ 제거
jinukeu Jan 24, 2024
4c31d76
feat: 받은 λ΄‰νˆ¬ μΆ”κ°€ μ‹œ, λ‚ μ§œ μž…λ ₯ ν™”λ©΄ κ΅¬ν˜„
jinukeu Jan 26, 2024
9d97efd
feat: 받은 λ΄‰νˆ¬ 생성 κΈ°λŠ₯ κ΅¬ν˜„
jinukeu Jan 26, 2024
4c9f436
chore: ktlint, detekt
jinukeu Jan 26, 2024
d88f1b3
Merge branch 'develop' into feature/MZ-193-received-envelope-add
jinukeu Jan 26, 2024
5b26f32
fix: resolve conflict
jinukeu Jan 26, 2024
d4d3494
chore: ktlint
jinukeu Jan 26, 2024
7649669
feat: λ΄‰νˆ¬ 응닡 κ°’ μˆ˜μ •
jinukeu Jan 26, 2024
b343c74
feat: μž₯λΆ€ μΆ”κ°€, λ΄‰νˆ¬ μΆ”κ°€ μ‹œ λ°”ν…€μ‹œνŠΈ dismiss μ‹œμ—λ„ μ§€μ •λœ λ‚ μ§œκ°€ μ„ νƒλ˜λ„λ‘ μˆ˜μ •
jinukeu Jan 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.susu.core.designsystem.component.badge

import android.util.Log
import androidx.compose.ui.graphics.Color
import com.susu.core.designsystem.theme.Gray10
import com.susu.core.designsystem.theme.Gray70
import java.lang.IllegalArgumentException

enum class BadgeColor(
val backgroundColor: Color,
Expand Down Expand Up @@ -36,4 +38,14 @@ enum class BadgeColor(
backgroundColor = com.susu.core.designsystem.theme.Red60,
textColor = Gray10,
),
;

companion object {
fun safeValueOf(value: String) = try {
valueOf(value)
} catch (e: IllegalArgumentException) {
Log.e("SafeValueOfError", "Invalid value provided", e)
Gray40
}
}
}
1 change: 1 addition & 0 deletions core/model/src/main/java/com/susu/core/model/Category.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ data class Category(
val seq: Int = 0,
val name: String = "",
val customCategory: String? = null,
val style: String = "",
)
15 changes: 15 additions & 0 deletions core/model/src/main/java/com/susu/core/model/Envelope.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.susu.core.model

import java.time.LocalDateTime

data class Envelope(
val id: Long,
val uid: Long,
val type: String,
val friend: Friend,
val amount: Long,
val gift: String? = null,
val memo: String? = null,
val hasVisited: Boolean? = null,
val handedOverAt: LocalDateTime? = null,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.susu.core.model

data class EnvelopeStatics(
val friend: Friend = Friend(),
val receivedAmounts: Int = 0,
val sentAmounts: Int = 0,
val totalAmounts: Int = 0,
)
10 changes: 10 additions & 0 deletions core/model/src/main/java/com/susu/core/model/Friend.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.susu.core.model

data class Friend(
val id: Long = 0,
val uid: Long = 0,
val name: String = "",
val phoneNumber: String = "",
val createdAt: String = "",
val modifiedAt: String = "",
)
14 changes: 14 additions & 0 deletions core/model/src/main/java/com/susu/core/model/FriendSearch.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.susu.core.model

import java.time.LocalDateTime

data class FriendSearch(
val friend: Friend,
val relationship: Relationship,
val recentEnvelope: RecentEnvelope? = null,
)

data class RecentEnvelope(
val category: String,
val handedOverAt: LocalDateTime,
)
2 changes: 1 addition & 1 deletion core/model/src/main/java/com/susu/core/model/Ledger.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import kotlinx.serialization.Serializable
@Stable
@Serializable
data class Ledger(
val id: Int = -1,
val id: Long = -1,
val title: String = "",
val description: String = "",
val startAt: LocalDateTime = java.time.LocalDateTime.now().toKotlinLocalDateTime(),
Expand Down
10 changes: 10 additions & 0 deletions core/model/src/main/java/com/susu/core/model/Relationship.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.susu.core.model

import androidx.compose.runtime.Stable

@Stable
data class Relationship(
val id: Int = -1,
val relation: String = "",
val customRelation: String? = null,
)
1 change: 1 addition & 0 deletions core/ui/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ android {

dependencies {
implementation(libs.kotlinx.serialization.json)
implementation(libs.kotlinx.immutable)
}
4 changes: 4 additions & 0 deletions core/ui/src/main/java/com/susu/core/ui/Consts.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import androidx.annotation.StringRes
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import kotlinx.collections.immutable.persistentListOf

// TODO REMOVE
val alignList
@Composable
get() = listOf(
Expand All @@ -15,6 +17,8 @@ val alignList
stringResource(id = R.string.word_align_low_amount),
)

val moneyList = persistentListOf(10_000, 30_000, 50_000, 100_000, 500_000)

const val USER_NAME_MAX_LENGTH = 10
val nameRegex = Regex("[a-zA-Zκ°€-힣]{0,10}")

Expand Down
14 changes: 14 additions & 0 deletions data/src/main/java/com/susu/data/data/di/RepositoryModule.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.susu.data.data.di

import com.susu.data.data.repository.CategoryConfigRepositoryImpl
import com.susu.data.data.repository.EnvelopesRepositoryImpl
import com.susu.data.data.repository.ExcelRepositoryImpl
import com.susu.data.data.repository.FriendRepositoryImpl
import com.susu.data.data.repository.LedgerRecentSearchRepositoryImpl
import com.susu.data.data.repository.LedgerRepositoryImpl
import com.susu.data.data.repository.LoginRepositoryImpl
Expand All @@ -12,7 +14,9 @@ import com.susu.data.data.repository.TokenRepositoryImpl
import com.susu.data.data.repository.UserRepositoryImpl
import com.susu.data.data.repository.VoteRepositoryImpl
import com.susu.domain.repository.CategoryConfigRepository
import com.susu.domain.repository.EnvelopesRepository
import com.susu.domain.repository.ExcelRepository
import com.susu.domain.repository.FriendRepository
import com.susu.domain.repository.LedgerRecentSearchRepository
import com.susu.domain.repository.LedgerRepository
import com.susu.domain.repository.LoginRepository
Expand Down Expand Up @@ -76,6 +80,16 @@ abstract class RepositoryModule {
excelRepositoryImpl: ExcelRepositoryImpl,
): ExcelRepository

@Binds
abstract fun bindEnvelopesRepository(
envelopesRepositoryImpl: EnvelopesRepositoryImpl,
): EnvelopesRepository

@Binds
abstract fun bindFriendRepository(
friendRepositoryImpl: FriendRepositoryImpl,
): FriendRepository

@Binds
abstract fun bindStatisticsRepository(
statisticsRepositoryImpl: StatisticsRepositoryImpl,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package com.susu.data.data.repository

import com.susu.core.model.Envelope
import com.susu.core.model.EnvelopeStatics
import com.susu.core.model.Relationship
import com.susu.data.remote.api.EnvelopesService
import com.susu.data.remote.model.request.CategoryRequest
import com.susu.data.remote.model.request.EnvelopeRequest
import com.susu.data.remote.model.response.toModel
import com.susu.domain.repository.EnvelopesRepository
import javax.inject.Inject

class EnvelopesRepositoryImpl @Inject constructor(
private val envelopesService: EnvelopesService,
) : EnvelopesRepository {
override suspend fun getEnvelopesList(
friendIds: List<Int>?,
fromTotalAmounts: Int?,
toTotalAmounts: Int?,
page: Int?,
size: Int?,
sort: String?,
): List<EnvelopeStatics> = envelopesService.getEnvelopesList(
friendIds = friendIds,
fromTotalAmounts = fromTotalAmounts,
toTotalMounts = toTotalAmounts,
page = page,
size = size,
sort = sort,
).getOrThrow().toModel()

override suspend fun getRelationShipConfigList(): List<Relationship> = envelopesService
.getRelationShipConfigList()
.getOrThrow()
.toModel()

override suspend fun createEnvelope(
type: String,
friendId: Long,
ledgerId: Long?,
amount: Long,
gift: String?,
memo: String?,
hasVisited: Boolean?,
handedOverAt: kotlinx.datetime.LocalDateTime,
categoryId: Long?,
customCategory: String?,
): Envelope = envelopesService.createEnvelope(
envelopeRequest = EnvelopeRequest(
type = type,
friendId = friendId,
ledgerId = ledgerId,
amount = amount,
gift = gift,
memo = memo,
hasVisited = hasVisited,
handedOverAt = handedOverAt,
category = if (categoryId != null) {
CategoryRequest(
id = categoryId,
customCategory = customCategory,
)
} else {
null
},
),
).getOrThrow().toModel()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.susu.data.data.repository

import com.susu.core.model.FriendSearch
import com.susu.data.remote.api.FriendService
import com.susu.data.remote.model.request.FriendRequest
import com.susu.data.remote.model.response.toModel
import com.susu.domain.repository.FriendRepository
import javax.inject.Inject

class FriendRepositoryImpl @Inject constructor(
private val friendService: FriendService,
) : FriendRepository {
override suspend fun createFriend(
name: String,
phoneNumber: String?,
relationshipId: Int,
customRelation: String?,
): Long = friendService.createFriend(
FriendRequest(
name = name,
phoneNumber = phoneNumber,
relationshipId = relationshipId,
customRelation = customRelation,
),
).getOrThrow().id

override suspend fun searchFriend(name: String): List<FriendSearch> = friendService.searchFriend(
name = name,
).getOrThrow().data.map { it.toModel() }
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class LedgerRepositoryImpl @Inject constructor(
ledgerRequest = ledger.toData(),
).getOrThrow().toModel()

override suspend fun deleteLedger(id: Int) = ledgerService.deleteLedgerList(
override suspend fun deleteLedger(id: Long) = ledgerService.deleteLedgerList(
listOf(id),
).getOrThrow()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,19 @@ data class CategoryConfigEntity(
val id: Int,
val seq: Int,
val name: String,
val style: String,
)

internal fun CategoryConfigEntity.toModel() = Category(
id = id,
seq = seq,
name = name,
style = style,
)

internal fun Category.toEntity() = CategoryConfigEntity(
id = id,
seq = seq,
name = name,
style = style,
)
31 changes: 31 additions & 0 deletions data/src/main/java/com/susu/data/remote/api/EnvelopesService.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.susu.data.remote.api

import com.susu.data.remote.model.request.EnvelopeRequest
import com.susu.data.remote.model.response.EnvelopeResponse
import com.susu.data.remote.model.response.EnvelopesListResponse
import com.susu.data.remote.model.response.RelationShipListResponse
import com.susu.data.remote.retrofit.ApiResult
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Query

interface EnvelopesService {
@GET("envelopes/friend-statistics")
suspend fun getEnvelopesList(
@Query("friendIds") friendIds: List<Int>?,
@Query("fromTotalAmounts") fromTotalAmounts: Int?,
@Query("toTotalAmounts") toTotalMounts: Int?,
@Query("page") page: Int?,
@Query("size") size: Int?,
@Query("sort") sort: String?,
): ApiResult<EnvelopesListResponse>

@GET("envelopes/configs/create-envelopes")
suspend fun getRelationShipConfigList(): ApiResult<RelationShipListResponse>

@POST("envelopes")
suspend fun createEnvelope(
@Body envelopeRequest: EnvelopeRequest,
): ApiResult<EnvelopeResponse>
}
23 changes: 23 additions & 0 deletions data/src/main/java/com/susu/data/remote/api/FriendService.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.susu.data.remote.api

import com.susu.data.remote.model.request.FriendRequest
import com.susu.data.remote.model.response.FriendResponse
import com.susu.data.remote.model.response.FriendSearchListResponse
import com.susu.data.remote.retrofit.ApiResult
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Query

interface FriendService {

@POST("friends")
suspend fun createFriend(
@Body friendRequest: FriendRequest,
): ApiResult<FriendResponse>

@GET("friends")
suspend fun searchFriend(
@Query("name") name: String,
): ApiResult<FriendSearchListResponse>
}
4 changes: 2 additions & 2 deletions data/src/main/java/com/susu/data/remote/api/LedgerService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ interface LedgerService {

@PATCH("ledgers/{id}")
suspend fun editLedger(
@Path("id") id: Int,
@Path("id") id: Long,
@Body ledgerRequest: LedgerRequest,
): ApiResult<LedgerResponse>

Expand All @@ -37,7 +37,7 @@ interface LedgerService {
): ApiResult<LedgerResponse>

@DELETE("ledgers")
suspend fun deleteLedgerList(@Query("ids") idList: List<Int>): ApiResult<Unit>
suspend fun deleteLedgerList(@Query("ids") idList: List<Long>): ApiResult<Unit>

@GET("ledgers/configs/create-ledger")
suspend fun getCreateLedgerConfig(): ApiResult<CreateLedgerConfigResponse>
Expand Down
Loading
Loading