Skip to content

Commit

Permalink
[AN] 놀이터 서비스 기능 및 리팩토링 (#720)
Browse files Browse the repository at this point in the history
  • Loading branch information
dpcks0509 authored Oct 23, 2024
1 parent 9eedd97 commit 0b9fc31
Show file tree
Hide file tree
Showing 77 changed files with 1,215 additions and 1,021 deletions.
4 changes: 2 additions & 2 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
android:exported="false"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize" />

<activity
android:name=".presentation.ui.register.RegisterActivity"
android:exported="true"
Expand Down Expand Up @@ -119,7 +119,7 @@
</intent-filter>
</activity>
<activity
android:name=".presentation.ui.message.MessageActivity"
android:name=".presentation.ui.statemessage.StateMessageActivity"
android:exported="false"
android:screenOrientation="portrait"
android:theme="@style/TransparentActivityTheme"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ abstract class DataSourceModule {

@Binds
@Singleton
abstract fun bindsWoofDataSource(dataSourceImpl: PlaygroundDataSourceImpl): PlaygroundDataSource
abstract fun bindsPlaygroundDataSource(dataSourceImpl: PlaygroundDataSourceImpl): PlaygroundDataSource

@Binds
@Singleton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import android.content.Context
import com.happy.friendogly.local.di.AddressModule
import com.happy.friendogly.local.di.AlarmTokenModule
import com.happy.friendogly.local.di.ChatAlarmModule
import com.happy.friendogly.local.di.PlaygroundAlarmModule
import com.happy.friendogly.local.di.TokenManager
import com.happy.friendogly.local.di.WoofAlarmModule
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
Expand Down Expand Up @@ -42,7 +42,7 @@ object DataStoreModule {

@Provides
@Singleton
fun providesWoofAlarmModule(
fun providesPlaygroundAlarmModule(
@ApplicationContext appContext: Context,
): WoofAlarmModule = WoofAlarmModule(appContext)
): PlaygroundAlarmModule = PlaygroundAlarmModule(appContext)
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ abstract class RepositoryModule {

@Binds
@Singleton
abstract fun bindsWoofRepository(repositoryImpl: PlaygroundRepositoryImpl): PlaygroundRepository
abstract fun bindsPlaygroundRepository(repositoryImpl: PlaygroundRepositoryImpl): PlaygroundRepository

@Binds
@Singleton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ object ServiceModule {

@Provides
@Singleton
fun providesWoofService(retrofit: Retrofit): PlaygroundService = retrofit.create(PlaygroundService::class.java)
fun providesPlaygroundService(retrofit: Retrofit): PlaygroundService = retrofit.create(PlaygroundService::class.java)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.happy.friendogly.data.mapper

import com.happy.friendogly.data.model.MyPlaygroundDto
import com.happy.friendogly.presentation.ui.playground.model.MyPlayground
import com.happy.friendogly.presentation.ui.playground.model.Playground

fun MyPlaygroundDto.toDomain(): MyPlayground {
return MyPlayground(
Expand All @@ -11,12 +10,3 @@ fun MyPlaygroundDto.toDomain(): MyPlayground {
longitude = longitude,
)
}

fun MyPlayground.toPlayground(): Playground {
return Playground(
id = id,
latitude = latitude,
longitude = longitude,
isParticipating = true,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import com.happy.friendogly.remote.mapper.toLocal

fun RecentPetDto.toLocal(): RecentPetEntity =
RecentPetEntity(
memberId = id,
memberId = memberId,
petId = petId,
name = name,
imgUrl = imgUrl,
birthday = birthday,
Expand All @@ -18,7 +19,7 @@ fun RecentPetDto.toLocal(): RecentPetEntity =

fun RecentPetDto.toDomain(): RecentPet =
RecentPet(
memberId = id,
memberId = memberId,
name = name,
imgUrl = imgUrl,
birthday = birthday,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import java.time.LocalDateTime
data class RecentPetDto(
val id: Long = 0,
val memberId: Long,
val petId: Long,
val name: String,
val birthday: LocalDate,
val imgUrl: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ class AlarmSettingRepositoryImpl

override suspend fun deleteChatSetting(): Result<Unit> = source.deleteChatSetting()

override suspend fun saveWoofSetting(isSet: Boolean): Result<Unit> = source.saveWoofSetting(isSet)
override suspend fun savePlaygroundSetting(isSet: Boolean): Result<Unit> = source.savePlaygroundSetting(isSet)

override suspend fun getWoofSetting(): Result<Boolean> = source.getWoofSetting()
override suspend fun getPlaygroundSetting(): Result<Boolean> = source.getPlaygroundSetting()

override suspend fun deleteWoofSetting(): Result<Unit> = source.deleteWoofSetting()
override suspend fun deletePlaygroundSetting(): Result<Unit> = source.deletePlaygroundSetting()
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ class PlaygroundRepositoryImpl
)
}

override suspend fun getFootprintMarkBtnInfo(): Result<PetExistence> =
source.getFootprintMarkBtnInfo().mapCatching { dto ->
override suspend fun getPetExistence(): Result<PetExistence> =
source.getPetExistence().mapCatching { dto ->
dto.toDomain()
}

override suspend fun getPlaygrounds(): Result<List<Playground>> =
source
.getNearFootprints()
.getNearPlaygrounds()
.mapCatching { dto ->
dto.toDomain()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,17 @@ class RecentPetsRepositoryImpl
)

override suspend fun insertRecentPet(
id: Long,
memberId: Long,
petId: Long,
name: String,
imgUrl: String,
birthday: LocalDate,
gender: Gender,
sizeType: SizeType,
): DomainResult<Unit, DataError.Local> {
return dataSource.insertRecentPet(
id = id,
memberId = memberId,
petId = petId,
name = name,
imgUrl = imgUrl,
birthday = birthday,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ interface AlarmSettingDataSource {

suspend fun deleteChatSetting(): Result<Unit>

suspend fun saveWoofSetting(isSet: Boolean): Result<Unit>
suspend fun savePlaygroundSetting(isSet: Boolean): Result<Unit>

suspend fun getWoofSetting(): Result<Boolean>
suspend fun getPlaygroundSetting(): Result<Boolean>

suspend fun deleteWoofSetting(): Result<Unit>
suspend fun deletePlaygroundSetting(): Result<Unit>
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ interface PlaygroundDataSource {

suspend fun patchPlaygroundArrival(request: PatchPlaygroundArrivalRequest): Result<PlaygroundArrivalDto>

suspend fun getFootprintMarkBtnInfo(): Result<PetExistenceDto>
suspend fun getPetExistence(): Result<PetExistenceDto>

suspend fun getNearFootprints(): Result<List<PlaygroundDto>>
suspend fun getNearPlaygrounds(): Result<List<PlaygroundDto>>

suspend fun getPlaygroundInfo(id: Long): Result<PlaygroundInfoDto>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ interface RecentPetsDataSource {
suspend fun getAllRecentPet(): Result<List<RecentPetDto>>

suspend fun insertRecentPet(
id: Long,
memberId: Long,
petId: Long,
name: String,
imgUrl: String,
birthday: LocalDate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ interface AlarmSettingRepository {

suspend fun deleteChatSetting(): Result<Unit>

suspend fun saveWoofSetting(isSet: Boolean): Result<Unit>
suspend fun savePlaygroundSetting(isSet: Boolean): Result<Unit>

suspend fun getWoofSetting(): Result<Boolean>
suspend fun getPlaygroundSetting(): Result<Boolean>

suspend fun deleteWoofSetting(): Result<Unit>
suspend fun deletePlaygroundSetting(): Result<Unit>
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ interface PlaygroundRepository {
longitude: Double,
): DomainResult<PlaygroundArrival, DataError.Network>

suspend fun getFootprintMarkBtnInfo(): Result<PetExistence>
suspend fun getPetExistence(): Result<PetExistence>

suspend fun getPlaygrounds(): Result<List<Playground>>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ interface RecentPetsRepository {
suspend fun getAllRecentPet(): DomainResult<List<RecentPet>, DataError.Local>

suspend fun insertRecentPet(
id: Long,
memberId: Long,
petId: Long,
name: String,
imgUrl: String,
birthday: LocalDate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package com.happy.friendogly.domain.usecase
import com.happy.friendogly.domain.repository.AlarmSettingRepository
import javax.inject.Inject

class DeleteWoofAlarmUseCase
class DeletePlaygroundAlarmUseCase
@Inject
constructor(
private val repository: AlarmSettingRepository,
) {
suspend operator fun invoke(): Result<Unit> = repository.deleteWoofSetting()
suspend operator fun invoke(): Result<Unit> = repository.deletePlaygroundSetting()
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ import javax.inject.Inject
class GetPetExistenceUseCase
@Inject
constructor(private val repository: PlaygroundRepository) {
suspend operator fun invoke(): Result<PetExistence> = repository.getFootprintMarkBtnInfo()
suspend operator fun invoke(): Result<PetExistence> = repository.getPetExistence()
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package com.happy.friendogly.domain.usecase
import com.happy.friendogly.domain.repository.AlarmSettingRepository
import javax.inject.Inject

class GetWoofAlarmUseCase
class GetPlaygroundAlarmUseCase
@Inject
constructor(
private val repository: AlarmSettingRepository,
) {
suspend operator fun invoke(): Result<Boolean> = repository.getWoofSetting()
suspend operator fun invoke(): Result<Boolean> = repository.getPlaygroundSetting()
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@ class InsertRecentPetUseCase
val repository: RecentPetsRepository,
) {
suspend operator fun invoke(
id: Long,
memberId: Long,
petId: Long,
name: String,
imgUrl: String,
birthday: LocalDate,
gender: Gender,
sizeType: SizeType,
): DomainResult<Unit, DataError.Local> =
repository.insertRecentPet(
memberId = memberId,
petId = petId,
imgUrl = imgUrl,
name = name,
id = id,
birthday = birthday,
gender = gender,
sizeType = sizeType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package com.happy.friendogly.domain.usecase
import com.happy.friendogly.domain.repository.AlarmSettingRepository
import javax.inject.Inject

class SaveWoofAlarmUseCase
class SavePlaygroundAlarmUseCase
@Inject
constructor(
private val repository: AlarmSettingRepository,
) {
suspend operator fun invoke(isSet: Boolean): Result<Unit> = repository.saveWoofSetting(isSet)
suspend operator fun invoke(isSet: Boolean): Result<Unit> = repository.savePlaygroundSetting(isSet)
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ object Types {
const val KAKAO_LOGIN_CLICKED = "kakao_login_clicked"
const val GOOGLE_LOGIN_CLICKED = "google_login_clicked"
const val GROUP_LIST_FRAGMENT = "group_list_fragment"
const val WOOF_FRAGMENT = "woof_fragment"
const val PLAYGROUND_FRAGMENT = "playground_fragment"
const val CHAT_LIST_FRAGMENT = "chat_list_fragment"
const val MY_PAGE_FRAGMENT = "my_page_fragment"
const val CLUB_LIST_FRAGMENT_SWITCHED = "group_list_fragment_switched"
Expand All @@ -41,12 +41,17 @@ object Types {
const val REGISTER_MARKER_BTN_CLICKED = "register_marker_btn_clicked"
const val LOCATION_BTN_CLICKED = "location_btn_clicked"
const val MY_PLAYGROUND_BTN_CLICKED = "my_playground_btn_clicked"
const val REFRESH_BTN_CLICKED = "refresh_btn_clicked"
const val PLAYGROUND_REFRESH_BTN_CLICKED = "playground_refresh_btn_clicked"
const val PLAYGROUND_INFO_REFRESH_BTN_CLICKED = "playground_info_refresh_btn_clicked"
const val BACK_BTN_CLICKED = "back_btn_clicked"
const val CLOSE_BTN_CLICKED = "close_btn_clicked"
const val PLAYGROUND_PET_DETAIL_CLICKED = "playground_pet_detail_clicked"
const val HELP_BTN_CLICKED = "help_btn_clicked"
const val PET_IMAGE_CLICKED = "pet_image_clicked"
const val STATE_MESSAGE_CLICKED = "state_message_clicked"
const val JOIN_PLAYGROUND_CLICKED = "join_playground_clicked"
const val LEAVE_PLAYGROUND_CLICKED = "leave_playground_clicked"
const val CHECK_PET_EXISTENCE_CLICKED = "check_pet_existence_clicked"
const val CLUB_SELECT_PARTICIPATION_FILTER = "club_select_participation_filter"
const val CLUB_SELECT_CLUB_FILTER = "club_select_club_filter"
const val CLUB_ADD_UN_SELECT_FILTER = "club_add_un_select_filter"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,30 @@ package com.happy.friendogly.local.dao
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Transaction
import com.happy.friendogly.local.model.RecentPetEntity
import java.time.LocalDateTime

@Dao
interface RecentPetsDao {
@Query("SELECT * FROM recent_pet WHERE memberId = :id")
suspend fun getRecentPetById(id: Long): RecentPetEntity?

@Query("SELECT * FROM recent_pet")
@Query("SELECT * FROM recent_pet ORDER BY created_at DESC")
suspend fun getAllRecentPet(): List<RecentPetEntity>

@Query("DELETE FROM recent_pet WHERE petId = :petId AND DATE(created_at) = DATE(:createdAt)")
suspend fun deleteByPetIdAndCreatedAt(
petId: Long,
createdAt: LocalDateTime,
)

@Insert
suspend fun insertRecentPet(recentPetEntity: RecentPetEntity)

@Transaction
suspend fun insertOrUpdateRecentPet(recentPetEntity: RecentPetEntity) {
deleteByPetIdAndCreatedAt(recentPetEntity.petId, recentPetEntity.createdAt)
insertRecentPet(recentPetEntity)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.map
import java.io.IOException

class WoofAlarmModule(val context: Context) {
class PlaygroundAlarmModule(val context: Context) {
private val Context.dataStore: DataStore<Preferences> by preferencesDataStore(name = DATA_STORE_NAME)

private val key = booleanPreferencesKey(ALARM_SETTING)
Expand Down Expand Up @@ -41,7 +41,7 @@ class WoofAlarmModule(val context: Context) {
}

companion object {
private const val ALARM_SETTING = "WOOF_ALARM_SETTING"
private const val DATA_STORE_NAME = "woofAlarmDataStore"
private const val ALARM_SETTING = "PLAYGROUND_ALARM_SETTING"
private const val DATA_STORE_NAME = "playgroundAlarmDataStore"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import com.happy.friendogly.local.model.RecentPetEntity

fun RecentPetEntity.toData(): RecentPetDto =
RecentPetDto(
memberId = id,
memberId = memberId,
petId = petId,
name = name,
imgUrl = imgUrl,
birthday = birthday,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import java.time.LocalDateTime
data class RecentPetEntity(
@ColumnInfo(name = "memberId")
val memberId: Long,
@ColumnInfo(name = "petId")
val petId: Long,
@ColumnInfo(name = "name")
val name: String,
@ColumnInfo(name = "imgUrl")
Expand Down
Loading

0 comments on commit 0b9fc31

Please sign in to comment.