Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT/#75] 아워, 마이 투두 조회, 생성, 삭제 / 서버통신 구현 #84

Merged
merged 28 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1af6549
[ADD/#75] 투두 생성 domain
Marchbreeze Jan 11, 2024
60e5dc5
[FEAT/#75] 투두 생성 data 모듈 설정
Marchbreeze Jan 11, 2024
ad7909a
[ADD/#75] 마이투두 생성 뷰모델 설정
Marchbreeze Jan 11, 2024
1120f79
[FIX/#75] 서버통신 날짜 형식 수정
Marchbreeze Jan 11, 2024
6f5cc28
[FIX/#75] allocator 파라미터 수정
Marchbreeze Jan 11, 2024
7cfc768
[FIX/#75] participantId로 수정
Marchbreeze Jan 11, 2024
b480609
[FIX/#75] 투두 생성 data Unit으로 변경
Marchbreeze Jan 11, 2024
8bc3278
[FIX/#75] 마이투두 리스트어댑터로 변경
Marchbreeze Jan 11, 2024
ce03bfe
[FIX/#75] 투두 생성 시 서버통신 재실행
Marchbreeze Jan 11, 2024
bc5a4ba
[FIX/#75] 투두 재설정 수정
Marchbreeze Jan 11, 2024
51b60f0
[ADD/$75] 아워투두 뷰모델 설정
Marchbreeze Jan 11, 2024
0d3c6b4
[ADD/#75] TripPariticipant 으로 어댑터 설정
Marchbreeze Jan 11, 2024
80917f1
[FEAT/#75] 아워투두 생성 서버통신 구현
Marchbreeze Jan 11, 2024
897d666
[FEAT/#75] 생성 시 리스트 새로고침
Marchbreeze Jan 11, 2024
eb035e4
Merge branch 'develop' of https://github.com/Team-Going/Going-Android…
Marchbreeze Jan 11, 2024
5344db0
[FEAT/#75] 투두삭제 data, domain 모듈 설정
Marchbreeze Jan 11, 2024
2cf2949
[FEAT/#75] 투두조회 data, domain 모듈 설정
Marchbreeze Jan 11, 2024
565b90b
[ADD/#75] 투두 뷰모델 적용
Marchbreeze Jan 11, 2024
0df653d
[MOVE/#75] 투두 조회뷰 재분배
Marchbreeze Jan 11, 2024
178c13b
[FEAT/#75] 아이템 클릭과 연결
Marchbreeze Jan 11, 2024
b826501
[FEAT/#75] 나만보기 투두 조회 완료
Marchbreeze Jan 11, 2024
a59e1be
[FIX/#75] Participant, Allocator 분리
Marchbreeze Jan 11, 2024
2f9d0e7
[ADD/#75] Public 조회 수정
Marchbreeze Jan 11, 2024
94136f5
[FIX/#75] UiState로 다시 변경
Marchbreeze Jan 12, 2024
94861e8
[FIX/#75] 아워투두 이름 맨 앞사람 주황색
Marchbreeze Jan 12, 2024
55b048a
[FEAT/#75] 투두 삭제 구현
Marchbreeze Jan 12, 2024
d5bfbc9
[FIX/#75] manifest 수정
Marchbreeze Jan 12, 2024
6c53ef4
Merge branch 'develop' of https://github.com/Team-Going/Going-Android…
Marchbreeze Jan 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
android:screenOrientation="portrait" />

<activity
android:name="com.going.presentation.todo.mytodo.detail.MyTodoDetailActivity"
android:name="com.going.presentation.todo.detail.PrivateDetailActivity"
android:exported="false"
android:screenOrientation="portrait" />

Expand All @@ -115,7 +115,7 @@
android:screenOrientation="portrait" />

<activity
android:name="com.going.presentation.todo.ourtodo.detail.OurTodoDetailActivity"
android:name="com.going.presentation.todo.detail.PublicDetailActivity"
android:exported="false"
android:screenOrientation="portrait" />

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.going.ui.extension

enum class EnumUiState {
LOADING, SUCCESS, FAILURE
LOADING, SUCCESS, FAILURE, EMPTY
}
21 changes: 19 additions & 2 deletions data/src/main/java/com/going/data/datasource/TodoDataSource.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
package com.going.data.datasource

import com.going.data.dto.BaseResponse
import com.going.data.dto.NonDataBaseResponse
import com.going.data.dto.request.TodoCreateRequestDto
import com.going.data.dto.response.TodoDetailResponseDto
import com.going.data.dto.response.TodoResponseDto

interface TodoDataSource {

suspend fun getTodoListData(
tripId: Long,
category: String,
progress: String,
progress: String
): BaseResponse<List<TodoResponseDto>>
}

suspend fun postToCreateTodoData(
tripId: Long,
request: TodoCreateRequestDto
): NonDataBaseResponse<Unit>

suspend fun deleteTodoData(
todoId: Long
): NonDataBaseResponse<Unit>
Comment on lines +20 to +24
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요거 다시 보니까 T를 안쓰는데 T를 받아오더라구여!
그래서 NoDataBaseResponse에서 NoDataBaseResponse로 수정했습니다! 조만간 올릴텐데 그때 맞춰서 수정하면 좋을 것 같아용~

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네넨


suspend fun getTodoDetailData(
todoId: Long
): BaseResponse<TodoDetailResponseDto>

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package com.going.data.datasourceImpl

import com.going.data.datasource.TodoDataSource
import com.going.data.dto.BaseResponse
import com.going.data.dto.NonDataBaseResponse
import com.going.data.dto.request.TodoCreateRequestDto
import com.going.data.dto.response.TodoDetailResponseDto
import com.going.data.dto.response.TodoResponseDto
import com.going.data.service.TodoService
import javax.inject.Inject
Expand All @@ -17,4 +20,20 @@ class TodoDataSourceImpl @Inject constructor(
): BaseResponse<List<TodoResponseDto>> =
todoService.getTodoList(tripId, category, progress)

override suspend fun postToCreateTodoData(
tripId: Long,
request: TodoCreateRequestDto
): NonDataBaseResponse<Unit> =
todoService.postToCreateTodo(tripId, request)
Comment on lines +25 to +27
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unit으로 설정한 이유가 몬가요...?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

받아올게 없어서요 ~


override suspend fun deleteTodoData(
todoId: Long
): NonDataBaseResponse<Unit> =
todoService.deleteTodo(todoId)

override suspend fun getTodoDetailData(
todoId: Long
): BaseResponse<TodoDetailResponseDto> =
todoService.getTodoDetail(todoId)

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.going.data.dto.request

import com.going.domain.entity.request.TodoCreateRequestModel
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class TodoCreateRequestDto(
@SerialName("title")
val title: String,
@SerialName("endDate")
val endDate: String,
@SerialName("allocators")
val allocators: List<Long>,
@SerialName("memo")
val memo: String?,
@SerialName("secret")
val secret: Boolean
)

fun TodoCreateRequestModel.toTodoCreateRequestDto(): TodoCreateRequestDto =
TodoCreateRequestDto(title, endDate, allocators, memo, secret)
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.going.data.dto.response

import com.going.domain.entity.response.TodoDetailModel
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class TodoDetailResponseDto(
@SerialName("title")
val title: String,
@SerialName("endDate")
val endDate: String,
@SerialName("allocators")
val allocators: List<TodoResponseDto.TodoAllocatorResponseDto>,
@SerialName("memo")
val memo: String,
@SerialName("secret")
val secret: Boolean
) {
fun toTodoDetailModel(): TodoDetailModel =
TodoDetailModel(title, endDate, allocators.map { it.toTodoAllocatorModel() }, memo, secret)
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ data class TodoResponseDto(
@SerialName("secret")
val secret: Boolean
) {

@Serializable
data class TodoAllocatorResponseDto(
@SerialName("name")
Expand All @@ -29,7 +28,6 @@ data class TodoResponseDto(
fun toTodoAllocatorModel() =
TodoAllocatorModel(name, isOwner)
}

fun toTodoModel() =
TodoModel(todoId, title, endDate, allocators.map { it.toTodoAllocatorModel() }, secret)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.going.data.repositoryImpl

import com.going.data.datasource.TodoDataSource
import com.going.data.dto.request.toTodoCreateRequestDto
import com.going.domain.entity.request.TodoCreateRequestModel
import com.going.domain.entity.response.TodoDetailModel
import com.going.domain.entity.response.TodoModel
import com.going.domain.repository.TodoRepository
import javax.inject.Inject
Expand All @@ -18,4 +21,26 @@ class TodoRepositoryImpl @Inject constructor(
todoDataSource.getTodoListData(tripId, category, progress).data.map { it.toTodoModel() }
}

override suspend fun postToCreateTodo(
tripId: Long,
request: TodoCreateRequestModel
): Result<Unit> =
runCatching {
todoDataSource.postToCreateTodoData(tripId, request.toTodoCreateRequestDto())
}

override suspend fun deleteTodo(
todoId: Long
): Result<Unit> =
runCatching {
todoDataSource.deleteTodoData(todoId)
}

override suspend fun getTodoDetail(
todoId: Long
): Result<TodoDetailModel> =
runCatching {
todoDataSource.getTodoDetailData(todoId).data.toTodoDetailModel()
}

}
22 changes: 22 additions & 0 deletions data/src/main/java/com/going/data/service/TodoService.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package com.going.data.service

import com.going.data.dto.BaseResponse
import com.going.data.dto.NonDataBaseResponse
import com.going.data.dto.request.TodoCreateRequestDto
import com.going.data.dto.response.TodoDetailResponseDto
import com.going.data.dto.response.TodoResponseDto
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Path
import retrofit2.http.Query

Expand All @@ -15,4 +21,20 @@ interface TodoService {
@Query("progress") progress: String
): BaseResponse<List<TodoResponseDto>>

@POST("api/trips/{tripId}/todos")
suspend fun postToCreateTodo(
@Path("tripId") tripId: Long,
@Body request: TodoCreateRequestDto
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이렇게 감싸야하는군요 오늘도 배워갑니다

): NonDataBaseResponse<Unit>

@DELETE("api/trips/todos/{todoId}")
suspend fun deleteTodo(
@Path("todoId") todoId: Long
): NonDataBaseResponse<Unit>

@GET("api/trips/todos/{todoId}")
suspend fun getTodoDetail(
@Path("todoId") todoId: Long
): BaseResponse<TodoDetailResponseDto>

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.going.domain.entity.request

data class TodoCreateRequestModel(
val title: String,
val endDate: String,
val allocators: List<Long>,
val memo: String?,
val secret: Boolean
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.going.domain.entity.response

data class TodoDetailModel(
val title: String,
val endDate: String,
val allocators: List<TodoAllocatorModel>,
val memo: String,
val secret: Boolean
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.going.domain.repository

import com.going.domain.entity.request.TodoCreateRequestModel
import com.going.domain.entity.response.TodoDetailModel
import com.going.domain.entity.response.TodoModel

interface TodoRepository {
Expand All @@ -10,4 +12,17 @@ interface TodoRepository {
progress: String
): Result<List<TodoModel>>

suspend fun postToCreateTodo(
tripId: Long,
request: TodoCreateRequestModel
): Result<Unit>

suspend fun deleteTodo(
todoId: Long
): Result<Unit>

suspend fun getTodoDetail(
todoId: Long
): Result<TodoDetailModel>

}
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ class SettingLogoutDialogFragment() :
private fun observeUserSignOutState() {
viewModel.userSignOutState.flowWithLifecycle(lifecycle).onEach { state ->
when (state) {
EnumUiState.LOADING -> {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{} 처리하는 것과 return@onEach 하는 것의 차이가 뭔가요???
지금까지 {}로 했는데 불필요한 내용을 실행하지 않는다는 의미로 return@onEach이 더 맞는거 같다는생각이 들었습니당

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

밑에는 return@onEach로 되어있네요! 하나로 통일하면 더 좋을 것 같습니다 :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{} 제 파일 아님요 ㅋㅋ
저는 그냥 {}에 주황 밑줄 그어지는거 싫어서 리턴해버림

EnumUiState.SUCCESS -> restartApp(requireContext())
EnumUiState.FAILURE -> toast(getString(R.string.server_error))
EnumUiState.LOADING -> {}
EnumUiState.EMPTY -> {}
}
}.launchIn(lifecycleScope)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ class SettingQuitDialogFragment :
private fun observeUserWithDrawState() {
viewModel.userWithDrawState.flowWithLifecycle(lifecycle).onEach { state ->
when (state) {
EnumUiState.LOADING -> {}
EnumUiState.SUCCESS -> restartApp(requireContext())
EnumUiState.FAILURE -> toast(getString(R.string.server_error))
EnumUiState.LOADING -> {}
EnumUiState.EMPTY -> {}
}
}.launchIn(lifecycleScope)
}
Expand Down
Loading