Skip to content

Commit

Permalink
Merge pull request #275 from Runnect/feature/refactor-course-detail-s…
Browse files Browse the repository at this point in the history
…creen

[REFACTOR] 코스 상세페이지 / 전면 리팩토링
  • Loading branch information
leeeha authored Nov 16, 2023
2 parents db27254 + bc34a5d commit 95b7c84
Show file tree
Hide file tree
Showing 68 changed files with 1,139 additions and 1,292 deletions.
20 changes: 14 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'

id 'kotlin-android-extensions'
//serialization
//id 'kotlin-parcelize'

id 'org.jetbrains.kotlin.plugin.serialization' version '1.7.20'
//hilt
id 'dagger.hilt.android.plugin'
//plugin for databinding & hilt

// plugin for data binding, hilt
id 'kotlin-kapt'
//for hiding keys used in manifest

// plugin for hiding keys used in manifest
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'

// Add the Google services Gradle plugin
id("com.google.gms.google-services")
id 'com.google.gms.google-services'
}

Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())

android {
namespace 'com.runnect.runnect'
compileSdk 33
Expand All @@ -36,6 +41,7 @@ android {
buildConfigField "String", "REMOTE_KEY_APP_VERSION", properties["REMOTE_KEY_APP_VERSION"]

}

buildFeatures {
buildConfig = true
}
Expand All @@ -46,21 +52,23 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = '1.8'
}

buildFeatures {
dataBinding true
viewBinding true
}
}

