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

[FEAT] 코스 발견 / 상세페이지 타 유저 프로필 조회 #305

Merged
merged 30 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
745f35f
[ADD] #303 코스 디테일 Response 에 유저 아이디 추가
sxunea Dec 29, 2023
6ea1549
[FEAT] #303 CourseDetail에서 유저 Profile로 화면 전환 구현
sxunea Dec 29, 2023
62c5ece
[FEAT] #303 유저 프로필 조회 서버통신 serivce, datasource 구현
sxunea Dec 29, 2023
5380146
[FEAT] #303 유저 프로필 조회 서버통신 repository 구현
sxunea Dec 29, 2023
000c410
[ADD] #303 유저 프로필 조회 서버통신 Response 데이터 클래스 추가
sxunea Dec 29, 2023
da01b48
[FEAT] #303 ViewModel 유저 프로필 조회 구현
sxunea Dec 29, 2023
2d82d7a
[FEAT] #303 인텐트로 받은 유저 아이디로 프로필 조회
sxunea Dec 29, 2023
3ab1d5e
[FEAT] #303 프로필 스탬프 이미지 bindingAdapter 추가
sxunea Dec 29, 2023
203aea9
[FEAT] #303 로딩 시 프로그레스바 보여주도록
sxunea Dec 29, 2023
675b473
[CHORE] #303 실패 시 스낵바 보여주도록
sxunea Dec 29, 2023
a09a2cf
[FEAT] #303 백버튼 뒤로가기 화면 전환 구현
sxunea Dec 29, 2023
0ed58aa
[FEAT] #303 업로드한 코스 스크랩 구현
sxunea Dec 29, 2023
fe859fc
[FEAT] #303 스크랩 성공/취소 시, 아이콘 즉시 변동 있도록
sxunea Dec 29, 2023
54c26ad
[FEAT] #303 업로드한 코스 클릭 시 해당 상세페이지로 이동
sxunea Dec 29, 2023
c21ad73
Merge branch 'develop' into feature/feat-get-user-profile
sxunea Dec 29, 2023
b888215
[MOD] #303 Extra 값 이름과 동일하게 변경
sxunea Jan 4, 2024
72221d1
[ADD] #303 CourseDetailActivity 무한 생성 방지 위한 IntentFlag 관리
sxunea Jan 6, 2024
4826f1b
[FEAT] #303 onNewIntent 활용해 스택에 존재하던 액티비티의 데이터를 갱신하도록
sxunea Jan 6, 2024
feec2f0
[ADD] #303 addListener(), addObserver()로 확장성 있게 관리
sxunea Jan 6, 2024
b1f7769
[CHORE] #303 Timber 로그 메시지의 레벨 변경
sxunea Jan 6, 2024
b1a729c
[CHORE] #303 직관성을 위한 onScrapButtonClick 으로의 네이밍 변경
sxunea Jan 6, 2024
c80d446
[CHORE] #303 네이밍 변경
sxunea Jan 6, 2024
3d548d3
[FEAT] #303 스크랩 POST 결과를 관찰해 뷰를 업데이트하도록
sxunea Jan 6, 2024
36b5138
Merge branch 'develop' of https://github.com/Runnect/Runnect-Android …
sxunea Jan 6, 2024
cbc3f17
[FIX] #303 레이아웃 마진 수정
sxunea Jan 7, 2024
25891ce
[MOD] #303 exit -> enter로 진입 애니메이션 변경
sxunea Jan 7, 2024
e672516
[ADD] #303 response 값 변경에 따른 스크랩 서버통신 응답 데이터 클래스 생성
sxunea Jan 9, 2024
52fd46c
[MOD] #303 response 변경에 따른 스크랩 기존 코드 수정
sxunea Jan 9, 2024
77db0a1
[MOD] #303 유저 프로필 스크랩 구현 로직 변경
sxunea Jan 9, 2024
b9df77d
Merge branch 'develop' of https://github.com/Runnect/Runnect-Android …
sxunea Jan 10, 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
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@
<activity
android:name=".presentation.mypage.upload.MyUploadActivity"
android:exported="false" />
<activity
android:name=".presentation.profile.ProfileActivity"
android:exported="false" />

<provider
android:name="androidx.core.content.FileProvider"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ data class ResponseGetCourseDetail(
@SerialName("image")
val image: String,
@SerialName("isNowUser")
val isNowUser: Boolean
val isNowUser: Boolean,
@SerialName("id")
val id: Int
)

