Skip to content

Commit

Permalink
Merge pull request #288 from Hyeonz1/main
Browse files Browse the repository at this point in the history
[AOS/REFACTOR] ApiResponse 적용
  • Loading branch information
Hyeonz1 authored Feb 27, 2024
2 parents 7a01e0a + e4acc30 commit d057833
Show file tree
Hide file tree
Showing 16 changed files with 188 additions and 135 deletions.
1 change: 1 addition & 0 deletions AOS/AOS-README.md → AOS/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# EEOS Android README
## 📸 Screen Shots
|로그인|홈 화면|멤버 상태 변경|행사 세부 내용|출석 상태 선택|
|:---:|:---:|:---:|:---:|:---:|
Expand Down
43 changes: 20 additions & 23 deletions AOS/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ android {
minSdk 31
targetSdk 33
versionCode 1
versionName "1.0"
versionName "0.1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down Expand Up @@ -85,9 +85,14 @@ android {
}

ktlint {
// version = "0.50.0"
android = true
ignoreFailures = false
disabledRules = ["no-wildcard-imports", "indent"]
/*
additionalEditorconfig = [
"max_line_length": "150"
]*/
reporters {
reporter "plain"
reporter "checkstyle"
Expand All @@ -96,46 +101,38 @@ ktlint {
}

dependencies {
implementation 'androidx.datastore:datastore-core:1.0.0'
def nav_version = "2.6.0"

/* Kotlin 관련 Dependency */
implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.0"))
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
implementation 'androidx.activity:activity-compose:1.5.1'
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1"

/* Jetpack Compose 관련 Dependency */
implementation platform('androidx.compose:compose-bom:2023.06.01')
implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.0"))
implementation 'androidx.compose.ui:ui'
implementation 'androidx.compose.ui:ui-graphics'
implementation 'androidx.compose.ui:ui-tooling-preview'
implementation 'androidx.compose.material3:material3'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
// androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
debugImplementation 'androidx.compose.ui:ui-tooling'
debugImplementation 'androidx.compose.ui:ui-test-manifest'
implementation 'androidx.compose.material3:material3'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
implementation 'androidx.activity:activity-compose:1.5.1'
implementation "androidx.navigation:navigation-compose:$nav_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1"

// Hilt Dependency
/* Hilt 관련 Dependency */
implementation "com.google.dagger:hilt-android:2.44"
kapt "com.google.dagger:hilt-compiler:2.44"
implementation 'androidx.hilt:hilt-navigation-compose:1.0.0'
implementation 'androidx.hilt:hilt-navigation-fragment:1.0.0'

// Retrofit Dependency
/* Retrofit 관련 Dependency */
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'

// define a BOM and its version
/* Okhttp3 관련 Dependency */
implementation(platform("com.squareup.okhttp3:okhttp-bom:4.11.0"))
implementation 'com.squareup.okhttp3:logging-interceptor'

// define any required OkHttp artifacts without version
implementation("com.squareup.okhttp3:okhttp")
implementation("com.squareup.okhttp3:logging-interceptor")

implementation "com.github.skydoves:landscapist-glide:2.1.2"
/* 이외의 Dependency */
implementation "com.github.skydoves:sandwich:1.3.3"
implementation "com.halilibo.compose-richtext:richtext-commonmark:0.11.0"
}

// Allow references to generated code
Expand Down
2 changes: 1 addition & 1 deletion AOS/app/src/main/java/com/example/eeos/consts/Consts.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.example.eeos.consts

val category = listOf("all", "weekly", "presidentTeam", "eventTeam", "etc")
val programCategory = listOf("all", "weekly", "presidentTeam", "eventTeam", "etc")
val programStatus = listOf("active", "end")

val categoryChips: List<String> = listOf(
Expand Down
62 changes: 62 additions & 0 deletions AOS/app/src/main/java/com/example/eeos/consts/ErrorCode.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,65 @@
package com.example.eeos.consts

/** [1XXX] 프로그램 관련 에러
* - PROGRAM_NOT_FOUND : 존재하지 않는 프로그램입니다.
* - CREATION_DATE_INVALID : 오늘 이후 날짜에 해당하는 행사만 생성할 수 있습니다.
* - CATEGORY_NOT_FOUND : 존재하지 않는 프로그램 카테고리입니다.
* - PROGRAM_TYPE_NOT_FOUND : 존재하지 않는 프로그램 타입입니다.
* - PROGRAM_STATUS_NOT_FOUND : 존재하지 않는 프로그램 상태입니다.
* - EDIT_PERMISSION_DENIED : 프로그램 편집 권한이 없는 사용자입니다.
* - PROGRAM_TYPE_CHANGE_DENIED : 프로그램 수요조사 여부는 수정할 수 없습니다.
* - PROGRAM_IN_PROGRESS : 진행 중인 프로그램의 대상자를 수정할 수 없습니다.
*/
const val PROGRAM_NOT_FOUND = "1000"
const val CREATION_DATE_INVALID = "1001"
const val CATEGORY_NOT_FOUND = "1002"
const val PROGRAM_TYPE_NOT_FOUND = "1003"
const val PROGRAM_STATUS_NOT_FOUND = "1004"
const val EDIT_PERMISSION_DENIED = "1005"
const val PROGRAM_TYPE_CHANGE_DENIED = "1006"
const val PROGRAM_IN_PROGRESS = "1007"



/** [2XXX] 행사 참여 상태 변경과 관련된 에러
* - ATTEND_STATUS_NOT_FOUND : 존재하지 않는 참석 상태입니다.
* - PREVIOUS_ATTEND_STATUS_INCORRECT : 회원의 이전 상태가 올바르지 않습니다.
* - ATTEND_STATUS_ALREADY_CHANGED : {name} 회원의 상태 변경을 다른 멤버가 수행했습니다.
* - PROGRAM_EXPIRED : 프로그램 마감 기한이 지난 후 참석 상태 변경은 불가능합니다.
* - ATTEND_INFO_NOT_FOUND : 존재하지 않는 참석 정보입니다.
* - USER_NON_RELATED : 프로그램의 참석 대상자가 아닙니다.
*/
const val ATTEND_STATUS_NOT_FOUND = "2000"
const val PREVIOUS_ATTEND_STATUS_INCORRECT = "2001"
const val ATTEND_STATUS_ALREADY_CHANGED = "2002"
const val PROGRAM_EXPIRED = "2003"
const val ATTEND_INFO_NOT_FOUND = "2004"
const val USER_NON_RELATED = "2005"



/** [3XXX] 멤버 관련 에러
* - MEMBER_NOT_FOUND : 존재하지 않는 멤버입니다.
* - ACTIVE_STATUS_NOT_FOUND : 존재하지 않는 활동 상태입니다.
* - ACTIVE_STATUS_BANNED : %s 활동 상태로 변경은 금지되었습니다.
*/
const val MEMBER_NOT_FOUND = "3000"
const val ACTIVE_STATUS_NOT_FOUND = "3001"
const val ACTIVE_STATUS_BANNED = "3002"



/** [4XXX] 인증/인가 관련 에러
* - ACCESS_TOKEN_NOT_FOUND : 액세스 토큰이 존재하지 않습니다.
* - ACCESS_TOKEN_EXPIRED : 엑세스 토큰이 만료되었습니다.
* - OAUTH_SERVER_NOT_FOUND : 존재하지 않는 OAUTH 서버입니다.
* - REFRESH_TOKEN_NOT_FOUND : 리프레쉬 토큰이 존재하지 않습니다.
* - REFRESH_TOKEN_EXPIRED : 리프레쉬 토큰이 만료되었습니다.
* - USER_NAME_INVALID : %s 유저의 이름이 형식과 일치하지 않습니다.
*/
const val ACCESS_TOKEN_NOT_FOUND = "4000"
const val ACCESS_TOKEN_EXPIRED = "4001"
const val OAUTH_SERVER_NOT_FOUND = "4002"
const val REFRESH_TOKEN_NOT_FOUND = "4004"
const val REFRESH_TOKEN_EXPIRED = "4005"
const val USER_NAME_INVALID = "4006"
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
package com.example.eeos.data.repository

import com.example.eeos.data.model.remote.request.RequestPutActiveStatusDto
import com.example.eeos.data.model.remote.response.ResponseGetActiveStatusDto
import com.example.eeos.data.model.remote.response.ResponsePutActiveStatusDto
import com.example.eeos.data.model.remote.response.base.BaseResponse
import com.example.eeos.data.source.InfoDataSource
import com.example.eeos.domain.model.ActiveStatus
import com.example.eeos.domain.repository.InfoRepository
import com.skydoves.sandwich.ApiResponse
import javax.inject.Inject

class InfoRepositoryImpl @Inject constructor(
private val infoDataSource: InfoDataSource
) : InfoRepository {
override suspend fun getActiveStatus(): Result<ActiveStatus> =
runCatching {
infoDataSource.getActiveStatus().data!!.toActiveStatus()
}
override suspend fun getActiveStatus(): ApiResponse<BaseResponse<ResponseGetActiveStatusDto>> =
infoDataSource.getActiveStatus()

override suspend fun putActiveStatus(requestPutActiveStatusDto: RequestPutActiveStatusDto): Result<Unit> =
runCatching {
infoDataSource.putActiveStatus(requestPutActiveStatusDto).data
}
override suspend fun putActiveStatus(requestPutActiveStatusDto: RequestPutActiveStatusDto): ApiResponse<BaseResponse<ResponsePutActiveStatusDto>> =
infoDataSource.putActiveStatus(requestPutActiveStatusDto)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ import com.example.eeos.data.model.remote.request.RequestPutActiveStatusDto
import com.example.eeos.data.model.remote.response.ResponseGetActiveStatusDto
import com.example.eeos.data.model.remote.response.ResponsePutActiveStatusDto
import com.example.eeos.data.model.remote.response.base.BaseResponse
import com.skydoves.sandwich.ApiResponse
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.PUT

interface InfoService {
@GET("members/activeStatus")
suspend fun getActiveStatus(): BaseResponse<ResponseGetActiveStatusDto>
suspend fun getActiveStatus(): ApiResponse<BaseResponse<ResponseGetActiveStatusDto>>

@PUT("members/activeStatus")
suspend fun putActiveStatus(
@Body requestPutActiveStatusDto: RequestPutActiveStatusDto
): BaseResponse<ResponsePutActiveStatusDto>
): ApiResponse<BaseResponse<ResponsePutActiveStatusDto>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ import com.example.eeos.data.model.remote.response.ResponseGetActiveStatusDto
import com.example.eeos.data.model.remote.response.ResponsePutActiveStatusDto
import com.example.eeos.data.model.remote.response.base.BaseResponse
import com.example.eeos.data.service.InfoService
import com.skydoves.sandwich.ApiResponse
import javax.inject.Inject

class InfoDataSource @Inject constructor(
private val infoService: InfoService
) {
suspend fun getActiveStatus(): BaseResponse<ResponseGetActiveStatusDto> =
suspend fun getActiveStatus(): ApiResponse<BaseResponse<ResponseGetActiveStatusDto>> =
infoService.getActiveStatus()

suspend fun putActiveStatus(
requestPutActiveStatusDto: RequestPutActiveStatusDto
): BaseResponse<ResponsePutActiveStatusDto> = infoService.putActiveStatus(
requestPutActiveStatusDto
)
): ApiResponse<BaseResponse<ResponsePutActiveStatusDto>> =
infoService.putActiveStatus(requestPutActiveStatusDto)
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package com.example.eeos.domain.repository

import com.example.eeos.data.model.remote.request.RequestPutActiveStatusDto
import com.example.eeos.domain.model.ActiveStatus
import com.example.eeos.data.model.remote.response.ResponseGetActiveStatusDto
import com.example.eeos.data.model.remote.response.ResponsePutActiveStatusDto
import com.example.eeos.data.model.remote.response.base.BaseResponse
import com.skydoves.sandwich.ApiResponse

interface InfoRepository {
suspend fun getActiveStatus(): Result<ActiveStatus>
suspend fun getActiveStatus(): ApiResponse<BaseResponse<ResponseGetActiveStatusDto>>

suspend fun putActiveStatus(
requestPutActiveStatusDto: RequestPutActiveStatusDto
): Result<Unit>
): ApiResponse<BaseResponse<ResponsePutActiveStatusDto>>
}
Loading

0 comments on commit d057833

Please sign in to comment.