diff --git a/core/data/src/main/java/com/msg/data/di/RepositoryModule.kt b/core/data/src/main/java/com/msg/data/di/RepositoryModule.kt index 16b2775b..e501f5b3 100644 --- a/core/data/src/main/java/com/msg/data/di/RepositoryModule.kt +++ b/core/data/src/main/java/com/msg/data/di/RepositoryModule.kt @@ -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 @@ -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 @@ -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 diff --git a/core/data/src/main/java/com/msg/data/mapper/club/PostClubMapper.kt b/core/data/src/main/java/com/msg/data/mapper/club/PostClubMapper.kt new file mode 100644 index 00000000..566ff62f --- /dev/null +++ b/core/data/src/main/java/com/msg/data/mapper/club/PostClubMapper.kt @@ -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 +) \ No newline at end of file diff --git a/core/data/src/main/java/com/msg/data/mapper/company/GetCompanyListMapper.kt b/core/data/src/main/java/com/msg/data/mapper/company/GetCompanyListMapper.kt new file mode 100644 index 00000000..cb3a241a --- /dev/null +++ b/core/data/src/main/java/com/msg/data/mapper/company/GetCompanyListMapper.kt @@ -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 +) \ No newline at end of file diff --git a/core/data/src/main/java/com/msg/data/mapper/company/PostCompanyMapper.kt b/core/data/src/main/java/com/msg/data/mapper/company/PostCompanyMapper.kt new file mode 100644 index 00000000..ecd78f7b --- /dev/null +++ b/core/data/src/main/java/com/msg/data/mapper/company/PostCompanyMapper.kt @@ -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 +) \ No newline at end of file diff --git a/core/data/src/main/java/com/msg/data/mapper/government/GetGovernmentMapper.kt b/core/data/src/main/java/com/msg/data/mapper/government/GetGovernmentMapper.kt new file mode 100644 index 00000000..5f5e9fbe --- /dev/null +++ b/core/data/src/main/java/com/msg/data/mapper/government/GetGovernmentMapper.kt @@ -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 +) \ No newline at end of file diff --git a/core/data/src/main/java/com/msg/data/mapper/government/PostGovernmentMapper.kt b/core/data/src/main/java/com/msg/data/mapper/government/PostGovernmentMapper.kt new file mode 100644 index 00000000..e8651f69 --- /dev/null +++ b/core/data/src/main/java/com/msg/data/mapper/government/PostGovernmentMapper.kt @@ -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 +) \ No newline at end of file diff --git a/core/data/src/main/java/com/msg/data/mapper/school/PatchSchoolMapper.kt b/core/data/src/main/java/com/msg/data/mapper/school/PatchSchoolMapper.kt new file mode 100644 index 00000000..a36226f7 --- /dev/null +++ b/core/data/src/main/java/com/msg/data/mapper/school/PatchSchoolMapper.kt @@ -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 +) \ No newline at end of file diff --git a/core/data/src/main/java/com/msg/data/mapper/university/GetUniversityMapper.kt b/core/data/src/main/java/com/msg/data/mapper/university/GetUniversityMapper.kt new file mode 100644 index 00000000..a49fa3d0 --- /dev/null +++ b/core/data/src/main/java/com/msg/data/mapper/university/GetUniversityMapper.kt @@ -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 +) \ No newline at end of file diff --git a/core/data/src/main/java/com/msg/data/mapper/university/PostDepartmentMapper.kt b/core/data/src/main/java/com/msg/data/mapper/university/PostDepartmentMapper.kt new file mode 100644 index 00000000..da755e66 --- /dev/null +++ b/core/data/src/main/java/com/msg/data/mapper/university/PostDepartmentMapper.kt @@ -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 +) \ No newline at end of file diff --git a/core/data/src/main/java/com/msg/data/mapper/university/PostUniversityMapper.kt b/core/data/src/main/java/com/msg/data/mapper/university/PostUniversityMapper.kt new file mode 100644 index 00000000..e33faeeb --- /dev/null +++ b/core/data/src/main/java/com/msg/data/mapper/university/PostUniversityMapper.kt @@ -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 +) \ No newline at end of file diff --git a/core/data/src/main/java/com/msg/data/repository/club/ClubRepository.kt b/core/data/src/main/java/com/msg/data/repository/club/ClubRepository.kt index f2b64081..edd9f046 100644 --- a/core/data/src/main/java/com/msg/data/repository/club/ClubRepository.kt +++ b/core/data/src/main/java/com/msg/data/repository/club/ClubRepository.kt @@ -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> + fun getClubList(highSchool: String): Flow> + fun getClubListForSignUp(highSchool: String): Flow> fun getClubDetail(id: Long): Flow fun getStudentBelongClubDetail(id: Long, studentId: UUID): Flow fun getMyClubDetail(): Flow + fun postClub(schoolId: UUID, body: PostClubParam): Flow fun patchClub(id: Long, body: PatchClubParam): Flow fun deleteClub(id: Long): Flow } \ No newline at end of file diff --git a/core/data/src/main/java/com/msg/data/repository/club/ClubRepositoryImpl.kt b/core/data/src/main/java/com/msg/data/repository/club/ClubRepositoryImpl.kt index 022b113d..0ff0dae0 100644 --- a/core/data/src/main/java/com/msg/data/repository/club/ClubRepositoryImpl.kt +++ b/core/data/src/main/java/com/msg/data/repository/club/ClubRepositoryImpl.kt @@ -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 @@ -16,7 +17,7 @@ import javax.inject.Inject class ClubRepositoryImpl @Inject constructor( private val clubDataSource: ClubDataSource, ) : ClubRepository { - override fun getClubList(highSchool: HighSchool): Flow> { + override fun getClubList(highSchool: String): Flow> { return clubDataSource.getClubList( highSchool = highSchool ).transform { response -> @@ -24,6 +25,12 @@ class ClubRepositoryImpl @Inject constructor( } } + override fun getClubListForSignUp(highSchool: String): Flow> { + return clubDataSource.getClubListForSignUp( + highSchool = highSchool + ) + } + override fun getClubDetail(id: Long): Flow { return clubDataSource.getClubDetail( id = id @@ -51,6 +58,13 @@ class ClubRepositoryImpl @Inject constructor( } } + override fun postClub(schoolId: UUID, body: PostClubParam): Flow { + return clubDataSource.postClub( + schoolId = schoolId, + body = body.toRequest() + ) + } + override fun patchClub(id: Long, body: PatchClubParam): Flow { return clubDataSource.patchClub( id = id, diff --git a/core/data/src/main/java/com/msg/data/repository/company/CompanyRepository.kt b/core/data/src/main/java/com/msg/data/repository/company/CompanyRepository.kt new file mode 100644 index 00000000..976e7460 --- /dev/null +++ b/core/data/src/main/java/com/msg/data/repository/company/CompanyRepository.kt @@ -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 + fun postCompany(body: PostCompanyParam): Flow + fun deleteCompany(id: Long): Flow +} \ No newline at end of file diff --git a/core/data/src/main/java/com/msg/data/repository/company/CompanyRepositoryImpl.kt b/core/data/src/main/java/com/msg/data/repository/company/CompanyRepositoryImpl.kt new file mode 100644 index 00000000..85854bcb --- /dev/null +++ b/core/data/src/main/java/com/msg/data/repository/company/CompanyRepositoryImpl.kt @@ -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 { + return companyDataSource.getCompanyList().transform {response -> + emit(response.toEntity()) + } + } + + override fun postCompany(body: PostCompanyParam): Flow { + return companyDataSource.postCompany(body = body.toRequest()) + } + + override fun deleteCompany(id: Long): Flow { + return companyDataSource.deleteCompany(id = id) + } +} \ No newline at end of file diff --git a/core/data/src/main/java/com/msg/data/repository/faq/FaqRepositoryImpl.kt b/core/data/src/main/java/com/msg/data/repository/faq/FaqRepositoryImpl.kt index 358d27b3..0b380510 100644 --- a/core/data/src/main/java/com/msg/data/repository/faq/FaqRepositoryImpl.kt +++ b/core/data/src/main/java/com/msg/data/repository/faq/FaqRepositoryImpl.kt @@ -21,7 +21,7 @@ class FaqRepositoryImpl @Inject constructor( override fun getFrequentlyAskedQuestionsList(): Flow> { return faqDataSource.getFrequentlyAskedQuestionsList() .transform { response -> - response.map { it.toEntity() } + emit(response.map { it.toEntity() }) } } } \ No newline at end of file diff --git a/core/data/src/main/java/com/msg/data/repository/government/GovernmentRepository.kt b/core/data/src/main/java/com/msg/data/repository/government/GovernmentRepository.kt new file mode 100644 index 00000000..8f9cb34a --- /dev/null +++ b/core/data/src/main/java/com/msg/data/repository/government/GovernmentRepository.kt @@ -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 + fun postGovernment(body: PostGovernmentParam): Flow + fun deleteGovernment(id: Long): Flow +} \ No newline at end of file diff --git a/core/data/src/main/java/com/msg/data/repository/government/GovernmentRepositoryImpl.kt b/core/data/src/main/java/com/msg/data/repository/government/GovernmentRepositoryImpl.kt new file mode 100644 index 00000000..f90dbe5c --- /dev/null +++ b/core/data/src/main/java/com/msg/data/repository/government/GovernmentRepositoryImpl.kt @@ -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 { + return governmentDataSource.getGovernment().transform { + emit(it.toEntity()) + } + } + + override fun postGovernment(body: PostGovernmentParam): Flow { + return governmentDataSource.postGovernment(body = body.toRequest()) + } + + override fun deleteGovernment(id: Long): Flow { + return governmentDataSource.deleteGovernment(id = id) + } +} \ No newline at end of file diff --git a/core/data/src/main/java/com/msg/data/repository/school/SchoolRepository.kt b/core/data/src/main/java/com/msg/data/repository/school/SchoolRepository.kt index 4b9ba254..33ab4efc 100644 --- a/core/data/src/main/java/com/msg/data/repository/school/SchoolRepository.kt +++ b/core/data/src/main/java/com/msg/data/repository/school/SchoolRepository.kt @@ -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 fun getSchoolName(): Flow> fun postSchool(body: PostSchoolParam): Flow + fun patchSchool(id: Long, body: PatchSchoolParam): Flow + fun deleteSchool(id: Long): Flow } \ No newline at end of file diff --git a/core/data/src/main/java/com/msg/data/repository/school/SchoolRepositoryImpl.kt b/core/data/src/main/java/com/msg/data/repository/school/SchoolRepositoryImpl.kt index 0556eb78..5ea39981 100644 --- a/core/data/src/main/java/com/msg/data/repository/school/SchoolRepositoryImpl.kt +++ b/core/data/src/main/java/com/msg/data/repository/school/SchoolRepositoryImpl.kt @@ -3,10 +3,12 @@ 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( @@ -14,7 +16,7 @@ class SchoolRepositoryImpl @Inject constructor( ) : SchoolRepository { override fun getSchoolList(): Flow { return schoolDataSource.getSchoolList().transform { response -> - response.toEntity() + emit(response.toEntity()) } } @@ -25,4 +27,12 @@ class SchoolRepositoryImpl @Inject constructor( override fun postSchool(body: PostSchoolParam): Flow { return schoolDataSource.postSchool(body = body.toRequest()) } + + override fun patchSchool(id: Long, body: PatchSchoolParam): Flow { + return schoolDataSource.patchSchool(id = id, body = body.toRequest()) + } + + override fun deleteSchool(id: Long): Flow { + return schoolDataSource.deleteSchool(id = id) + } } \ No newline at end of file diff --git a/core/data/src/main/java/com/msg/data/repository/university/UniversityRepository.kt b/core/data/src/main/java/com/msg/data/repository/university/UniversityRepository.kt new file mode 100644 index 00000000..ff930668 --- /dev/null +++ b/core/data/src/main/java/com/msg/data/repository/university/UniversityRepository.kt @@ -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 + fun postUniversity(body: PostUniversityParam): Flow + fun patchUniversity(id: Long, body: PostUniversityParam): Flow + fun deleteUniversity(id: Long): Flow + fun postDepartment(body: PostDepartmentParam): Flow + fun deleteDepartment(id: Long, department: String): Flow +} \ No newline at end of file diff --git a/core/data/src/main/java/com/msg/data/repository/university/UniversityRepositoryImpl.kt b/core/data/src/main/java/com/msg/data/repository/university/UniversityRepositoryImpl.kt new file mode 100644 index 00000000..eeb47e5e --- /dev/null +++ b/core/data/src/main/java/com/msg/data/repository/university/UniversityRepositoryImpl.kt @@ -0,0 +1,42 @@ +package com.msg.data.repository.university + +import com.msg.data.mapper.university.toEntity +import com.msg.data.mapper.university.toRequest +import com.msg.model.entity.university.GetUniversityEntity +import com.msg.model.param.university.PostDepartmentParam +import com.msg.model.param.university.PostUniversityParam +import com.msg.network.datasource.university.UniversityDataSource +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.transform +import javax.inject.Inject + +class UniversityRepositoryImpl @Inject constructor( + private val universityDataSource: UniversityDataSource +) : UniversityRepository { + + override fun getUniversity(): Flow { + return universityDataSource.getUniversity().transform { + emit(it.toEntity()) + } + } + + override fun postUniversity(body: PostUniversityParam): Flow { + return universityDataSource.postUniversity(body = body.toRequest()) + } + + override fun patchUniversity(id: Long, body: PostUniversityParam): Flow { + return universityDataSource.patchUniversity(id = id, body = body.toRequest()) + } + + override fun deleteUniversity(id: Long): Flow { + return universityDataSource.deleteUniversity(id = id) + } + + override fun postDepartment(body: PostDepartmentParam): Flow { + return universityDataSource.postDepartment(body = body.toRequest()) + } + + override fun deleteDepartment(id: Long, department: String): Flow { + return universityDataSource.deleteDepartment(id = id, department = department) + } +} \ No newline at end of file diff --git a/core/domain/src/main/java/com/msg/domain/usecase/club/GetClubListForSignUpUseCase.kt b/core/domain/src/main/java/com/msg/domain/usecase/club/GetClubListForSignUpUseCase.kt new file mode 100644 index 00000000..65890ebe --- /dev/null +++ b/core/domain/src/main/java/com/msg/domain/usecase/club/GetClubListForSignUpUseCase.kt @@ -0,0 +1,12 @@ +package com.msg.domain.usecase.club + +import com.msg.data.repository.club.ClubRepository +import javax.inject.Inject + +class GetClubListForSignUpUseCase @Inject constructor( + private val clubRepository: ClubRepository +) { + operator fun invoke(highSchool: String) = runCatching { + clubRepository.getClubListForSignUp(highSchool = highSchool) + } +} \ No newline at end of file diff --git a/core/domain/src/main/java/com/msg/domain/usecase/club/GetClubListUseCase.kt b/core/domain/src/main/java/com/msg/domain/usecase/club/GetClubListUseCase.kt index c76166a6..cb6f505c 100644 --- a/core/domain/src/main/java/com/msg/domain/usecase/club/GetClubListUseCase.kt +++ b/core/domain/src/main/java/com/msg/domain/usecase/club/GetClubListUseCase.kt @@ -7,7 +7,7 @@ import javax.inject.Inject class GetClubListUseCase @Inject constructor( private val clubRepository: ClubRepository, ) { - suspend operator fun invoke(highSchool: HighSchool) = runCatching { + suspend operator fun invoke(highSchool: String) = runCatching { clubRepository.getClubList(highSchool = highSchool) } } \ No newline at end of file diff --git a/core/domain/src/main/java/com/msg/domain/usecase/club/PostClubUseCase.kt b/core/domain/src/main/java/com/msg/domain/usecase/club/PostClubUseCase.kt new file mode 100644 index 00000000..2077792d --- /dev/null +++ b/core/domain/src/main/java/com/msg/domain/usecase/club/PostClubUseCase.kt @@ -0,0 +1,14 @@ +package com.msg.domain.usecase.club + +import com.msg.data.repository.club.ClubRepository +import com.msg.model.param.club.PostClubParam +import java.util.UUID +import javax.inject.Inject + +class PostClubUseCase @Inject constructor( + private val clubRepository: ClubRepository +) { + operator fun invoke(schoolId: UUID, body: PostClubParam) = runCatching { + clubRepository.postClub(schoolId = schoolId, body = body) + } +} \ No newline at end of file diff --git a/core/domain/src/main/java/com/msg/domain/usecase/company/DeleteCompanyUseCase.kt b/core/domain/src/main/java/com/msg/domain/usecase/company/DeleteCompanyUseCase.kt new file mode 100644 index 00000000..577076a5 --- /dev/null +++ b/core/domain/src/main/java/com/msg/domain/usecase/company/DeleteCompanyUseCase.kt @@ -0,0 +1,12 @@ +package com.msg.domain.usecase.company + +import com.msg.data.repository.company.CompanyRepository +import javax.inject.Inject + +class DeleteCompanyUseCase @Inject constructor( + private val companyRepository: CompanyRepository +) { + operator fun invoke(id: Long) = runCatching { + companyRepository.deleteCompany(id = id) + } +} \ No newline at end of file diff --git a/core/domain/src/main/java/com/msg/domain/usecase/company/GetCompanyListUseCase.kt b/core/domain/src/main/java/com/msg/domain/usecase/company/GetCompanyListUseCase.kt new file mode 100644 index 00000000..67ec67c2 --- /dev/null +++ b/core/domain/src/main/java/com/msg/domain/usecase/company/GetCompanyListUseCase.kt @@ -0,0 +1,12 @@ +package com.msg.domain.usecase.company + +import com.msg.data.repository.company.CompanyRepository +import javax.inject.Inject + +class GetCompanyListUseCase @Inject constructor( + private val companyRepository: CompanyRepository +) { + operator fun invoke() = runCatching { + companyRepository.getCompanyList() + } +} \ No newline at end of file diff --git a/core/domain/src/main/java/com/msg/domain/usecase/company/PostCompanyUseCase.kt b/core/domain/src/main/java/com/msg/domain/usecase/company/PostCompanyUseCase.kt new file mode 100644 index 00000000..257ee3e7 --- /dev/null +++ b/core/domain/src/main/java/com/msg/domain/usecase/company/PostCompanyUseCase.kt @@ -0,0 +1,13 @@ +package com.msg.domain.usecase.company + +import com.msg.data.repository.company.CompanyRepository +import com.msg.model.param.company.PostCompanyParam +import javax.inject.Inject + +class PostCompanyUseCase @Inject constructor( + private val companyRepository: CompanyRepository +) { + operator fun invoke(body: PostCompanyParam) = runCatching { + companyRepository.postCompany(body = body) + } +} \ No newline at end of file diff --git a/core/domain/src/main/java/com/msg/domain/usecase/government/DeleteGovernmentUseCase.kt b/core/domain/src/main/java/com/msg/domain/usecase/government/DeleteGovernmentUseCase.kt new file mode 100644 index 00000000..2b8dbb58 --- /dev/null +++ b/core/domain/src/main/java/com/msg/domain/usecase/government/DeleteGovernmentUseCase.kt @@ -0,0 +1,12 @@ +package com.msg.domain.usecase.government + +import com.msg.data.repository.government.GovernmentRepository +import javax.inject.Inject + +class DeleteGovernmentUseCase @Inject constructor( + private val governmentRepository: GovernmentRepository +) { + operator fun invoke(id: Long) = runCatching { + governmentRepository.deleteGovernment(id = id) + } +} \ No newline at end of file diff --git a/core/domain/src/main/java/com/msg/domain/usecase/government/GetGovernmentUseCase.kt b/core/domain/src/main/java/com/msg/domain/usecase/government/GetGovernmentUseCase.kt new file mode 100644 index 00000000..5656d3ff --- /dev/null +++ b/core/domain/src/main/java/com/msg/domain/usecase/government/GetGovernmentUseCase.kt @@ -0,0 +1,12 @@ +package com.msg.domain.usecase.government + +import com.msg.data.repository.government.GovernmentRepository +import javax.inject.Inject + +class GetGovernmentUseCase @Inject constructor( + private val governmentRepository: GovernmentRepository +) { + operator fun invoke() = runCatching { + governmentRepository.getGovernment() + } +} \ No newline at end of file diff --git a/core/domain/src/main/java/com/msg/domain/usecase/government/PostGovernmentUseCase.kt b/core/domain/src/main/java/com/msg/domain/usecase/government/PostGovernmentUseCase.kt new file mode 100644 index 00000000..078c26ef --- /dev/null +++ b/core/domain/src/main/java/com/msg/domain/usecase/government/PostGovernmentUseCase.kt @@ -0,0 +1,13 @@ +package com.msg.domain.usecase.government + +import com.msg.data.repository.government.GovernmentRepository +import com.msg.model.param.government.PostGovernmentParam +import javax.inject.Inject + +class PostGovernmentUseCase @Inject constructor( + private val governmentRepository: GovernmentRepository +) { + operator fun invoke(body: PostGovernmentParam) = runCatching { + governmentRepository.postGovernment(body = body) + } +} \ No newline at end of file diff --git a/core/domain/src/main/java/com/msg/domain/usecase/school/DeleteSchoolUseCase.kt b/core/domain/src/main/java/com/msg/domain/usecase/school/DeleteSchoolUseCase.kt new file mode 100644 index 00000000..5a7a1c61 --- /dev/null +++ b/core/domain/src/main/java/com/msg/domain/usecase/school/DeleteSchoolUseCase.kt @@ -0,0 +1,12 @@ +package com.msg.domain.usecase.school + +import com.msg.data.repository.school.SchoolRepository +import javax.inject.Inject + +class DeleteSchoolUseCase @Inject constructor( + private val schoolRepository: SchoolRepository +) { + operator fun invoke(id: Long) = runCatching { + schoolRepository.deleteSchool(id = id) + } +} \ No newline at end of file diff --git a/core/domain/src/main/java/com/msg/domain/usecase/school/PatchSchoolUseCase.kt b/core/domain/src/main/java/com/msg/domain/usecase/school/PatchSchoolUseCase.kt new file mode 100644 index 00000000..3381e36f --- /dev/null +++ b/core/domain/src/main/java/com/msg/domain/usecase/school/PatchSchoolUseCase.kt @@ -0,0 +1,14 @@ +package com.msg.domain.usecase.school + +import com.msg.data.repository.school.SchoolRepository +import com.msg.model.param.school.PatchSchoolParam +import java.util.UUID +import javax.inject.Inject + +class PatchSchoolUseCase @Inject constructor( + private val schoolRepository: SchoolRepository +) { + operator fun invoke(id: Long, body: PatchSchoolParam) = runCatching { + schoolRepository.patchSchool(id = id, body = body) + } +} \ No newline at end of file diff --git a/core/domain/src/main/java/com/msg/domain/usecase/university/DeleteDepartmentUseCase.kt b/core/domain/src/main/java/com/msg/domain/usecase/university/DeleteDepartmentUseCase.kt new file mode 100644 index 00000000..a5c53fbc --- /dev/null +++ b/core/domain/src/main/java/com/msg/domain/usecase/university/DeleteDepartmentUseCase.kt @@ -0,0 +1,12 @@ +package com.msg.domain.usecase.university + +import com.msg.data.repository.university.UniversityRepository +import javax.inject.Inject + +class DeleteDepartmentUseCase @Inject constructor( + private val universityRepository: UniversityRepository +) { + operator fun invoke(id: Long, department: String) = runCatching { + universityRepository.deleteDepartment(id = id, department = department) + } +} \ No newline at end of file diff --git a/core/domain/src/main/java/com/msg/domain/usecase/university/DeleteUniversityUseCase.kt b/core/domain/src/main/java/com/msg/domain/usecase/university/DeleteUniversityUseCase.kt new file mode 100644 index 00000000..717e1611 --- /dev/null +++ b/core/domain/src/main/java/com/msg/domain/usecase/university/DeleteUniversityUseCase.kt @@ -0,0 +1,12 @@ +package com.msg.domain.usecase.university + +import com.msg.data.repository.university.UniversityRepository +import javax.inject.Inject + +class DeleteUniversityUseCase @Inject constructor( + private val universityRepository: UniversityRepository +) { + operator fun invoke(id: Long) = runCatching { + universityRepository.deleteUniversity(id = id) + } +} \ No newline at end of file diff --git a/core/domain/src/main/java/com/msg/domain/usecase/university/GetUniversityUseCase.kt b/core/domain/src/main/java/com/msg/domain/usecase/university/GetUniversityUseCase.kt new file mode 100644 index 00000000..e0dc9384 --- /dev/null +++ b/core/domain/src/main/java/com/msg/domain/usecase/university/GetUniversityUseCase.kt @@ -0,0 +1,12 @@ +package com.msg.domain.usecase.university + +import com.msg.data.repository.university.UniversityRepository +import javax.inject.Inject + +class GetUniversityUseCase @Inject constructor( + private val universityRepository: UniversityRepository +) { + operator fun invoke() = runCatching { + universityRepository.getUniversity() + } +} \ No newline at end of file diff --git a/core/domain/src/main/java/com/msg/domain/usecase/university/PatchUniversityUseCase.kt b/core/domain/src/main/java/com/msg/domain/usecase/university/PatchUniversityUseCase.kt new file mode 100644 index 00000000..bfb23841 --- /dev/null +++ b/core/domain/src/main/java/com/msg/domain/usecase/university/PatchUniversityUseCase.kt @@ -0,0 +1,13 @@ +package com.msg.domain.usecase.university + +import com.msg.data.repository.university.UniversityRepository +import com.msg.model.param.university.PostUniversityParam +import javax.inject.Inject + +class PatchUniversityUseCase @Inject constructor( + private val universityRepository: UniversityRepository +) { + operator fun invoke(id: Long, body: PostUniversityParam) = runCatching { + universityRepository.patchUniversity(id = id, body = body) + } +} \ No newline at end of file diff --git a/core/domain/src/main/java/com/msg/domain/usecase/university/PostDepartmentUseCase.kt b/core/domain/src/main/java/com/msg/domain/usecase/university/PostDepartmentUseCase.kt new file mode 100644 index 00000000..a6ad9944 --- /dev/null +++ b/core/domain/src/main/java/com/msg/domain/usecase/university/PostDepartmentUseCase.kt @@ -0,0 +1,13 @@ +package com.msg.domain.usecase.university + +import com.msg.data.repository.university.UniversityRepository +import com.msg.model.param.university.PostDepartmentParam +import javax.inject.Inject + +class PostDepartmentUseCase @Inject constructor( + private val universityRepository: UniversityRepository +) { + operator fun invoke(body: PostDepartmentParam) = runCatching { + universityRepository.postDepartment(body = body) + } +} \ No newline at end of file diff --git a/core/domain/src/main/java/com/msg/domain/usecase/university/PostUniversityUseCase.kt b/core/domain/src/main/java/com/msg/domain/usecase/university/PostUniversityUseCase.kt new file mode 100644 index 00000000..b0419e01 --- /dev/null +++ b/core/domain/src/main/java/com/msg/domain/usecase/university/PostUniversityUseCase.kt @@ -0,0 +1,13 @@ +package com.msg.domain.usecase.university + +import com.msg.data.repository.university.UniversityRepository +import com.msg.model.param.university.PostUniversityParam +import javax.inject.Inject + +class PostUniversityUseCase @Inject constructor( + private val universityRepository: UniversityRepository +) { + operator fun invoke(body: PostUniversityParam) = runCatching { + universityRepository.postUniversity(body = body) + } +} \ No newline at end of file diff --git a/core/model/src/main/java/com/msg/model/entity/company/GetCompanyListEntity.kt b/core/model/src/main/java/com/msg/model/entity/company/GetCompanyListEntity.kt new file mode 100644 index 00000000..389dbbec --- /dev/null +++ b/core/model/src/main/java/com/msg/model/entity/company/GetCompanyListEntity.kt @@ -0,0 +1,11 @@ +package com.msg.model.entity.company + +data class GetCompanyListEntity( + val companies: List +) { + data class Company( + val id: Long, + val companyName: String, + val field: String + ) +} diff --git a/core/model/src/main/java/com/msg/model/entity/government/GetGovernmentEntity.kt b/core/model/src/main/java/com/msg/model/entity/government/GetGovernmentEntity.kt new file mode 100644 index 00000000..4b3c1414 --- /dev/null +++ b/core/model/src/main/java/com/msg/model/entity/government/GetGovernmentEntity.kt @@ -0,0 +1,11 @@ +package com.msg.model.entity.government + +data class GetGovernmentEntity( + val governments: List +) { + data class Government( + val id: Long, + val field: String, + val governmentName: String + ) +} \ No newline at end of file diff --git a/core/model/src/main/java/com/msg/model/entity/university/GetUniversityEntity.kt b/core/model/src/main/java/com/msg/model/entity/university/GetUniversityEntity.kt new file mode 100644 index 00000000..b9735910 --- /dev/null +++ b/core/model/src/main/java/com/msg/model/entity/university/GetUniversityEntity.kt @@ -0,0 +1,11 @@ +package com.msg.model.entity.university + +data class GetUniversityEntity( + val universities: List +) { + data class University( + val id: Long, + val universityName: String, + val departments: List + ) +} \ No newline at end of file diff --git a/core/model/src/main/java/com/msg/model/param/club/PostClubParam.kt b/core/model/src/main/java/com/msg/model/param/club/PostClubParam.kt new file mode 100644 index 00000000..a6b1e1f7 --- /dev/null +++ b/core/model/src/main/java/com/msg/model/param/club/PostClubParam.kt @@ -0,0 +1,6 @@ +package com.msg.model.param.club + +data class PostClubParam( + val clubName: String, + val field: String +) diff --git a/core/model/src/main/java/com/msg/model/param/company/PostCompanyParam.kt b/core/model/src/main/java/com/msg/model/param/company/PostCompanyParam.kt new file mode 100644 index 00000000..31cdf799 --- /dev/null +++ b/core/model/src/main/java/com/msg/model/param/company/PostCompanyParam.kt @@ -0,0 +1,6 @@ +package com.msg.model.param.company + +data class PostCompanyParam( + val companyName: String, + val field: String +) \ No newline at end of file diff --git a/core/model/src/main/java/com/msg/model/param/government/PostGovernmentParam.kt b/core/model/src/main/java/com/msg/model/param/government/PostGovernmentParam.kt new file mode 100644 index 00000000..c907a39b --- /dev/null +++ b/core/model/src/main/java/com/msg/model/param/government/PostGovernmentParam.kt @@ -0,0 +1,6 @@ +package com.msg.model.param.government + +data class PostGovernmentParam( + val field: String, + val governmentName: String +) diff --git a/core/model/src/main/java/com/msg/model/param/school/PatchSchoolParam.kt b/core/model/src/main/java/com/msg/model/param/school/PatchSchoolParam.kt new file mode 100644 index 00000000..2bc995b0 --- /dev/null +++ b/core/model/src/main/java/com/msg/model/param/school/PatchSchoolParam.kt @@ -0,0 +1,9 @@ +package com.msg.model.param.school + +import okhttp3.MultipartBody + +data class PatchSchoolParam( + val schoolName: String, + val line: String, + val logoImage: MultipartBody.Part +) \ No newline at end of file diff --git a/core/model/src/main/java/com/msg/model/param/university/PostDepartmentParam.kt b/core/model/src/main/java/com/msg/model/param/university/PostDepartmentParam.kt new file mode 100644 index 00000000..07a1034a --- /dev/null +++ b/core/model/src/main/java/com/msg/model/param/university/PostDepartmentParam.kt @@ -0,0 +1,5 @@ +package com.msg.model.param.university + +data class PostDepartmentParam( + val department: String +) \ No newline at end of file diff --git a/core/model/src/main/java/com/msg/model/param/university/PostUniversityParam.kt b/core/model/src/main/java/com/msg/model/param/university/PostUniversityParam.kt new file mode 100644 index 00000000..f63cc386 --- /dev/null +++ b/core/model/src/main/java/com/msg/model/param/university/PostUniversityParam.kt @@ -0,0 +1,5 @@ +package com.msg.model.param.university + +data class PostUniversityParam( + val universityName: String +) \ No newline at end of file diff --git a/core/network/src/main/java/com/msg/network/api/ClubAPI.kt b/core/network/src/main/java/com/msg/network/api/ClubAPI.kt index ffb8b993..c07043dc 100644 --- a/core/network/src/main/java/com/msg/network/api/ClubAPI.kt +++ b/core/network/src/main/java/com/msg/network/api/ClubAPI.kt @@ -2,6 +2,7 @@ package com.msg.network.api import com.msg.model.enumdata.HighSchool import com.msg.network.request.club.PatchClubRequest +import com.msg.network.request.club.PostClubRequest import com.msg.network.response.club.ClubDetailResponse import com.msg.network.response.club.ClubListResponse import com.msg.network.response.club.StudentBelongClubResponse @@ -9,6 +10,7 @@ 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 import java.util.UUID @@ -16,9 +18,14 @@ import java.util.UUID interface ClubAPI { @GET("club") suspend fun getClubList( - @Query("highschool") highSchool: HighSchool, + @Query("highschool") highSchool: String, ): List + @GET("club/name") + suspend fun getClubListForSignUp( + @Query("highschool") highSchool: String + ): List + @GET("club/{id}") suspend fun getClubDetail( @Path("id") id: Long, @@ -33,6 +40,12 @@ interface ClubAPI { @GET("club/my") suspend fun getMyClubDetail(): ClubDetailResponse + @POST("club/{school_id}") + suspend fun postClub( + @Path("school_id") schoolId: UUID, + @Body body: PostClubRequest + ) + @PATCH("club/{id}") suspend fun patchClub( @Path("id") id: Long, diff --git a/core/network/src/main/java/com/msg/network/api/CompanyAPI.kt b/core/network/src/main/java/com/msg/network/api/CompanyAPI.kt new file mode 100644 index 00000000..9b08f02e --- /dev/null +++ b/core/network/src/main/java/com/msg/network/api/CompanyAPI.kt @@ -0,0 +1,25 @@ +package com.msg.network.api + +import com.msg.network.request.company.PostCompanyRequest +import com.msg.network.response.company.GetCompanyListResponse +import retrofit2.http.Body +import retrofit2.http.DELETE +import retrofit2.http.GET +import retrofit2.http.POST +import retrofit2.http.Path + +interface CompanyAPI { + + @GET("company") + suspend fun getCompanyList(): GetCompanyListResponse + + @POST("company") + suspend fun postCompany( + @Body body: PostCompanyRequest + ) + + @DELETE("company/{id}") + suspend fun deleteCompany( + @Path("id") id: Long + ) +} \ No newline at end of file diff --git a/core/network/src/main/java/com/msg/network/api/GovernmentAPI.kt b/core/network/src/main/java/com/msg/network/api/GovernmentAPI.kt new file mode 100644 index 00000000..f7cb3010 --- /dev/null +++ b/core/network/src/main/java/com/msg/network/api/GovernmentAPI.kt @@ -0,0 +1,25 @@ +package com.msg.network.api + +import com.msg.network.request.government.PostGovernmentRequest +import com.msg.network.response.government.GetGovernmentResponse +import retrofit2.http.Body +import retrofit2.http.DELETE +import retrofit2.http.GET +import retrofit2.http.POST +import retrofit2.http.Path + +interface GovernmentAPI { + + @GET("government") + suspend fun getGovernment(): GetGovernmentResponse + + @POST("government") + suspend fun postGovernment( + @Body body: PostGovernmentRequest + ) + + @DELETE("government/{id}") + suspend fun deleteGovernment( + @Path("id") id: Long + ) +} \ No newline at end of file diff --git a/core/network/src/main/java/com/msg/network/api/SchoolAPI.kt b/core/network/src/main/java/com/msg/network/api/SchoolAPI.kt index f767deed..1a92640a 100644 --- a/core/network/src/main/java/com/msg/network/api/SchoolAPI.kt +++ b/core/network/src/main/java/com/msg/network/api/SchoolAPI.kt @@ -1,11 +1,16 @@ package com.msg.network.api +import com.msg.network.request.school.PatchSchoolRequest import com.msg.network.request.school.PostSchoolRequest import com.msg.network.response.school.GetSchoolListResponse import retrofit2.http.Body +import retrofit2.http.DELETE import retrofit2.http.GET import retrofit2.http.Multipart +import retrofit2.http.PATCH import retrofit2.http.POST +import retrofit2.http.Path +import java.util.UUID interface SchoolAPI { @GET("school") @@ -19,4 +24,16 @@ interface SchoolAPI { suspend fun postSchool( @Body body: PostSchoolRequest ) + + @Multipart + @PATCH("school/{id}") + suspend fun patchSchool( + @Path("id") id: Long, + @Body body: PatchSchoolRequest + ) + + @DELETE("school/{id}") + suspend fun deleteSchool( + @Path("id") id: Long + ) } \ No newline at end of file diff --git a/core/network/src/main/java/com/msg/network/api/UniversityAPI.kt b/core/network/src/main/java/com/msg/network/api/UniversityAPI.kt new file mode 100644 index 00000000..6df1a122 --- /dev/null +++ b/core/network/src/main/java/com/msg/network/api/UniversityAPI.kt @@ -0,0 +1,45 @@ +package com.msg.network.api + +import com.msg.network.request.university.PostDepartmentRequest +import com.msg.network.request.university.PostUniversityRequest +import com.msg.network.response.university.GetUniversityResponse +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 UniversityAPI { + + @GET("university") + suspend fun getUniversity(): GetUniversityResponse + + @POST("university") + suspend fun postUniversity( + @Body body: PostUniversityRequest + ) + + @PATCH("university/{id}") + suspend fun patchUniversity( + @Path("id") id: Long, + @Body body: PostUniversityRequest + ) + + @DELETE("university/{id}") + suspend fun deleteUniversity( + @Path("id") id: Long + ) + + @POST("university/department/{id}") + suspend fun postDepartment( + @Body body: PostDepartmentRequest + ) + + @DELETE("university/department/{id}") + suspend fun deleteDepartment( + @Path("id") id: Long, + @Query("department") department: String + ) +} \ No newline at end of file diff --git a/core/network/src/main/java/com/msg/network/datasource/club/ClubDataSource.kt b/core/network/src/main/java/com/msg/network/datasource/club/ClubDataSource.kt index 09fd30dd..1e6f74cc 100644 --- a/core/network/src/main/java/com/msg/network/datasource/club/ClubDataSource.kt +++ b/core/network/src/main/java/com/msg/network/datasource/club/ClubDataSource.kt @@ -3,14 +3,17 @@ package com.msg.network.datasource.club import com.msg.network.response.club.* import com.msg.model.enumdata.HighSchool import com.msg.network.request.club.PatchClubRequest +import com.msg.network.request.club.PostClubRequest import kotlinx.coroutines.flow.Flow import java.util.UUID interface ClubDataSource { - fun getClubList(highSchool: HighSchool): Flow> + fun getClubList(highSchool: String): Flow> + fun getClubListForSignUp(highSchool: String): Flow> fun getClubDetail(id: Long): Flow fun getStudentBelongClubDetail(id:Long, studentId: UUID): Flow fun getMyClubDetail(): Flow + fun postClub(schoolId: UUID, body: PostClubRequest): Flow fun patchClub(id: Long, body: PatchClubRequest): Flow fun deleteClub(id: Long): Flow } \ No newline at end of file diff --git a/core/network/src/main/java/com/msg/network/datasource/club/ClubDataSourceImpl.kt b/core/network/src/main/java/com/msg/network/datasource/club/ClubDataSourceImpl.kt index a0c0a4dd..9e2ac1a9 100644 --- a/core/network/src/main/java/com/msg/network/datasource/club/ClubDataSourceImpl.kt +++ b/core/network/src/main/java/com/msg/network/datasource/club/ClubDataSourceImpl.kt @@ -4,6 +4,7 @@ import com.msg.network.response.club.* import com.msg.model.enumdata.HighSchool import com.msg.network.api.ClubAPI import com.msg.network.request.club.PatchClubRequest +import com.msg.network.request.club.PostClubRequest import com.msg.network.util.makeRequest import kotlinx.coroutines.flow.Flow import java.util.UUID @@ -12,9 +13,12 @@ import javax.inject.Inject class ClubDataSourceImpl @Inject constructor( private val clubAPI: ClubAPI, ) : ClubDataSource { - override fun getClubList(highSchool: HighSchool): Flow> = + override fun getClubList(highSchool: String): Flow> = makeRequest { clubAPI.getClubList(highSchool = highSchool) } + override fun getClubListForSignUp(highSchool: String): Flow> = + makeRequest { clubAPI.getClubListForSignUp(highSchool = highSchool) } + override fun getClubDetail(id: Long): Flow = makeRequest { clubAPI.getClubDetail(id = id) } @@ -24,6 +28,9 @@ class ClubDataSourceImpl @Inject constructor( override fun getMyClubDetail(): Flow = makeRequest { clubAPI.getMyClubDetail() } + override fun postClub(schoolId: UUID, body: PostClubRequest): Flow = + makeRequest { clubAPI.postClub(schoolId = schoolId, body = body) } + override fun patchClub(id: Long, body: PatchClubRequest): Flow = makeRequest { clubAPI.patchClub(id = id, body = body) } diff --git a/core/network/src/main/java/com/msg/network/datasource/company/CompanyDataSource.kt b/core/network/src/main/java/com/msg/network/datasource/company/CompanyDataSource.kt new file mode 100644 index 00000000..3b7f300b --- /dev/null +++ b/core/network/src/main/java/com/msg/network/datasource/company/CompanyDataSource.kt @@ -0,0 +1,11 @@ +package com.msg.network.datasource.company + +import com.msg.network.request.company.PostCompanyRequest +import com.msg.network.response.company.GetCompanyListResponse +import kotlinx.coroutines.flow.Flow + +interface CompanyDataSource { + fun getCompanyList(): Flow + fun postCompany(body: PostCompanyRequest): Flow + fun deleteCompany(id: Long): Flow +} \ No newline at end of file diff --git a/core/network/src/main/java/com/msg/network/datasource/company/CompanyDataSourceImpl.kt b/core/network/src/main/java/com/msg/network/datasource/company/CompanyDataSourceImpl.kt new file mode 100644 index 00000000..53722476 --- /dev/null +++ b/core/network/src/main/java/com/msg/network/datasource/company/CompanyDataSourceImpl.kt @@ -0,0 +1,22 @@ +package com.msg.network.datasource.company + +import com.msg.network.api.CompanyAPI +import com.msg.network.request.company.PostCompanyRequest +import com.msg.network.response.company.GetCompanyListResponse +import com.msg.network.util.makeRequest +import kotlinx.coroutines.flow.Flow +import javax.inject.Inject + +class CompanyDataSourceImpl @Inject constructor( + private val companyAPI: CompanyAPI +) : CompanyDataSource { + + override fun getCompanyList(): Flow = + makeRequest { companyAPI.getCompanyList() } + + override fun postCompany(body: PostCompanyRequest): Flow = + makeRequest { companyAPI.postCompany(body = body) } + + override fun deleteCompany(id: Long): Flow = + makeRequest { companyAPI.deleteCompany(id = id) } +} \ No newline at end of file diff --git a/core/network/src/main/java/com/msg/network/datasource/government/GovernmentDataSource.kt b/core/network/src/main/java/com/msg/network/datasource/government/GovernmentDataSource.kt new file mode 100644 index 00000000..383f9c23 --- /dev/null +++ b/core/network/src/main/java/com/msg/network/datasource/government/GovernmentDataSource.kt @@ -0,0 +1,11 @@ +package com.msg.network.datasource.government + +import com.msg.network.request.government.PostGovernmentRequest +import com.msg.network.response.government.GetGovernmentResponse +import kotlinx.coroutines.flow.Flow + +interface GovernmentDataSource { + fun getGovernment(): Flow + fun postGovernment(body: PostGovernmentRequest): Flow + fun deleteGovernment(id: Long): Flow +} \ No newline at end of file diff --git a/core/network/src/main/java/com/msg/network/datasource/government/GovernmentDataSourceImpl.kt b/core/network/src/main/java/com/msg/network/datasource/government/GovernmentDataSourceImpl.kt new file mode 100644 index 00000000..6317cb1a --- /dev/null +++ b/core/network/src/main/java/com/msg/network/datasource/government/GovernmentDataSourceImpl.kt @@ -0,0 +1,22 @@ +package com.msg.network.datasource.government + +import com.msg.network.api.GovernmentAPI +import com.msg.network.request.government.PostGovernmentRequest +import com.msg.network.response.government.GetGovernmentResponse +import com.msg.network.util.makeRequest +import kotlinx.coroutines.flow.Flow +import javax.inject.Inject + +class GovernmentDataSourceImpl @Inject constructor( + private val governmentAPI: GovernmentAPI +) : GovernmentDataSource { + + override fun getGovernment(): Flow = + makeRequest { governmentAPI.getGovernment() } + + override fun postGovernment(body: PostGovernmentRequest): Flow = + makeRequest { governmentAPI.postGovernment(body = body) } + + override fun deleteGovernment(id: Long): Flow = + makeRequest { governmentAPI.deleteGovernment(id = id) } +} \ No newline at end of file diff --git a/core/network/src/main/java/com/msg/network/datasource/school/SchoolDataSource.kt b/core/network/src/main/java/com/msg/network/datasource/school/SchoolDataSource.kt index dfcd0e94..7848316d 100644 --- a/core/network/src/main/java/com/msg/network/datasource/school/SchoolDataSource.kt +++ b/core/network/src/main/java/com/msg/network/datasource/school/SchoolDataSource.kt @@ -1,11 +1,15 @@ package com.msg.network.datasource.school +import com.msg.network.request.school.PatchSchoolRequest import com.msg.network.request.school.PostSchoolRequest import com.msg.network.response.school.GetSchoolListResponse import kotlinx.coroutines.flow.Flow +import java.util.UUID interface SchoolDataSource { fun getSchoolList(): Flow fun getSchoolName(): Flow> fun postSchool(body: PostSchoolRequest): Flow + fun patchSchool(id: Long, body: PatchSchoolRequest): Flow + fun deleteSchool(id: Long): Flow } \ No newline at end of file diff --git a/core/network/src/main/java/com/msg/network/datasource/school/SchoolDataSourceImpl.kt b/core/network/src/main/java/com/msg/network/datasource/school/SchoolDataSourceImpl.kt index b517333f..bc0eb885 100644 --- a/core/network/src/main/java/com/msg/network/datasource/school/SchoolDataSourceImpl.kt +++ b/core/network/src/main/java/com/msg/network/datasource/school/SchoolDataSourceImpl.kt @@ -1,10 +1,12 @@ package com.msg.network.datasource.school import com.msg.network.api.SchoolAPI +import com.msg.network.request.school.PatchSchoolRequest import com.msg.network.request.school.PostSchoolRequest import com.msg.network.response.school.GetSchoolListResponse import com.msg.network.util.makeRequest import kotlinx.coroutines.flow.Flow +import java.util.UUID import javax.inject.Inject class SchoolDataSourceImpl @Inject constructor( @@ -18,4 +20,10 @@ class SchoolDataSourceImpl @Inject constructor( override fun postSchool(body: PostSchoolRequest): Flow = makeRequest { schoolAPI.postSchool(body = body) } + + override fun patchSchool(id: Long, body: PatchSchoolRequest): Flow = + makeRequest { schoolAPI.patchSchool(id = id, body = body) } + + override fun deleteSchool(id: Long): Flow = + makeRequest { schoolAPI.deleteSchool(id = id) } } \ No newline at end of file diff --git a/core/network/src/main/java/com/msg/network/datasource/university/UniversityDataSource.kt b/core/network/src/main/java/com/msg/network/datasource/university/UniversityDataSource.kt new file mode 100644 index 00000000..8c5ea3ed --- /dev/null +++ b/core/network/src/main/java/com/msg/network/datasource/university/UniversityDataSource.kt @@ -0,0 +1,15 @@ +package com.msg.network.datasource.university + +import com.msg.network.request.university.PostDepartmentRequest +import com.msg.network.request.university.PostUniversityRequest +import com.msg.network.response.university.GetUniversityResponse +import kotlinx.coroutines.flow.Flow + +interface UniversityDataSource { + fun getUniversity(): Flow + fun postUniversity(body: PostUniversityRequest): Flow + fun patchUniversity(id: Long, body: PostUniversityRequest): Flow + fun deleteUniversity(id: Long): Flow + fun postDepartment(body: PostDepartmentRequest): Flow + fun deleteDepartment(id: Long, department: String): Flow +} \ No newline at end of file diff --git a/core/network/src/main/java/com/msg/network/datasource/university/UniversityDataSourceImpl.kt b/core/network/src/main/java/com/msg/network/datasource/university/UniversityDataSourceImpl.kt new file mode 100644 index 00000000..af07ea21 --- /dev/null +++ b/core/network/src/main/java/com/msg/network/datasource/university/UniversityDataSourceImpl.kt @@ -0,0 +1,32 @@ +package com.msg.network.datasource.university + +import com.msg.network.api.UniversityAPI +import com.msg.network.request.university.PostDepartmentRequest +import com.msg.network.request.university.PostUniversityRequest +import com.msg.network.response.university.GetUniversityResponse +import com.msg.network.util.makeRequest +import kotlinx.coroutines.flow.Flow +import javax.inject.Inject + +class UniversityDataSourceImpl @Inject constructor( + private val universityAPI: UniversityAPI +) : UniversityDataSource { + + override fun getUniversity(): Flow = + makeRequest { universityAPI.getUniversity() } + + override fun postUniversity(body: PostUniversityRequest): Flow = + makeRequest { universityAPI.postUniversity(body = body) } + + override fun patchUniversity(id: Long, body: PostUniversityRequest): Flow = + makeRequest { universityAPI.patchUniversity(id = id, body = body) } + + override fun deleteUniversity(id: Long): Flow = + makeRequest { universityAPI.deleteUniversity(id = id) } + + override fun postDepartment(body: PostDepartmentRequest): Flow = + makeRequest { universityAPI.postDepartment(body = body) } + + override fun deleteDepartment(id: Long, department: String): Flow = + makeRequest { universityAPI.deleteDepartment(id = id, department = department) } +} \ No newline at end of file diff --git a/core/network/src/main/java/com/msg/network/di/NetworkModule.kt b/core/network/src/main/java/com/msg/network/di/NetworkModule.kt index 90178258..a24823a6 100644 --- a/core/network/src/main/java/com/msg/network/di/NetworkModule.kt +++ b/core/network/src/main/java/com/msg/network/di/NetworkModule.kt @@ -7,12 +7,15 @@ import com.msg.network.api.AdminAPI import com.msg.network.api.AuthAPI import com.msg.network.api.CertificationAPI import com.msg.network.api.ClubAPI +import com.msg.network.api.CompanyAPI import com.msg.network.api.EmailAPI import com.msg.network.api.FaqAPI +import com.msg.network.api.GovernmentAPI import com.msg.network.api.LectureAPI import com.msg.network.api.MapAPI import com.msg.network.api.PostAPI import com.msg.network.api.SchoolAPI +import com.msg.network.api.UniversityAPI import com.msg.network.api.UserAPI import com.msg.network.util.AuthInterceptor import com.squareup.moshi.Moshi @@ -119,6 +122,18 @@ object NetworkModule { fun provideSchoolAPI(retrofit: Retrofit): SchoolAPI = retrofit.create(SchoolAPI::class.java) + @Provides + fun provideCompanyAPI(retrofit: Retrofit): CompanyAPI = + retrofit.create(CompanyAPI::class.java) + + @Provides + fun provideUniversityAPI(retrofit: Retrofit): UniversityAPI = + retrofit.create(UniversityAPI::class.java) + + @Provides + fun provideGovernmentAPI(retrofit: Retrofit): GovernmentAPI = + retrofit.create(GovernmentAPI::class.java) + @Provides fun provideMapAPI(retrofit: Retrofit): MapAPI = retrofit.create(MapAPI::class.java) diff --git a/core/network/src/main/java/com/msg/network/di/RemoteDataSourceModule.kt b/core/network/src/main/java/com/msg/network/di/RemoteDataSourceModule.kt index 7b0524ea..8b2826b0 100644 --- a/core/network/src/main/java/com/msg/network/di/RemoteDataSourceModule.kt +++ b/core/network/src/main/java/com/msg/network/di/RemoteDataSourceModule.kt @@ -10,10 +10,14 @@ import com.msg.network.datasource.certification.CertificationDataSource import com.msg.network.datasource.certification.CertificationDataSourceImpl import com.msg.network.datasource.club.ClubDataSource import com.msg.network.datasource.club.ClubDataSourceImpl +import com.msg.network.datasource.company.CompanyDataSource +import com.msg.network.datasource.company.CompanyDataSourceImpl import com.msg.network.datasource.email.EmailDataSource import com.msg.network.datasource.email.EmailDataSourceImpl import com.msg.network.datasource.faq.FaqDataSource import com.msg.network.datasource.faq.FaqDataSourceImpl +import com.msg.network.datasource.government.GovernmentDataSource +import com.msg.network.datasource.government.GovernmentDataSourceImpl import com.msg.network.datasource.lecture.LectureDataSource import com.msg.network.datasource.lecture.LectureDataSourceImpl import com.msg.network.datasource.map.MapDataSource @@ -22,6 +26,8 @@ import com.msg.network.datasource.post.PostDataSource import com.msg.network.datasource.post.PostDataSourceImpl import com.msg.network.datasource.school.SchoolDataSource import com.msg.network.datasource.school.SchoolDataSourceImpl +import com.msg.network.datasource.university.UniversityDataSource +import com.msg.network.datasource.university.UniversityDataSourceImpl import com.msg.network.datasource.user.UserDataSource import com.msg.network.datasource.user.UserDataSourceImpl import dagger.Binds @@ -87,6 +93,21 @@ abstract class RemoteDataSourceModule { schoolDataSourceImpl: SchoolDataSourceImpl ): SchoolDataSource + @Binds + abstract fun bindCompanyDataSource( + companyDataSourceImpl: CompanyDataSourceImpl + ): CompanyDataSource + + @Binds + abstract fun bindUniversityDataSource( + universityDataSourceImpl: UniversityDataSourceImpl + ): UniversityDataSource + + @Binds + abstract fun bindGovernmentDataSource( + governmentDataSourceImpl: GovernmentDataSourceImpl + ): GovernmentDataSource + @Binds abstract fun bindMapDataSource( mapDataSourceImpl: MapDataSourceImpl diff --git a/core/network/src/main/java/com/msg/network/request/club/PostClubRequest.kt b/core/network/src/main/java/com/msg/network/request/club/PostClubRequest.kt new file mode 100644 index 00000000..17094326 --- /dev/null +++ b/core/network/src/main/java/com/msg/network/request/club/PostClubRequest.kt @@ -0,0 +1,10 @@ +package com.msg.network.request.club + +import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass + +@JsonClass(generateAdapter = true) +data class PostClubRequest( + @Json(name = "clubName") val clubName: String, + @Json(name = "field") val field: String +) diff --git a/core/network/src/main/java/com/msg/network/request/company/PostCompanyRequest.kt b/core/network/src/main/java/com/msg/network/request/company/PostCompanyRequest.kt new file mode 100644 index 00000000..8afdb1e7 --- /dev/null +++ b/core/network/src/main/java/com/msg/network/request/company/PostCompanyRequest.kt @@ -0,0 +1,10 @@ +package com.msg.network.request.company + +import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass + +@JsonClass(generateAdapter = true) +data class PostCompanyRequest( + @Json(name = "companyName") val companyName: String, + @Json(name = "field") val field: String +) \ No newline at end of file diff --git a/core/network/src/main/java/com/msg/network/request/government/PostGovernmentRequest.kt b/core/network/src/main/java/com/msg/network/request/government/PostGovernmentRequest.kt new file mode 100644 index 00000000..365b00e1 --- /dev/null +++ b/core/network/src/main/java/com/msg/network/request/government/PostGovernmentRequest.kt @@ -0,0 +1,10 @@ +package com.msg.network.request.government + +import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass + +@JsonClass(generateAdapter = true) +data class PostGovernmentRequest( + @Json(name = "field") val field: String, + @Json(name = "governmentName") val governmentName: String +) \ No newline at end of file diff --git a/core/network/src/main/java/com/msg/network/request/school/PatchSchoolRequest.kt b/core/network/src/main/java/com/msg/network/request/school/PatchSchoolRequest.kt new file mode 100644 index 00000000..581050c4 --- /dev/null +++ b/core/network/src/main/java/com/msg/network/request/school/PatchSchoolRequest.kt @@ -0,0 +1,12 @@ +package com.msg.network.request.school + +import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass +import okhttp3.MultipartBody + +@JsonClass(generateAdapter = true) +data class PatchSchoolRequest( + @Json(name = "schoolName") val schoolName: String, + @Json(name = "line") val line: String, + @Json(name = "logoImage") val logoImage: MultipartBody.Part +) \ No newline at end of file diff --git a/core/network/src/main/java/com/msg/network/request/university/PostDepartmentRequest.kt b/core/network/src/main/java/com/msg/network/request/university/PostDepartmentRequest.kt new file mode 100644 index 00000000..643d5cc3 --- /dev/null +++ b/core/network/src/main/java/com/msg/network/request/university/PostDepartmentRequest.kt @@ -0,0 +1,9 @@ +package com.msg.network.request.university + +import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass + +@JsonClass(generateAdapter = true) +data class PostDepartmentRequest( + @Json(name = "department") val department: String +) \ No newline at end of file diff --git a/core/network/src/main/java/com/msg/network/request/university/PostUniversityRequest.kt b/core/network/src/main/java/com/msg/network/request/university/PostUniversityRequest.kt new file mode 100644 index 00000000..651453db --- /dev/null +++ b/core/network/src/main/java/com/msg/network/request/university/PostUniversityRequest.kt @@ -0,0 +1,9 @@ +package com.msg.network.request.university + +import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass + +@JsonClass(generateAdapter = true) +data class PostUniversityRequest( + @Json(name = "universityName") val universityName: String +) \ No newline at end of file diff --git a/core/network/src/main/java/com/msg/network/response/company/GetCompanyListResponse.kt b/core/network/src/main/java/com/msg/network/response/company/GetCompanyListResponse.kt new file mode 100644 index 00000000..cffe22e1 --- /dev/null +++ b/core/network/src/main/java/com/msg/network/response/company/GetCompanyListResponse.kt @@ -0,0 +1,15 @@ +package com.msg.network.response.company + +import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass + +@JsonClass(generateAdapter = true) +data class GetCompanyListResponse( + @Json(name = "companies") val companies: List +) { + data class Company( + @Json(name = "id") val id: Long, + @Json(name = "companyName") val companyName: String, + @Json(name = "field") val field: String + ) +} \ No newline at end of file diff --git a/core/network/src/main/java/com/msg/network/response/government/GetGovernmentResponse.kt b/core/network/src/main/java/com/msg/network/response/government/GetGovernmentResponse.kt new file mode 100644 index 00000000..f712ed97 --- /dev/null +++ b/core/network/src/main/java/com/msg/network/response/government/GetGovernmentResponse.kt @@ -0,0 +1,16 @@ +package com.msg.network.response.government + +import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass + +@JsonClass(generateAdapter = true) +data class GetGovernmentResponse( + @Json(name = "governments") val governments: List +) { + @JsonClass(generateAdapter = true) + data class Government( + @Json(name = "id") val id: Long, + @Json(name = "field") val field: String, + @Json(name = "governmentName") val governmentName: String + ) +} \ No newline at end of file diff --git a/core/network/src/main/java/com/msg/network/response/university/GetUniversityResponse.kt b/core/network/src/main/java/com/msg/network/response/university/GetUniversityResponse.kt new file mode 100644 index 00000000..b6203fd1 --- /dev/null +++ b/core/network/src/main/java/com/msg/network/response/university/GetUniversityResponse.kt @@ -0,0 +1,16 @@ +package com.msg.network.response.university + +import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass + +@JsonClass(generateAdapter = true) +data class GetUniversityResponse( + @Json(name = "universities") val universities: List +) { + @JsonClass(generateAdapter = true) + data class University( + @Json(name = "id") val id: Long, + @Json(name = "universityName") val universityName: String, + @Json(name = "departments") val departments: List + ) +} \ No newline at end of file diff --git a/core/network/src/main/java/com/msg/network/util/AuthInterceptor.kt b/core/network/src/main/java/com/msg/network/util/AuthInterceptor.kt index 9181659f..13005c1d 100644 --- a/core/network/src/main/java/com/msg/network/util/AuthInterceptor.kt +++ b/core/network/src/main/java/com/msg/network/util/AuthInterceptor.kt @@ -22,14 +22,17 @@ class AuthInterceptor @Inject constructor( val request = chain.request() val builder = request.newBuilder() val currentTime = System.currentTimeMillis().toLocalDateTime() - val ignorePath = listOf("/auth", "/faq") + val ignorePath = listOf("/auth", "/faq", "/club/name", "/school/name", "/company", "/university", "/government") val ignoreMethod = listOf("POST", "GET") val path = request.url.encodedPath val method = request.method - ignorePath.forEachIndexed { index, s -> - if (path.contains(s) && ignoreMethod[index] == method) { - return chain.proceed(request) + run breaking@{ + ignorePath.forEachIndexed { index, s -> + if (path.contains(s) && ignoreMethod[index] == method) { + if (ignorePath.subList(4, 6).contains(s) && index == 0) return@breaking + return chain.proceed(request) + } } } diff --git a/feature/club/src/main/java/com/msg/club/ClubScreen.kt b/feature/club/src/main/java/com/msg/club/ClubScreen.kt index 18003030..d34a7ee2 100644 --- a/feature/club/src/main/java/com/msg/club/ClubScreen.kt +++ b/feature/club/src/main/java/com/msg/club/ClubScreen.kt @@ -63,7 +63,7 @@ internal fun ClubScreenRoute( ClubScreen( data = viewModel.clubList, onSettingClicked = { - viewModel.getClubList(HighSchool.valueOf(it)) + viewModel.getClubList(HighSchool.valueOf(it).toString()) key = it }, onItemClicked = { diff --git a/feature/club/src/main/java/com/msg/club/viewmodel/ClubViewModel.kt b/feature/club/src/main/java/com/msg/club/viewmodel/ClubViewModel.kt index 03f43a66..35fe0e3d 100644 --- a/feature/club/src/main/java/com/msg/club/viewmodel/ClubViewModel.kt +++ b/feature/club/src/main/java/com/msg/club/viewmodel/ClubViewModel.kt @@ -93,7 +93,7 @@ class ClubViewModel @Inject constructor( } internal fun getClubList( - highSchool: HighSchool, + highSchool: String, ) = viewModelScope.launch { getClubListUseCase(highSchool = highSchool).onSuccess { it.catch { remoteError ->