@Serializable
Expand Down Expand Up @@ -65,6 +67,7 @@ data class ResponseGetCourseDetail(
level = user.level.toString(),
nickname = user.nickname,
isNowUser = user.isNowUser,
userId = user.id,
id = publicCourse.id,
courseId = publicCourse.courseId,
departure = publicCourse.departure.region + ' ' +
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package com.runnect.runnect.data.dto.response

import com.runnect.runnect.domain.entity.Departure
import com.runnect.runnect.domain.entity.UserCourse
import com.runnect.runnect.domain.entity.UserProfile
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class ResponseGetUserProfile(
@SerialName("user")
val user: User,
@SerialName("courses")
val courses: List<CourseData>
) {
@Serializable
data class User(
@SerialName("nickname")
val nickname: String,
@SerialName("level")
val level: Int,
@SerialName("levelPercent")
val levelPercent: Int,
@SerialName("latestStamp")
val latestStamp: String,
@SerialName("userId")
val userId: Int
)

@Serializable
data class CourseData(
@SerialName("publicCourseId")
val publicCourseId: Int,
@SerialName("courseId")
val courseId: Int,
@SerialName("title")
val title: String,
@SerialName("image")
val image: String,
@SerialName("departure")
val departure: Departure,
@SerialName("scrapTF")
val scrapTF: Boolean,
) {
@Serializable
data class Departure(
@SerialName("region")
val region: String,
@SerialName("city")
val city: String,
@SerialName("town")
val town: String,
@SerialName("name")
val name: String?,
@SerialName("detail")
val detail: String?
)
}

fun toUserProfile(): UserProfile {
val userCourseLists: List<UserCourse> = courses.map { course ->
UserCourse(
publicCourseId = course.publicCourseId,
courseId = course.courseId,
title = course.title,
image = course.image,
departure = Departure(
region = course.departure.region,
city = course.departure.city,
town = course.departure.town,
detail = course.departure.detail,
name = course.departure.name ?: ""
),
scrapTF = course.scrapTF
)
}

return UserProfile(
nickname = user.nickname,
level = user.level,
levelPercent = user.levelPercent,
latestStamp = user.latestStamp,
courseData = userCourseLists
)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.runnect.runnect.data.dto.response

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class ResponsePostScrap(
@SerialName("publicCourseId")
val publicCourseId: Long,
@SerialName("scrapCount")
val scrapCount: Long,
@SerialName("scrapTF")
val scrapTF: Boolean
)
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.runnect.runnect.data.dto.response.ResponsePostMyDrawCourse
import com.runnect.runnect.data.dto.response.ResponsePostMyHistory
import com.runnect.runnect.data.dto.response.ResponsePutMyDrawCourse
import com.runnect.runnect.data.dto.response.ResponsePostDiscoverUpload
import com.runnect.runnect.data.dto.response.ResponsePostScrap
import com.runnect.runnect.data.source.remote.RemoteCourseDataSource
import com.runnect.runnect.domain.entity.DiscoverSearchCourse
import com.runnect.runnect.domain.entity.DiscoverMultiViewItem.*
Expand Down Expand Up @@ -100,7 +101,7 @@ class CourseRepositoryImpl @Inject constructor(private val remoteCourseDataSourc

override suspend fun postCourseScrap(
requestPostCourseScrap: RequestPostCourseScrap
): Result<Unit?> = runCatching {
): Result<ResponsePostScrap?> = runCatching {
remoteCourseDataSource.postCourseScrap(requestPostCourseScrap = requestPostCourseScrap).data
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.runnect.runnect.data.repository

import com.runnect.runnect.data.dto.HistoryInfoDTO
import com.runnect.runnect.domain.entity.UserProfile
import com.runnect.runnect.data.dto.UserUploadCourseDTO
import com.runnect.runnect.data.dto.request.RequestDeleteHistory
import com.runnect.runnect.data.dto.request.RequestDeleteUploadCourse
Expand All @@ -9,9 +10,9 @@ import com.runnect.runnect.data.dto.request.RequestPatchNickName
import com.runnect.runnect.data.dto.response.ResponseDeleteHistory
import com.runnect.runnect.data.dto.response.ResponseDeleteUploadCourse
import com.runnect.runnect.data.dto.response.ResponseDeleteUser
import com.runnect.runnect.data.dto.response.ResponseGetUser
import com.runnect.runnect.data.dto.response.ResponsePatchHistoryTitle
import com.runnect.runnect.data.dto.response.ResponsePatchUserNickName
import com.runnect.runnect.data.dto.response.ResponseGetUser
import com.runnect.runnect.data.source.remote.RemoteUserDataSource
import com.runnect.runnect.domain.repository.UserRepository
import com.runnect.runnect.util.extension.toData
Expand All @@ -36,6 +37,11 @@ class UserRepositoryImpl @Inject constructor(private val remoteUserDataSource: R
.toMutableList()
}

override suspend fun getUserProfile(userId: Int): Result<UserProfile?> =
runCatching {
remoteUserDataSource.getUserProfile(userId).data?.toUserProfile()
}

override suspend fun putDeleteUploadCourse(
requestDeleteUploadCourse: RequestDeleteUploadCourse
): Result<ResponseDeleteUploadCourse?> = runCatching {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.runnect.runnect.data.service

import com.runnect.runnect.data.dto.request.RequestPatchPublicCourse
import com.runnect.runnect.data.dto.request.RequestPostCourseScrap
import com.runnect.runnect.data.dto.request.RequestPostPublicCourse
import com.runnect.runnect.data.dto.request.RequestPostRunningHistory
import com.runnect.runnect.data.dto.request.RequestPutMyDrawCourse
import com.runnect.runnect.data.dto.request.RequestPatchPublicCourse
import com.runnect.runnect.data.dto.request.RequestPostPublicCourse
import com.runnect.runnect.data.dto.response.*
import com.runnect.runnect.data.dto.response.base.BaseResponse
import okhttp3.MultipartBody
Expand All @@ -25,7 +25,7 @@ interface CourseService {
@POST("/api/scrap")
suspend fun postCourseScrap(
@Body requestPostCourseScrap: RequestPostCourseScrap,
): BaseResponse<Unit>
): BaseResponse<ResponsePostScrap>

@GET("/api/public-course/search?")
suspend fun getCourseSearch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,10 @@ interface UserService {

@DELETE("api/user")
suspend fun deleteUser(): ResponseDeleteUser

// 유저 프로필 조회
@GET("/api/user/{profileUserId}")
suspend fun getUserProfile(
@Path("profileUserId") userId: Int,
): BaseResponse<ResponseGetUserProfile>
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package com.runnect.runnect.data.source.remote

import com.runnect.runnect.data.service.CourseService
import com.runnect.runnect.data.dto.request.RequestPatchPublicCourse
import com.runnect.runnect.data.dto.request.RequestPostCourseScrap
import com.runnect.runnect.data.dto.request.RequestPostPublicCourse
import com.runnect.runnect.data.dto.request.RequestPostRunningHistory
import com.runnect.runnect.data.dto.request.RequestPutMyDrawCourse
import com.runnect.runnect.data.dto.request.RequestPatchPublicCourse
import com.runnect.runnect.data.dto.request.RequestPostPublicCourse
import com.runnect.runnect.data.dto.response.ResponseGetCourseDetail
import com.runnect.runnect.data.dto.response.ResponseGetDiscoverMarathon
import com.runnect.runnect.data.dto.response.ResponsePatchPublicCourse
import com.runnect.runnect.data.dto.response.ResponseGetDiscoverRecommend
import com.runnect.runnect.data.dto.response.ResponsePatchPublicCourse
import com.runnect.runnect.data.dto.response.ResponsePostScrap
import com.runnect.runnect.data.dto.response.base.BaseResponse
import com.runnect.runnect.data.service.CourseService
import okhttp3.MultipartBody
import okhttp3.RequestBody
import javax.inject.Inject
Expand All @@ -27,7 +28,7 @@ class RemoteCourseDataSource @Inject constructor(
): BaseResponse<ResponseGetDiscoverRecommend> =
courseService.getRecommendCourse(pageNo = pageNo, ordering = ordering)

suspend fun postCourseScrap(requestPostCourseScrap: RequestPostCourseScrap): BaseResponse<Unit> =
suspend fun postCourseScrap(requestPostCourseScrap: RequestPostCourseScrap): BaseResponse<ResponsePostScrap> =
courseService.postCourseScrap(requestPostCourseScrap)

suspend fun getCourseSearch(keyword: String) = courseService.getCourseSearch(keyword)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
package com.runnect.runnect.data.source.remote

import com.runnect.runnect.data.service.UserService
import com.runnect.runnect.data.dto.request.RequestDeleteHistory
import com.runnect.runnect.data.dto.request.RequestDeleteUploadCourse
import com.runnect.runnect.data.dto.request.RequestPatchHistoryTitle
import com.runnect.runnect.data.dto.request.RequestPatchNickName
import com.runnect.runnect.data.dto.response.*
import com.runnect.runnect.data.dto.response.ResponseDeleteHistory
import com.runnect.runnect.data.dto.response.ResponseDeleteUploadCourse
import com.runnect.runnect.data.dto.response.ResponseDeleteUser
import com.runnect.runnect.data.dto.response.ResponseGetMyHistory
import com.runnect.runnect.data.dto.response.ResponseGetMyStamp
import com.runnect.runnect.data.dto.response.ResponseGetUser
import com.runnect.runnect.data.dto.response.ResponseGetUserProfile
import com.runnect.runnect.data.dto.response.ResponseGetUserUploadCourse
import com.runnect.runnect.data.dto.response.ResponsePatchHistoryTitle
import com.runnect.runnect.data.dto.response.ResponsePatchUserNickName
import com.runnect.runnect.data.dto.response.base.BaseResponse
import com.runnect.runnect.data.service.UserService
import javax.inject.Inject

class RemoteUserDataSource @Inject constructor(private val userService: UserService) {
Expand All @@ -16,7 +25,11 @@ class RemoteUserDataSource @Inject constructor(private val userService: UserServ

suspend fun getMyStamp(): ResponseGetMyStamp = userService.getMyStamp()
suspend fun getRecord(): ResponseGetMyHistory = userService.getRecord()
suspend fun getUserUploadCourse(): ResponseGetUserUploadCourse = userService.getUserUploadCourse()
suspend fun getUserUploadCourse(): ResponseGetUserUploadCourse =
userService.getUserUploadCourse()

suspend fun getUserProfile(userId: Int): BaseResponse<ResponseGetUserProfile> =
userService.getUserProfile(userId)

suspend fun putDeleteUploadCourse(
requestDeleteUploadCourse: RequestDeleteUploadCourse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ data class CourseDetail(
val path: List<List<Double>>,
val distance: String,
val departure: String,
val userId: Int
)
26 changes: 26 additions & 0 deletions app/src/main/java/com/runnect/runnect/domain/entity/UserProfile.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.runnect.runnect.domain.entity

data class UserProfile(
val nickname: String,
val level: Int,
val levelPercent: Int,
val latestStamp: String,
val courseData: List<UserCourse>
)

data class UserCourse(
val publicCourseId: Int,
val courseId: Int,
val title: String,
val image: String,
val departure: Departure,
var scrapTF: Boolean,
)

data class Departure(
val region: String,
val city: String,
val town: String,
val detail: String?,
val name: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,24 @@ import com.runnect.runnect.data.dto.response.ResponseGetMyDrawDetail
import com.runnect.runnect.data.dto.response.ResponsePostDiscoverUpload
import com.runnect.runnect.data.dto.response.ResponsePostMyDrawCourse
import com.runnect.runnect.data.dto.response.ResponsePostMyHistory
import com.runnect.runnect.data.dto.response.ResponsePostScrap
import com.runnect.runnect.data.dto.response.ResponsePutMyDrawCourse
import com.runnect.runnect.domain.entity.CourseDetail
import com.runnect.runnect.domain.entity.DiscoverMultiViewItem.MarathonCourse
import com.runnect.runnect.domain.entity.DiscoverSearchCourse
import com.runnect.runnect.domain.entity.DiscoverMultiViewItem.*
import com.runnect.runnect.domain.entity.RecommendCoursePagingData
import com.runnect.runnect.domain.entity.EditableCourseDetail
import com.runnect.runnect.domain.entity.RecommendCoursePagingData
import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.Response

interface CourseRepository {
suspend fun getMarathonCourse(): Result<List<MarathonCourse>?>

suspend fun getRecommendCourse(pageNo: String, ordering: String): Result<RecommendCoursePagingData?>
suspend fun getRecommendCourse(
pageNo: String,
ordering: String
): Result<RecommendCoursePagingData?>

suspend fun getCourseSearch(keyword: String): Result<List<DiscoverSearchCourse>?>

Expand All @@ -40,12 +44,13 @@ interface CourseRepository {
suspend fun uploadCourse(
image: MultipartBody.Part, courseCreateRequestDto: RequestBody
): Response<ResponsePostMyDrawCourse>

suspend fun getCourseDetail(publicCourseId: Int): Result<CourseDetail?>

suspend fun patchPublicCourse(
publicCourseId: Int,
requestPatchPublicCourse: RequestPatchPublicCourse
): Result<EditableCourseDetail?>

suspend fun postCourseScrap(requestPostCourseScrap: RequestPostCourseScrap): Result<Unit?>
suspend fun postCourseScrap(requestPostCourseScrap: RequestPostCourseScrap): Result<ResponsePostScrap?>
}
Loading
Loading