From dbfdacefe482e6aaf208ef76fed306e3be0f8270 Mon Sep 17 00:00:00 2001 From: KimBeomJin Date: Sun, 26 Feb 2023 19:36:31 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20(#271)=20gcn=20method=20=ED=86=B5?= =?UTF-8?q?=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dms/domain/manager/usecase/RemoveStudentUseCase.kt | 3 --- .../aliens/dms/domain/point/spi/vo/StudentWithPointVO.kt | 2 +- .../dms/domain/student/usecase/CheckStudentGcnUseCase.kt | 2 +- .../team/aliens/dms/domain/student/usecase/SignUpUseCase.kt | 6 +++++- .../studyroom/usecase/ManagerQueryStudyRoomUseCase.kt | 2 +- .../domain/student/usecase/CheckStudentGcnUseCaseTests.kt | 4 ++-- .../aliens/dms/domain/student/usecase/SignUpUseCaseTests.kt | 6 +++++- .../kotlin/team/aliens/dms/domain/student/model/Student.kt | 6 ++++-- 8 files changed, 19 insertions(+), 12 deletions(-) diff --git a/dms-application/src/main/kotlin/team/aliens/dms/domain/manager/usecase/RemoveStudentUseCase.kt b/dms-application/src/main/kotlin/team/aliens/dms/domain/manager/usecase/RemoveStudentUseCase.kt index af8e3e422..8bee6d74f 100644 --- a/dms-application/src/main/kotlin/team/aliens/dms/domain/manager/usecase/RemoveStudentUseCase.kt +++ b/dms-application/src/main/kotlin/team/aliens/dms/domain/manager/usecase/RemoveStudentUseCase.kt @@ -50,9 +50,6 @@ class RemoveStudentUseCase( ) } - // 잔류 내역 삭제 - commandRemainStatusPort.deleteByStudentId(studentId) - commandUserPort.saveUser( studentUser.copy(deletedAt = LocalDateTime.now()) ) diff --git a/dms-application/src/main/kotlin/team/aliens/dms/domain/point/spi/vo/StudentWithPointVO.kt b/dms-application/src/main/kotlin/team/aliens/dms/domain/point/spi/vo/StudentWithPointVO.kt index e7203d139..d15482384 100644 --- a/dms-application/src/main/kotlin/team/aliens/dms/domain/point/spi/vo/StudentWithPointVO.kt +++ b/dms-application/src/main/kotlin/team/aliens/dms/domain/point/spi/vo/StudentWithPointVO.kt @@ -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 { return if (type == PointType.BONUS) { diff --git a/dms-application/src/main/kotlin/team/aliens/dms/domain/student/usecase/CheckStudentGcnUseCase.kt b/dms-application/src/main/kotlin/team/aliens/dms/domain/student/usecase/CheckStudentGcnUseCase.kt index 8d1e73a69..b65db1abf 100644 --- a/dms-application/src/main/kotlin/team/aliens/dms/domain/student/usecase/CheckStudentGcnUseCase.kt +++ b/dms-application/src/main/kotlin/team/aliens/dms/domain/student/usecase/CheckStudentGcnUseCase.kt @@ -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 diff --git a/dms-application/src/main/kotlin/team/aliens/dms/domain/student/usecase/SignUpUseCase.kt b/dms-application/src/main/kotlin/team/aliens/dms/domain/student/usecase/SignUpUseCase.kt index fe5e62161..4fb609a50 100644 --- a/dms-application/src/main/kotlin/team/aliens/dms/domain/student/usecase/SignUpUseCase.kt +++ b/dms-application/src/main/kotlin/team/aliens/dms/domain/student/usecase/SignUpUseCase.kt @@ -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 diff --git a/dms-application/src/main/kotlin/team/aliens/dms/domain/studyroom/usecase/ManagerQueryStudyRoomUseCase.kt b/dms-application/src/main/kotlin/team/aliens/dms/domain/studyroom/usecase/ManagerQueryStudyRoomUseCase.kt index ae4433fde..21c49ba67 100644 --- a/dms-application/src/main/kotlin/team/aliens/dms/domain/studyroom/usecase/ManagerQueryStudyRoomUseCase.kt +++ b/dms-application/src/main/kotlin/team/aliens/dms/domain/studyroom/usecase/ManagerQueryStudyRoomUseCase.kt @@ -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!! ) } diff --git a/dms-application/src/test/kotlin/team/aliens/dms/domain/student/usecase/CheckStudentGcnUseCaseTests.kt b/dms-application/src/test/kotlin/team/aliens/dms/domain/student/usecase/CheckStudentGcnUseCaseTests.kt index c399f86d6..9904f3414 100644 --- a/dms-application/src/test/kotlin/team/aliens/dms/domain/student/usecase/CheckStudentGcnUseCaseTests.kt +++ b/dms-application/src/test/kotlin/team/aliens/dms/domain/student/usecase/CheckStudentGcnUseCaseTests.kt @@ -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 ) ) @@ -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 ) ) diff --git a/dms-application/src/test/kotlin/team/aliens/dms/domain/student/usecase/SignUpUseCaseTests.kt b/dms-application/src/test/kotlin/team/aliens/dms/domain/student/usecase/SignUpUseCaseTests.kt index 3cbb58bff..c628dd46c 100644 --- a/dms-application/src/test/kotlin/team/aliens/dms/domain/student/usecase/SignUpUseCaseTests.kt +++ b/dms-application/src/test/kotlin/team/aliens/dms/domain/student/usecase/SignUpUseCaseTests.kt @@ -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 `회원가입 성공`() { diff --git a/dms-domain/src/main/kotlin/team/aliens/dms/domain/student/model/Student.kt b/dms-domain/src/main/kotlin/team/aliens/dms/domain/student/model/Student.kt index 3a5202a31..7fe7ee730 100644 --- a/dms-domain/src/main/kotlin/team/aliens/dms/domain/student/model/Student.kt +++ b/dms-domain/src/main/kotlin/team/aliens/dms/domain/student/model/Student.kt @@ -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() } }