Skip to content

Commit

Permalink
refactor: (#271) gcn method 통합
Browse files Browse the repository at this point in the history
  • Loading branch information
softpeanut committed Feb 26, 2023
1 parent a55b724 commit dbfdace
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ class RemoveStudentUseCase(
)
}

// 잔류 내역 삭제
commandRemainStatusPort.deleteByStudentId(studentId)

commandUserPort.saveUser(
studentUser.copy(deletedAt = LocalDateTime.now())
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ data class StudentWithPointVO(
val bonusTotal: Int,
val minusTotal: Int
) {
val gcn: String = "${this.grade}${this.classRoom}${Student.processNumber(number)}"
val gcn: String = Student.processGcn(this.grade, this.classRoom, this.number)

fun calculateUpdatedPointTotal(type: PointType, score: Int): Pair<Int, Int> {
return if (type == PointType.BONUS) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class CheckStudentGcnUseCase(
val school = querySchoolPort.querySchoolById(request.schoolId) ?: throw SchoolNotFoundException

val verifiedStudent = queryVerifiedStudentPort.queryVerifiedStudentByGcnAndSchoolName(
gcn = "${request.grade}${request.classRoom}${Student.processNumber(request.number)}",
gcn = Student.processGcn(request.grade, request.classRoom, request.number),
schoolName = school.name
) ?: throw VerifiedStudentNotFoundException

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ class SignUpUseCase(
* 검증된 학생 조회
**/
val verifiedStudent = queryVerifiedStudentPort.queryVerifiedStudentByGcnAndSchoolName(
gcn = "${grade}${classRoom}${Student.processNumber(number)}",
gcn = Student.processGcn(
grade = grade,
classRoom = classRoom,
number = number
),
schoolName = school.name
) ?: throw VerifiedStudentNotFoundException

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ManagerQueryStudyRoomUseCase(
StudentElement(
id = it.studentId,
name = it.studentName!!,
gcn = "${it.studentGrade}${it.studentClassRoom}${Student.processNumber(it.studentNumber!!)}",
gcn = Student.processGcn(it.studentGrade!!, it.studentClassRoom!!, it.studentNumber!!),
profileImageUrl = it.studentProfileImageUrl!!
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class CheckStudentGcnUseCaseTests {

given(
queryVerifiedStudentPort.queryVerifiedStudentByGcnAndSchoolName(
gcn = "${requestStub.grade}${requestStub.classRoom}${Student.processNumber(requestStub.number)}",
gcn = Student.processGcn(requestStub.grade, requestStub.classRoom, requestStub.number),
schoolName = schoolStub.name
)
)
Expand Down Expand Up @@ -112,7 +112,7 @@ class CheckStudentGcnUseCaseTests {

given(
queryVerifiedStudentPort.queryVerifiedStudentByGcnAndSchoolName(
gcn = "${requestStub.grade}${requestStub.classRoom}${Student.processNumber(requestStub.number)}",
gcn = Student.processGcn(requestStub.grade, requestStub.classRoom, requestStub.number),
schoolName = schoolStub.name
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,11 @@ class SignUpUseCaseTests {
)
}

private val gcnStub = "${requestStub.grade}${requestStub.classRoom}${Student.processNumber(requestStub.number)}"
private val gcnStub = Student.processGcn(
grade = requestStub.grade,
classRoom = requestStub.classRoom,
number = requestStub.number
)

// @Test
// fun `회원가입 성공`() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ data class Student(

) {

val gcn: String = "${this.grade}${this.classRoom}${processNumber(number)}"
val gcn: String = processGcn(this.grade, this.classRoom, this.number)

companion object {
const val PROFILE_IMAGE = "https://image-dms.s3.ap-northeast-2.amazonaws.com/59fd0067-93ef-4bcb-8722-5bc8786c5156%7C%7C%E1%84%83%E1%85%A1%E1%84%8B%E1%85%AE%E1%86%AB%E1%84%85%E1%85%A9%E1%84%83%E1%85%B3.png"

fun processNumber(number: Int) = if (number < 10) "0$number" else number.toString()
fun processGcn(grade: Int, classRoom: Int, number: Int) = "${grade}${classRoom}${processNumber(number)}"

private fun processNumber(number: Int) = if (number < 10) "0$number" else number.toString()
}
}

0 comments on commit dbfdace

Please sign in to comment.