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

[REFACTOR] api 로직 수정 #345

Merged
merged 28 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
cd2bc5c
[refactor] 추천 코스 요청 코드 Flow로 변경
dongx0915 Mar 27, 2024
525afae
[refactor] 내 업로드 코스 요청 코드 flow로 변환
dongx0915 Mar 27, 2024
c632952
[fix] 추천 코스 새로고침 시 크래시 수정
dongx0915 Mar 28, 2024
105ae77
[refactor] 코스 스크랩 부분 Flow로 변환
dongx0915 Mar 28, 2024
487ee2b
[refactor] 코스 업로드 요청 부분 Flow로 변환
dongx0915 Mar 28, 2024
ead78fb
[refactor] 코스 검색 요청 부분 Flow로 변환
dongx0915 Mar 28, 2024
77cc612
[refactor] 유저 정보 조회 요청 부분 Flow로 변환
dongx0915 Mar 28, 2024
32eedc8
[refactor] 업로드한 코스 요청 부분 Flow로 변환
dongx0915 Mar 28, 2024
e6b3b84
[refactor] 코스 삭제 요청 부분 Flow로 변환
dongx0915 Mar 29, 2024
c9ceed7
[refactor] 회원 탈퇴 요청 부분 Flow로 변환
dongx0915 Mar 29, 2024
bfcf0a9
[refactor] 스탬프 조회 요청 부분 Flow로 변환
dongx0915 Mar 29, 2024
4fa5433
[refactor] 러닝 기록 조회 요청 부분 Flow로 변환
dongx0915 Mar 29, 2024
1f670be
Merge branch 'develop' into feature/refactor-api-flow-discover-mypage
dongx0915 Mar 31, 2024
b7e95ab
[refactor] #344 기록 코스 삭제 부분 Flow로 변환
dongx0915 Mar 31, 2024
7336e1a
[refactor] #344 기록 코스 제목 수정 부분 Flow로 변환
dongx0915 Mar 31, 2024
cde622f
[refactor] #344 닉네임 수정 부분 Flow로 변환
dongx0915 Mar 31, 2024
d367229
[refactor] #344 로그인 요청 부분 Flow로 변환
dongx0915 Mar 31, 2024
af3c8da
[refactor] #344 코스 상세 조회 부분 Flow로 변환
dongx0915 Mar 31, 2024
f8a5d67
[refactor] #344 코스 수정 부분 Flow로 변환
dongx0915 Mar 31, 2024
bdb2560
[refactor] #344 내가 그린 코스 삭제 부분 Flow로 변환
dongx0915 Apr 2, 2024
f33d8a8
[refactor] #344 collect -> collectResult 수정
dongx0915 Apr 9, 2024
77d600b
Merge branch 'feature/refactor-api-flow-draw-course' of into feature/…
dongx0915 Apr 9, 2024
6e0e57d
[refactor] #344 유저 프로필 조회 Flow로 변환
dongx0915 Apr 10, 2024
012e3e2
[fix] #344 ResponseInterceptor BaseResponse 체크 구문 수정
dongx0915 Apr 10, 2024
5c31c0e
[refactor] #344 CourseService V2 명칭 변경
dongx0915 Apr 13, 2024
3a7a767
[refactor] #344 LoginService V2 명칭 변경
dongx0915 Apr 13, 2024
09c0633
[refactor] #344 코드 정리
dongx0915 Apr 13, 2024
05fb441
Merge branch 'develop' into feature/refactor-api-flow-discover-mypage
dongx0915 Apr 30, 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
11 changes: 0 additions & 11 deletions app/src/main/java/com/runnect/runnect/data/dto/LocationData.kt

This file was deleted.

1 change: 0 additions & 1 deletion app/src/main/java/com/runnect/runnect/data/dto/LoginDTO.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.runnect.runnect.data.dto

data class LoginDTO(
val status: Int,
val accessToken: String,
val refreshToken: String,
val email: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,29 @@ import kotlinx.serialization.Serializable
@Serializable
data class ResponseGetMyDrawCourse(
@SerialName("courses")
val courses: List<Course>,
val courses: List<Course>?,
@SerialName("user")
val user: User,
val user: User?,
) {
@Serializable
data class Course(
@SerialName("createdAt")
val createdAt: String,
val createdAt: String?,
@SerialName("departure")
val departure: Departure,
val departure: Departure?,
@SerialName("id")
val id: Int,
val id: Int?,
@SerialName("image")
val image: String,
val image: String?,
@SerialName("title")
val title: String
val title: String?
) {
@Serializable
data class Departure(
@SerialName("city")
val city: String,
val city: String?,
@SerialName("region")
val region: String,
val region: String?,
)
}

Expand All @@ -41,13 +41,17 @@ data class ResponseGetMyDrawCourse(
}

fun ResponseGetMyDrawCourse.toMyDrawCourse(): List<MyDrawCourse> {
return this.courses.map {
MyDrawCourse(
courseId = it.id,
image = it.image,
city = it.departure.city,
region = it.departure.region,
title = it.title
)

return if (this.courses.isNullOrEmpty()) emptyList()
else {
this.courses.map {
MyDrawCourse(
courseId = it.id,
image = it.image,
city = it.departure?.city ?: "", //todo - 예외 처리 논의
region = it.departure?.region ?: "",
title = it.title ?: ""
)
}
}
}
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,
)
}
}

}
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]}”"
}
}
}
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 }
}
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
)
}
}
Loading
Loading