generated from IN-SOPT-ANDROID/in-sopt-android-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
233 additions
and
98 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.sopt.sample.api | ||
|
||
import okhttp3.MultipartBody | ||
import org.sopt.sample.data.dto.request.RequestRegisterMusicDto | ||
import org.sopt.sample.data.dto.response.ResponseGetMusicListDto | ||
import org.sopt.sample.data.dto.response.ResponseRegisterMusicDto | ||
import retrofit2.http.* // ktlint-disable no-wildcard-imports | ||
|
||
interface MusicService { | ||
// 음악 리스트 조회 API | ||
@GET("music/list") | ||
suspend fun getMusicList(): ResponseGetMusicListDto | ||
|
||
// 음악 생성 API | ||
@Multipart | ||
@POST("music") | ||
suspend fun registerMusic( | ||
@Part image: MultipartBody.Part?, | ||
@Body requestRegisterMusic: RequestRegisterMusicDto | ||
): ResponseRegisterMusicDto | ||
} |
9 changes: 9 additions & 0 deletions
9
app/src/main/java/org/sopt/sample/data/dto/request/RequestRegisterMusicDto.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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.sopt.sample.data.dto.request | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class RequestRegisterMusicDto( | ||
val singer: String, | ||
val title: String | ||
) |
19 changes: 19 additions & 0 deletions
19
app/src/main/java/org/sopt/sample/data/dto/response/ResponseGetMusicListDto.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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.sopt.sample.data.dto.response | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ResponseGetMusicListDto( | ||
val statusCode: Int, | ||
val success: Boolean, | ||
val message: String, | ||
val data: List<Music> | ||
) { | ||
@Serializable | ||
data class Music( | ||
val id: Int, | ||
val image: String, | ||
val title: String, | ||
val singer: String | ||
) | ||
} |
11 changes: 11 additions & 0 deletions
11
app/src/main/java/org/sopt/sample/data/dto/response/ResponseRegisterMusicDto.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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.sopt.sample.data.dto.response | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ResponseRegisterMusicDto( | ||
val statusCode: Int, | ||
val success: Boolean, | ||
val message: String, | ||
val data: ResponseGetMusicListDto.Music | ||
) |
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 |
---|---|---|
|
@@ -2,5 +2,6 @@ package org.sopt.sample.data.local | |
|
||
enum class BaseUrlType { | ||
IN_SOPT, | ||
REQRES | ||
REQRES, | ||
MUSIC | ||
} |
15 changes: 15 additions & 0 deletions
15
app/src/main/java/org/sopt/sample/data/repository/MusicRepository.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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.sopt.sample.data.repository | ||
|
||
import okhttp3.MultipartBody | ||
import org.sopt.sample.data.dto.request.RequestRegisterMusicDto | ||
import org.sopt.sample.data.dto.response.ResponseGetMusicListDto | ||
import org.sopt.sample.data.dto.response.ResponseRegisterMusicDto | ||
|
||
interface MusicRepository { | ||
suspend fun getMusicList(): Result<ResponseGetMusicListDto> | ||
|
||
suspend fun registerMusic( | ||
image: MultipartBody.Part, | ||
requestRegisterMusicDto: RequestRegisterMusicDto | ||
): Result<ResponseRegisterMusicDto> | ||
} |
21 changes: 21 additions & 0 deletions
21
app/src/main/java/org/sopt/sample/data/repository/MusicRepositoryImpl.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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.sopt.sample.data.repository | ||
|
||
import okhttp3.MultipartBody | ||
import org.sopt.sample.data.dto.request.RequestRegisterMusicDto | ||
import org.sopt.sample.data.dto.response.ResponseGetMusicListDto | ||
import org.sopt.sample.data.dto.response.ResponseRegisterMusicDto | ||
import org.sopt.sample.data.source.MusicDataSource | ||
import javax.inject.Inject | ||
|
||
class MusicRepositoryImpl @Inject constructor( | ||
private val musicDataSource: MusicDataSource | ||
) : MusicRepository { | ||
override suspend fun getMusicList(): Result<ResponseGetMusicListDto> = | ||
kotlin.runCatching { musicDataSource.getMusicList() } | ||
|
||
override suspend fun registerMusic( | ||
image: MultipartBody.Part, | ||
requestRegisterMusicDto: RequestRegisterMusicDto | ||
): Result<ResponseRegisterMusicDto> = | ||
kotlin.runCatching { musicDataSource.registerMusic(image, requestRegisterMusicDto) } | ||
} |
18 changes: 18 additions & 0 deletions
18
app/src/main/java/org/sopt/sample/data/source/MusicDataSource.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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.sopt.sample.data.source | ||
|
||
import okhttp3.MultipartBody | ||
import org.sopt.sample.api.MusicService | ||
import org.sopt.sample.data.dto.request.RequestRegisterMusicDto | ||
import org.sopt.sample.data.dto.response.ResponseGetMusicListDto | ||
import org.sopt.sample.data.dto.response.ResponseRegisterMusicDto | ||
import javax.inject.Inject | ||
|
||
class MusicDataSource @Inject constructor( | ||
private val musicService: MusicService | ||
) { | ||
suspend fun getMusicList(): ResponseGetMusicListDto = | ||
musicService.getMusicList() | ||
|
||
suspend fun registerMusic(image: MultipartBody.Part, requestRegisterMusic: RequestRegisterMusicDto): ResponseRegisterMusicDto = | ||
musicService.registerMusic(image, requestRegisterMusic) | ||
} |
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
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
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
19 changes: 19 additions & 0 deletions
19
app/src/main/java/org/sopt/sample/presentation/main/music/MusicFragment.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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.sopt.sample.presentation.main.music | ||
|
||
import android.os.Bundle | ||
import android.view.View | ||
import org.sopt.sample.R | ||
import org.sopt.sample.databinding.FragmentMusicBinding | ||
import org.sopt.sample.util.binding.BindingFragment | ||
|
||
class MusicFragment : BindingFragment<FragmentMusicBinding>(R.layout.fragment_music) { | ||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
} | ||
|
||
companion object { | ||
fun newInstance(): MusicFragment { | ||
return MusicFragment() | ||
} | ||
} | ||
} |
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
29 changes: 0 additions & 29 deletions
29
app/src/main/java/org/sopt/sample/presentation/main/user/UserFragment.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<vector android:height="24dp" android:tint="#FFFFFF" | ||
android:viewportHeight="24" android:viewportWidth="24" | ||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="@android:color/white" android:pathData="M20,2L8,2c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L22,4c0,-1.1 -0.9,-2 -2,-2zM18,7h-3v5.5c0,1.38 -1.12,2.5 -2.5,2.5S10,13.88 10,12.5s1.12,-2.5 2.5,-2.5c0.57,0 1.08,0.19 1.5,0.51L14,5h4v2zM4,6L2,6v14c0,1.1 0.9,2 2,2h14v-2L4,20L4,6z"/> | ||
</vector> |
Oops, something went wrong.