Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Expand Up @@ -82,3 +82,13 @@ fun searchLocations(query: String, list: List<LocationRow>, limit: Int = 20): Li
.take(limit)
}

fun List<LocationRow>.toCodeMap(): Map<String, LocationRow> =
associateBy { it.code }

fun mapRegionCodesToFullNames(
regionCodes: List<String>,
locations: List<LocationRow>
): List<String> {
val map = locations.toCodeMap()
return regionCodes.mapNotNull { code -> map[code]?.fullName }
}
Comment on lines +85 to +94
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, let's find and read the Location.kt file to understand the full context
find . -type f -name "Location.kt" | head -5

Repository: SPOTeam/Android-V2

Length of output: 134


🏁 Script executed:

# Search for usages of mapRegionCodesToFullNames to understand how it's used
rg "mapRegionCodesToFullNames" --type kotlin -B 3 -A 3

Repository: SPOTeam/Android-V2

Length of output: 1662


🏁 Script executed:

# Search for LocationRow definition to understand its structure
rg "class LocationRow|data class LocationRow" --type kotlin -B 2 -A 5

Repository: SPOTeam/Android-V2

Length of output: 794


🏁 Script executed:

# Look for any tests related to this function
rg "mapRegionCodesToFullNames|toCodeMap" --type kotlin -B 2 -A 5

Repository: SPOTeam/Android-V2

Length of output: 2273


🏁 Script executed:

# Read the full Location.kt file to see the complete LocationRow definition and any extensions
cat -n ./core/common/src/main/java/com/umcspot/spot/common/location/Location.kt

Repository: SPOTeam/Android-V2

Length of output: 3564


🏁 Script executed:

# Search for fullName in the codebase to understand where it comes from
rg "fullName" --type kotlin -B 2 -A 2

Repository: SPOTeam/Android-V2

Length of output: 4301


🏁 Script executed:

# Find usages of mapRegionCodesToFullNames in detail
rg "mapRegionCodesToFullNames" --type kotlin -B 5 -A 10

Repository: SPOTeam/Android-V2

Length of output: 3296


🏁 Script executed:

# Check UserRepositoryImpl for the specific usage context
cat -n ./data/user/src/main/java/com/umcspot/spot/user/repositoryimpl/UserRepositoryImpl.kt | grep -A 20 "mapRegionCodesToFullNames"

Repository: SPOTeam/Android-V2

Length of output: 1199


🏁 Script executed:

# Search for actual usage of mapRegionCodesToFullNames function call
rg "mapRegionCodesToFullNames\s*\(" --type kotlin -B 10 -A 5

Repository: SPOTeam/Android-V2

Length of output: 1645


🏁 Script executed:

# Let's check if mapRegionCodesToFullNames is actually being used anywhere
rg "mapRegionCodesToFullNames" --type kotlin | grep -v "fun mapRegionCodesToFullNames" | grep -v "import"

Repository: SPOTeam/Android-V2

Length of output: 44


🏁 Script executed:

# Check the full UserRepositoryImpl.kt file for any usage of mapRegionCodesToFullNames
wc -l ./data/user/src/main/java/com/umcspot/spot/user/repositoryimpl/UserRepositoryImpl.kt

Repository: SPOTeam/Android-V2

Length of output: 149


🏁 Script executed:

# Read the full file
cat -n ./data/user/src/main/java/com/umcspot/spot/user/repositoryimpl/UserRepositoryImpl.kt

Repository: SPOTeam/Android-V2

Length of output: 4086


mapNotNull로 인해 존재하지 않는 코드가 자동으로 필터링됩니다.

입력 regionCodes에 포함된 코드가 locations에 없으면 결과에서 제외되어 길이 불일치가 발생할 수 있습니다. UI가 동일 길이를 기대하거나 데이터 무결성이 중요하다면 누락된 코드를 보존하는 방식이 더 안전합니다.