dependencies {

implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.8.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.runnect.runnect.data.dto


import android.os.Parcelable
import com.naver.maps.geometry.LatLng
import kotlinx.android.parcel.Parcelize

@Parcelize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.google.gson.annotations.SerializedName
import kotlinx.serialization.Serializable

@Serializable
data class RequestDeleteUploadCourse(
data class RequestDeleteUploadCourseDto(
@SerializedName("publicCourseIdList")
val publicCourseIdList: List<Int>
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import com.google.gson.annotations.SerializedName
import kotlinx.serialization.Serializable

@Serializable
data class RequestUpdatePublicCourse(
data class RequestPatchPublicCourseDto(
@SerializedName("title")
val title: String,
@SerializedName("description")
val description: String,
@SerializedName("title")
val title: String
)

This file was deleted.

This file was deleted.

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

import com.google.gson.annotations.SerializedName
import kotlinx.serialization.Serializable
@Serializable
data class ResponseDeleteUploadCourseDto(
@SerializedName("deletedPublicCourseCount")
val deletedPublicCourseCount: Int
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package com.runnect.runnect.data.dto.response


import com.runnect.runnect.domain.entity.CourseDetail
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class ResponseGetCourseDetailDto(
@SerialName("user")
val user: User,
@SerialName("publicCourse")
val publicCourse: PublicCourse
) {
@Serializable
data class User(
@SerialName("nickname")
val nickname: String,
@SerialName("level")
val level: Int,
@SerialName("image")
val image: String,
@SerialName("isNowUser")
val isNowUser: Boolean
)

@Serializable
data class PublicCourse(
@SerialName("id")
val id: Int,
@SerialName("courseId")
val courseId: Int,
@SerialName("scrap")
val scrap: Boolean,
@SerialName("image")
val image: String,
@SerialName("title")
val title: String,
@SerialName("description")
val description: String,
@SerialName("path")
val path: List<List<Double>>,
@SerialName("distance")
val distance: Double,
@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?
)
}

fun toCourseDetail() = CourseDetail(
stampId = user.image,
level = user.level.toString(),
nickname = user.nickname,
isNowUser = user.isNowUser,
id = publicCourse.id,
courseId = publicCourse.courseId,
departure = publicCourse.departure.region + ' ' +
publicCourse.departure.city + ' ' +
publicCourse.departure.town + ' ' +
((publicCourse.departure.name) ?: ""),
description = publicCourse.description,
distance = publicCourse.distance.toString(),
image = publicCourse.image,
isScrap = publicCourse.scrap,
title = publicCourse.title,
path = publicCourse.path
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,17 @@ import com.google.gson.annotations.SerializedName
import kotlinx.serialization.Serializable

@Serializable
data class ResponseUpdatePublicCourse(
@SerializedName("data")
val `data`: UpdatePublicCourseData,
@SerializedName("message")
val message: String,
@SerializedName("status")
val status: Int,
@SerializedName("success")
val success: Boolean
data class ResponsePatchPublicCourseDto(
@SerializedName("publicCourse")
val publicCourse: PublicCourse
)

@Serializable
data class PublicCourse(
@SerializedName("description")
val description: String,
@SerializedName("id")
val id: Int,
@SerializedName("title")
val title: String
val title: String,
@SerializedName("description")
val description: String
)

@Serializable
data class UpdatePublicCourseData(
@SerializedName("publicCourse")
val publicCourse: PublicCourse
)
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package com.runnect.runnect.data.repository

import com.runnect.runnect.data.dto.CourseDetailDTO
import com.runnect.runnect.domain.entity.CourseDetail
import com.runnect.runnect.data.dto.CourseLoadInfoDTO
import com.runnect.runnect.data.dto.CourseSearchDTO
import com.runnect.runnect.data.dto.RecommendCourseDTO
import com.runnect.runnect.data.dto.request.RequestCourseScrap
import com.runnect.runnect.data.dto.request.RequestPostRecordDTO
import com.runnect.runnect.data.dto.request.RequestPutMyDrawDTO
import com.runnect.runnect.data.dto.request.RequestUpdatePublicCourse
import com.runnect.runnect.data.dto.request.RequestPatchPublicCourseDto
import com.runnect.runnect.data.dto.request.RequestUploadMyCourse
import com.runnect.runnect.data.dto.response.PublicCourse
import com.runnect.runnect.data.dto.response.ResponseCourseScrap
import com.runnect.runnect.data.dto.response.ResponseGetMyDrawDetailDTO
import com.runnect.runnect.data.dto.response.ResponsePostCourseDTO
import com.runnect.runnect.data.dto.response.ResponsePostRecordDTO
import com.runnect.runnect.data.dto.response.ResponsePutMyDrawDTO
import com.runnect.runnect.data.dto.response.ResponseUpdatePublicCourse
import com.runnect.runnect.data.dto.response.ResponseUploadMyCourse
import com.runnect.runnect.data.source.remote.RemoteCourseDataSource
import com.runnect.runnect.domain.CourseRepository
Expand All @@ -27,37 +27,40 @@ import javax.inject.Inject
class CourseRepositoryImpl @Inject constructor(private val remoteCourseDataSource: RemoteCourseDataSource) :
CourseRepository {
override suspend fun getRecommendCourse(pageNo: String?): MutableList<RecommendCourseDTO> {
return remoteCourseDataSource.getRecommendCourse(pageNo = pageNo).data.publicCourses.map { it.toData() }.toMutableList()
return remoteCourseDataSource.getRecommendCourse(pageNo = pageNo).data.publicCourses.map { it.toData() }
.toMutableList()
}

override suspend fun postCourseScrap(requestCourseScrap: RequestCourseScrap): ResponseCourseScrap {
return remoteCourseDataSource.postCourseScrap(requestCourseScrap = requestCourseScrap)
}

override suspend fun getCourseSearch(keyword: String): MutableList<CourseSearchDTO> {
return remoteCourseDataSource.getCourseSearch(keyword = keyword).data.publicCourses.map { it.toData() }.toMutableList()
return remoteCourseDataSource.getCourseSearch(keyword = keyword).data.publicCourses.map { it.toData() }
.toMutableList()
}

override suspend fun getCourseDetail(publicCourseId: Int): CourseDetailDTO {
return remoteCourseDataSource.getCourseDetail(publicCourseId = publicCourseId).data.toData()
override suspend fun getCourseDetail(publicCourseId: Int): Result<CourseDetail?> = runCatching {
remoteCourseDataSource.getCourseDetail(publicCourseId = publicCourseId).data?.toCourseDetail()
}

override suspend fun getMyCourseLoad(): MutableList<CourseLoadInfoDTO> {
return remoteCourseDataSource.getMyCourseLoad().data.privateCourses.map { it.toData() }.toMutableList()
return remoteCourseDataSource.getMyCourseLoad().data.privateCourses.map { it.toData() }
.toMutableList()
}

override suspend fun postUploadMyCourse(requestUploadMyCourse: RequestUploadMyCourse): ResponseUploadMyCourse {
return remoteCourseDataSource.postUploadMyCourse(requestUploadMyCourse = requestUploadMyCourse)
}

override suspend fun patchUpdatePublicCourse(
override suspend fun patchPublicCourse(
publicCourseId: Int,
requestUpdatePublicCourse: RequestUpdatePublicCourse
): ResponseUpdatePublicCourse {
return remoteCourseDataSource.patchUpdatePublicCourse(
requestPatchPublicCourse: RequestPatchPublicCourseDto
): Result<PublicCourse?> = runCatching {
remoteCourseDataSource.patchPublicCourse(
publicCourseId = publicCourseId,
requestUpdatePublicCourse = requestUpdatePublicCourse
)
requestPatchPublicCourseDto = requestPatchPublicCourse
).data?.publicCourse
}

override suspend fun deleteMyDrawCourse(deleteCourseList: RequestPutMyDrawDTO): Response<ResponsePutMyDrawDTO> {
Expand Down
Loading

0 comments on commit 95b7c84

Please sign in to comment.