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

πŸ”€ :: (#236) - Apply api changes #243

Merged
merged 6 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 14 additions & 0 deletions core/data/src/main/java/com/msg/data/di/RepositoryModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import com.msg.data.repository.email.EmailRepository
import com.msg.data.repository.email.EmailRepositoryImpl
import com.msg.data.repository.faq.FaqRepository
import com.msg.data.repository.faq.FaqRepositoryImpl
import com.msg.data.repository.government.GovernmentRepository
import com.msg.data.repository.government.GovernmentRepositoryImpl
import com.msg.data.repository.lecture.LectureRepository
import com.msg.data.repository.lecture.LectureRepositoryImpl
import com.msg.data.repository.map.MapRepository
Expand All @@ -22,6 +24,8 @@ import com.msg.data.repository.post.PostRepository
import com.msg.data.repository.post.PostRepositoryImpl
import com.msg.data.repository.school.SchoolRepository
import com.msg.data.repository.school.SchoolRepositoryImpl
import com.msg.data.repository.university.UniversityRepository
import com.msg.data.repository.university.UniversityRepositoryImpl
import com.msg.data.repository.user.UserRepository
import com.msg.data.repository.user.UserRepositoryImpl
import dagger.Binds
Expand Down Expand Up @@ -87,6 +91,16 @@ abstract class RepositoryModule {
schoolRepositoryImpl: SchoolRepositoryImpl
): SchoolRepository

@Binds
abstract fun bindUniversityRepository(
universityRepositoryImpl: UniversityRepositoryImpl
): UniversityRepository

@Binds
abstract fun bindGovernmentRepository(
governmentRepositoryImpl: GovernmentRepositoryImpl
): GovernmentRepository

@Binds
abstract fun bindMapRepository(
mapRepositoryImpl: MapRepositoryImpl
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.msg.data.mapper.club

import com.msg.model.param.club.PostClubParam
import com.msg.network.request.club.PostClubRequest

fun PostClubParam.toRequest() = PostClubRequest(
clubName = clubName,
field = field
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.msg.data.mapper.company

import com.msg.model.entity.company.GetCompanyListEntity
import com.msg.model.entity.company.GetCompanyListEntity.Company as DomainCompany
import com.msg.network.response.company.GetCompanyListResponse

fun GetCompanyListResponse.toEntity() = GetCompanyListEntity(
companies = companies.map { it.toDomainCompany() }
)

fun GetCompanyListResponse.Company.toDomainCompany() = DomainCompany(
id = id,
companyName = companyName,
field = field
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.msg.data.mapper.company

import com.msg.model.param.company.PostCompanyParam
import com.msg.network.request.company.PostCompanyRequest

fun PostCompanyParam.toRequest() = PostCompanyRequest(
companyName = companyName,
field = field
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.msg.data.mapper.government

import com.msg.model.entity.government.GetGovernmentEntity
import com.msg.network.response.government.GetGovernmentResponse
import com.msg.model.entity.government.GetGovernmentEntity.Government as DomainGovernment
import com.msg.network.response.government.GetGovernmentResponse.Government

fun GetGovernmentResponse.toEntity() = GetGovernmentEntity(
governments = governments.map { it.toDomainGovernment() }
)

fun Government.toDomainGovernment() = DomainGovernment(
id = id,
field = field,
governmentName = governmentName
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.msg.data.mapper.government

import com.msg.model.param.government.PostGovernmentParam
import com.msg.network.request.government.PostGovernmentRequest

fun PostGovernmentParam.toRequest() = PostGovernmentRequest(
field = field,
governmentName = governmentName
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.msg.data.mapper.school

import com.msg.model.param.school.PatchSchoolParam
import com.msg.network.request.school.PatchSchoolRequest

fun PatchSchoolParam.toRequest() = PatchSchoolRequest(
schoolName = schoolName,
line = line,
logoImage = logoImage
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.msg.data.mapper.university

import com.msg.model.entity.university.GetUniversityEntity
import com.msg.network.response.university.GetUniversityResponse
import com.msg.model.entity.university.GetUniversityEntity.University as DomainUniversity
import com.msg.network.response.university.GetUniversityResponse.University

fun GetUniversityResponse.toEntity() = GetUniversityEntity(
universities = universities.map { it.toDomainUniversity() }
)

fun University.toDomainUniversity() = DomainUniversity(
id = id,
universityName = universityName,
departments = departments
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.msg.data.mapper.university

import com.msg.model.param.university.PostDepartmentParam
import com.msg.network.request.university.PostDepartmentRequest

fun PostDepartmentParam.toRequest() = PostDepartmentRequest(
department = department
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.msg.data.mapper.university

import com.msg.model.param.university.PostUniversityParam
import com.msg.network.request.university.PostUniversityRequest

fun PostUniversityParam.toRequest() = PostUniversityRequest(
universityName = universityName
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ import com.msg.model.entity.club.ClubListEntity
import com.msg.model.entity.club.StudentBelongClubEntity
import com.msg.model.enumdata.HighSchool
import com.msg.model.param.club.PatchClubParam
import com.msg.model.param.club.PostClubParam
import kotlinx.coroutines.flow.Flow
import java.util.UUID

interface ClubRepository {
fun getClubList(highSchool: HighSchool): Flow<List<ClubListEntity>>
fun getClubList(highSchool: String): Flow<List<ClubListEntity>>
fun getClubListForSignUp(highSchool: String): Flow<List<String>>
fun getClubDetail(id: Long): Flow<ClubDetailEntity>
fun getStudentBelongClubDetail(id: Long, studentId: UUID): Flow<StudentBelongClubEntity>
fun getMyClubDetail(): Flow<ClubDetailEntity>
fun postClub(schoolId: UUID, body: PostClubParam): Flow<Unit>
fun patchClub(id: Long, body: PatchClubParam): Flow<Unit>
fun deleteClub(id: Long): Flow<Unit>
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.msg.model.entity.club.ClubListEntity
import com.msg.model.entity.club.StudentBelongClubEntity
import com.msg.model.enumdata.HighSchool
import com.msg.model.param.club.PatchClubParam
import com.msg.model.param.club.PostClubParam
import com.msg.network.datasource.club.ClubDataSource
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.transform
Expand All @@ -16,14 +17,20 @@ import javax.inject.Inject
class ClubRepositoryImpl @Inject constructor(
private val clubDataSource: ClubDataSource,
) : ClubRepository {
override fun getClubList(highSchool: HighSchool): Flow<List<ClubListEntity>> {
override fun getClubList(highSchool: String): Flow<List<ClubListEntity>> {
return clubDataSource.getClubList(
highSchool = highSchool
).transform { response ->
response.map { it.toEntity() }
}
}

override fun getClubListForSignUp(highSchool: String): Flow<List<String>> {
return clubDataSource.getClubListForSignUp(
highSchool = highSchool
)
}

override fun getClubDetail(id: Long): Flow<ClubDetailEntity> {
return clubDataSource.getClubDetail(
id = id
Expand Down Expand Up @@ -51,6 +58,13 @@ class ClubRepositoryImpl @Inject constructor(
}
}

override fun postClub(schoolId: UUID, body: PostClubParam): Flow<Unit> {
return clubDataSource.postClub(
schoolId = schoolId,
body = body.toRequest()
)
}

override fun patchClub(id: Long, body: PatchClubParam): Flow<Unit> {
return clubDataSource.patchClub(
id = id,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.msg.data.repository.company

import com.msg.model.entity.company.GetCompanyListEntity
import com.msg.model.param.company.PostCompanyParam
import kotlinx.coroutines.flow.Flow

interface CompanyRepository {
fun getCompanyList(): Flow<GetCompanyListEntity>
fun postCompany(body: PostCompanyParam): Flow<Unit>
fun deleteCompany(id: Long): Flow<Unit>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.msg.data.repository.company

import com.msg.data.mapper.company.toEntity
import com.msg.data.mapper.company.toRequest
import com.msg.model.entity.company.GetCompanyListEntity
import com.msg.model.param.company.PostCompanyParam
import com.msg.network.datasource.company.CompanyDataSource
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.transform
import javax.inject.Inject

class CompanyRepositoryImpl @Inject constructor(
private val companyDataSource: CompanyDataSource
) : CompanyRepository {

override fun getCompanyList(): Flow<GetCompanyListEntity> {
return companyDataSource.getCompanyList().transform {response ->
emit(response.toEntity())
}
}

override fun postCompany(body: PostCompanyParam): Flow<Unit> {
return companyDataSource.postCompany(body = body.toRequest())
}

override fun deleteCompany(id: Long): Flow<Unit> {
return companyDataSource.deleteCompany(id = id)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class FaqRepositoryImpl @Inject constructor(
override fun getFrequentlyAskedQuestionsList(): Flow<List<GetFrequentlyAskedQuestionDetailEntity>> {
return faqDataSource.getFrequentlyAskedQuestionsList()
.transform { response ->
response.map { it.toEntity() }
emit(response.map { it.toEntity() })
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.msg.data.repository.government

import com.msg.model.entity.government.GetGovernmentEntity
import com.msg.model.param.government.PostGovernmentParam
import kotlinx.coroutines.flow.Flow

interface GovernmentRepository {
fun getGovernment(): Flow<GetGovernmentEntity>
fun postGovernment(body: PostGovernmentParam): Flow<Unit>
fun deleteGovernment(id: Long): Flow<Unit>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.msg.data.repository.government

import com.msg.data.mapper.government.toEntity
import com.msg.data.mapper.government.toRequest
import com.msg.model.entity.government.GetGovernmentEntity
import com.msg.model.param.government.PostGovernmentParam
import com.msg.network.datasource.government.GovernmentDataSource
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.transform
import javax.inject.Inject

class GovernmentRepositoryImpl @Inject constructor(
private val governmentDataSource: GovernmentDataSource
) : GovernmentRepository
{

override fun getGovernment(): Flow<GetGovernmentEntity> {
return governmentDataSource.getGovernment().transform {
emit(it.toEntity())
}
}

override fun postGovernment(body: PostGovernmentParam): Flow<Unit> {
return governmentDataSource.postGovernment(body = body.toRequest())
}

override fun deleteGovernment(id: Long): Flow<Unit> {
return governmentDataSource.deleteGovernment(id = id)
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package com.msg.data.repository.school

import com.msg.model.entity.school.GetSchoolListEntity
import com.msg.model.param.school.PatchSchoolParam
import com.msg.model.param.school.PostSchoolParam
import com.msg.network.request.school.PostSchoolRequest
import kotlinx.coroutines.flow.Flow
import java.util.UUID

interface SchoolRepository {
fun getSchoolList(): Flow<GetSchoolListEntity>
fun getSchoolName(): Flow<List<String>>
fun postSchool(body: PostSchoolParam): Flow<Unit>
fun patchSchool(id: Long, body: PatchSchoolParam): Flow<Unit>
fun deleteSchool(id: Long): Flow<Unit>
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@ package com.msg.data.repository.school
import com.msg.data.mapper.school.toEntity
import com.msg.data.mapper.school.toRequest
import com.msg.model.entity.school.GetSchoolListEntity
import com.msg.model.param.school.PatchSchoolParam
import com.msg.model.param.school.PostSchoolParam
import com.msg.network.datasource.school.SchoolDataSource
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.transform
import java.util.UUID
import javax.inject.Inject

class SchoolRepositoryImpl @Inject constructor(
private val schoolDataSource: SchoolDataSource
) : SchoolRepository {
override fun getSchoolList(): Flow<GetSchoolListEntity> {
return schoolDataSource.getSchoolList().transform { response ->
response.toEntity()
emit(response.toEntity())
}
}

Expand All @@ -25,4 +27,12 @@ class SchoolRepositoryImpl @Inject constructor(
override fun postSchool(body: PostSchoolParam): Flow<Unit> {
return schoolDataSource.postSchool(body = body.toRequest())
}

override fun patchSchool(id: Long, body: PatchSchoolParam): Flow<Unit> {
return schoolDataSource.patchSchool(id = id, body = body.toRequest())
}

override fun deleteSchool(id: Long): Flow<Unit> {
return schoolDataSource.deleteSchool(id = id)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.msg.data.repository.university

import com.msg.model.entity.university.GetUniversityEntity
import com.msg.model.param.university.PostDepartmentParam
import com.msg.model.param.university.PostUniversityParam
import kotlinx.coroutines.flow.Flow

interface UniversityRepository {
fun getUniversity(): Flow<GetUniversityEntity>
fun postUniversity(body: PostUniversityParam): Flow<Unit>
fun patchUniversity(id: Long, body: PostUniversityParam): Flow<Unit>
fun deleteUniversity(id: Long): Flow<Unit>
fun postDepartment(body: PostDepartmentParam): Flow<Unit>
fun deleteDepartment(id: Long, department: String): Flow<Unit>
}
Loading
Loading