Skip to content

Commit

Permalink
Merge pull request #235 from School-of-Company/feature/#234_apply_cha…
Browse files Browse the repository at this point in the history
…nged_or_added_api

🔀 :: (#234) - Apply changed or added api
  • Loading branch information
wjdcksdn authored Jul 12, 2024
2 parents fb54fc6 + b899f9d commit e5ce251
Show file tree
Hide file tree
Showing 55 changed files with 508 additions and 5 deletions.
1 change: 1 addition & 0 deletions core/data/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ dependencies {
implementation(project(":core:network"))

implementation(libs.kotlinx.serialization.json)
implementation(libs.okhttp.logging)
}
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 @@ -16,8 +16,12 @@ import com.msg.data.repository.faq.FaqRepository
import com.msg.data.repository.faq.FaqRepositoryImpl
import com.msg.data.repository.lecture.LectureRepository
import com.msg.data.repository.lecture.LectureRepositoryImpl
import com.msg.data.repository.map.MapRepository
import com.msg.data.repository.map.MapRepositoryImpl
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.user.UserRepository
import com.msg.data.repository.user.UserRepositoryImpl
import dagger.Binds
Expand Down Expand Up @@ -77,4 +81,14 @@ abstract class RepositoryModule {
abstract fun bindEmailRepository(
emailRepositoryImpl: EmailRepositoryImpl
): EmailRepository

@Binds
abstract fun bindSchoolRepository(
schoolRepositoryImpl: SchoolRepositoryImpl
): SchoolRepository

@Binds
abstract fun bindMapRepository(
mapRepositoryImpl: MapRepositoryImpl
): MapRepository
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.msg.data.mapper.club

import com.msg.model.param.club.PatchClubParam
import com.msg.network.request.club.PatchClubRequest

fun PatchClubParam.toRequest() = PatchClubRequest(
clubName = clubName,
field = field,
schoolId = schoolId
)
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,9 @@ fun DetailLectureResponse.toEntity() = DetailLectureEntity(
isRegistered = isRegistered,
lecturer = lecturer,
credit = credit,
locationX = locationX,
locationY = locationY,
address = address,
locationDetails = locationDetails,
essentialComplete = essentialComplete
)
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ fun OpenLectureParam.toRequest() = OpenLectureRequest(
lectureDates = lectureDates,
lectureType = lectureType,
credit = credit,
address = address,
locationDetails = locationDetails,
maxRegisteredUser = maxRegisteredUser,
essentialComplete = essentialComplete,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.msg.data.mapper.map

import com.msg.model.entity.map.GetLocationEntity
import com.msg.network.response.map.GetLocationResponse

fun GetLocationResponse.toEntity() = GetLocationEntity(
x = x,
y = y
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.msg.data.mapper.school

import com.msg.model.entity.school.GetSchoolListEntity
import com.msg.network.response.school.GetSchoolListResponse

fun GetSchoolListResponse.toEntity() = GetSchoolListEntity(
schools = schools
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.msg.data.mapper.school

import com.msg.model.param.school.PostSchoolParam
import com.msg.network.request.school.PostSchoolRequest

fun PostSchoolParam.toRequest() = PostSchoolRequest(
schoolName = schoolName,
line = line,
department = department,
logoImage = logoImage
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.msg.model.entity.club.ClubDetailEntity
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 kotlinx.coroutines.flow.Flow
import java.util.UUID

Expand All @@ -12,4 +13,6 @@ interface ClubRepository {
fun getClubDetail(id: Long): Flow<ClubDetailEntity>
fun getStudentBelongClubDetail(id: Long, studentId: UUID): Flow<StudentBelongClubEntity>
fun getMyClubDetail(): Flow<ClubDetailEntity>
fun patchClub(id: Long, body: PatchClubParam): Flow<Unit>
fun deleteClub(id: Long): Flow<Unit>
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.msg.data.repository.club

import com.msg.data.mapper.club.toEntity
import com.msg.data.mapper.club.toRequest
import com.msg.model.entity.club.ClubDetailEntity
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.network.datasource.club.ClubDataSource
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.transform
Expand Down Expand Up @@ -48,4 +50,17 @@ class ClubRepositoryImpl @Inject constructor(
response.toEntity()
}
}

override fun patchClub(id: Long, body: PatchClubParam): Flow<Unit> {
return clubDataSource.patchClub(
id = id,
body = body.toRequest()
)
}

override fun deleteClub(id: Long): Flow<Unit> {
return clubDataSource.deleteClub(
id = id
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interface LectureRepository {
fun openLecture(body: OpenLectureParam): Flow<Unit>
fun getLectureList(page: Int, size: Int, type: String?): Flow<LectureListEntity>
fun getDetailLecture(id: UUID): Flow<DetailLectureEntity>
fun patchLecture(id: UUID, body: OpenLectureParam): Flow<Unit>
fun lectureApplication(id: UUID): Flow<Unit>
fun lectureApplicationCancel(id: UUID): Flow<Unit>
fun searchProfessor(keyword: String): Flow<SearchProfessorEntity>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ class LectureRepositoryImpl @Inject constructor(
}
}

override fun patchLecture(id: UUID, body: OpenLectureParam): Flow<Unit> {
return lectureDataSource.patchLecture(
id = id,
body = body.toRequest()
)
}

override fun lectureApplication(id: UUID): Flow<Unit> {
return lectureDataSource.lectureApplication(
id = id
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.msg.data.repository.map

import com.msg.model.entity.map.GetLocationEntity
import kotlinx.coroutines.flow.Flow

interface MapRepository {
fun getLocation(address: String): Flow<GetLocationEntity>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.msg.data.repository.map

import com.msg.data.mapper.map.toEntity
import com.msg.model.entity.map.GetLocationEntity
import com.msg.network.datasource.map.MapDataSource
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.transform
import javax.inject.Inject

class MapRepositoryImpl @Inject constructor(
private val mapDataSource: MapDataSource
) : MapRepository {
override fun getLocation(address: String): Flow<GetLocationEntity> {
return mapDataSource.getLocation(address = address).transform {
it.toEntity()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.msg.data.repository.school

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

interface SchoolRepository {
fun getSchoolList(): Flow<GetSchoolListEntity>
fun getSchoolName(): Flow<List<String>>
fun postSchool(body: PostSchoolParam): Flow<Unit>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
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.PostSchoolParam
import com.msg.network.datasource.school.SchoolDataSource
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.transform
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()
}
}

override fun getSchoolName(): Flow<List<String>> {
return schoolDataSource.getSchoolName()
}

override fun postSchool(body: PostSchoolParam): Flow<Unit> {
return schoolDataSource.postSchool(body = body.toRequest())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.msg.domain.usecase.club

import com.msg.data.repository.club.ClubRepository
import javax.inject.Inject

class DeleteClubUseCase @Inject constructor(
private val clubRepository: ClubRepository
){
operator fun invoke(id: Long) = runCatching {
clubRepository.deleteClub(id = id)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.msg.domain.usecase.club

import com.msg.data.repository.club.ClubRepository
import com.msg.model.param.club.PatchClubParam
import javax.inject.Inject

class PatchClubUseCase @Inject constructor(
private val clubRepository: ClubRepository
){
operator fun invoke(id: Long, body: PatchClubParam) = runCatching {
clubRepository.patchClub(id = id, body = body)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.msg.domain.usecase.lecture

import com.msg.data.repository.lecture.LectureRepository
import com.msg.model.param.lecture.OpenLectureParam
import java.util.UUID
import javax.inject.Inject

class PatchLecture @Inject constructor(
private val lectureRepository: LectureRepository
) {
operator fun invoke(id: UUID, body: OpenLectureParam) = runCatching {
lectureRepository.patchLecture(id = id, body = body)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.msg.domain.usecase.map

import com.msg.data.repository.map.MapRepository
import javax.inject.Inject

class GetLocationUseCase @Inject constructor(
private val mapRepository: MapRepository
) {
operator fun invoke(address: String) = runCatching {
mapRepository.getLocation(address = address)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.msg.domain.usecase.school

import com.msg.data.repository.school.SchoolRepository
import javax.inject.Inject

class GetSchoolListUseCase @Inject constructor(
private val schoolRepository: SchoolRepository
) {
operator fun invoke() = runCatching {
schoolRepository.getSchoolList()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.msg.domain.usecase.school

import com.msg.data.repository.school.SchoolRepository
import javax.inject.Inject

class GetSchoolNameUseCase @Inject constructor(
private val schoolRepository: SchoolRepository
) {
operator fun invoke() = runCatching {
schoolRepository.getSchoolName()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.msg.domain.usecase.school

import com.msg.data.repository.school.SchoolRepository
import com.msg.model.param.school.PostSchoolParam
import javax.inject.Inject

class PostSchoolUseCase @Inject constructor(
private val schoolRepository: SchoolRepository
) {
operator fun invoke(body: PostSchoolParam) = runCatching {
schoolRepository.postSchool(body = body)
}
}
1 change: 1 addition & 0 deletions core/model/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ plugins {
}

dependencies {
implementation(libs.okhttp)
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,9 @@ data class DetailLectureEntity(
val isRegistered: Boolean,
val lecturer: String,
val credit: Int,
val locationX: String,
val locationY: String,
val address: String,
val locationDetails: String,
val essentialComplete: Boolean,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.msg.model.entity.map

data class GetLocationEntity(
val x: String,
val y: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.msg.model.entity.school

import com.msg.model.model.school.SchoolModel

data class GetSchoolListEntity(
val schools: List<SchoolModel>
)
Loading

0 comments on commit e5ce251

Please sign in to comment.