Skip to content

Commit

Permalink
Merge pull request #341 from Runnect/feature/feat-my-draw-course-shar…
Browse files Browse the repository at this point in the history
…e-edit

[FEAT] 보관함 / 내가 그린 코스 수정, 삭제, 공유 기능 구현
  • Loading branch information
leeeha committed May 2, 2024
2 parents d8dd161 + 22787ff commit 474d4a1
Show file tree
Hide file tree
Showing 40 changed files with 1,306 additions and 836 deletions.
7 changes: 4 additions & 3 deletions app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE"
<uses-permission
android:name="android.permission.READ_PRIVILEGED_PHONE_STATE"
tools:ignore="ProtectedPermissions" />

<application
android:name=".application.ApplicationClass"
android:allowBackup="true"
android:allowBackup="false"
android:dataExtractionRules="@xml/data_extraction_rules"
android:enableOnBackInvokedCallback="true"
android:fullBackupContent="@xml/backup_rules"
android:fullBackupContent="false"
android:icon="@mipmap/ic_runnect_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_runnect_launcher_round"
Expand Down
42 changes: 26 additions & 16 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

<application
android:name=".application.ApplicationClass"
android:allowBackup="true"
android:allowBackup="false"
android:dataExtractionRules="@xml/data_extraction_rules"
android:enableOnBackInvokedCallback="true"
android:fullBackupContent="@xml/backup_rules"
android:fullBackupContent="false"
android:icon="@mipmap/ic_runnect_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_runnect_launcher_round"
Expand Down Expand Up @@ -58,21 +58,43 @@
android:scheme="@string/kakao_redirection_scheme" />
</intent-filter>
</activity>

<activity
android:name=".presentation.login.LoginActivity"
android:exported="false" />

<activity
android:name=".presentation.mydrawdetail.MyDrawDetailActivity"
android:name=".presentation.storage.mydrawdetail.MyDrawDetailActivity"
android:exported="false" />

<activity
android:name=".presentation.scheme.SchemeActivity"
android:exported="true">

<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data
android:host="rnnt.page.link"
android:scheme="https" />
</intent-filter>

</activity>

<activity
android:name=".presentation.splash.SplashActivity"
android:exported="true"
android:theme="@style/SplashTheme">

<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

</activity>
<activity
android:name=".presentation.endrun.EndRunActivity"
Expand Down Expand Up @@ -111,19 +133,7 @@
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".presentation.detail.CourseDetailActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data
android:host="rnnt.page.link"
android:scheme="https" />
</intent-filter>
</activity>

android:exported="false" />
<activity
android:name=".presentation.mypage.reward.MyRewardActivity"
android:exported="false" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class ApplicationClass : Application() {
!::appContext.isInitialized -> BuildConfig.RUNNECT_PROD_URL
else -> {
val mode = ApiMode.getCurrentApiMode(appContext)
Timber.d("현재 서버: ${mode}")
when (mode) {
ApiMode.JAVA -> BuildConfig.RUNNECT_PROD_URL
ApiMode.TEST -> BuildConfig.RUNNECT_DEV_URL
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.runnect.runnect.data.dto.request

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

@Serializable
data class RequestPatchMyDrawCourseTitle(
@SerialName("title")
val title: String
)
Original file line number Diff line number Diff line change
@@ -1,61 +1,61 @@
package com.runnect.runnect.data.dto.response


import com.runnect.runnect.domain.entity.MyDrawCourseDetail
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("user")
val user: User,
@SerialName("course")
val course: Course
) {
@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("isNowUser")
val isNowUser: Boolean,
@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,
)
}
}