길이 보존 예시
-    return regionCodes.mapNotNull { code -> map[code]?.fullName }
+    return regionCodes.map { code -> map[code]?.fullName ?: code }
🤖 Prompt for AI Agents
In `@core/common/src/main/java/com/umcspot/spot/common/location/Location.kt`
around lines 85 - 94, The current mapRegionCodesToFullNames uses mapNotNull
which drops any regionCodes not found in locations (via toCodeMap), causing
length mismatch; update mapRegionCodesToFullNames to iterate regionCodes with
map (not mapNotNull) and return a placeholder for missing entries (e.g., the
original code or an empty string) by using the lookup map[code]?.fullName ?:
code (or another agreed placeholder) so the output list preserves the same
length and order as the input.

Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,26 @@ enum class ImageButtonState(
bg = B100,
icon = B400
)
)
),

XOUTLINEB100State(
normal = ImageButtonColors(
bg = Color.Transparent,
icon = Black
),
disabled = ImageButtonColors(
bg = White,
icon = B400
),
pressed = ImageButtonColors(
bg = B100,
icon = B400
),
selected = ImageButtonColors(
bg = B100,
icon = B400
)
)
}

fun ImageButtonState.resolveColors(
Expand All @@ -118,6 +136,7 @@ fun BlankButton(
state: ImageButtonState = ImageButtonState.XOUTLINEState,
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
shape: Shape = SpotShapes.Hard,
align : Alignment = Alignment.Center,
content: @Composable BoxScope.() -> Unit = {}

) {
Expand All @@ -134,7 +153,7 @@ fun BlankButton(
indication = null,
onClick = onClick
),
contentAlignment = Alignment.Center
contentAlignment = align
) {
// ✅ 보더 없이 배경만: ShapeBox 재사용
ShapeBox(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,19 @@ package com.umcspot.spot.designsystem.shapes
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.umcspot.spot.designsystem.theme.*
import com.umcspot.spot.designsystem.theme.B100
import com.umcspot.spot.designsystem.theme.B200
import com.umcspot.spot.designsystem.theme.B400
import com.umcspot.spot.designsystem.theme.B500
import com.umcspot.spot.designsystem.theme.G300
import com.umcspot.spot.designsystem.theme.G500
import com.umcspot.spot.designsystem.theme.R500
import com.umcspot.spot.designsystem.theme.SpotTheme


/** Border Shape **/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.umcspot.spot.designsystem.shapes

import android.graphics.Paint
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.border
Expand Down Expand Up @@ -179,7 +180,8 @@ fun ShapeBox(
borderWidth: Dp = 0.dp,
borderColor: Color? = Color.Transparent,
modifier: Modifier = Modifier,
content: @Composable BoxScope.() -> Unit = {}
alignment : Alignment = Alignment.Center,
content: @Composable BoxScope.() -> Unit = {},
) {
Box(
modifier = modifier
Expand All @@ -190,7 +192,8 @@ fun ShapeBox(
} else {
Modifier
}
)
),
contentAlignment = alignment
) {
content()
}
Expand Down
19 changes: 17 additions & 2 deletions core/model/src/main/java/com/umcspot/spot/model/Global.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ enum class StudyTheme(
PROJECT("프로젝트"),
COMPETITION("공모전"),
MAJOR_CAREER("전공 / 진로 학습"),
OTHER("기타")
OTHER("기타");

companion object {
fun from(value: String): StudyTheme? =
values().firstOrNull { it.name == value }
}
Comment on lines +63 to +68
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# Find and read the Global.kt file
fd "Global.kt" --type f

Repository: SPOTeam/Android-V2

Length of output: 119


🏁 Script executed:

# Also get size to determine how to read
wc -l core/model/src/main/java/com/umcspot/spot/model/Global.kt

Repository: SPOTeam/Android-V2

Length of output: 123


🏁 Script executed:

cat -n core/model/src/main/java/com/umcspot/spot/model/Global.kt

Repository: SPOTeam/Android-V2

Length of output: 3038


🏁 Script executed:

# Search for usages of StudyTheme.from
rg "StudyTheme\.from" --type kt -B 2 -A 2

Repository: SPOTeam/Android-V2

Length of output: 88


🏁 Script executed:

# Search for API models and responses that might use StudyTheme
rg "StudyTheme" --type kt -l

Repository: SPOTeam/Android-V2

Length of output: 88


🏁 Script executed:

# Search for StudyTheme.from usages without type filter
rg "StudyTheme\.from" -B 2 -A 2

Repository: SPOTeam/Android-V2

Length of output: 614


🏁 Script executed:

# Search for all StudyTheme references to understand usage patterns
rg "StudyTheme" --include="*.kt" -l

Repository: SPOTeam/Android-V2

Length of output: 503


🏁 Script executed:

# Search for all StudyTheme references
rg "StudyTheme"

Repository: SPOTeam/Android-V2

Length of output: 13899


🏁 Script executed:

# Find UserPreferredCategoryResponseDto to see API contract
rg "UserPreferredCategoryResponseDto" -B 5 -A 10

Repository: SPOTeam/Android-V2

Length of output: 12643


🏁 Script executed:

# Search for test files related to UserPreferredCategoryResponseDto or StudyTheme conversion
find . -name "*Test.kt" -o -name "*test.kt" | head -20

Repository: SPOTeam/Android-V2

Length of output: 188


🏁 Script executed:

# Search for test data or fixtures showing API response format
rg "UserPreferredCategoryResponseDto\|categories.*=" -A 3 -B 1

Repository: SPOTeam/Android-V2

Length of output: 44


🏁 Script executed:

# Search for API response examples or mock data
rg "categories.*LANGUAGE\|categories.*Language\|categories.*language" -B 2 -A 2

Repository: SPOTeam/Android-V2

Length of output: 44


🏁 Script executed:

# Check how other enums handle from() conversions
rg "fun from\(" --include="*.kt" -B 2 -A 5

Repository: SPOTeam/Android-V2

Length of output: 503


🏁 Script executed:

# Search for from() function patterns in all files
rg "fun from\(" -B 2 -A 5

Repository: SPOTeam/Android-V2

Length of output: 1377


🏁 Script executed:

# Let's check the actual API response DTO more carefully
cat -n data/user/src/main/java/com/umcspot/spot/user/dto/response/UserPreferredCategoryResponseDto.kt

Repository: SPOTeam/Android-V2

Length of output: 551


StudyTheme.from() 매핑 방식을 SocialLoginType.from() 패턴과 일관성 있게 정정하세요.

현재 enum name 완전 일치 방식만 사용하는데, 같은 파일의 SocialLoginType은 소문자 정규화와 title 필드 매칭을 적용하고 있습니다. API가 소문자나 한글 title 값을 보내면 null이 되는 위험이 있으므로, 다음과 같이 case-insensitive와 title 필드 매칭을 추가하세요.

🔧 매핑 범위 확장 예시
    companion object {
        fun from(value: String): StudyTheme? =
            values().firstOrNull { it.name == value }
    }
    companion object {
        fun from(value: String): StudyTheme? {
            val normalized = value.trim()
            return values().firstOrNull {
                it.name.equals(normalized, ignoreCase = true) || it.title == normalized
            }
        }
    }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
OTHER("기타");
companion object {
fun from(value: String): StudyTheme? =
values().firstOrNull { it.name == value }
}
OTHER("기타");
companion object {
fun from(value: String): StudyTheme? {
val normalized = value.trim()
return values().firstOrNull {
it.name.equals(normalized, ignoreCase = true) || it.title == normalized
}
}
}
🤖 Prompt for AI Agents
In `@core/model/src/main/java/com/umcspot/spot/model/Global.kt` around lines 63 -
68, StudyTheme.from currently only matches enum.name exactly; make it consistent
with SocialLoginType.from by normalizing input and matching both the enum name
and its title case-insensitively. Update the StudyTheme.from function to trim
and case-normalize the incoming value and return the first matching enum where
value equals name (ignore case) or equals title (ignore case) — keep the method
on the StudyTheme companion object and follow the same matching logic used in
SocialLoginType.from.

}

enum class StudyStyle {
Expand Down Expand Up @@ -88,5 +93,15 @@ enum class SocialLoginType(
val title: String
) {
KAKAO("kakao"),
NAVER("naver"),
NAVER("naver");

companion object {
fun from(value: String): SocialLoginType {
val normalized = value.lowercase()

return values().firstOrNull {
it.title == normalized
} ?: KAKAO
}
Comment on lines +98 to +105
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

fd "Global.kt" --type f

Repository: SPOTeam/Android-V2

Length of output: 119


🏁 Script executed:

cat -n core/model/src/main/java/com/umcspot/spot/model/Global.kt | head -120

Repository: SPOTeam/Android-V2

Length of output: 3038


🏁 Script executed:

rg "SocialLoginType\.from\(" --type kotlin --type java -B 2 -A 2

Repository: SPOTeam/Android-V2

Length of output: 632


🏁 Script executed:

rg "SocialLoginType" --type kotlin --type java | head -30

Repository: SPOTeam/Android-V2

Length of output: 3859


🏁 Script executed:

rg "\.from\(" core/model/src/main/java/com/umcspot/spot/model/Global.kt -A 10 -B 2

Repository: SPOTeam/Android-V2

Length of output: 44


🏁 Script executed:

cat -n data/user/src/main/java/com/umcspot/spot/user/mapper/UserMapper.kt | head -50

Repository: SPOTeam/Android-V2

Length of output: 2350


알 수 없는 로그인 타입을 KAKAO로 기본 처리하면 오분류됩니다.

신규/오타 값이 들어오면 잘못된 타입으로 저장될 수 있습니다. UserMapper.kt에서 API 응답의 loginType을 매핑할 때 예상치 못한 값이 오면 KAKAO로 처리되어 데이터 불일치가 발생합니다. UNKNOWN 추가 또는 nullable 반환을 고려해 주세요. 또한 lowercase()는 Locale 영향을 받으니 Locale.ROOT 권장입니다.

🔧 안전한 기본값/로케일 처리 예시
+import java.util.Locale
 
 enum class SocialLoginType(
     val title: String
 ) {
+    UNKNOWN("unknown"),
     KAKAO("kakao"),
     NAVER("naver");
 
     companion object {
         fun from(value: String): SocialLoginType {
-            val normalized = value.lowercase()
+            val normalized = value.lowercase(Locale.ROOT)
             return values().firstOrNull {
                 it.title == normalized
-            } ?: KAKAO
+            } ?: UNKNOWN
         }
     }
 }
🤖 Prompt for AI Agents
In `@core/model/src/main/java/com/umcspot/spot/model/Global.kt` around lines 98 -
105, The from(value: String) factory in Global.kt currently lowercases the input
with value.lowercase() and defaults unknown values to KAKAO, causing
misclassification; change it to use value.lowercase(Locale.ROOT) and stop
defaulting to KAKAO—either return a nullable SocialLoginType? or add an UNKNOWN
enum constant and return that; then update callers such as UserMapper.kt (the
loginType mapping) to handle the nullable/UNKNOWN case explicitly instead of
silently treating it as KAKAO.

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import com.umcspot.spot.network.model.BaseResponse
import com.umcspot.spot.network.model.NullResultResponse
import com.umcspot.spot.user.dto.request.UserNameRequestDto
import com.umcspot.spot.user.dto.request.UserThemeRequestDto
import com.umcspot.spot.user.dto.response.MyPageResponseDto
import com.umcspot.spot.user.dto.response.UserPreferredCategoryResponseDto
import com.umcspot.spot.user.dto.response.UserPreferredRegionResponseDto
import com.umcspot.spot.user.dto.response.UserResponseDto

Expand All @@ -13,4 +15,7 @@ interface UserDataSource {
suspend fun setUserTheme(themes : UserThemeRequestDto): NullResultResponse
suspend fun setUserPreferredRegion(regions : List<String>) : NullResultResponse
suspend fun getUserPreferredRegion() : BaseResponse<UserPreferredRegionResponseDto>

suspend fun getMyPageInfo() : BaseResponse<MyPageResponseDto>
suspend fun getUserPreferredCategory() : BaseResponse<UserPreferredCategoryResponseDto>
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import com.umcspot.spot.network.model.NullResultResponse
import com.umcspot.spot.user.datasource.UserDataSource
import com.umcspot.spot.user.dto.request.UserNameRequestDto
import com.umcspot.spot.user.dto.request.UserThemeRequestDto
import com.umcspot.spot.user.dto.response.MyPageResponseDto
import com.umcspot.spot.user.dto.response.UserPreferredCategoryResponseDto
import com.umcspot.spot.user.dto.response.UserPreferredRegionResponseDto
import com.umcspot.spot.user.dto.response.UserResponseDto
import com.umcspot.spot.user.dto.response.UserThemeResponseDto
Expand Down Expand Up @@ -41,8 +43,12 @@ class UserDataSourceImpl @Inject constructor(
return res
}



override suspend fun getUserPreferredRegion(): BaseResponse<UserPreferredRegionResponseDto> =
userService.getUserPreferredRegion()

override suspend fun getMyPageInfo(): BaseResponse<MyPageResponseDto> =
userService.getMyPageInfo()

override suspend fun getUserPreferredCategory(): BaseResponse<UserPreferredCategoryResponseDto> =
userService.getUserPreferredCategory()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.umcspot.spot.user.dto.response

import android.annotation.SuppressLint
import com.umcspot.spot.model.ImageRef
import com.umcspot.spot.model.WeatherType
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@SuppressLint("UnsafeOptInUsageError")
@Serializable
data class MyPageResponseDto(
@SerialName("memberId")
val memberId : Long,
@SerialName("nickname")
val nickname : String,
@SerialName("profileImageUrl")
val profileImageUrl : String?,
@SerialName("loginType")
val loginType : String,
@SerialName("email")
val email : String,
@SerialName("studyParticipationInfo")
val studyParticipationInfo : StudyParticipationInfo,
)

@SuppressLint("UnsafeOptInUsageError")
@Serializable
data class StudyParticipationInfo(
@SerialName("participatingStudyCount")
val participatingStudyCount : Int,
@SerialName("recruitingStudyCount")
val recruitingStudyCount : Int,
@SerialName("appliedStudyCount")
val appliedStudyCount : Int
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.umcspot.spot.user.dto.response

import android.annotation.SuppressLint
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@SuppressLint("UnsafeOptInUsageError")
@Serializable
data class UserPreferredCategoryResponseDto(
@SerialName("categories")
val categories: List<String>,

@SerialName("totalCount")
val totalCount: Int
)
30 changes: 24 additions & 6 deletions data/user/src/main/java/com/umcspot/spot/user/mapper/UserMapper.kt
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
package com.umcspot.spot.user.mapper

import com.umcspot.spot.model.SocialLoginType
import com.umcspot.spot.model.StudyTheme
import com.umcspot.spot.model.toImageRef
import com.umcspot.spot.user.dto.request.UserNameRequestDto
import com.umcspot.spot.user.dto.request.UserPreferredRegionRequestDto
import com.umcspot.spot.user.dto.request.UserThemeRequestDto
import com.umcspot.spot.user.dto.response.MyPageResponseDto
import com.umcspot.spot.user.dto.response.StudyParticipationInfo
import com.umcspot.spot.user.dto.response.UserPreferredCategoryResponseDto
import com.umcspot.spot.user.dto.response.UserPreferredRegionResponseDto
import com.umcspot.spot.user.model.UserResult
import com.umcspot.spot.user.dto.response.UserResponseDto
import com.umcspot.spot.user.dto.response.UserThemeResponseDto
import com.umcspot.spot.user.model.MyPageResult
import com.umcspot.spot.user.model.UserPreferredCategoryResult
import com.umcspot.spot.user.model.UserPreferredRegionResult
import com.umcspot.spot.user.model.UserTheme
import java.time.LocalTime
import java.time.format.DateTimeFormatter
import java.time.format.DateTimeParseException
import java.util.Locale

fun List<StudyTheme>.toRequestDto(): UserThemeRequestDto =
UserThemeRequestDto(userThemes = this)
Expand All @@ -38,3 +39,20 @@ fun UserPreferredRegionResponseDto.toDomain(): UserPreferredRegionResult =
totalCount = totalCount
)

fun MyPageResponseDto.toDomain(): MyPageResult =
MyPageResult(
memberId = memberId,
nickname = nickname,
profileImageUrl = profileImageUrl.toImageRef(),
loginType = SocialLoginType.from(loginType),
email = email,
participateCount = studyParticipationInfo.participatingStudyCount,
recruitingCount = studyParticipationInfo.recruitingStudyCount,
appliedCount = studyParticipationInfo.appliedStudyCount
)

fun UserPreferredCategoryResponseDto.toDomain(): UserPreferredCategoryResult =
UserPreferredCategoryResult(
categories = categories.map { StudyTheme.from(it)?.title },
totalCount = totalCount
)
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
package com.umcspot.spot.user.repositoryimpl

import android.content.Context
import android.util.Log
import com.umcspot.spot.common.location.LocationStore
import com.umcspot.spot.common.location.mapRegionCodesToFullNames
import com.umcspot.spot.model.StudyTheme
import com.umcspot.spot.user.datasource.UserDataSource
import com.umcspot.spot.user.mapper.toDomain
import com.umcspot.spot.user.mapper.toRequestDto
import com.umcspot.spot.user.model.MyPageResult
import com.umcspot.spot.user.model.UserPreferredCategoryResult
import com.umcspot.spot.user.model.UserPreferredRegionResult
import com.umcspot.spot.user.model.UserResult
import com.umcspot.spot.user.repository.UserRepository
import dagger.hilt.android.qualifiers.ApplicationContext
import javax.inject.Inject

class UserRepositoryImpl @Inject constructor(
private val userDataSource: UserDataSource
private val userDataSource: UserDataSource,
@ApplicationContext private val appContext: Context, // @ApplicationContext 로 주입 추천
) : UserRepository {
override suspend fun getUserName(): Result<UserResult> =
runCatching {
Expand All @@ -37,12 +44,47 @@ class UserRepositoryImpl @Inject constructor(
userDataSource.setUserPreferredRegion(regions)
}


override suspend fun getUserPreferredRegion(): Result<UserPreferredRegionResult> =
runCatching {
val userPreferredRegions = userDataSource.getUserPreferredRegion()
userPreferredRegions.result.toDomain()
}.onFailure { e ->
Log.e("UserRepository", "getUserPreferredRegion failed", e)
}

override suspend fun getUserPreferredRegionName(): Result<UserPreferredRegionResult> =
runCatching {
val dto = userDataSource.getUserPreferredRegion()

// assets 기반 지역 테이블 로드
val locations = LocationStore.load(appContext)

val codeMap = locations.associateBy { it.code }

// 4) code 리스트를 fullName(지명) 리스트로 변환
val regionNames = dto.result.regionCodes.mapNotNull { code ->
codeMap[code]?.neighborhood
}

UserPreferredRegionResult(
regionCodes = regionNames,
totalCount = dto.result.totalCount
)
}.onFailure { e ->
Log.e("UserRepository", "getUserPreferredRegion failed", e)
}

override suspend fun getMyPageInfo(): Result<MyPageResult> =
runCatching {
userDataSource.getMyPageInfo().result.toDomain()
}.onFailure {
Log.e("UserRepository", "getMyPageInfo failed", it)
}

override suspend fun getUserPreferredCategory(): Result<UserPreferredCategoryResult> =
runCatching {
userDataSource.getUserPreferredCategory().result.toDomain()
}.onFailure {
Log.e("UserRepository", "getUserPreferredCategory failed", it)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import com.umcspot.spot.network.model.NullResultResponse
import com.umcspot.spot.user.dto.request.UserNameRequestDto
import com.umcspot.spot.user.dto.request.UserPreferredRegionRequestDto
import com.umcspot.spot.user.dto.request.UserThemeRequestDto
import com.umcspot.spot.user.dto.response.MyPageResponseDto
import com.umcspot.spot.user.dto.response.UserPreferredCategoryResponseDto
import com.umcspot.spot.user.dto.response.UserPreferredRegionResponseDto
import com.umcspot.spot.user.dto.response.UserResponseDto
import retrofit2.http.Body
Expand Down Expand Up @@ -34,4 +36,12 @@ interface UserService {
@GET("/api/members/prefer-regions")
suspend fun getUserPreferredRegion(
): BaseResponse<UserPreferredRegionResponseDto>

@GET("/api/members/info")
suspend fun getMyPageInfo(
): BaseResponse<MyPageResponseDto>

@GET("/api/members/prefer-categories")
suspend fun getUserPreferredCategory(
): BaseResponse<UserPreferredCategoryResponseDto>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.umcspot.spot.user.model

import com.umcspot.spot.model.ImageRef
import com.umcspot.spot.model.SocialLoginType

data class MyPageResult(
val memberId: Long,
val nickname: String,
val profileImageUrl: ImageRef,
val loginType: SocialLoginType,
val email: String,
val participateCount: Int,
val recruitingCount: Int,
val appliedCount: Int
)
Loading