-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #350 from 6QuizOnTheBlock/and/feat#320-teacher_man…
…age_class And/feat#320 선생님 학급 설정 탭 세부 기능 구현
- Loading branch information
Showing
52 changed files
with
1,625 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp"> | ||
|
||
<path android:fillColor="@android:color/white" android:pathData="M16,1L4,1c-1.1,0 -2,0.9 -2,2v14h2L4,3h12L16,1zM19,5L8,5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h11c1.1,0 2,-0.9 2,-2L21,7c0,-1.1 -0.9,-2 -2,-2zM19,21L8,21L8,7h11v14z"/> | ||
|
||
</vector> |
6 changes: 6 additions & 0 deletions
6
android/core/model/src/main/java/com/sixkids/model/ChatFilterWord.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.sixkids.model | ||
|
||
data class ChatFilterWord( | ||
val id: Long, | ||
val badWord: String, | ||
) |
7 changes: 7 additions & 0 deletions
7
android/core/model/src/main/java/com/sixkids/model/ClassSummary.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.sixkids.model | ||
|
||
data class ClassSummary( | ||
val challengeCounts: List<MemberSimpleClassSummary>, | ||
val relayCounts: List<MemberSimpleClassSummary>, | ||
val postsCounts: List<MemberSimpleClassSummary>, | ||
) |
6 changes: 6 additions & 0 deletions
6
android/core/model/src/main/java/com/sixkids/model/MemberSimpleClassSummary.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.sixkids.model | ||
|
||
data class MemberSimpleClassSummary ( | ||
val member: MemberSimple, | ||
val count: Int | ||
) |
41 changes: 41 additions & 0 deletions
41
android/data/src/main/java/com/sixkids/data/api/ChatFilterService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.sixkids.data.api | ||
|
||
import com.sixkids.data.model.request.ChatFilterRequest | ||
import com.sixkids.data.model.response.ChattingFilterListResponse | ||
import com.sixkids.data.model.response.ChattingFilterResponse | ||
import com.sixkids.data.network.ApiResponse | ||
import com.sixkids.data.network.ApiResult | ||
import retrofit2.http.Body | ||
import retrofit2.http.DELETE | ||
import retrofit2.http.GET | ||
import retrofit2.http.PATCH | ||
import retrofit2.http.POST | ||
import retrofit2.http.Path | ||
import retrofit2.http.Query | ||
|
||
interface ChatFilterService { | ||
@GET("filters") | ||
suspend fun getChatFilters( | ||
@Query("organizationId") organizationId: Int, | ||
@Query("page") page: Int, | ||
@Query("size") size: Int, | ||
): ApiResult<ApiResponse<ChattingFilterListResponse>> | ||
|
||
@DELETE("filters/{id}") | ||
suspend fun deleteChatFilter( | ||
@Path("id") id: Long, | ||
): ApiResult<ApiResponse<Boolean>> | ||
|
||
@POST("filters/{organizationId}") | ||
suspend fun createChatFilter( | ||
@Path("organizationId") organizationId: Long, | ||
@Body badWord: ChatFilterRequest, | ||
): ApiResult<ApiResponse<Long>> | ||
|
||
@PATCH("filters/{organizationId}/{id}") | ||
suspend fun updateChatFilter( | ||
@Path("organizationId") organizationId: Long, | ||
@Path("id") id: Long, | ||
@Body badWord: ChatFilterRequest, | ||
): ApiResult<ApiResponse<Boolean>> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
android/data/src/main/java/com/sixkids/data/model/request/ChatFilterRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.sixkids.data.model.request | ||
|
||
data class ChatFilterRequest( | ||
val badWord: String, | ||
) |
20 changes: 20 additions & 0 deletions
20
android/data/src/main/java/com/sixkids/data/model/response/ChattingFilterListResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.sixkids.data.model.response | ||
|
||
import com.sixkids.model.ChatFilterWord | ||
|
||
data class ChattingFilterListResponse( | ||
val hasNext: Boolean, | ||
val words: List<ChattingFilterResponse>, | ||
) | ||
|
||
data class ChattingFilterResponse( | ||
val id: Long, | ||
val badWord: String, | ||
) | ||
|
||
fun ChattingFilterResponse.toModel(): ChatFilterWord { | ||
return ChatFilterWord( | ||
id = id, | ||
badWord = badWord, | ||
) | ||
} |
21 changes: 21 additions & 0 deletions
21
android/data/src/main/java/com/sixkids/data/model/response/ClassSummaryResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.sixkids.data.model.response | ||
|
||
import com.sixkids.model.MemberSimpleClassSummary | ||
|
||
data class ClassSummaryResponse( | ||
val challengeCounts: List<ClassSummaryMemberResponse>, | ||
val relayCounts: List<ClassSummaryMemberResponse>, | ||
val postsCounts: List<ClassSummaryMemberResponse>, | ||
) | ||
|
||
data class ClassSummaryMemberResponse( | ||
val member: MemberSimpleInfoResponse, | ||
val count: Int | ||
) | ||
|
||
fun ClassSummaryMemberResponse.toModel(): MemberSimpleClassSummary { | ||
return MemberSimpleClassSummary( | ||
member.toModel(), | ||
count | ||
) | ||
} |
5 changes: 5 additions & 0 deletions
5
android/data/src/main/java/com/sixkids/data/model/response/OrganizationInviteCodeResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.sixkids.data.model.response | ||
|
||
data class OrganizationInviteCodeResponse( | ||
val code: String | ||
) |
5 changes: 5 additions & 0 deletions
5
android/data/src/main/java/com/sixkids/data/model/response/OrganizationNameResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.sixkids.data.model.response | ||
|
||
data class OrganizationNameResponse( | ||
val name: String | ||
) |
54 changes: 54 additions & 0 deletions
54
.../src/main/java/com/sixkids/data/repository/chattingfilter/ChattingFilterRepositoryImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.sixkids.data.repository.chattingfilter | ||
|
||
import androidx.paging.Pager | ||
import androidx.paging.PagingConfig | ||
import androidx.paging.PagingData | ||
import androidx.paging.map | ||
import com.sixkids.data.api.ChatFilterService | ||
import com.sixkids.data.model.response.toModel | ||
import com.sixkids.data.repository.chattingfilter.remote.ChattingFilterPagingSource | ||
import com.sixkids.data.repository.chattingfilter.remote.ChattingFilterRemoteDataSource | ||
import com.sixkids.domain.repository.ChattingFilterRepository | ||
import com.sixkids.model.ChatFilterWord | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.map | ||
import javax.inject.Inject | ||
|
||
class ChattingFilterRepositoryImpl @Inject constructor( | ||
private val chattingFilterRemoteDataSource: ChattingFilterRemoteDataSource, | ||
private val chatFilterService: ChatFilterService | ||
) : ChattingFilterRepository { | ||
override suspend fun getChattingFilters( | ||
organizationId: Int | ||
): Flow<PagingData<ChatFilterWord>> { | ||
return Pager( | ||
config = PagingConfig(ChattingFilterPagingSource.DEFAULT_SIZE), | ||
pagingSourceFactory = { | ||
ChattingFilterPagingSource( | ||
chatFilterService, | ||
organizationId | ||
) | ||
} | ||
).flow.map {pagingData -> | ||
pagingData.map { | ||
chattingFilterResponse -> chattingFilterResponse.toModel() | ||
} | ||
} | ||
} | ||
|
||
override suspend fun deleteChatFilter(id: Long): Boolean { | ||
return chattingFilterRemoteDataSource.deleteChatFilter(id) | ||
} | ||
|
||
override suspend fun createChatFilter(organizationId: Long, badWord: String): Long { | ||
return chattingFilterRemoteDataSource.createChatFilter(organizationId, badWord) | ||
} | ||
|
||
override suspend fun updateChatFilter( | ||
organizationId: Long, | ||
id: Long, | ||
badWord: String | ||
): Boolean { | ||
return chattingFilterRemoteDataSource.updateChatFilter(organizationId, id, badWord) | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...main/java/com/sixkids/data/repository/chattingfilter/remote/ChattingFilterPagingSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.sixkids.data.repository.chattingfilter.remote | ||
|
||
import androidx.paging.PagingSource | ||
import androidx.paging.PagingState | ||
import com.sixkids.data.api.ChatFilterService | ||
import com.sixkids.data.api.ChattingService | ||
import com.sixkids.data.model.response.ChattingFilterListResponse | ||
import com.sixkids.data.model.response.ChattingFilterResponse | ||
import javax.inject.Inject | ||
|
||
class ChattingFilterPagingSource @Inject constructor( | ||
private val chatFilterService: ChatFilterService, | ||
private val organizationId: Int, | ||
): PagingSource<Int, ChattingFilterResponse>() { | ||
override fun getRefreshKey(state: PagingState<Int, ChattingFilterResponse>): Int? { | ||
return state.anchorPosition?.let { anchorPosition -> | ||
state.closestPageToPosition(anchorPosition)?.prevKey?.plus(1) | ||
?: state.closestPageToPosition(anchorPosition)?.nextKey?.minus(1) | ||
} | ||
} | ||
|
||
override suspend fun load(params: LoadParams<Int>): LoadResult<Int, ChattingFilterResponse> { | ||
val page = params.key ?: 0 | ||
return try { | ||
val response = chatFilterService.getChatFilters( | ||
organizationId, | ||
page, | ||
DEFAULT_SIZE | ||
).getOrThrow().data.words | ||
|
||
LoadResult.Page( | ||
data = response, | ||
prevKey = if (page == 0) null else page.minus(1), | ||
nextKey = if (response.isEmpty()) null else page.plus(1) | ||
) | ||
} catch (e: Exception) { | ||
LoadResult.Error(e) | ||
} | ||
} | ||
|
||
companion object { | ||
const val DEFAULT_SIZE = 30 | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
.../java/com/sixkids/data/repository/chattingfilter/remote/ChattingFilterRemoteDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.sixkids.data.repository.chattingfilter.remote | ||
|
||
import com.sixkids.data.model.response.ChattingFilterListResponse | ||
|
||
interface ChattingFilterRemoteDataSource { | ||
|
||
suspend fun deleteChatFilter( | ||
id: Long | ||
): Boolean | ||
|
||
suspend fun createChatFilter( | ||
organizationId: Long, | ||
badWord: String, | ||
): Long | ||
|
||
suspend fun updateChatFilter( | ||
organizationId: Long, | ||
id: Long, | ||
badWord: String, | ||
): Boolean | ||
|
||
} |
Oops, something went wrong.