fun toMyDrawCourseDetail() = MyDrawCourseDetail(
title = course.title,
imgUrl = course.image,
isNowUser = course.isNowUser,
distance = course.distance,
courseId = course.id,
path = course.path,
departureName = course.departure.name
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.runnect.runnect.data.dto.response

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

@Serializable
data class ResponsePatchMyDrawCourseTitle(
@SerialName("course")
val course: Course
) {
@Serializable
data class Course(
@SerialName("id")
val id: Int,
@SerialName("title")
val title: String
)

fun toEditableMyDrawCourseDetail() = EditableMyDrawCourseDetail(
title = course.title
)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.runnect.runnect.data.repository

import com.runnect.runnect.data.dto.request.RequestPatchMyDrawCourseTitle
import com.runnect.runnect.domain.entity.CourseDetail
import com.runnect.runnect.data.dto.request.RequestPostCourseScrap
import com.runnect.runnect.data.dto.request.RequestPostRunningHistory
Expand Down Expand Up @@ -67,8 +68,15 @@ class CourseRepositoryImpl @Inject constructor(private val remoteCourseDataSourc
return remoteCourseDataSource.deleteMyDrawCourse(deleteCourseList = deleteCourseList)
}

override suspend fun getMyDrawDetail(courseId: Int): Response<ResponseGetMyDrawDetail> {
return remoteCourseDataSource.getMyDrawDetail(courseId = courseId)
override suspend fun getMyDrawDetail(courseId: Int) = runCatching {
remoteCourseDataSource.getMyDrawDetail(courseId).data?.toMyDrawCourseDetail()
}

override suspend fun patchMyDrawCourseTitle(
courseId: Int,
requestPatchMyDrawCourseTitle: RequestPatchMyDrawCourseTitle
) = runCatching {
remoteCourseDataSource.patchMyDrawCourseTitle(courseId, requestPatchMyDrawCourseTitle).data?.toEditableMyDrawCourseDetail()
}

override suspend fun postRecord(request: RequestPostRunningHistory): Response<ResponsePostMyHistory> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.runnect.runnect.data.service

import com.runnect.runnect.data.dto.request.RequestPatchMyDrawCourseTitle
import com.runnect.runnect.data.dto.request.RequestPatchPublicCourse
import com.runnect.runnect.data.dto.request.RequestPostCourseScrap
import com.runnect.runnect.data.dto.request.RequestPostPublicCourse
Expand All @@ -12,6 +13,7 @@ import com.runnect.runnect.data.dto.response.ResponseGetDiscoverUploadCourse
import com.runnect.runnect.data.dto.response.ResponseGetMyDrawCourse
import com.runnect.runnect.data.dto.response.ResponseGetMyDrawDetail
import com.runnect.runnect.data.dto.response.ResponseGetMyScrapCourse
import com.runnect.runnect.data.dto.response.ResponsePatchMyDrawCourseTitle
import com.runnect.runnect.data.dto.response.ResponsePatchPublicCourse
import com.runnect.runnect.data.dto.response.ResponsePostDiscoverUpload
import com.runnect.runnect.data.dto.response.ResponsePostMyDrawCourse
Expand Down Expand Up @@ -61,34 +63,39 @@ interface CourseService {
@Body requestPatchPublicCourse: RequestPatchPublicCourse
): BaseResponse<ResponsePatchPublicCourse>

// {id}와 같이 동적인 경로 변수가 없다면 @Path 생략 가능
//내가 그린 코스 수정
@PUT("/api/course")
suspend fun deleteMyDrawCourse(
@Body deleteCourseList: RequestPutMyDrawCourse
): Response<ResponsePutMyDrawCourse>

//보관함 내가 그린 코스 가져오기
// 보관함 내가 그린 코스 가져오기
@GET("/api/course/user")
suspend fun getDrawCourseList(): BaseResponse<ResponseGetMyDrawCourse>

//보관함 스크랩 코스 가져오기
// 보관함 스크랩 코스 가져오기
@GET("/api/scrap/user")
suspend fun getScrapCourseList(): BaseResponse<ResponseGetMyScrapCourse>

//내가 그린 코스 Detail 가져오기
// 내가 그린 코스 Detail 가져오기
@GET("/api/course/detail/{courseId}")
suspend fun getMyDrawDetail(
@Path("courseId") courseId: Int,
): Response<ResponseGetMyDrawDetail>
): BaseResponse<ResponseGetMyDrawDetail>

//기록 업로드
// 내가 그린 코스 제목 수정
@PATCH("/api/course/{courseId}")
suspend fun patchMyDrawCourseTitle(
@Path("courseId") courseId: Int,
@Body requestPatchMyDrawCourseTitle: RequestPatchMyDrawCourseTitle
): BaseResponse<ResponsePatchMyDrawCourseTitle>

// 기록 업로드
@POST("/api/record")
suspend fun postRecord(
@Body request: RequestPostRunningHistory
): Response<ResponsePostMyHistory>

//코스 업로드
// 코스 업로드
@Multipart
@POST("/api/course")
suspend fun uploadCourse(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.runnect.runnect.data.source.remote

import com.runnect.runnect.data.dto.request.RequestPatchMyDrawCourseTitle
import com.runnect.runnect.data.dto.request.RequestPatchPublicCourse
import com.runnect.runnect.data.dto.request.RequestPostCourseScrap
import com.runnect.runnect.data.dto.request.RequestPostPublicCourse
Expand Down Expand Up @@ -54,6 +55,11 @@ class RemoteCourseDataSource @Inject constructor(

suspend fun getMyDrawDetail(courseId: Int) = courseService.getMyDrawDetail(courseId)

suspend fun patchMyDrawCourseTitle(
courseId: Int,
requestPatchMyDrawCourseTitle: RequestPatchMyDrawCourseTitle
) = courseService.patchMyDrawCourseTitle(courseId, requestPatchMyDrawCourseTitle)

suspend fun postRecord(request: RequestPostRunningHistory) = courseService.postRecord(request)

suspend fun uploadCourse(image: MultipartBody.Part, data: RequestBody) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ sealed class DiscoverMultiViewItem(
data class MarathonCourse(
override val id: Int,
val courseId: Int,
var title: String,
val title: String,
val image: String,
var scrap: Boolean,
val scrap: Boolean,
val departure: String,
) : DiscoverMultiViewItem(id)

data class RecommendCourse(
override val id: Int,
val courseId: Int,
var title: String,
val title: String,
val image: String,
var scrap: Boolean,
val scrap: Boolean,
val departure: String,
) : DiscoverMultiViewItem(id)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package com.runnect.runnect.domain.entity
data class DiscoverSearchCourse(
val id: Int,
val courseId: Int,
var title: String,
val title: String,
val image: String,
var scrap: Boolean,
val scrap: Boolean,
val departure: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.runnect.runnect.domain.entity

data class EditableMyDrawCourseDetail(
val title: String
)
Loading

0 comments on commit 474d4a1

Please sign in to comment.