diff --git a/app/build.gradle.kts b/app/build.gradle.kts index b71a680b..a5bddb7e 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -63,6 +63,7 @@ android { dependencies { implementation(project(":data")) + implementation(project(":domain")) KotlinDependencies.run { implementation(kotlin) diff --git a/app/src/main/java/com/hous/hous_aos/di/RepositoryModule.kt b/app/src/main/java/com/hous/hous_aos/di/RepositoryModule.kt index 11378a7e..f28323c3 100644 --- a/app/src/main/java/com/hous/hous_aos/di/RepositoryModule.kt +++ b/app/src/main/java/com/hous/hous_aos/di/RepositoryModule.kt @@ -2,7 +2,7 @@ package com.hous.hous_aos.di import com.hous.data.repository.HomeRepository import com.hous.data.repository.HomeRepositoryImpl -import com.hous.data.repository.NewRulesRepository +import com.hous.domain.repository.NewRulesRepository import com.hous.data.repository.NewRulesRepositoryImpl import com.hous.data.repository.ProfileRepository import com.hous.data.repository.ProfileRepositoryImpl diff --git a/app/src/main/java/com/hous/hous_aos/ui/newrules/NewRulesScreen.kt b/app/src/main/java/com/hous/hous_aos/ui/newrules/NewRulesScreen.kt index 65890157..00f962fb 100644 --- a/app/src/main/java/com/hous/hous_aos/ui/newrules/NewRulesScreen.kt +++ b/app/src/main/java/com/hous/hous_aos/ui/newrules/NewRulesScreen.kt @@ -24,6 +24,7 @@ import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.font.FontStyle import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +import com.hous.domain.model.Homie import com.hous.hous_aos.R import com.hous.hous_aos.ui.newrules.component.CategoryItem import com.hous.hous_aos.ui.newrules.component.ManagerItem @@ -176,7 +177,7 @@ fun NewRulesScreen( } fun isAddDay( - homies: List, + homies: List, homieState: HashMap ): Boolean { var temp = false diff --git a/app/src/main/java/com/hous/hous_aos/ui/newrules/NewRulesViewModel.kt b/app/src/main/java/com/hous/hous_aos/ui/newrules/NewRulesViewModel.kt index b7dfe453..e0acbe07 100644 --- a/app/src/main/java/com/hous/hous_aos/ui/newrules/NewRulesViewModel.kt +++ b/app/src/main/java/com/hous/hous_aos/ui/newrules/NewRulesViewModel.kt @@ -3,12 +3,14 @@ package com.hous.hous_aos.ui.newrules import android.util.Log import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import com.hous.data.entity.DayData -import com.hous.data.entity.Manager -import com.hous.data.entity.State -import com.hous.data.repository.NewRulesRepository +import com.hous.domain.model.Category +import com.hous.domain.model.DayData +import com.hous.domain.model.Homie +import com.hous.domain.model.Manager +import com.hous.domain.model.State +import com.hous.domain.usecase.AddNewRuleUseCase +import com.hous.domain.usecase.GetNewRuleInfoUseCase import dagger.hilt.android.lifecycle.HiltViewModel -import javax.inject.Inject import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow @@ -16,10 +18,12 @@ import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.launch +import javax.inject.Inject @HiltViewModel class NewRulesViewModel @Inject constructor( - private val newRulesRepository: NewRulesRepository + private val addNewRuleUseCase: AddNewRuleUseCase, + private val getNewRuleInfoUseCase: GetNewRuleInfoUseCase ) : ViewModel() { private val _uiState = MutableStateFlow(NewRulesUiState()) val uiState = _uiState.asStateFlow() @@ -32,12 +36,11 @@ class NewRulesViewModel @Inject constructor( init { viewModelScope.launch { - newRulesRepository.getNewRuleList("") + getNewRuleInfoUseCase("") .onSuccess { - Log.d("NewRulesViewModel", "getNewRuleList success : ${it.message}") _uiState.value = _uiState.value.copy( - ruleCategory = it.data!!.ruleCategories, - homies = it.data!!.homies + ruleCategory = it.ruleCategories, + homies = it.homies ) setUserMapping() } @@ -147,7 +150,7 @@ class NewRulesViewModel @Inject constructor( } } - fun choiceManager(managerIndex: Int, homie: com.hous.data.entity.Homie) { + fun choiceManager(managerIndex: Int, homie: Homie) { if (uiState.value.ManagerList[managerIndex].managerHomie.userName != "담당자 없음") { _uiState.value.homieState[uiState.value.ManagerList[managerIndex].managerHomie.userName] = true @@ -188,25 +191,22 @@ class NewRulesViewModel @Inject constructor( } fun addNewRule() { - Log.d("NewRulesViewModel", "data : ${uiState.value}") viewModelScope.launch { - newRulesRepository.addNewRule( + addNewRuleUseCase( ruleName = uiState.value.ruleName, categoryId = uiState.value.categoryId, notificationState = uiState.value.notificationState, checkBoxState = uiState.value.checkBoxState, managerList = uiState.value.ManagerList ) - .onSuccess { Log.d("NewRulesViewModel", "addNewRule success : ${it.message}") } - .onFailure { Log.d("NewRulesViewModel", "addNewRule fail : ${it.message}") } } } - private fun nextManager(): com.hous.data.entity.Homie { - var tempHomie = com.hous.data.entity.Homie("", "담당자 없음", typeColor = "NULL") + private fun nextManager(): Homie { + var tempHomie = Homie("", "담당자 없음", typeColor = "NULL") for (i in uiState.value.homies) { if (uiState.value.homieState[i.userName]!!) { - tempHomie = com.hous.data.entity.Homie( + tempHomie = Homie( id = i.id, userName = i.userName, typeColor = i.typeColor @@ -252,20 +252,20 @@ data class NewRulesUiState( val categoryId: String = "", val notificationState: Boolean = false, val checkBoxState: State = State.UNSELECT, - val ruleCategory: List = + val ruleCategory: List = listOf( - com.hous.data.entity.Category("1", "청소기"), - com.hous.data.entity.Category("2", "분리수거"), - com.hous.data.entity.Category("3", "세탁기"), - com.hous.data.entity.Category("4", "물 주기") + Category("1", "청소기"), + Category("2", "분리수거"), + Category("3", "세탁기"), + Category("4", "물 주기") ), - val homies: List = + val homies: List = listOf( - com.hous.data.entity.Homie("1", "강원용", typeColor = "RED"), - com.hous.data.entity.Homie("2", "이영주", typeColor = "BLUE"), - com.hous.data.entity.Homie("3", "이준원", typeColor = "YELLOW"), - com.hous.data.entity.Homie("4", "최인영", typeColor = "GREEN"), - com.hous.data.entity.Homie("5", "최소현", typeColor = "PURPLE") + Homie("1", "강원용", typeColor = "RED"), + Homie("2", "이영주", typeColor = "BLUE"), + Homie("3", "이준원", typeColor = "YELLOW"), + Homie("4", "최인영", typeColor = "GREEN"), + Homie("5", "최소현", typeColor = "PURPLE") ), val homieState: HashMap = hashMapOf( "강원용" to true, diff --git a/app/src/main/java/com/hous/hous_aos/ui/newrules/component/CategoryDropDown.kt b/app/src/main/java/com/hous/hous_aos/ui/newrules/component/CategoryDropDown.kt index 3892fa3a..b3c9ab53 100644 --- a/app/src/main/java/com/hous/hous_aos/ui/newrules/component/CategoryDropDown.kt +++ b/app/src/main/java/com/hous/hous_aos/ui/newrules/component/CategoryDropDown.kt @@ -17,7 +17,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.res.painterResource import com.hous.hous_aos.R -import com.hous.data.entity.Category +import com.hous.domain.model.Category @Composable fun CategoryDropDownMenu( diff --git a/app/src/main/java/com/hous/hous_aos/ui/newrules/component/CategoryItem.kt b/app/src/main/java/com/hous/hous_aos/ui/newrules/component/CategoryItem.kt index aaf9d695..8d945f6b 100644 --- a/app/src/main/java/com/hous/hous_aos/ui/newrules/component/CategoryItem.kt +++ b/app/src/main/java/com/hous/hous_aos/ui/newrules/component/CategoryItem.kt @@ -19,7 +19,7 @@ import androidx.compose.ui.text.font.FontStyle import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import com.hous.hous_aos.R -import com.hous.data.entity.Category +import com.hous.domain.model.Category @Composable fun CategoryItem( diff --git a/app/src/main/java/com/hous/hous_aos/ui/newrules/component/CheckBox.kt b/app/src/main/java/com/hous/hous_aos/ui/newrules/component/CheckBox.kt index be2243e0..9a74c50e 100644 --- a/app/src/main/java/com/hous/hous_aos/ui/newrules/component/CheckBox.kt +++ b/app/src/main/java/com/hous/hous_aos/ui/newrules/component/CheckBox.kt @@ -22,7 +22,7 @@ import androidx.compose.ui.text.font.Font import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.font.FontStyle import androidx.compose.ui.unit.dp -import com.hous.data.entity.State +import com.hous.domain.model.State import com.hous.hous_aos.R @Composable diff --git a/app/src/main/java/com/hous/hous_aos/ui/newrules/component/Day.kt b/app/src/main/java/com/hous/hous_aos/ui/newrules/component/Day.kt index 32d69a50..dd9e653e 100644 --- a/app/src/main/java/com/hous/hous_aos/ui/newrules/component/Day.kt +++ b/app/src/main/java/com/hous/hous_aos/ui/newrules/component/Day.kt @@ -17,8 +17,8 @@ import androidx.compose.ui.text.font.Font import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.font.FontStyle import androidx.compose.ui.unit.dp -import com.hous.data.entity.DayData -import com.hous.data.entity.State +import com.hous.domain.model.DayData +import com.hous.domain.model.State import com.hous.hous_aos.R @Composable diff --git a/app/src/main/java/com/hous/hous_aos/ui/newrules/component/DayList.kt b/app/src/main/java/com/hous/hous_aos/ui/newrules/component/DayList.kt index 8aba09be..f0c02486 100644 --- a/app/src/main/java/com/hous/hous_aos/ui/newrules/component/DayList.kt +++ b/app/src/main/java/com/hous/hous_aos/ui/newrules/component/DayList.kt @@ -5,8 +5,8 @@ import androidx.compose.foundation.lazy.LazyRow import androidx.compose.foundation.lazy.itemsIndexed import androidx.compose.runtime.Composable import androidx.compose.ui.unit.dp -import com.hous.data.entity.DayData -import com.hous.data.entity.Manager +import com.hous.domain.model.DayData +import com.hous.domain.model.Manager @Composable fun NewRulesDayList( diff --git a/app/src/main/java/com/hous/hous_aos/ui/newrules/component/DeleteButton.kt b/app/src/main/java/com/hous/hous_aos/ui/newrules/component/DeleteButton.kt index c2184fe1..6cba0dfe 100644 --- a/app/src/main/java/com/hous/hous_aos/ui/newrules/component/DeleteButton.kt +++ b/app/src/main/java/com/hous/hous_aos/ui/newrules/component/DeleteButton.kt @@ -5,7 +5,7 @@ import androidx.compose.foundation.clickable import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.painterResource -import com.hous.data.entity.State +import com.hous.domain.model.State import com.hous.hous_aos.R @Composable diff --git a/app/src/main/java/com/hous/hous_aos/ui/newrules/component/ManagerAddButton.kt b/app/src/main/java/com/hous/hous_aos/ui/newrules/component/ManagerAddButton.kt index df97d91f..922e59b6 100644 --- a/app/src/main/java/com/hous/hous_aos/ui/newrules/component/ManagerAddButton.kt +++ b/app/src/main/java/com/hous/hous_aos/ui/newrules/component/ManagerAddButton.kt @@ -16,8 +16,8 @@ import androidx.compose.ui.draw.clip import androidx.compose.ui.res.colorResource import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.dp +import com.hous.domain.model.Homie import com.hous.hous_aos.R -import com.hous.data.entity.Homie import com.hous.hous_aos.ui.newrules.isAddDay @Composable diff --git a/app/src/main/java/com/hous/hous_aos/ui/newrules/component/ManagerBox.kt b/app/src/main/java/com/hous/hous_aos/ui/newrules/component/ManagerBox.kt index 258d63a4..53ac621d 100644 --- a/app/src/main/java/com/hous/hous_aos/ui/newrules/component/ManagerBox.kt +++ b/app/src/main/java/com/hous/hous_aos/ui/newrules/component/ManagerBox.kt @@ -20,9 +20,9 @@ import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.font.FontStyle import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp -import com.hous.data.entity.Homie -import com.hous.data.entity.Manager -import com.hous.data.entity.State +import com.hous.domain.model.Homie +import com.hous.domain.model.Manager +import com.hous.domain.model.State import com.hous.hous_aos.R @Composable @@ -41,7 +41,7 @@ fun ManagerBox( .size(36.dp) .clip(shape = RoundedCornerShape(radius)) .background(colorResource(id = R.color.white)) - .padding(horizontal = 12.dp), + .padding(horizontal = 12.dp) ) { val color = when (manager.managerHomie.typeColor) { "RED" -> colorResource(id = R.color.hous_red) @@ -54,7 +54,7 @@ fun ManagerBox( } Row( modifier = Modifier.fillMaxSize(), - verticalAlignment = Alignment.CenterVertically, + verticalAlignment = Alignment.CenterVertically ) { if (color != null) { Box( @@ -79,7 +79,7 @@ fun ManagerBox( Box( modifier = Modifier - .fillMaxSize(), + .fillMaxSize() ) { ManagerDropDownMenu( managerIndex = managerIndex, diff --git a/app/src/main/java/com/hous/hous_aos/ui/newrules/component/ManagerDropDown.kt b/app/src/main/java/com/hous/hous_aos/ui/newrules/component/ManagerDropDown.kt index ed897eee..ab54ecad 100644 --- a/app/src/main/java/com/hous/hous_aos/ui/newrules/component/ManagerDropDown.kt +++ b/app/src/main/java/com/hous/hous_aos/ui/newrules/component/ManagerDropDown.kt @@ -30,8 +30,8 @@ import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.font.FontStyle import androidx.compose.ui.unit.dp import com.hous.hous_aos.R -import com.hous.data.entity.Homie -import com.hous.data.entity.State +import com.hous.domain.model.Homie +import com.hous.domain.model.State import com.hous.hous_aos.ui.newrules.isAddDay @Composable diff --git a/app/src/main/java/com/hous/hous_aos/ui/newrules/component/ManagerItem.kt b/app/src/main/java/com/hous/hous_aos/ui/newrules/component/ManagerItem.kt index 15ff07a6..f2db6187 100644 --- a/app/src/main/java/com/hous/hous_aos/ui/newrules/component/ManagerItem.kt +++ b/app/src/main/java/com/hous/hous_aos/ui/newrules/component/ManagerItem.kt @@ -8,10 +8,10 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp -import com.hous.data.entity.DayData -import com.hous.data.entity.Homie -import com.hous.data.entity.Manager -import com.hous.data.entity.State +import com.hous.domain.model.DayData +import com.hous.domain.model.Homie +import com.hous.domain.model.Manager +import com.hous.domain.model.State @Composable fun ManagerItem( diff --git a/app/src/main/java/com/hous/hous_aos/ui/newrules/component/NewRuleToolBar.kt b/app/src/main/java/com/hous/hous_aos/ui/newrules/component/NewRuleToolBar.kt index 8bf2a7c4..e94325b3 100644 --- a/app/src/main/java/com/hous/hous_aos/ui/newrules/component/NewRuleToolBar.kt +++ b/app/src/main/java/com/hous/hous_aos/ui/newrules/component/NewRuleToolBar.kt @@ -14,7 +14,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.Font import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.font.FontStyle -import com.hous.data.entity.State +import com.hous.domain.model.State import com.hous.hous_aos.R @Composable diff --git a/data/build.gradle.kts b/data/build.gradle.kts index e4a9e1b8..64d404de 100644 --- a/data/build.gradle.kts +++ b/data/build.gradle.kts @@ -38,6 +38,7 @@ android { } dependencies { + implementation(project(":domain")) KotlinDependencies.run { implementation(kotlin) diff --git a/data/src/main/java/com/hous/data/api/NewRulesApi.kt b/data/src/main/java/com/hous/data/api/NewRulesApi.kt index b4cf1151..d97e7c38 100644 --- a/data/src/main/java/com/hous/data/api/NewRulesApi.kt +++ b/data/src/main/java/com/hous/data/api/NewRulesApi.kt @@ -12,11 +12,11 @@ interface NewRulesApi { @POST("room/{roomId}/rule") suspend fun addNewRule( @Path("roomId") roomId: String, - @Body newRulesRequest: com.hous.data.model.request.NewRulesRequest - ): com.hous.data.model.WrapperClass + @Body newRulesRequest: NewRulesRequest + ) @GET("room/{roomId}/rule/new") suspend fun getNewRuleList( @Path("roomId") roomId: String - ): com.hous.data.model.WrapperClass + ): WrapperClass } diff --git a/data/src/main/java/com/hous/data/entity/Category.kt b/data/src/main/java/com/hous/data/entity/Category.kt index 3a216cba..44e2b084 100644 --- a/data/src/main/java/com/hous/data/entity/Category.kt +++ b/data/src/main/java/com/hous/data/entity/Category.kt @@ -1,6 +1,7 @@ package com.hous.data.entity import com.google.gson.annotations.SerializedName +import com.hous.domain.model.Category data class Category( @SerializedName("_id") val id: String = "", @@ -8,4 +9,6 @@ data class Category( val categoryIcon: String = "", val ruleName: String = "", var isChecked: Boolean = false -) +) { + fun toCategory() = Category(id, categoryName, categoryIcon, ruleName, isChecked) +} diff --git a/data/src/main/java/com/hous/data/entity/Homie.kt b/data/src/main/java/com/hous/data/entity/Homie.kt index f315822f..c64987ef 100644 --- a/data/src/main/java/com/hous/data/entity/Homie.kt +++ b/data/src/main/java/com/hous/data/entity/Homie.kt @@ -1,6 +1,7 @@ package com.hous.data.entity import com.google.gson.annotations.SerializedName +import com.hous.domain.model.Homie data class Homie( @SerializedName("_id") val id: String? = null, @@ -14,4 +15,18 @@ data class Homie( val typeScore: List = emptyList(), var isChecked: Boolean = false, val notificationState: Boolean = false -) +) { + fun toHomie(): Homie = Homie( + id, + userName, + typeName, + typeId, + typeColor, + job, + introduction, + hashTag, + typeScore, + isChecked, + notificationState + ) +} diff --git a/data/src/main/java/com/hous/data/repository/NewRulesRepository.kt b/data/src/main/java/com/hous/data/repository/NewRulesRepository.kt deleted file mode 100644 index 28294172..00000000 --- a/data/src/main/java/com/hous/data/repository/NewRulesRepository.kt +++ /dev/null @@ -1,17 +0,0 @@ -package com.hous.data.repository - -import com.hous.data.entity.Manager -import com.hous.data.entity.State -import com.hous.data.model.WrapperClass - -interface NewRulesRepository { - suspend fun addNewRule( - ruleName: String, - categoryId: String, - notificationState: Boolean, - checkBoxState: State, - managerList: List - ): Result> - - suspend fun getNewRuleList(roomId: String): Result> -} diff --git a/data/src/main/java/com/hous/data/repository/NewRulesRepositoryImpl.kt b/data/src/main/java/com/hous/data/repository/NewRulesRepositoryImpl.kt index 4868b6ce..33a8f07b 100644 --- a/data/src/main/java/com/hous/data/repository/NewRulesRepositoryImpl.kt +++ b/data/src/main/java/com/hous/data/repository/NewRulesRepositoryImpl.kt @@ -1,14 +1,14 @@ package com.hous.data.repository import android.util.Log -import com.hous.data.entity.DayData -import com.hous.data.entity.Manager -import com.hous.data.entity.State -import com.hous.data.model.WrapperClass import com.hous.data.model.request.Member import com.hous.data.model.request.NewRulesRequest -import com.hous.data.model.response.NewRulesListResponse import com.hous.data.source.remote.RemoteNewRulesDataSource +import com.hous.domain.model.DayData +import com.hous.domain.model.Manager +import com.hous.domain.model.NewRuleInfo +import com.hous.domain.model.State +import com.hous.domain.repository.NewRulesRepository import javax.inject.Inject class NewRulesRepositoryImpl @Inject constructor( @@ -20,7 +20,7 @@ class NewRulesRepositoryImpl @Inject constructor( notificationState: Boolean, checkBoxState: State, managerList: List - ): Result> { + ) { val ruleMember = managerList.map { val dayList = dayToInt(it.dayDataList) Member( @@ -36,11 +36,17 @@ class NewRulesRepositoryImpl @Inject constructor( ruleMembers = if (checkBoxState != State.SELECT) ruleMember else emptyList() ) Log.d("NewRulesViewModel", "repository rules data: $newRulesRequest") - return runCatching { remoteNewRulesDataSource.addNewRule(newRulesRequest) } + remoteNewRulesDataSource.addNewRule(newRulesRequest) } - override suspend fun getNewRuleList(roomId: String): Result> = - runCatching { remoteNewRulesDataSource.getNewRuleList(roomId) } + override suspend fun getNewRuleList(roomId: String): Result = + runCatching { + val response = remoteNewRulesDataSource.getNewRuleList(roomId) + NewRuleInfo( + response.data!!.ruleCategories.map { it.toCategory() }, + response.data.homies.map { it.toHomie() } + ) + } private fun dayToInt(dayDataList: List): List { val tempList = mutableListOf() diff --git a/data/src/main/java/com/hous/data/source/remote/RemoteNewRulesDataSource.kt b/data/src/main/java/com/hous/data/source/remote/RemoteNewRulesDataSource.kt index 9ace7dac..bcca97fd 100644 --- a/data/src/main/java/com/hous/data/source/remote/RemoteNewRulesDataSource.kt +++ b/data/src/main/java/com/hous/data/source/remote/RemoteNewRulesDataSource.kt @@ -5,6 +5,6 @@ import com.hous.data.model.request.NewRulesRequest import com.hous.data.model.response.NewRulesListResponse interface RemoteNewRulesDataSource { - suspend fun addNewRule(newRulesRequest: NewRulesRequest): WrapperClass + suspend fun addNewRule(newRulesRequest: NewRulesRequest) suspend fun getNewRuleList(roomId: String): WrapperClass } diff --git a/data/src/main/java/com/hous/data/source/remote/RemoteNewRulesDataSourceImpl.kt b/data/src/main/java/com/hous/data/source/remote/RemoteNewRulesDataSourceImpl.kt index 22482453..f8ddf150 100644 --- a/data/src/main/java/com/hous/data/source/remote/RemoteNewRulesDataSourceImpl.kt +++ b/data/src/main/java/com/hous/data/source/remote/RemoteNewRulesDataSourceImpl.kt @@ -12,8 +12,9 @@ class RemoteNewRulesDataSourceImpl @Inject constructor( ) : RemoteNewRulesDataSource { private val ROOM_ID = BuildConfig.ROOM_ID - override suspend fun addNewRule(newRulesRequest: NewRulesRequest): WrapperClass = - newRulesApi.addNewRule(ROOM_ID, newRulesRequest) + override suspend fun addNewRule(newRulesRequest: NewRulesRequest) { + runCatching { newRulesApi.addNewRule(ROOM_ID, newRulesRequest) } + } override suspend fun getNewRuleList(roomId: String): WrapperClass = newRulesApi.getNewRuleList(ROOM_ID) diff --git a/domain/.gitignore b/domain/.gitignore new file mode 100644 index 00000000..42afabfd --- /dev/null +++ b/domain/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/domain/build.gradle.kts b/domain/build.gradle.kts new file mode 100644 index 00000000..0399abb0 --- /dev/null +++ b/domain/build.gradle.kts @@ -0,0 +1,29 @@ +plugins { + id("java-library") + kotlin("jvm") + id("org.jlleitschuh.gradle.ktlint") version "10.3.0" +} + +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} + +dependencies { + KotlinDependencies.run { + implementation(kotlin) + implementation(inject) + } +} + +ktlint { + android.set(true) + coloredOutput.set(true) + verbose.set(true) + outputToConsole.set(true) + disabledRules.set(setOf("max-line-length", "import-ordering")) + reporters { + reporter(org.jlleitschuh.gradle.ktlint.reporter.ReporterType.PLAIN) + reporter(org.jlleitschuh.gradle.ktlint.reporter.ReporterType.CHECKSTYLE) + } +} diff --git a/domain/src/main/java/com/hous/domain/model/Category.kt b/domain/src/main/java/com/hous/domain/model/Category.kt new file mode 100644 index 00000000..f50a1bbe --- /dev/null +++ b/domain/src/main/java/com/hous/domain/model/Category.kt @@ -0,0 +1,9 @@ +package com.hous.domain.model + +data class Category( + val id: String = "", + val categoryName: String = "", + val categoryIcon: String = "", + val ruleName: String = "", + var isChecked: Boolean = false +) diff --git a/domain/src/main/java/com/hous/domain/model/DayData.kt b/domain/src/main/java/com/hous/domain/model/DayData.kt new file mode 100644 index 00000000..b1a6f9c8 --- /dev/null +++ b/domain/src/main/java/com/hous/domain/model/DayData.kt @@ -0,0 +1,6 @@ +package com.hous.domain.model + +data class DayData( + val day: String, + val dayState: State +) diff --git a/domain/src/main/java/com/hous/domain/model/Homie.kt b/domain/src/main/java/com/hous/domain/model/Homie.kt new file mode 100644 index 00000000..073804d5 --- /dev/null +++ b/domain/src/main/java/com/hous/domain/model/Homie.kt @@ -0,0 +1,15 @@ +package com.hous.domain.model + +data class Homie( + val id: String? = null, + val userName: String = "", + val typeName: String = "", + val typeId: String = "", + val typeColor: String = "", + val job: String = "", + val introduction: String = "", + val hashTag: List = emptyList(), + val typeScore: List = emptyList(), + var isChecked: Boolean = false, + val notificationState: Boolean = false +) diff --git a/domain/src/main/java/com/hous/domain/model/Manager.kt b/domain/src/main/java/com/hous/domain/model/Manager.kt new file mode 100644 index 00000000..d4d30ba8 --- /dev/null +++ b/domain/src/main/java/com/hous/domain/model/Manager.kt @@ -0,0 +1,17 @@ +package com.hous.domain.model + +data class Manager( + val managerHomie: Homie = Homie( + userName = "담당자 없음", + typeColor = "NULL" + ), + val dayDataList: List = listOf( + DayData("월", State.UNSELECT), + DayData("화", State.UNSELECT), + DayData("수", State.UNSELECT), + DayData("목", State.UNSELECT), + DayData("금", State.UNSELECT), + DayData("토", State.UNSELECT), + DayData("일", State.UNSELECT) + ) +) diff --git a/domain/src/main/java/com/hous/domain/model/NewRuleInfo.kt b/domain/src/main/java/com/hous/domain/model/NewRuleInfo.kt new file mode 100644 index 00000000..7d05ae08 --- /dev/null +++ b/domain/src/main/java/com/hous/domain/model/NewRuleInfo.kt @@ -0,0 +1,6 @@ +package com.hous.domain.model + +data class NewRuleInfo( + val ruleCategories: List = emptyList(), + val homies: List = emptyList() +) diff --git a/domain/src/main/java/com/hous/domain/model/State.kt b/domain/src/main/java/com/hous/domain/model/State.kt new file mode 100644 index 00000000..3dcf6a97 --- /dev/null +++ b/domain/src/main/java/com/hous/domain/model/State.kt @@ -0,0 +1,5 @@ +package com.hous.domain.model + +enum class State { + UNSELECT, SELECT, BLOCK +} diff --git a/domain/src/main/java/com/hous/domain/repository/NewRulesRepository.kt b/domain/src/main/java/com/hous/domain/repository/NewRulesRepository.kt new file mode 100644 index 00000000..4a646fc4 --- /dev/null +++ b/domain/src/main/java/com/hous/domain/repository/NewRulesRepository.kt @@ -0,0 +1,17 @@ +package com.hous.domain.repository + +import com.hous.domain.model.Manager +import com.hous.domain.model.NewRuleInfo +import com.hous.domain.model.State + +interface NewRulesRepository { + suspend fun addNewRule( + ruleName: String, + categoryId: String, + notificationState: Boolean, + checkBoxState: State, + managerList: List + ) + + suspend fun getNewRuleList(roomId: String): Result +} diff --git a/domain/src/main/java/com/hous/domain/usecase/AddNewRuleUseCase.kt b/domain/src/main/java/com/hous/domain/usecase/AddNewRuleUseCase.kt new file mode 100644 index 00000000..44e94bac --- /dev/null +++ b/domain/src/main/java/com/hous/domain/usecase/AddNewRuleUseCase.kt @@ -0,0 +1,24 @@ +package com.hous.domain.usecase + +import com.hous.domain.model.Manager +import com.hous.domain.model.State +import com.hous.domain.repository.NewRulesRepository +import javax.inject.Inject + +class AddNewRuleUseCase @Inject constructor( + private val newRulesRepository: NewRulesRepository +) { + suspend operator fun invoke( + ruleName: String, + categoryId: String, + notificationState: Boolean, + checkBoxState: State, + managerList: List + ) = newRulesRepository.addNewRule( + ruleName, + categoryId, + notificationState, + checkBoxState, + managerList + ) +} diff --git a/domain/src/main/java/com/hous/domain/usecase/GetNewRuleInfoUseCase.kt b/domain/src/main/java/com/hous/domain/usecase/GetNewRuleInfoUseCase.kt new file mode 100644 index 00000000..8407293a --- /dev/null +++ b/domain/src/main/java/com/hous/domain/usecase/GetNewRuleInfoUseCase.kt @@ -0,0 +1,12 @@ +package com.hous.domain.usecase + +import com.hous.domain.model.NewRuleInfo +import com.hous.domain.repository.NewRulesRepository +import javax.inject.Inject + +class GetNewRuleInfoUseCase @Inject constructor( + private val newRulesRepository: NewRulesRepository +) { + suspend operator fun invoke(roomId: String): Result = + newRulesRepository.getNewRuleList(roomId) +} diff --git a/settings.gradle.kts b/settings.gradle.kts index e254bb12..6429db23 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -15,3 +15,4 @@ dependencyResolutionManagement { rootProject.name = "Hous-Aos" include(":app") include(":data") +include(":domain")