-
Notifications
You must be signed in to change notification settings - Fork 1
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 #345 from Runnect/feature/refactor-api-flow-discov…
…er-mypage [REFACTOR] api 로직 수정
- Loading branch information
Showing
75 changed files
with
1,288 additions
and
1,245 deletions.
There are no files selected for viewing
11 changes: 0 additions & 11 deletions
11
app/src/main/java/com/runnect/runnect/data/dto/LocationData.kt
This file was deleted.
Oops, something went wrong.
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
94 changes: 61 additions & 33 deletions
94
app/src/main/java/com/runnect/runnect/data/dto/response/ResponseGetMyHistory.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 |
---|---|---|
@@ -1,44 +1,72 @@ | ||
package com.runnect.runnect.data.dto.response | ||
|
||
import com.runnect.runnect.data.dto.HistoryInfoDTO | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ResponseGetMyHistory( | ||
val `data`: HistoryData, | ||
val message: String, | ||
val status: Int, | ||
val success: Boolean | ||
) | ||
val user: RecordUser, | ||
val records: List<Record>, | ||
) { | ||
@Serializable | ||
data class RecordUser( | ||
@SerialName("userId") val id: Int | ||
) | ||
|
||
@Serializable | ||
data class Record( | ||
val courseId: Int, | ||
val createdAt: String, | ||
val departure: Departure, | ||
val distance: Double, | ||
val id: Int, | ||
val image: String, | ||
val pace: String, | ||
val publicCourseId: Int?, | ||
val time: String, | ||
val title: String | ||
) | ||
@Serializable | ||
data class Record( | ||
val courseId: Int, | ||
val createdAt: String, | ||
val departure: Departure, | ||
val distance: Double, | ||
val id: Int, | ||
val image: String, | ||
val pace: String, | ||
val publicCourseId: Int?, | ||
val time: String, | ||
val title: String | ||
) { | ||
@Serializable | ||
data class Departure( | ||
val city: String, | ||
val region: String | ||
) | ||
} | ||
|
||
@Serializable | ||
data class Departure( | ||
val city: String, | ||
val region: String | ||
) | ||
fun toHistoryInfoList(): List<HistoryInfoDTO> { | ||
return records.map { | ||
HistoryInfoDTO( | ||
id = it.id, | ||
img = it.image, | ||
title = it.title, | ||
location = "${it.departure.region} ${it.departure.city}", | ||
date = (it.createdAt.split(" ")[0]).replace("-", "."), | ||
distance = it.distance.toString(), | ||
time = timeConvert(it.time), | ||
pace = paceConvert(it.pace) | ||
) | ||
} | ||
} | ||
|
||
@Serializable | ||
data class RecordUser( | ||
@SerialName("userId") val id: Int | ||
) | ||
|
||
@Serializable | ||
data class HistoryData( | ||
val records: List<Record>, | ||
val user: RecordUser | ||
) | ||
private fun timeConvert(time: String): String { | ||
val hms = time.split(":").toMutableList() | ||
if (hms[0] == "00") { | ||
hms[0] = "0" | ||
} | ||
return "${hms[0]}:${hms[1]}:${hms[2]}" | ||
} | ||
|
||
private fun paceConvert(p: String): String { | ||
val pace = p.split(":").toMutableList() | ||
return if (pace[0] == "00") { | ||
pace.removeAt(0) | ||
if (pace[0][0] == '0') { | ||
pace[0] = pace[0][1].toString() | ||
} | ||
"${pace[0]}’${pace[1]}”" | ||
} else { | ||
"${pace[0]}’${pace[1]}”${pace[2]}”" | ||
} | ||
} | ||
} |
31 changes: 13 additions & 18 deletions
31
app/src/main/java/com/runnect/runnect/data/dto/response/ResponseGetMyStamp.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 |
---|---|---|
@@ -1,26 +1,21 @@ | ||
package com.runnect.runnect.data.dto.response | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ResponseGetMyStamp( | ||
val `data`: StampData, | ||
val message: String, | ||
val status: Int, | ||
val success: Boolean | ||
) | ||
|
||
@Serializable | ||
data class StampData( | ||
val user: StampUser, | ||
val stamps: List<Stamp>, | ||
val user: StampUser | ||
) | ||
) { | ||
@Serializable | ||
data class StampUser( | ||
val id: Int | ||
) | ||
|
||
@Serializable | ||
data class Stamp( | ||
val id: String | ||
) | ||
@Serializable | ||
data class Stamp( | ||
val id: String | ||
) | ||
|
||
@Serializable | ||
data class StampUser( | ||
val id: Int | ||
) | ||
fun toStampList() = stamps.map { it.id } | ||
} |
38 changes: 21 additions & 17 deletions
38
app/src/main/java/com/runnect/runnect/data/dto/response/ResponseGetUser.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 |
---|---|---|
@@ -1,25 +1,29 @@ | ||
package com.runnect.runnect.data.dto.response | ||
|
||
import com.runnect.runnect.domain.entity.User | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ResponseGetUser( | ||
val data: Data, | ||
val message: String, | ||
val status: Int, | ||
val success: Boolean | ||
) | ||
val user: UserResponse, | ||
) { | ||
|
||
@Serializable | ||
data class Data( | ||
val user: User | ||
) | ||
@Serializable | ||
data class UserResponse( | ||
val email: String, | ||
val latestStamp: String, | ||
val level: Int, | ||
val levelPercent: Int, | ||
val nickname: String | ||
) | ||
|
||
@Serializable | ||
data class User( | ||
val email:String, | ||
val latestStamp: String, | ||
val level: Int, | ||
val levelPercent: Int, | ||
val nickname: String | ||
) | ||
fun toUser(): User { | ||
return User( | ||
email = user.email, | ||
latestStamp = user.latestStamp, | ||
level = user.level, | ||
levelPercent = user.levelPercent, | ||
nickname = user.nickname | ||
) | ||
} | ||
} |
86 changes: 45 additions & 41 deletions
86
app/src/main/java/com/runnect/runnect/data/dto/response/ResponseGetUserUploadCourse.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 |
---|---|---|
@@ -1,49 +1,53 @@ | ||
package com.runnect.runnect.data.dto.response | ||
|
||
import com.google.gson.annotations.SerializedName | ||
import com.runnect.runnect.domain.entity.UserUploadCourse | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ResponseGetUserUploadCourse( | ||
@SerializedName("data") | ||
val `data`: DataUpload, | ||
@SerializedName("message") | ||
val message: String, | ||
@SerializedName("status") | ||
val status: Int, | ||
@SerializedName("success") | ||
val success: Boolean | ||
) | ||
@Serializable | ||
data class UserUpload( | ||
@SerializedName("id") | ||
val id: Int | ||
) | ||
@Serializable | ||
data class PublicCourseUpload( | ||
@SerializedName("courseId") | ||
val courseId: Int, | ||
@SerializedName("departure") | ||
val departure: DepartureUpload, | ||
@SerializedName("id") | ||
val id: Int, | ||
@SerializedName("image") | ||
val image: String, | ||
@SerializedName("title") | ||
val title: String | ||
) | ||
|
||
@Serializable | ||
data class DepartureUpload( | ||
@SerializedName("city") | ||
val city: String, | ||
@SerializedName("region") | ||
val region: String | ||
) | ||
@Serializable | ||
data class DataUpload( | ||
@SerializedName("publicCourse") | ||
val publicCourses: List<PublicCourseUpload>, | ||
@SerializedName("user") | ||
val user: UserUpload | ||
) | ||
val user: UserId, | ||
@SerializedName("publicCourses") | ||
val publicCourses: List<PublicCourseUpload>, | ||
) { | ||
|
||
@Serializable | ||
data class UserId( | ||
@SerializedName("id") | ||
val id: Int, | ||
) | ||
|
||
@Serializable | ||
data class PublicCourseUpload( | ||
@SerializedName("id") | ||
val id: Int, | ||
@SerializedName("courseId") | ||
val courseId: Int, | ||
@SerializedName("title") | ||
val title: String, | ||
@SerializedName("scrap") | ||
val scrap: Boolean, | ||
@SerializedName("image") | ||
val image: String, | ||
@SerializedName("departure") | ||
val departure: DepartureUpload, | ||
) | ||
|
||
@Serializable | ||
data class DepartureUpload( | ||
@SerializedName("region") | ||
val region: String, | ||
@SerializedName("city") | ||
val city: String, | ||
) | ||
|
||
fun toUserUploadCourse(): List<UserUploadCourse> = publicCourses.map { | ||
UserUploadCourse( | ||
id = it.id, | ||
title = it.title, | ||
img = it.image, | ||
departure = "${it.departure.region} ${it.departure.city}" | ||
) | ||
} | ||
} |
Oops, something went wrong.