-
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
78 changed files
with
1,343 additions
and
1,321 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
82 changes: 35 additions & 47 deletions
82
app/src/main/java/com/runnect/runnect/data/dto/response/ResponseGetMyDrawDetail.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,61 +1,49 @@ | ||
package com.runnect.runnect.data.dto.response | ||
|
||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ResponseGetMyDrawDetail( | ||
@SerialName("data") | ||
val data: Data, | ||
@SerialName("message") | ||
val message: String, | ||
@SerialName("status") | ||
val status: Int, | ||
@SerialName("success") | ||
val success: Boolean, | ||
@SerialName("course") | ||
val course: Course, | ||
@SerialName("user") | ||
val user: User, | ||
) { | ||
@Serializable | ||
data class Data( | ||
@SerialName("course") | ||
val course: Course, | ||
@SerialName("user") | ||
val user: User, | ||
) { | ||
data class User( | ||
@SerialName("userId") | ||
val id: Int, | ||
) | ||
|
||
@Serializable | ||
data class Course( | ||
@SerialName("id") | ||
val id: Int, | ||
@SerialName("createdAt") | ||
val createdAt: String, | ||
@SerialName("path") | ||
val path: List<List<Double>>, | ||
@SerialName("distance") | ||
val distance: Float, | ||
@SerialName("image") | ||
val image: String, | ||
@SerialName("title") | ||
val title: String, | ||
@SerialName("departure") | ||
val departure: Departure, | ||
) { | ||
@Serializable | ||
data class User( | ||
@SerialName("userId") | ||
val id: Int, | ||
data class Departure( | ||
@SerialName("region") | ||
val region: String, | ||
@SerialName("city") | ||
val city: String, | ||
@SerialName("town") | ||
val town: String, | ||
@SerialName("name") | ||
val name: String, | ||
) | ||
@Serializable | ||
data class Course( | ||
@SerialName("id") | ||
val id: Int, | ||
@SerialName("createdAt") | ||
val createdAt: String, | ||
@SerialName("path") | ||
val path: List<List<Double>>, | ||
@SerialName("distance") | ||
val distance: Float, | ||
@SerialName("image") | ||
val image: String, | ||
@SerialName("title") | ||
val title: String, | ||
@SerialName("departure") | ||
val departure: Departure, | ||
) { | ||
@Serializable | ||
data class Departure( | ||
@SerialName("region") | ||
val region: String, | ||
@SerialName("city") | ||
val city: String, | ||
@SerialName("town") | ||
val town: String, | ||
@SerialName("name") | ||
val name: String, | ||
) | ||
} | ||
} | ||
|
||
} |
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 | ||
) | ||
} | ||
} |
Oops, something went wrong.