-
Notifications
You must be signed in to change notification settings - Fork 0
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
π :: (#224) - standard λΆλΆ λ€νΈμν¬ μΈν μ νμ΅λλ€. #225
Changes from all commits
96155a7
2d69ed4
ea3757e
3d35bca
065b337
be75dcb
c0ab5be
6b22198
016cc8e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.school_of_company.data.repository.standard | ||
|
||
import com.school_of_company.model.entity.standard.StandardAttendListResponseEntity | ||
import com.school_of_company.model.entity.standard.StandardProgramListResponseEntity | ||
import com.school_of_company.model.model.standard.StandardRequestModel | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface StandardRepository { | ||
fun registerStandardProgram(expoId: String, body: StandardRequestModel): Flow<Unit> | ||
fun registerStandardListProgram(expoId: String, body: List<StandardRequestModel>): Flow<Unit> | ||
fun modifyStandardProgram(standardProId: Long, body: StandardRequestModel): Flow<Unit> | ||
fun deleteStandardProgram(standardProId: Long): Flow<Unit> | ||
fun standardProgramList(expoId: String): Flow<List<StandardProgramListResponseEntity>> | ||
fun standardProgramAttendList(standardProId: Long): Flow<List<StandardAttendListResponseEntity>> | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.school_of_company.data.repository.standard | ||
|
||
import com.school_of_company.model.entity.standard.StandardAttendListResponseEntity | ||
import com.school_of_company.model.entity.standard.StandardProgramListResponseEntity | ||
import com.school_of_company.model.model.standard.StandardRequestModel | ||
import com.school_of_company.network.datasource.standard.StandardDataSource | ||
import com.school_of_company.network.mapper.standard.request.toDto | ||
import com.school_of_company.network.mapper.standard.response.toModel | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.transform | ||
import javax.inject.Inject | ||
|
||
class StandardRepositoryImpl @Inject constructor( | ||
private val dataSource: StandardDataSource | ||
) : StandardRepository { | ||
override fun registerStandardProgram(expoId: String, body: StandardRequestModel): Flow<Unit> { | ||
return dataSource.registerStandardProgram( | ||
expoId = expoId, | ||
body = body.toDto() | ||
) | ||
} | ||
|
||
override fun registerStandardListProgram( | ||
expoId: String, | ||
body: List<StandardRequestModel> | ||
): Flow<Unit> { | ||
return dataSource.registerStandardListProgram( | ||
expoId = expoId, | ||
body = body.map { it.toDto() } | ||
) | ||
} | ||
|
||
override fun modifyStandardProgram( | ||
standardProId: Long, | ||
body: StandardRequestModel | ||
): Flow<Unit> { | ||
return dataSource.modifyStandardProgram( | ||
standardProId = standardProId, | ||
body = body.toDto() | ||
) | ||
} | ||
|
||
override fun deleteStandardProgram(standardProId: Long): Flow<Unit> { | ||
return dataSource.deleteStandardProgram(standardProId = standardProId) | ||
} | ||
|
||
override fun standardProgramList(expoId: String): Flow<List<StandardProgramListResponseEntity>> { | ||
return dataSource.standardProgramList(expoId = expoId).transform { list -> emit(list.map { it.toModel() }) } | ||
} | ||
|
||
override fun standardProgramAttendList(standardProId: Long): Flow<List<StandardAttendListResponseEntity>> { | ||
return dataSource.standardProgramAttendList(standardProId = standardProId).transform { list -> emit(list.map { it.toModel() }) } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.school_of_company.domain.usecase.standard | ||
|
||
import com.school_of_company.data.repository.standard.StandardRepository | ||
import javax.inject.Inject | ||
|
||
class DeleteStandardProgramListUseCase @Inject constructor( | ||
private val repository: StandardRepository | ||
) { | ||
operator fun invoke(standardProId: Long) = runCatching { | ||
repository.deleteStandardProgram(standardProId = standardProId) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.school_of_company.domain.usecase.standard | ||
|
||
import com.school_of_company.data.repository.standard.StandardRepository | ||
import com.school_of_company.model.model.standard.StandardRequestModel | ||
import javax.inject.Inject | ||
|
||
class ModifyStandardProgramUseCase @Inject constructor( | ||
private val repository: StandardRepository | ||
) { | ||
operator fun invoke( | ||
standardProId: Long, | ||
body: StandardRequestModel | ||
) = runCatching { | ||
repository.modifyStandardProgram( | ||
standardProId = standardProId, | ||
body = body | ||
) | ||
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.school_of_company.domain.usecase.standard | ||
|
||
import com.school_of_company.data.repository.standard.StandardRepository | ||
import com.school_of_company.model.model.standard.StandardRequestModel | ||
import javax.inject.Inject | ||
|
||
class RegisterStandardListProgramUseCase @Inject constructor( | ||
private val repository: StandardRepository | ||
) { | ||
operator fun invoke( | ||
expoId: String, | ||
body: List<StandardRequestModel> | ||
) = runCatching { | ||
repository.registerStandardListProgram( | ||
expoId = expoId, | ||
body = body | ||
) | ||
} | ||
} | ||
Comment on lines
+7
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π οΈ Refactor suggestion μ½λ μ€λ³΅ λ° μ±λ₯ κ°μ μ΄ νμν©λλ€.
μμ μ½λ: operator fun invoke(
expoId: String,
body: List<StandardRequestModel>
) = runCatching {
+ require(body.size <= MAX_BATCH_SIZE) { "μ΅λ μ²λ¦¬ κ°λ₯ν ν¬κΈ°λ₯Ό μ΄κ³Όνμ΅λλ€" }
+
+ body.chunked(OPTIMAL_CHUNK_SIZE)
+ .asFlow()
+ .flatMapMerge { chunk ->
repository.registerStandardListProgram(
expoId = expoId,
- body = body
+ body = chunk
)
+ }
}
+companion object {
+ private const val MAX_BATCH_SIZE = 1000
+ private const val OPTIMAL_CHUNK_SIZE = 100
+}
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.school_of_company.domain.usecase.standard | ||
|
||
import com.school_of_company.data.repository.standard.StandardRepository | ||
import com.school_of_company.model.model.standard.StandardRequestModel | ||
import javax.inject.Inject | ||
|
||
class RegisterStandardProgramUseCase @Inject constructor( | ||
private val repository: StandardRepository | ||
) { | ||
operator fun invoke( | ||
expoId: String, | ||
body: StandardRequestModel | ||
) = runCatching { | ||
repository.registerStandardProgram( | ||
expoId = expoId, | ||
body = body | ||
) | ||
} | ||
Comment on lines
+13
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π οΈ Refactor suggestion μλ¬ μ²λ¦¬ κ°μ μ΄ νμν©λλ€. νμ¬
μμ μ½λ: - ) = runCatching {
+ ) = runCatching {
+ require(expoId.isNotBlank()) { "expoIdλ λΉμ΄μμ μ μμ΅λλ€" }
+ require(body.isValid()) { "μ ν¨νμ§ μμ μμ²μ
λλ€" }
+
repository.registerStandardProgram(
expoId = expoId,
body = body
)
+ }.onFailure { throwable ->
+ when (throwable) {
+ is IllegalArgumentException -> throw BusinessException(throwable)
+ is IOException -> throw NetworkException(throwable)
+ else -> throw throwable
+ }
}
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.school_of_company.domain.usecase.standard | ||
|
||
import com.school_of_company.data.repository.standard.StandardRepository | ||
import com.school_of_company.model.entity.standard.StandardAttendListResponseEntity | ||
import kotlinx.coroutines.flow.Flow | ||
import javax.inject.Inject | ||
|
||
class StandardProgramAttendListUseCase @Inject constructor( | ||
private val repository: StandardRepository | ||
) { | ||
operator fun invoke(standardProId: Long) : Flow<List<StandardAttendListResponseEntity>> = | ||
repository.standardProgramAttendList(standardProId = standardProId) | ||
Comment on lines
+11
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π οΈ Refactor suggestion μ λ ₯κ° κ²μ¦κ³Ό μμΈ μ²λ¦¬κ° νμν©λλ€
operator fun invoke(standardProId: Long) : Flow<List<StandardAttendListResponseEntity>> =
+ require(standardProId > 0) { "standardProIdλ 0λ³΄λ€ μ»€μΌ ν©λλ€" }
repository.standardProgramAttendList(standardProId = standardProId)
+ .catch { throwable ->
+ when (throwable) {
+ is NoSuchElementException -> throw StandardProgramNotFoundException(standardProId)
+ else -> throw throwable
+ }
+ }
|
||
} |
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,13 @@ | ||||||||||||
package com.school_of_company.domain.usecase.standard | ||||||||||||
|
||||||||||||
import com.school_of_company.data.repository.standard.StandardRepository | ||||||||||||
import com.school_of_company.model.entity.standard.StandardProgramListResponseEntity | ||||||||||||
import kotlinx.coroutines.flow.Flow | ||||||||||||
import javax.inject.Inject | ||||||||||||
|
||||||||||||
class StandardProgramListUseCase @Inject constructor( | ||||||||||||
private val repository: StandardRepository | ||||||||||||
) { | ||||||||||||
operator fun invoke(expoId: String) : Flow<List<StandardProgramListResponseEntity>> = | ||||||||||||
repository.standardProgramList(expoId = expoId) | ||||||||||||
Comment on lines
+11
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π οΈ Refactor suggestion μ λ ₯κ° κ²μ¦μ΄ νμν©λλ€
operator fun invoke(expoId: String) : Flow<List<StandardProgramListResponseEntity>> =
+ require(expoId.isNotBlank()) { "expoIdλ λΉμ΄μμ μ μμ΅λλ€" }
repository.standardProgramList(expoId = expoId) π Committable suggestion
Suggested change
|
||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.school_of_company.model.entity.standard | ||
|
||
data class StandardAttendListResponseEntity( | ||
val name: String, | ||
val affiliation: String, | ||
val position: String, | ||
val programName: String, | ||
val status: Boolean, | ||
val entryTime: String, | ||
val leaveTime: String | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.school_of_company.model.entity.standard | ||
|
||
data class StandardProgramListResponseEntity( | ||
val id: Long, | ||
val title: String, | ||
val startedAt: String, | ||
val endedAt: String, | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.school_of_company.model.model.standard | ||
|
||
data class StandardRequestModel( | ||
val title: String, | ||
val startedAt: String, | ||
val endedAt: String, | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.school_of_company.network.api | ||
|
||
import com.school_of_company.network.dto.standard.request.StandardRequest | ||
import com.school_of_company.network.dto.standard.response.StandardAttendListResponse | ||
import com.school_of_company.network.dto.standard.response.StandardProgramListResponse | ||
import retrofit2.http.Body | ||
import retrofit2.http.DELETE | ||
import retrofit2.http.GET | ||
import retrofit2.http.POST | ||
import retrofit2.http.Path | ||
|
||
interface StandardAPI { | ||
|
||
@POST("/standard/{expo_id}") | ||
suspend fun registerStandardProgram( | ||
@Path("expo_id") expoId: String, | ||
@Body body: StandardRequest | ||
) | ||
Comment on lines
+14
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π οΈ Refactor suggestion API μλν¬μΈνΈ κ²½λ‘μ μΌκ΄μ± κ²ν κ° νμν©λλ€. μλν¬μΈνΈ κ²½λ‘μμ λ€μκ³Ό κ°μ λΉμΌκ΄μ±μ΄ λ°κ²¬λ©λλ€:
λ€μκ³Ό κ°μ΄ μμ νλ κ²μ μ μλ립λλ€: - @POST("/standard/{expo_id}")
+ @POST("/standard/program/{expoId}")
suspend fun registerStandardProgram(
- @Path("expo_id") expoId: String,
+ @Path("expoId") expoId: String,
@Body body: StandardRequest
)
- @POST("/standard/list/{expo_id}")
+ @POST("/standard/program/list/{expoId}")
suspend fun registerStandardListProgram(
- @Path("expo_id") expoId: String,
+ @Path("expoId") expoId: String,
@Body body: List<StandardRequest>
)
- @POST("/standard/{standardPro_id}")
+ @POST("/standard/program/{standardProId}")
suspend fun modifyStandardProgram(
- @Path("standardPro_id") standardProId: Long,
+ @Path("standardProId") standardProId: Long,
@Body body: StandardRequest
) Also applies to: 20-24, 26-30 |
||
|
||
@POST("/standard/list/{expo_id}") | ||
suspend fun registerStandardListProgram( | ||
@Path("expo_id") expoId: String, | ||
@Body body: List<StandardRequest> | ||
) | ||
|
||
@POST("/standard/{standardPro_id}") | ||
suspend fun modifyStandardProgram( | ||
@Path("standardPro_id") standardProId: Long, | ||
@Body body: StandardRequest | ||
) | ||
|
||
@DELETE("/standard/{standardPro_id}") | ||
suspend fun deleteStandardProgram( | ||
@Path("standardPro_id") standardProId: Long | ||
) | ||
|
||
@GET("/standard/program/{expo_id}") | ||
suspend fun standardProgramList( | ||
@Path("expo_id") expoId: String | ||
) : List<StandardProgramListResponse> | ||
|
||
@GET("/standard/{standardPro_id}") | ||
suspend fun standardProgramAttendList( | ||
@Path("standardPro_id") standardProId: Long | ||
) : List<StandardAttendListResponse> | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.school_of_company.network.datasource.standard | ||
|
||
import com.school_of_company.network.dto.standard.request.StandardRequest | ||
import com.school_of_company.network.dto.standard.response.StandardAttendListResponse | ||
import com.school_of_company.network.dto.standard.response.StandardProgramListResponse | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface StandardDataSource { | ||
fun registerStandardProgram(expoId: String, body: StandardRequest) : Flow<Unit> | ||
fun registerStandardListProgram(expoId: String, body: List<StandardRequest>) : Flow<Unit> | ||
fun modifyStandardProgram(standardProId: Long, body: StandardRequest) : Flow<Unit> | ||
fun deleteStandardProgram(standardProId: Long) : Flow<Unit> | ||
fun standardProgramList(expoId: String) : Flow<List<StandardProgramListResponse>> | ||
fun standardProgramAttendList(standardProId: Long) : Flow<List<StandardAttendListResponse>> | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,43 @@ | ||||||||||||||||||||||||
package com.school_of_company.network.datasource.standard | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
import com.school_of_company.network.api.StandardAPI | ||||||||||||||||||||||||
import com.school_of_company.network.dto.standard.request.StandardRequest | ||||||||||||||||||||||||
import com.school_of_company.network.dto.standard.response.StandardAttendListResponse | ||||||||||||||||||||||||
import com.school_of_company.network.dto.standard.response.StandardProgramListResponse | ||||||||||||||||||||||||
import com.school_of_company.network.util.performApiRequest | ||||||||||||||||||||||||
import kotlinx.coroutines.flow.Flow | ||||||||||||||||||||||||
import javax.inject.Inject | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
class StandardDataSourceImpl @Inject constructor( | ||||||||||||||||||||||||
private val service: StandardAPI | ||||||||||||||||||||||||
) : StandardDataSource { | ||||||||||||||||||||||||
override fun registerStandardProgram(expoId: String, body: StandardRequest): Flow<Unit> = | ||||||||||||||||||||||||
performApiRequest { service.registerStandardProgram( | ||||||||||||||||||||||||
expoId = expoId, | ||||||||||||||||||||||||
body = body | ||||||||||||||||||||||||
) } | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
override fun registerStandardListProgram( | ||||||||||||||||||||||||
expoId: String, | ||||||||||||||||||||||||
body: List<StandardRequest> | ||||||||||||||||||||||||
): Flow<Unit> = | ||||||||||||||||||||||||
performApiRequest { service.registerStandardListProgram( | ||||||||||||||||||||||||
expoId = expoId, | ||||||||||||||||||||||||
body = body | ||||||||||||||||||||||||
) } | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
override fun modifyStandardProgram(standardProId: Long, body: StandardRequest): Flow<Unit> = | ||||||||||||||||||||||||
performApiRequest { service.modifyStandardProgram( | ||||||||||||||||||||||||
standardProId = standardProId, | ||||||||||||||||||||||||
body = body | ||||||||||||||||||||||||
) } | ||||||||||||||||||||||||
Comment on lines
+29
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π οΈ Refactor suggestion Long νμ 맀κ°λ³μ μ ν¨μ± κ²μ¬ μΆκ° νμ standardProIdκ° 0λ³΄λ€ μμ κ²½μ°μ λν μ²λ¦¬κ° νμν©λλ€. λ€μκ³Ό κ°μ μ ν¨μ± κ²μ¬ μΆκ°λ₯Ό μ μν©λλ€: override fun modifyStandardProgram(standardProId: Long, body: StandardRequest): Flow<Unit> =
+ require(standardProId > 0) { "standardProId must be positive" }
performApiRequest { service.modifyStandardProgram(
standardProId = standardProId,
body = body
) } π Committable suggestion
Suggested change
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
override fun deleteStandardProgram(standardProId: Long): Flow<Unit> = | ||||||||||||||||||||||||
performApiRequest { service.deleteStandardProgram(standardProId = standardProId) } | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
override fun standardProgramList(expoId: String): Flow<List<StandardProgramListResponse>> = | ||||||||||||||||||||||||
performApiRequest { service.standardProgramList(expoId = expoId) } | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
override fun standardProgramAttendList(standardProId: Long): Flow<List<StandardAttendListResponse>> = | ||||||||||||||||||||||||
performApiRequest { service.standardProgramAttendList(standardProId = standardProId) } | ||||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.school_of_company.network.dto.standard.request | ||
|
||
import com.squareup.moshi.Json | ||
import com.squareup.moshi.JsonClass | ||
|
||
@JsonClass(generateAdapter = true) | ||
data class StandardRequest( | ||
@Json(name = "title") val title: String, | ||
@Json(name = "startedAt") val startedAt: String, | ||
@Json(name = "endedAt") val endedAt: String, | ||
Comment on lines
+8
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π‘ Codebase verification μκ° νλμ λν κ²μ¦μ΄ νμνλ©° λ¬Έμνκ° λ―Έν‘ν©λλ€. μ½λλ² μ΄μ€ λΆμ κ²°κ³Ό λ€μκ³Ό κ°μ λ¬Έμ μ λ€μ΄ λ°κ²¬λμμ΅λλ€:
κ°μ κΆμ₯μ¬ν:
π Analysis chainμκ° νλμ λν μ ν¨μ± κ²μ¬μ λ¬Έμνκ° νμν©λλ€. startedAtκ³Ό endedAt νλμ κ΄λ ¨νμ¬ λ€μ μ¬νλ€μ κ³ λ €ν΄μ£ΌμΈμ:
λ€μ μ€ν¬λ¦½νΈλ‘ μκ° κ΄λ ¨ κ²μ¦ λ‘μ§μ μ‘΄μ¬ μ¬λΆλ₯Ό νμΈν μ μμ΅λλ€: Let's search more broadly to understand the context and validation patterns in the codebase. Let's search for date/time validation and formatting related code to better understand how dates are handled in the codebase. π Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Check for time validation logic in the codebase
# Search for time validation patterns
rg -i "validate.*time|time.*validate|check.*time|time.*check"
# Search for date/time utility functions
ast-grep --pattern 'fun $_($$TIME|$$Date|$$DateTime)$_($$$) { $$$ }'
Length of output: 134 Script: #!/bin/bash
# Search for any date/time related validation or utility code
rg -i "date|time" -A 3 --type kotlin
# Search specifically in the network module
fd . "core/network" -e kt -x cat {}
# Look for validation related code
rg -i "validate|check" -A 3 --type kotlin
Length of output: 100877 Script: #!/bin/bash
# Let's check for date/time validation and formatting utilities
rg -i "format.*date|date.*format|parse.*date|date.*parse" -A 3
# Look for any date/time related utilities or helper functions
fd . "core/ui/src/main/java" -e kt -x cat {}
# Check for any validation related code in the codebase
ast-grep --pattern 'fun $_validate$_($$$) { $$$ }'
Length of output: 5945 |
||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π οΈ Refactor suggestion
ν΄λμ€ μ΄λ¦μ΄ κΈ°λ₯κ³Ό μΌμΉνμ§ μμ΅λλ€
νμ¬ ν΄λμ€ μ΄λ¦μ
DeleteStandardProgramListUseCase
μ΄μ§λ§ μ€μ λ‘λ λ¨μΌ νλ‘κ·Έλ¨μ μμ νλ κΈ°λ₯μ μνν©λλ€. λ λͺ νν μλ―Έ μ λ¬μ μν΄DeleteStandardProgramUseCase
λ‘ λ³κ²½νλ κ²μ΄ μ’κ² μ΅λλ€.π Committable suggestion