Skip to content

Commit

Permalink
Merge pull request #403 from GSM-MSG/develop
Browse files Browse the repository at this point in the history
지금까지의 변경상황을 마스터로 머지합니다
  • Loading branch information
louis7308 authored Jul 11, 2024
2 parents 826642a + dbc5fd1 commit aae5cd6
Show file tree
Hide file tree
Showing 25 changed files with 165 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package team.msg.sms.domain.authentication.dto.res

import team.msg.sms.domain.authentication.model.MarkingBoardType

data class QueryAuthenticationVerifyResponseData(
val name: String,
val score: Double,
val grader: String?,
val markingBoardType: MarkingBoardType
)
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ data class MarkingBoard(
val authenticationId: UUID,
val studentId: UUID,
val totalScore: Double = 0.0,
val markingBoardType: MarkingBoardType
val markingBoardType: MarkingBoardType,
val graderName: String?
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import team.msg.sms.domain.authentication.model.MarkingBoardType
import java.util.*

interface GetMarkingBoardService {
fun verifyMarkingBoardByStudentId(studentId: UUID): MarkingBoard?
fun getMarkingBoardById(id: UUID): MarkingBoard
fun getMarkingBoardByStudentIds(
studentIds: List<UUID>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import java.util.UUID
class GetMarkingBoardServiceImpl(
private val markingBoardPort: MarkingBoardPort
) : GetMarkingBoardService {
override fun verifyMarkingBoardByStudentId(studentId: UUID): MarkingBoard? =
markingBoardPort.verifyMarkingBoardByStudentId(studentId)

override fun getMarkingBoardById(id: UUID): MarkingBoard {
return markingBoardPort.queryMarkingBoardById(id) ?: throw MarkingBoardNotFoundException
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import team.msg.sms.domain.authentication.model.MarkingBoardType
import java.util.UUID

interface QueryMarkingBoardPort {
fun verifyMarkingBoardByStudentId(studentId: UUID): MarkingBoard?
fun queryMarkingBoardById(id: UUID): MarkingBoard?
fun queryMarkingBoardByStudentIds(
studentIds: List<UUID>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import team.msg.sms.domain.authentication.service.MarkingBoardService
import team.msg.sms.domain.authentication.service.MarkingValueService
import team.msg.sms.domain.authentication.service.UserFormValueService
import team.msg.sms.domain.teacher.service.TeacherService
import team.msg.sms.domain.user.service.UserService
import java.time.LocalDateTime
import java.util.UUID

Expand All @@ -18,14 +19,17 @@ class GradingAuthenticationFormUseCase(
private val markingValueService: MarkingValueService,
private val markingBoardService: MarkingBoardService,
private val userFormValueService: UserFormValueService,
private val teacherService: TeacherService
private val teacherService: TeacherService,
private val userService: UserService
) {
fun execute(markingBoardId: UUID, gradingDataList: List<GradingRequestData>) {
//요청한 setId 들 중 실제 userFormValue 테이블에 없는 setId 일 경우 최종점수에 영향을 미칠 수 있어 예외처리
if (!userFormValueService.checkUserFormValueBySetIds(gradingDataList.map { it.setId })) throw UserFormValueNotFoundException

val teacher = teacherService.currentTeacher()

val user = userService.getUserById(teacher.userId)

val markingValueList = markingValueService.findMarkingValueListByMarkingBoardId(markingBoardId)

val markingValueMap = markingValueList.associateBy { it.setId }
Expand Down Expand Up @@ -55,7 +59,8 @@ class GradingAuthenticationFormUseCase(
markingBoardService.save(
markingBoard.copy(
totalScore = totalScore,
markingBoardType = MarkingBoardType.COMPLETED
markingBoardType = MarkingBoardType.COMPLETED,
graderName = user.name
)
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package team.msg.sms.domain.authentication.usecase

import team.msg.sms.common.annotation.ReadOnlyUseCase
import team.msg.sms.domain.authentication.dto.res.QueryAuthenticationVerifyResponseData
import team.msg.sms.domain.authentication.model.MarkingBoardType
import team.msg.sms.domain.authentication.service.MarkingBoardService
import team.msg.sms.domain.student.service.StudentService

@ReadOnlyUseCase
class QueryAuthenticationVerifyUseCase(
private val studentService: StudentService,
private val markingBoardService: MarkingBoardService
) {
fun execute(): QueryAuthenticationVerifyResponseData {
val student = studentService.currentStudent()
val markingBoard = markingBoardService.verifyMarkingBoardByStudentId(student.id)

return if (markingBoard == null) {
QueryAuthenticationVerifyResponseData(
name = student.name,
score = 0.0,
grader = null,
markingBoardType = MarkingBoardType.NOT_SUBMITTED
)
} else {
QueryAuthenticationVerifyResponseData(
name = student.name,
score = markingBoard.totalScore,
grader = markingBoard.graderName,
markingBoardType = markingBoard.markingBoardType
)
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import team.msg.sms.domain.authentication.model.FieldType
import team.msg.sms.domain.authentication.model.MarkingBoard
import team.msg.sms.domain.authentication.model.MarkingBoardType
import team.msg.sms.domain.authentication.model.UserFormValue
import team.msg.sms.domain.authentication.service.AuthenticationFormService
import team.msg.sms.domain.authentication.service.AuthenticationSectionService
import team.msg.sms.domain.authentication.service.MarkingBoardService
import team.msg.sms.domain.authentication.service.UserFormValueService
Expand All @@ -15,11 +16,16 @@ import java.util.*

@UseCase
class SubmitUserFormDataUseCase(
private val authenticationFormService: AuthenticationFormService,
private val userFormValueService: UserFormValueService,
private val markingBoardService: MarkingBoardService,
private val studentService: StudentService
) {
fun execute(submitDataList: List<SubmitUserFormRequestData>, authenticationFormId: UUID) {
fun execute(submitDataList: List<SubmitUserFormRequestData>, uuid: String?) {
val authenticationFormId =
if (uuid.equals(null)) authenticationFormService.getActiveAuthenticationFormId()
else UUID.fromString(uuid)

val student = studentService.currentStudent()
val userFormValues = submitDataList.flatMap { submitData ->

Expand All @@ -46,6 +52,7 @@ class SubmitUserFormDataUseCase(
markingBoardType = MarkingBoardType.PENDING_REVIEW,
authenticationId = authenticationFormId,
studentId = student.id,
graderName = null
)
markingBoardService.save(markingBoard)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import team.msg.sms.domain.student.model.MilitaryService
data class DetailStudentInfoTeacherResponseData(
val name: String,
val introduce: String,
val portfolioUrl: String?,
val portfolioUrl: String,
val portfolioFileUrl: String?,
val grade: Int,
val classNum: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import team.msg.sms.domain.student.model.MilitaryService
data class DetailStudentInfoTokenResponseData(
val name: String,
val introduce: String,
val portfolioUrl: String?,
val portfolioUrl: String,
val portfolioFileUrl: String?,
val grade: Int,
val classNum: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class ModifyStudentInfoUseCase(
val checkStudentMismatch = studentService.checkStudentDataMismatch(student, modifyStudentInfoDataModel)
if (checkStudentMismatch) {
val portfolioFileUrl =
if(student.portfolioUrl != modifyStudentInfoDataModel.portfolioUrl
if(student.portfolioUrl != modifyStudentInfoDataModel.portfolioUrl // true && true) //해당 데이터가 다르면서 수정 데이터는 있으면 null
&& modifyStudentInfoData.portfolioUrl != null) null
else student.portfolioFileUrl

Expand Down Expand Up @@ -299,6 +299,7 @@ class ModifyStudentInfoUseCase(
}

else -> when (departmentCode) {
"0" -> Department.SW_DEVELOPMENT
"1", "2" -> Department.SW_DEVELOPMENT
"3", "4" -> Department.SMART_IOT_DEVELOPMENT
else -> throw StuNumNotRightException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import team.msg.sms.domain.project.service.ProjectService
import team.msg.sms.domain.project.service.ProjectTechStackService
import team.msg.sms.domain.region.service.RegionService
import team.msg.sms.domain.student.dto.res.DetailStudentInfoTeacherResponseData
import team.msg.sms.domain.student.model.Student
import team.msg.sms.domain.student.model.StudentTechStack
import team.msg.sms.domain.student.service.StudentService
import team.msg.sms.domain.student.service.StudentTechStackService
Expand Down Expand Up @@ -48,7 +49,7 @@ class StudentInfoTeacherUseCase(
return DetailStudentInfoTeacherResponseData(
name = student.name,
introduce = student.introduce,
portfolioUrl = student.portfolioUrl,
portfolioUrl = getStudentPortfolioUrl(student),
portfolioFileUrl = student.portfolioFileUrl,
grade = student.stuNum.substring(0, 1).toInt(),
classNum = student.stuNum.substring(1, 2).toInt(),
Expand Down Expand Up @@ -90,5 +91,13 @@ class StudentInfoTeacherUseCase(

private fun toStudentTechStacks(techStacks: List<TechStack>, studentTechStack: StudentTechStack): TechStack? =
techStacks.find { it.id == studentTechStack.techStackId }

private fun getStudentPortfolioUrl(student: Student.StudentWithUserInfo): String {
return when {
!student.portfolioUrl.isNullOrBlank() -> student.portfolioUrl
!student.portfolioFileUrl.isNullOrBlank() -> student.portfolioFileUrl
else -> ""
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class StudentInfoTokenUseCase(
return DetailStudentInfoTokenResponseData(
name = student.name,
introduce = student.introduce,
portfolioUrl = student.portfolioUrl,
portfolioUrl = getStudentPortfolioUrl(student),
portfolioFileUrl = student.portfolioFileUrl,
grade = student.stuNum.substring(0, 1).toInt(),
classNum = student.stuNum.substring(1, 2).toInt(),
Expand Down Expand Up @@ -94,5 +94,13 @@ class StudentInfoTokenUseCase(

private fun toStudentTechStacks(techStacks: List<TechStack>, studentTechStack: StudentTechStack): TechStack? =
techStacks.find { it.id == studentTechStack.techStackId }

private fun getStudentPortfolioUrl(student: Student.StudentWithUserInfo): String {
return when {
!student.portfolioUrl.isNullOrBlank() -> student.portfolioUrl
!student.portfolioFileUrl.isNullOrBlank() -> student.portfolioFileUrl
else -> ""
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import team.msg.sms.domain.student.model.MilitaryService
data class UserProfileDetailResponseData(
val name: String,
val introduce: String,
val portfolioUrl: String?,
val portfolioUrl: String,
val portfolioFileUrl: String?,
val grade: Int,
val classNum: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class QueryCurrentUserProfileDetailUseCase(
UserProfileDetailResponseData(
name = student.name,
introduce = student.introduce,
portfolioUrl = student.portfolioUrl,
portfolioUrl = getStudentPortfolioUrl(student),
portfolioFileUrl = student.portfolioFileUrl,
grade = student.stuNum.substring(0, 1).toInt(),
classNum = student.stuNum.substring(1, 2).toInt(),
Expand Down Expand Up @@ -113,4 +113,12 @@ class QueryCurrentUserProfileDetailUseCase(

private fun toStudentTechStacks(techStacks: List<TechStack>, studentTechStack: StudentTechStack): TechStack? =
techStacks.find { it.id == studentTechStack.techStackId }

private fun getStudentPortfolioUrl(student: Student.StudentWithUserInfo): String {
return when {
!student.portfolioUrl.isNullOrBlank() -> student.portfolioUrl
!student.portfolioFileUrl.isNullOrBlank() -> student.portfolioFileUrl
else -> ""
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class SecurityConfig(
.antMatchers(HttpMethod.GET, "/health").permitAll()

// Auth
.antMatchers(HttpMethod.GET, "/auth/verity/access").authenticated()
.antMatchers(HttpMethod.GET, "/auth/verify/access").authenticated()
.antMatchers(HttpMethod.POST, "/auth").permitAll()
.antMatchers(HttpMethod.PATCH, "/auth").permitAll()
.antMatchers(HttpMethod.DELETE, "/auth").authenticated()
Expand Down Expand Up @@ -98,9 +98,10 @@ class SecurityConfig(
.antMatchers(HttpMethod.GET, "/authentication/form").hasAnyAuthority(STUDENT, TEACHER)
.antMatchers(HttpMethod.GET, "/authentication/{uuid}/form").hasAuthority(TEACHER)
.antMatchers(HttpMethod.GET, "/authentication").hasAuthority(TEACHER)
.antMatchers(HttpMethod.GET, "/authentication/verify").hasAuthority(STUDENT)
.antMatchers(HttpMethod.PUT, "/authentication/{uuid}").hasAuthority(STUDENT)
.antMatchers(HttpMethod.POST, "/authentication").hasAuthority(STUDENT)
.antMatchers(HttpMethod.POST, "/authentication/submit/{uuid}").hasAuthority(STUDENT)
.antMatchers(HttpMethod.POST, "/authentication/submit").hasAuthority(STUDENT)
.antMatchers(HttpMethod.POST, "/authentication/create").hasAuthority(TEACHER)
.antMatchers(HttpMethod.POST, "/authentication/grading/{markingBoardId}").hasAuthority(TEACHER)
.antMatchers(HttpMethod.PATCH, "/authentication/teacher/{uuid}/approve").hasAuthority(TEACHER)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ class MarkingBoardPersistenceAdapter(
markingBoardJpaRepository.save(markingBoard.toEntity())
}

override fun verifyMarkingBoardByStudentId(studentId: UUID): MarkingBoard? =
markingBoardCustomRepository.findMarkingBoardWithStudentId(studentId)?.toDomain()

override fun queryMarkingBoardById(id: UUID): MarkingBoard? =
markingBoardJpaRepository.findByIdOrNull(id)?.toDomain()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,7 @@ class MarkingBoardJpaEntity(
val totalScore: Double,

@Enumerated(EnumType.STRING)
val markingBoardType : MarkingBoardType
val markingBoardType : MarkingBoardType,

val graderName: String?
): BaseUuidEntity(id)
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ fun MarkingBoardJpaEntity.toDomain() =
studentId = studentId,
title = title,
totalScore = totalScore,
markingBoardType = markingBoardType
markingBoardType = markingBoardType,
graderName = graderName
)

fun MarkingBoard.toEntity() =
Expand All @@ -20,5 +21,6 @@ fun MarkingBoard.toEntity() =
studentId = studentId,
title = title,
totalScore = totalScore,
markingBoardType = markingBoardType
markingBoardType = markingBoardType,
graderName = graderName
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ package team.msg.sms.persistence.authentication.repository.queryDSL

import team.msg.sms.domain.authentication.dto.res.UserBoardPageResponseData
import team.msg.sms.domain.authentication.model.MarkingBoardType
import team.msg.sms.persistence.authentication.entity.MarkingBoardJpaEntity
import java.util.*

interface MarkingBoardCustomRepository {
fun findMarkingBoardWithStudentId(studentId: UUID): MarkingBoardJpaEntity?

fun findMarkingBoardWithStudentInfoByStudentIds(
studentIds: List<UUID>,
authenticationId: UUID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import org.springframework.data.domain.PageRequest
import org.springframework.stereotype.Repository
import team.msg.sms.domain.authentication.dto.res.UserBoardPageResponseData
import team.msg.sms.domain.authentication.dto.res.UserBoardWithStudentInfoResponseData
import team.msg.sms.domain.authentication.model.MarkingBoard
import team.msg.sms.domain.authentication.model.MarkingBoardType
import team.msg.sms.persistence.authentication.entity.MarkingBoardJpaEntity
import team.msg.sms.persistence.authentication.entity.QAuthenticationFormJpaEntity
import team.msg.sms.persistence.authentication.entity.QMarkingBoardJpaEntity
import team.msg.sms.persistence.student.entity.QStudentJpaEntity
import team.msg.sms.persistence.user.entity.QUserJpaEntity
Expand All @@ -17,6 +20,22 @@ import java.util.*
class MarkingBoardRepositoryImpl(
private val jpaQueryFactory: JPAQueryFactory
) : MarkingBoardCustomRepository {
override fun findMarkingBoardWithStudentId(studentId: UUID): MarkingBoardJpaEntity? {
val qMarkingBoard = QMarkingBoardJpaEntity.markingBoardJpaEntity
val qAuthenticationForm = QAuthenticationFormJpaEntity.authenticationFormJpaEntity
val data = jpaQueryFactory
.select(qMarkingBoard)
.from(qMarkingBoard)
.join(qAuthenticationForm).on(qMarkingBoard.authenticationId.eq(qAuthenticationForm.id))
.where(
qMarkingBoard.studentId.eq(studentId)
.and(qAuthenticationForm.active.isTrue)
)
.fetch()
return if (data.isEmpty()) null else {
data.first()
}
}

override fun findMarkingBoardWithStudentInfoByStudentIds(
studentIds: List<UUID>,
Expand Down
Loading

0 comments on commit aae5cd6

Please sign in to comment.