diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepository.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepository.kt index a052f913..0ac05a60 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepository.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepository.kt @@ -15,6 +15,8 @@ interface EventRepository { suspend fun getEvent(eventId: String): Result + suspend fun deleteEvent(eventId: String): Result + suspend fun postEvent( title: String, content: String, diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepositoryImpl.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepositoryImpl.kt index cecbfd55..0c05b251 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepositoryImpl.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/event/EventRepositoryImpl.kt @@ -41,6 +41,9 @@ class EventRepositoryImpl @Inject constructor( override suspend fun getEvent(eventId: String): Result = eventDataSource.getEvent(eventId).mapCatching { eventResponse -> eventResponse.toDomain() } + override suspend fun deleteEvent(eventId: String): Result = + eventDataSource.deleteEvent(eventId) + override suspend fun postEvent( title: String, content: String, diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/DeleteEventUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/DeleteEventUseCase.kt new file mode 100644 index 00000000..cbc7bc67 --- /dev/null +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/event/DeleteEventUseCase.kt @@ -0,0 +1,12 @@ +package com.wap.wapp.core.domain.usecase.event + +import com.wap.wapp.core.data.repository.event.EventRepository +import com.wap.wapp.core.model.event.Event +import javax.inject.Inject + +class DeleteEventUseCase @Inject constructor( + private val eventRepository: EventRepository, +) { + suspend operator fun invoke(eventId: String): Result> = + eventRepository.getEventList() +} diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSource.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSource.kt index 95a36997..f0c4aabb 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSource.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSource.kt @@ -14,6 +14,8 @@ interface EventDataSource { suspend fun getEvent(eventId: String): Result + suspend fun deleteEvent(eventId: String): Result + suspend fun postEvent( title: String, content: String, diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt index 54b51350..adbd9dde 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt @@ -112,6 +112,13 @@ class EventDataSourceImpl @Inject constructor( checkNotNull(document.toObject()) } + override suspend fun deleteEvent(eventId: String): Result = runCatching { + firebaseFirestore.collection(EVENT_COLLECTION) + .document(eventId) + .delete() + .await() + } + override suspend fun postEvent( title: String, content: String,