Skip to content

Commit

Permalink
[FEATURE] #105 : DeleteEvent 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
tgyuuAn committed Jan 17, 2024
1 parent 9183a32 commit f55643e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ interface EventRepository {

suspend fun getEvent(eventId: String): Result<Event>

suspend fun deleteEvent(eventId: String): Result<Unit>

suspend fun postEvent(
title: String,
content: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class EventRepositoryImpl @Inject constructor(
override suspend fun getEvent(eventId: String): Result<Event> =
eventDataSource.getEvent(eventId).mapCatching { eventResponse -> eventResponse.toDomain() }

override suspend fun deleteEvent(eventId: String): Result<Unit> =
eventDataSource.deleteEvent(eventId)

override suspend fun postEvent(
title: String,
content: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -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<List<Event>> =
eventRepository.getEventList()
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ interface EventDataSource {

suspend fun getEvent(eventId: String): Result<EventResponse>

suspend fun deleteEvent(eventId: String): Result<Unit>

suspend fun postEvent(
title: String,
content: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ class EventDataSourceImpl @Inject constructor(
checkNotNull(document.toObject<EventResponse>())
}

override suspend fun deleteEvent(eventId: String): Result<Unit> = runCatching {
firebaseFirestore.collection(EVENT_COLLECTION)
.document(eventId)
.delete()
.await()
}

override suspend fun postEvent(
title: String,
content: String,
Expand Down

0 comments on commit f55643e

Please sign in to comment.