diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/outing/service/CheckOutingService.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/outing/service/CheckOutingService.kt index 077fc5830..c2a331bdc 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/outing/service/CheckOutingService.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/outing/service/CheckOutingService.kt @@ -22,4 +22,6 @@ interface CheckOutingService { outingTime: LocalTime, arrivalTime: LocalTime ) + + fun checkOutingApplicationQueryAble() : Boolean } diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/outing/service/CheckOutingServiceImpl.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/outing/service/CheckOutingServiceImpl.kt index d61ab6ad0..9b1b544a2 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/outing/service/CheckOutingServiceImpl.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/outing/service/CheckOutingServiceImpl.kt @@ -66,4 +66,10 @@ class CheckOutingServiceImpl( } } } + + override fun checkOutingApplicationQueryAble(): Boolean { + val currentTime = LocalTime.now() + + return currentTime.isBefore(LocalTime.of(20, 0)) + } } diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/outing/service/GetOutingServiceImpl.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/outing/service/GetOutingServiceImpl.kt index 70b19f62e..37a887082 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/outing/service/GetOutingServiceImpl.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/outing/service/GetOutingServiceImpl.kt @@ -16,6 +16,7 @@ import team.aliens.dms.domain.outing.spi.vo.OutingCompanionDetailsVO import team.aliens.dms.domain.outing.spi.vo.OutingHistoryVO import java.time.DayOfWeek import java.time.LocalDate +import java.time.LocalTime import java.util.UUID @Service @@ -39,9 +40,10 @@ class GetOutingServiceImpl( override fun getAllOutingApplicationVOsBetweenStartAndEnd(start: LocalDate, end: LocalDate) = queryOutingApplicationPort.queryAllOutingApplicationVOsBetweenStartAndEnd(start, end) - override fun getCurrentOutingApplication(studentId: UUID): CurrentOutingApplicationVO = - queryOutingApplicationPort.queryCurrentOutingApplicationVO(studentId) - ?: throw OutingApplicationNotFoundException + override fun getCurrentOutingApplication(studentId: UUID): CurrentOutingApplicationVO { + return queryOutingApplicationPort.queryCurrentOutingApplicationVO(studentId) + ?: throw OutingApplicationNotFoundException + } override fun getOutingHistoriesByStudentNameAndDate( studentName: String?, @@ -60,4 +62,5 @@ class GetOutingServiceImpl( override fun getOutingAvailableTimeById(outingAvailableTimeId: UUID): OutingAvailableTime = queryOutingAvailableTimePort.queryOutingAvailableTimeById(outingAvailableTimeId) ?: throw OutingAvailableTimeNotFoundException + } diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/outing/spi/vo/OutingApplicationVO.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/outing/spi/vo/OutingApplicationVO.kt index 0912b5325..33bdf2dd8 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/outing/spi/vo/OutingApplicationVO.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/outing/spi/vo/OutingApplicationVO.kt @@ -9,7 +9,6 @@ open class OutingApplicationVO( val studentGrade: Int, val studentClassRoom: Int, val studentNumber: Int, - val reason: String?, val outingType: String, val outingDate: LocalDate, val outingTime: LocalTime, diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/outing/usecase/GetCurrentOutingApplicationUseCase.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/outing/usecase/GetCurrentOutingApplicationUseCase.kt index f2c19916c..880ac20d2 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/outing/usecase/GetCurrentOutingApplicationUseCase.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/outing/usecase/GetCurrentOutingApplicationUseCase.kt @@ -14,6 +14,8 @@ class GetCurrentOutingApplicationUseCase( fun execute(): GetCurrentOutingApplicationResponse { val student = studentService.getCurrentStudent() + outingService.checkOutingApplicationQueryAble() + val currentOutingApplicationVO = outingService.getCurrentOutingApplication(student.id) return GetCurrentOutingApplicationResponse.of(currentOutingApplicationVO, student.name) diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/tag/dto/TagResponse.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/tag/dto/TagResponse.kt index 829ff7cd9..12f19d5bb 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/tag/dto/TagResponse.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/tag/dto/TagResponse.kt @@ -3,7 +3,6 @@ package team.aliens.dms.domain.tag.dto import team.aliens.dms.domain.tag.model.Tag import java.util.UUID - data class TagResponse( val id: UUID, val name: String?, diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/dto/request/CreateVolunteerRequest.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/dto/request/CreateVolunteerRequest.kt index 14891ae4e..ac03b8e37 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/dto/request/CreateVolunteerRequest.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/dto/request/CreateVolunteerRequest.kt @@ -1,10 +1,13 @@ package team.aliens.dms.domain.volunteer.dto.request +import team.aliens.dms.domain.student.model.Sex +import team.aliens.dms.domain.volunteer.model.AvailableGrade + data class CreateVolunteerRequest( val name: String, val content: String, - val availableSex: String, - val availableGrade: String, + val availableSex: Sex, + val availableGrade: AvailableGrade, val score: Int, val optionalScore: Int, val maxApplicants: Int diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/dto/request/UpdateVolunteerRequest.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/dto/request/UpdateVolunteerRequest.kt index 44b0c499a..add29ed9b 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/dto/request/UpdateVolunteerRequest.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/dto/request/UpdateVolunteerRequest.kt @@ -1,12 +1,14 @@ package team.aliens.dms.domain.volunteer.dto.request +import team.aliens.dms.domain.student.model.Sex +import team.aliens.dms.domain.volunteer.model.AvailableGrade import java.util.UUID data class UpdateVolunteerRequest( val name: String, val content: String, - val availableSex: String, - val availableGrade: String, + val availableSex: Sex, + val availableGrade: AvailableGrade, val score: Int, val optionalScore: Int, val maxApplicants: Int, diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/dto/response/VolunteerResponse.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/dto/response/VolunteerResponse.kt index 368cdf5ac..436643665 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/dto/response/VolunteerResponse.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/dto/response/VolunteerResponse.kt @@ -1,7 +1,7 @@ package team.aliens.dms.domain.volunteer.dto.response import team.aliens.dms.domain.student.model.Sex -import team.aliens.dms.domain.volunteer.model.GradeCondition +import team.aliens.dms.domain.volunteer.model.AvailableGrade import team.aliens.dms.domain.volunteer.model.Volunteer import team.aliens.dms.domain.volunteer.model.VolunteerApplication import team.aliens.dms.domain.volunteer.spi.vo.CurrentVolunteerApplicantVO @@ -50,7 +50,7 @@ data class VolunteerResponse( val optionalScore: Int, val maxApplicants: Int, val availableSex: Sex, - val availableGrade: GradeCondition + val availableGrade: AvailableGrade ) { companion object { fun of(volunteer: Volunteer): VolunteerResponse { @@ -92,11 +92,15 @@ data class VolunteerApplicantsResponse( data class CurrentVolunteerApplicantResponse( val volunteerName: String, + val availableSex: Sex, + val availableGrade: AvailableGrade, val applicants: List ) { companion object { fun of(currentVolunteerApplicant: CurrentVolunteerApplicantVO) = CurrentVolunteerApplicantResponse( volunteerName = currentVolunteerApplicant.volunteerName, + availableSex = currentVolunteerApplicant.availableSex, + availableGrade = currentVolunteerApplicant.availableGrade, applicants = currentVolunteerApplicant.applicants .map { VolunteerApplicantResponse.of(it) } ) diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/exception/VolunteerErrorCode.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/exception/VolunteerErrorCode.kt index dff32d25f..f21061ef3 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/exception/VolunteerErrorCode.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/exception/VolunteerErrorCode.kt @@ -9,11 +9,14 @@ enum class VolunteerErrorCode( private val sequence: Int ) : ErrorProperty { + VOLUNTEER_NOT_AVAILABLE(ErrorStatus.FORBIDDEN, "Volunteer Not Available", 1), + VOLUNTEER_APPLICATION_NOT_FOUND(ErrorStatus.NOT_FOUND, "Volunteer Application Not Found", 1), VOLUNTEER_NOT_FOUND(ErrorStatus.NOT_FOUND, "Volunteer Not Found", 2), VOLUNTEER_APPLICATION_ALREADY_ASSIGNED(ErrorStatus.CONFLICT, "Volunteer Application Already Assigned", 1), - VOLUNTEER_APPLICATION_NOT_ASSIGNED(ErrorStatus.CONFLICT, "Volunteer Application Not Assigned", 2) + VOLUNTEER_APPLICATION_NOT_ASSIGNED(ErrorStatus.CONFLICT, "Volunteer Application Not Assigned", 2), + VOLUNTEER_APPLICATION_ALREADY_EXISTS(ErrorStatus.CONFLICT, "Volunteer Application Already Exists", 3) ; override fun status(): Int = status diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/exception/VolunteerExceptions.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/exception/VolunteerExceptions.kt index 9d887a3c9..04a3bcf16 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/exception/VolunteerExceptions.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/exception/VolunteerExceptions.kt @@ -2,10 +2,18 @@ package team.aliens.dms.domain.volunteer.exception import team.aliens.dms.common.error.DmsException +object VolunteerNotAvailableException : DmsException( + VolunteerErrorCode.VOLUNTEER_NOT_AVAILABLE +) + object VolunteerApplicationNotFoundException : DmsException( VolunteerErrorCode.VOLUNTEER_APPLICATION_NOT_FOUND ) +object VolunteerNotFoundException : DmsException( + VolunteerErrorCode.VOLUNTEER_NOT_FOUND +) + object VolunteerApplicationAlreadyAssigned : DmsException( VolunteerErrorCode.VOLUNTEER_APPLICATION_ALREADY_ASSIGNED ) @@ -14,6 +22,6 @@ object VolunteerApplicationNotAssigned : DmsException( VolunteerErrorCode.VOLUNTEER_APPLICATION_NOT_ASSIGNED ) -object VolunteerNotFoundException : DmsException( - VolunteerErrorCode.VOLUNTEER_NOT_FOUND +object VolunteerApplicationAlreadyExists : DmsException( + VolunteerErrorCode.VOLUNTEER_APPLICATION_ALREADY_EXISTS ) diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/model/GradeCondition.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/model/AvailableGrade.kt similarity index 56% rename from dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/model/GradeCondition.kt rename to dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/model/AvailableGrade.kt index d9ae7559c..aa39b9be1 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/model/GradeCondition.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/model/AvailableGrade.kt @@ -1,13 +1,13 @@ package team.aliens.dms.domain.volunteer.model -enum class GradeCondition( +enum class AvailableGrade( val grades: Set ) { ALL(setOf(1, 2, 3)), FIRST(setOf(1)), SECOND(setOf(2)), THIRD(setOf(3)), - FIRST_SECOND(setOf(1, 2)), - SECOND_THIRD(setOf(2, 3)), - FIRST_THIRD(setOf(1, 3)) + FIRST_AND_SECOND(setOf(1, 2)), + SECOND_AND_THIRD(setOf(2, 3)), + FIRST_AND_THIRD(setOf(1, 3)) } diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/model/Volunteer.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/model/Volunteer.kt index 971502a37..24eb0f846 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/model/Volunteer.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/model/Volunteer.kt @@ -3,6 +3,8 @@ package team.aliens.dms.domain.volunteer.model import team.aliens.dms.common.annotation.Aggregate import team.aliens.dms.common.model.SchoolIdDomain import team.aliens.dms.domain.student.model.Sex +import team.aliens.dms.domain.student.model.Student +import team.aliens.dms.domain.volunteer.exception.VolunteerNotAvailableException import java.util.UUID @Aggregate @@ -22,7 +24,17 @@ data class Volunteer( val availableSex: Sex, - val availableGrade: GradeCondition, + val availableGrade: AvailableGrade, override val schoolId: UUID -) : SchoolIdDomain +) : SchoolIdDomain { + + fun isAvailable(student: Student): Boolean { + return this.availableGrade.grades.contains(student.grade) && + (this.availableSex == student.sex || this.availableSex == Sex.ALL) + } + + fun checkAvailable(student: Student) { + if (!isAvailable(student)) throw VolunteerNotAvailableException + } +} diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/service/CheckVolunteerService.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/service/CheckVolunteerService.kt new file mode 100644 index 000000000..b2cfeff94 --- /dev/null +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/service/CheckVolunteerService.kt @@ -0,0 +1,8 @@ +package team.aliens.dms.domain.volunteer.service + +import java.util.UUID + +interface CheckVolunteerService { + + fun checkVolunteerApplicationExists(studentId: UUID, volunteerId: UUID) +} diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/service/CheckVolunteerServiceImpl.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/service/CheckVolunteerServiceImpl.kt new file mode 100644 index 000000000..0226ab72f --- /dev/null +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/service/CheckVolunteerServiceImpl.kt @@ -0,0 +1,20 @@ +package team.aliens.dms.domain.volunteer.service + +import team.aliens.dms.common.annotation.Service +import team.aliens.dms.domain.volunteer.exception.VolunteerApplicationAlreadyExists +import team.aliens.dms.domain.volunteer.spi.QueryVolunteerApplicationPort +import java.util.UUID + +@Service +class CheckVolunteerServiceImpl( + private val queryVolunteerApplicationPort: QueryVolunteerApplicationPort +) : CheckVolunteerService { + + override fun checkVolunteerApplicationExists(studentId: UUID, volunteerId: UUID) { + queryVolunteerApplicationPort + .queryVolunteerApplicationByStudentIdAndVolunteerId(studentId, volunteerId) + ?.let { + throw VolunteerApplicationAlreadyExists + } + } +} diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/service/CommandVolunteerService.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/service/CommandVolunteerService.kt index 6f4f046e7..2a7d0904e 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/service/CommandVolunteerService.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/service/CommandVolunteerService.kt @@ -2,6 +2,7 @@ package team.aliens.dms.domain.volunteer.service import team.aliens.dms.domain.volunteer.model.Volunteer import team.aliens.dms.domain.volunteer.model.VolunteerApplication +import java.util.UUID interface CommandVolunteerService { @@ -9,6 +10,8 @@ interface CommandVolunteerService { fun deleteVolunteerApplication(volunteerApplication: VolunteerApplication) + fun deleteAllVolunteerApplicationsByVolunteerId(volunteerId: UUID) + fun saveVolunteer(volunteer: Volunteer): Volunteer fun deleteVolunteer(volunteer: Volunteer) diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/service/CommandVolunteerServiceImpl.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/service/CommandVolunteerServiceImpl.kt index c234649fe..370e82504 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/service/CommandVolunteerServiceImpl.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/service/CommandVolunteerServiceImpl.kt @@ -5,6 +5,7 @@ import team.aliens.dms.domain.volunteer.model.Volunteer import team.aliens.dms.domain.volunteer.model.VolunteerApplication import team.aliens.dms.domain.volunteer.spi.CommandVolunteerApplicationPort import team.aliens.dms.domain.volunteer.spi.CommandVolunteerPort +import java.util.UUID @Service class CommandVolunteerServiceImpl( @@ -19,6 +20,10 @@ class CommandVolunteerServiceImpl( commandVolunteerApplicationPort.deleteVolunteerApplication(volunteerApplication) } + override fun deleteAllVolunteerApplicationsByVolunteerId(volunteerId: UUID) { + commandVolunteerApplicationPort.deleteAllVolunteerApplicationsByVolunteerId(volunteerId) + } + override fun saveVolunteer(volunteer: Volunteer): Volunteer = commandVolunteerPort.saveVolunteer(volunteer) diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/service/GetVolunteerService.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/service/GetVolunteerService.kt index 453c5b4d5..24957624f 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/service/GetVolunteerService.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/service/GetVolunteerService.kt @@ -1,5 +1,6 @@ package team.aliens.dms.domain.volunteer.service +import team.aliens.dms.domain.student.model.Student import team.aliens.dms.domain.volunteer.model.Volunteer import team.aliens.dms.domain.volunteer.model.VolunteerApplication import team.aliens.dms.domain.volunteer.spi.vo.CurrentVolunteerApplicantVO @@ -12,7 +13,7 @@ interface GetVolunteerService { fun getVolunteerById(volunteerId: UUID): Volunteer - fun getVolunteerByStudentId(studentId: UUID): List + fun getVolunteerByStudent(student: Student): List fun getAllVolunteersBySchoolId(schoolId: UUID): List @@ -20,7 +21,5 @@ interface GetVolunteerService { fun getAllApplicantsBySchoolIdGroupByVolunteer(schoolId: UUID): List - fun getAllVolunteers(): List - fun getVolunteerApplicationsWithVolunteersByStudentId(studentId: UUID): List> } diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/service/GetVolunteerServiceImpl.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/service/GetVolunteerServiceImpl.kt index cb1c6208a..7f8c257d8 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/service/GetVolunteerServiceImpl.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/service/GetVolunteerServiceImpl.kt @@ -1,6 +1,7 @@ package team.aliens.dms.domain.volunteer.service import team.aliens.dms.common.annotation.Service +import team.aliens.dms.domain.student.model.Student import team.aliens.dms.domain.volunteer.exception.VolunteerApplicationNotFoundException import team.aliens.dms.domain.volunteer.exception.VolunteerNotFoundException import team.aliens.dms.domain.volunteer.model.Volunteer @@ -14,7 +15,7 @@ import java.util.UUID @Service class GetVolunteerServiceImpl( private val queryVolunteerApplicationPort: QueryVolunteerApplicationPort, - private val queryVolunteerPort: QueryVolunteerPort, + private val queryVolunteerPort: QueryVolunteerPort ) : GetVolunteerService { override fun getVolunteerApplicationById(volunteerApplicationId: UUID): VolunteerApplication = @@ -25,8 +26,13 @@ class GetVolunteerServiceImpl( queryVolunteerPort.queryVolunteerById(volunteerId) ?: throw VolunteerNotFoundException - override fun getVolunteerByStudentId(studentId: UUID): List = - queryVolunteerPort.queryVolunteerByStudentId(studentId) + override fun getVolunteerByStudent(student: Student): List { + val volunteers = queryVolunteerPort.queryAllVolunteersBySchoolId(student.schoolId) + + return volunteers.filter { volunteer -> + volunteer.isAvailable(student) + } + } override fun getAllVolunteersBySchoolId(schoolId: UUID): List = queryVolunteerPort.queryAllVolunteersBySchoolId(schoolId) @@ -37,9 +43,6 @@ class GetVolunteerServiceImpl( override fun getAllApplicantsBySchoolIdGroupByVolunteer(schoolId: UUID): List = queryVolunteerApplicationPort.queryAllApplicantsBySchoolIdGroupByVolunteer(schoolId) - override fun getAllVolunteers(): List = - queryVolunteerPort.queryAllVolunteers() - override fun getVolunteerApplicationsWithVolunteersByStudentId(studentId: UUID): List> { return queryVolunteerApplicationPort.getVolunteerApplicationsWithVolunteersByStudentId(studentId) } diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/service/VolunteerService.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/service/VolunteerService.kt index 6cac32837..0dedef626 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/service/VolunteerService.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/service/VolunteerService.kt @@ -4,7 +4,9 @@ import team.aliens.dms.common.annotation.Service @Service class VolunteerService( + checkVolunteerService: CheckVolunteerService, commandVolunteerService: CommandVolunteerService, getVolunteerService: GetVolunteerService -) : CommandVolunteerService by commandVolunteerService, +) : CheckVolunteerService by checkVolunteerService, + CommandVolunteerService by commandVolunteerService, GetVolunteerService by getVolunteerService diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/spi/CommandVolunteerApplicationPort.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/spi/CommandVolunteerApplicationPort.kt index 5fb7f0fd0..1f66353b4 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/spi/CommandVolunteerApplicationPort.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/spi/CommandVolunteerApplicationPort.kt @@ -1,10 +1,13 @@ package team.aliens.dms.domain.volunteer.spi import team.aliens.dms.domain.volunteer.model.VolunteerApplication +import java.util.UUID interface CommandVolunteerApplicationPort { fun saveVolunteerApplication(volunteerApplication: VolunteerApplication): VolunteerApplication fun deleteVolunteerApplication(volunteerApplication: VolunteerApplication) + + fun deleteAllVolunteerApplicationsByVolunteerId(volunteerId: UUID) } diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/spi/QueryVolunteerApplicationPort.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/spi/QueryVolunteerApplicationPort.kt index 203ecf66e..433ec75ae 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/spi/QueryVolunteerApplicationPort.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/spi/QueryVolunteerApplicationPort.kt @@ -14,5 +14,7 @@ interface QueryVolunteerApplicationPort { fun queryAllApplicantsBySchoolIdGroupByVolunteer(schoolId: UUID): List + fun queryVolunteerApplicationByStudentIdAndVolunteerId(studentId: UUID, volunteerId: UUID): VolunteerApplication? + fun getVolunteerApplicationsWithVolunteersByStudentId(studentId: UUID): List> } diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/spi/QueryVolunteerPort.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/spi/QueryVolunteerPort.kt index b8d5be861..c5df8723f 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/spi/QueryVolunteerPort.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/spi/QueryVolunteerPort.kt @@ -7,9 +7,5 @@ interface QueryVolunteerPort { fun queryVolunteerById(volunteerId: UUID): Volunteer? - fun queryVolunteerByStudentId(studentId: UUID): List - fun queryAllVolunteersBySchoolId(schoolId: UUID): List - - fun queryAllVolunteers(): List } diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/spi/vo/CurrentVolunteerApplicantVO.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/spi/vo/CurrentVolunteerApplicantVO.kt index 58be08900..86e48c0e5 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/spi/vo/CurrentVolunteerApplicantVO.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/spi/vo/CurrentVolunteerApplicantVO.kt @@ -1,6 +1,11 @@ package team.aliens.dms.domain.volunteer.spi.vo +import team.aliens.dms.domain.student.model.Sex +import team.aliens.dms.domain.volunteer.model.AvailableGrade + open class CurrentVolunteerApplicantVO( val volunteerName: String, + val availableSex: Sex, + val availableGrade: AvailableGrade, val applicants: List ) diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/usecase/ApplyVolunteerUseCase.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/usecase/ApplyVolunteerUseCase.kt index 3791d5c62..3ace330b6 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/usecase/ApplyVolunteerUseCase.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/usecase/ApplyVolunteerUseCase.kt @@ -15,11 +15,17 @@ class ApplyVolunteerUseCase( fun execute(volunteerId: UUID): ApplyVolunteerResponse { val student = studentService.getCurrentStudent() + val currentVolunteer = volunteerService.getVolunteerById(volunteerId) + + volunteerService.checkVolunteerApplicationExists( + studentId = student.id, + volunteerId = currentVolunteer.id + ) val volunteer = volunteerService.saveVolunteerApplication( VolunteerApplication( studentId = student.id, - volunteerId = volunteerId, + volunteerId = currentVolunteer.also { it.checkAvailable(student) }.id, approved = false ) ) diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/usecase/CreateVolunteerUseCase.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/usecase/CreateVolunteerUseCase.kt index bad40681e..e55234789 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/usecase/CreateVolunteerUseCase.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/usecase/CreateVolunteerUseCase.kt @@ -2,9 +2,7 @@ package team.aliens.dms.domain.volunteer.usecase import team.aliens.dms.common.annotation.UseCase import team.aliens.dms.common.service.security.SecurityService -import team.aliens.dms.domain.student.model.Sex import team.aliens.dms.domain.volunteer.dto.request.CreateVolunteerRequest -import team.aliens.dms.domain.volunteer.model.GradeCondition import team.aliens.dms.domain.volunteer.model.Volunteer import team.aliens.dms.domain.volunteer.service.VolunteerService @@ -20,8 +18,8 @@ class CreateVolunteerUseCase( val volunteer = Volunteer( name = createVolunteerRequest.name, content = createVolunteerRequest.content, - availableSex = Sex.valueOf(createVolunteerRequest.availableSex), - availableGrade = GradeCondition.valueOf(createVolunteerRequest.availableGrade), + availableSex = createVolunteerRequest.availableSex, + availableGrade = createVolunteerRequest.availableGrade, score = createVolunteerRequest.score, optionalScore = createVolunteerRequest.optionalScore, maxApplicants = createVolunteerRequest.maxApplicants, diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/usecase/DeleteVolunteerUseCase.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/usecase/DeleteVolunteerUseCase.kt index 253425295..5e2921140 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/usecase/DeleteVolunteerUseCase.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/usecase/DeleteVolunteerUseCase.kt @@ -13,6 +13,8 @@ class DeleteVolunteerUseCase( val currentVolunteer = volunteerService.getVolunteerById(volunteerId) + volunteerService.deleteAllVolunteerApplicationsByVolunteerId(currentVolunteer.id) + volunteerService.deleteVolunteer(currentVolunteer) } } diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/usecase/QueryAvailableVolunteersUseCase.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/usecase/QueryAvailableVolunteersUseCase.kt index fb772dfd0..93c7c3b2f 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/usecase/QueryAvailableVolunteersUseCase.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/usecase/QueryAvailableVolunteersUseCase.kt @@ -15,7 +15,7 @@ class QueryAvailableVolunteersUseCase( fun execute(): AvailableVolunteersResponse { val student = studentService.getCurrentStudent() - val availableVolunteers = volunteerService.getVolunteerByStudentId(student.id) + val availableVolunteers = volunteerService.getVolunteerByStudent(student) return AvailableVolunteersResponse( availableVolunteers diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/usecase/UpdateVolunteerUseCase.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/usecase/UpdateVolunteerUseCase.kt index 09f7b407b..686bc4269 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/usecase/UpdateVolunteerUseCase.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/usecase/UpdateVolunteerUseCase.kt @@ -1,9 +1,7 @@ package team.aliens.dms.domain.volunteer.usecase import team.aliens.dms.common.annotation.UseCase -import team.aliens.dms.domain.student.model.Sex import team.aliens.dms.domain.volunteer.dto.request.UpdateVolunteerRequest -import team.aliens.dms.domain.volunteer.model.GradeCondition import team.aliens.dms.domain.volunteer.service.VolunteerService @UseCase @@ -18,8 +16,8 @@ class UpdateVolunteerUseCase( currentVolunteer.copy( name = updateVolunteerRequest.name, content = updateVolunteerRequest.content, - availableSex = Sex.valueOf(updateVolunteerRequest.availableSex), - availableGrade = GradeCondition.valueOf(updateVolunteerRequest.availableGrade), + availableSex = updateVolunteerRequest.availableSex, + availableGrade = updateVolunteerRequest.availableGrade, score = updateVolunteerRequest.score, optionalScore = updateVolunteerRequest.optionalScore, maxApplicants = updateVolunteerRequest.maxApplicants, diff --git a/dms-infrastructure/src/main/kotlin/team/aliens/dms/global/security/SecurityConfig.kt b/dms-infrastructure/src/main/kotlin/team/aliens/dms/global/security/SecurityConfig.kt index 75f74496d..8445d8ddc 100644 --- a/dms-infrastructure/src/main/kotlin/team/aliens/dms/global/security/SecurityConfig.kt +++ b/dms-infrastructure/src/main/kotlin/team/aliens/dms/global/security/SecurityConfig.kt @@ -193,14 +193,14 @@ class SecurityConfig( .requestMatchers(HttpMethod.POST, "/volunteers").hasAuthority(MANAGER.name) .requestMatchers(HttpMethod.PATCH, "/volunteers/{volunteer-id}").hasAuthority(MANAGER.name) .requestMatchers(HttpMethod.DELETE, "/volunteers/{volunteer-id}").hasAuthority(MANAGER.name) - .requestMatchers(HttpMethod.GET, "/volunteers/manage").hasAuthority(MANAGER.name) + .requestMatchers(HttpMethod.GET, "/volunteers/manager").hasAuthority(MANAGER.name) .requestMatchers(HttpMethod.GET, "/volunteers/{volunteer-id}").hasAuthority(MANAGER.name) - .requestMatchers(HttpMethod.GET, "/volunteers/apply/{volunteer-application-id}").hasAuthority(MANAGER.name) - .requestMatchers(HttpMethod.DELETE, "/volunteers/reject/{volunteer-application-id}").hasAuthority(MANAGER.name) - .requestMatchers(HttpMethod.DELETE, "/volunteers/exclude/{volunteer-application-id}").hasAuthority(MANAGER.name) + .requestMatchers(HttpMethod.POST, "/volunteers/approval/{volunteer-application-id}").hasAuthority(MANAGER.name) + .requestMatchers(HttpMethod.DELETE, "/volunteers/rejection/{volunteer-application-id}").hasAuthority(MANAGER.name) + .requestMatchers(HttpMethod.DELETE, "/volunteers/exception/{volunteer-application-id}").hasAuthority(MANAGER.name) .requestMatchers(HttpMethod.GET, "/volunteers/current").hasAuthority(MANAGER.name) - .requestMatchers(HttpMethod.POST, "/volunteers/apply/{volunteer-id}").hasAuthority(STUDENT.name) - .requestMatchers(HttpMethod.DELETE, "/volunteers/cancel/{volunteer-application-id}").hasAuthority(STUDENT.name) + .requestMatchers(HttpMethod.POST, "/volunteers/application/{volunteer-id}").hasAuthority(STUDENT.name) + .requestMatchers(HttpMethod.DELETE, "/volunteers/cancellation/{volunteer-application-id}").hasAuthority(STUDENT.name) .requestMatchers(HttpMethod.GET, "/volunteers").hasAuthority(STUDENT.name) .requestMatchers(HttpMethod.GET, "/volunteers/my/application").hasAuthority(STUDENT.name) diff --git a/dms-infrastructure/src/main/kotlin/team/aliens/dms/thirdparty/parser/ExcelAdapter.kt b/dms-infrastructure/src/main/kotlin/team/aliens/dms/thirdparty/parser/ExcelAdapter.kt index 1bde11e64..4247afa31 100644 --- a/dms-infrastructure/src/main/kotlin/team/aliens/dms/thirdparty/parser/ExcelAdapter.kt +++ b/dms-infrastructure/src/main/kotlin/team/aliens/dms/thirdparty/parser/ExcelAdapter.kt @@ -248,14 +248,14 @@ class ExcelAdapter : ParseFilePort, WriteFilePort, ExcelPort() { } override fun writeOutingApplicationExcelFile(outingApplicationExcelVos: List): ByteArray { - val attributes = mutableListOf("ㅤ학번ㅤ", "ㅤ이름ㅤ", "외출 사유", "외출 시간", "도착 시간", "외출 확인", "복귀 확인") + val attributes = mutableListOf("ㅤ학번ㅤ", "ㅤ이름ㅤ", "외출 유형", "외출 시간", "도착 시간", "외출 확인", "복귀 확인") val outingApplicationInfoSet = outingApplicationExcelVos.map { outingApplication -> val outingApplicationInfoList = mutableListOf( listOf( outingApplication.studentGcn, outingApplication.studentName, - outingApplication.reason ?: "", + outingApplication.outingType, outingApplication.outingTime.toString(), outingApplication.arrivalTime.toString(), null, diff --git a/dms-infrastructure/src/main/resources/db/migration/V6__change_column_in_tbl_volunteer_available_grade.sql b/dms-infrastructure/src/main/resources/db/migration/V6__change_column_in_tbl_volunteer_available_grade.sql new file mode 100644 index 000000000..c295ba3ec --- /dev/null +++ b/dms-infrastructure/src/main/resources/db/migration/V6__change_column_in_tbl_volunteer_available_grade.sql @@ -0,0 +1,6 @@ +ALTER TABLE tbl_volunteer + MODIFY COLUMN available_grade VARCHAR(16); + +UPDATE tbl_volunteer + set available_grade = REPLACE(available_grade, "_", "_AND_") + where available_grade LIKE "%_%"; \ No newline at end of file diff --git a/dms-persistence/src/main/kotlin/team/aliens/dms/persistence/outing/OutingApplicationPersistenceAdapter.kt b/dms-persistence/src/main/kotlin/team/aliens/dms/persistence/outing/OutingApplicationPersistenceAdapter.kt index cd371ec5e..257a588eb 100644 --- a/dms-persistence/src/main/kotlin/team/aliens/dms/persistence/outing/OutingApplicationPersistenceAdapter.kt +++ b/dms-persistence/src/main/kotlin/team/aliens/dms/persistence/outing/OutingApplicationPersistenceAdapter.kt @@ -65,8 +65,7 @@ class OutingApplicationPersistenceAdapter( studentJpaEntity.grade, studentJpaEntity.classRoom, studentJpaEntity.number, - outingApplicationJpaEntity.reason, - outingApplicationJpaEntity.reason, + outingApplicationJpaEntity.outingType.id.title, outingApplicationJpaEntity.outingDate, outingApplicationJpaEntity.outingTime, outingApplicationJpaEntity.arrivalTime, diff --git a/dms-persistence/src/main/kotlin/team/aliens/dms/persistence/outing/repository/vo/QueryOutingApplicationVO.kt b/dms-persistence/src/main/kotlin/team/aliens/dms/persistence/outing/repository/vo/QueryOutingApplicationVO.kt index 23452011e..1120ff6cf 100644 --- a/dms-persistence/src/main/kotlin/team/aliens/dms/persistence/outing/repository/vo/QueryOutingApplicationVO.kt +++ b/dms-persistence/src/main/kotlin/team/aliens/dms/persistence/outing/repository/vo/QueryOutingApplicationVO.kt @@ -11,7 +11,6 @@ class QueryOutingApplicationVO @QueryProjection constructor( studentGrade: Int, studentClassRoom: Int, studentNumber: Int, - reason: String, outingType: String, outingDate: LocalDate, outingTime: LocalTime, @@ -22,7 +21,6 @@ class QueryOutingApplicationVO @QueryProjection constructor( studentGrade = studentGrade, studentClassRoom = studentClassRoom, studentNumber = studentNumber, - reason = reason, outingType = outingType, outingDate = outingDate, outingTime = outingTime, diff --git a/dms-persistence/src/main/kotlin/team/aliens/dms/persistence/volunteer/VolunteerApplicationPersistenceAdapter.kt b/dms-persistence/src/main/kotlin/team/aliens/dms/persistence/volunteer/VolunteerApplicationPersistenceAdapter.kt index af249b343..0a5553946 100644 --- a/dms-persistence/src/main/kotlin/team/aliens/dms/persistence/volunteer/VolunteerApplicationPersistenceAdapter.kt +++ b/dms-persistence/src/main/kotlin/team/aliens/dms/persistence/volunteer/VolunteerApplicationPersistenceAdapter.kt @@ -66,20 +66,30 @@ class VolunteerApplicationPersistenceAdapter( ) } + override fun deleteAllVolunteerApplicationsByVolunteerId(volunteerId: UUID) { + volunteerApplicationRepository.deleteAllByVolunteerId(volunteerId) + } + override fun queryAllApplicantsBySchoolIdGroupByVolunteer(schoolId: UUID): List { return queryFactory - .selectFrom(volunteerApplicationJpaEntity) - .join(volunteerApplicationJpaEntity.volunteer, volunteerJpaEntity) - .join(volunteerApplicationJpaEntity.student, studentJpaEntity) + .selectFrom(volunteerJpaEntity) + .leftJoin(volunteerApplicationJpaEntity) + .on( + volunteerApplicationJpaEntity.volunteer.id.eq(volunteerJpaEntity.id) + .and(volunteerApplicationJpaEntity.approved.isFalse.not()) + ) + .leftJoin(studentJpaEntity) + .on(studentJpaEntity.id.eq(volunteerApplicationJpaEntity.student.id)) .where( - volunteerJpaEntity.school.id.eq(schoolId), - volunteerApplicationJpaEntity.approved.eq(true) + volunteerJpaEntity.school.id.eq(schoolId) ) .transform( - groupBy(volunteerJpaEntity.name) + groupBy(volunteerJpaEntity.id) .list( QQueryCurrentVolunteerApplicantVO( volunteerJpaEntity.name, + volunteerJpaEntity.availableSex, + volunteerJpaEntity.availableGrade, list( QQueryVolunteerApplicantVO( volunteerApplicationJpaEntity.id, @@ -87,13 +97,24 @@ class VolunteerApplicationPersistenceAdapter( studentJpaEntity.classRoom, studentJpaEntity.number, studentJpaEntity.name, - ) + ).skipNulls() ) ) ) ) } + override fun queryVolunteerApplicationByStudentIdAndVolunteerId( + studentId: UUID, + volunteerId: UUID + ): VolunteerApplication? { + return volunteerApplicationMapper.toDomain( + volunteerApplicationRepository.findByStudentIdAndVolunteerId( + studentId, volunteerId + ) + ) + } + override fun getVolunteerApplicationsWithVolunteersByStudentId(studentId: UUID): List> { val result = queryFactory .select(volunteerApplicationJpaEntity, volunteerJpaEntity) diff --git a/dms-persistence/src/main/kotlin/team/aliens/dms/persistence/volunteer/VolunteerPersistenceAdapter.kt b/dms-persistence/src/main/kotlin/team/aliens/dms/persistence/volunteer/VolunteerPersistenceAdapter.kt index 29f016f23..664ef7354 100644 --- a/dms-persistence/src/main/kotlin/team/aliens/dms/persistence/volunteer/VolunteerPersistenceAdapter.kt +++ b/dms-persistence/src/main/kotlin/team/aliens/dms/persistence/volunteer/VolunteerPersistenceAdapter.kt @@ -2,11 +2,8 @@ package team.aliens.dms.persistence.volunteer import org.springframework.data.repository.findByIdOrNull import org.springframework.stereotype.Component -import team.aliens.dms.domain.student.exception.StudentNotFoundException -import team.aliens.dms.domain.student.model.Sex import team.aliens.dms.domain.volunteer.model.Volunteer import team.aliens.dms.domain.volunteer.spi.VolunteerPort -import team.aliens.dms.persistence.student.repository.StudentJpaRepository import team.aliens.dms.persistence.volunteer.mapper.VolunteerMapper import team.aliens.dms.persistence.volunteer.repository.VolunteerJpaRepository import java.util.UUID @@ -14,8 +11,7 @@ import java.util.UUID @Component class VolunteerPersistenceAdapter( private val volunteerMapper: VolunteerMapper, - private val volunteerJpaRepository: VolunteerJpaRepository, - private val studentRepository: StudentJpaRepository + private val volunteerJpaRepository: VolunteerJpaRepository ) : VolunteerPort { override fun saveVolunteer(volunteer: Volunteer): Volunteer = volunteerMapper.toDomain( @@ -34,28 +30,8 @@ class VolunteerPersistenceAdapter( volunteerJpaRepository.findByIdOrNull(volunteerId) ) - override fun queryVolunteerByStudentId(studentId: UUID): List { - val student = studentRepository.findById(studentId) - .orElseThrow { throw StudentNotFoundException } - - val volunteers = volunteerJpaRepository.findAll() - return volunteers - .filter { volunteer -> - ( - volunteer.availableGrade.grades.contains(student.grade) && - (volunteer.availableSex == student.sex || volunteer.availableSex == Sex.ALL) - ) - } - .mapNotNull { volunteerMapper.toDomain(it) } - } - override fun queryAllVolunteersBySchoolId(schoolId: UUID): List { return volunteerJpaRepository.findAllBySchoolId(schoolId) .map { volunteerMapper.toDomain(it)!! } } - - override fun queryAllVolunteers(): List { - return volunteerJpaRepository.findAll() - .map { volunteerMapper.toDomain(it)!! } - } } diff --git a/dms-persistence/src/main/kotlin/team/aliens/dms/persistence/volunteer/entity/VolunteerJpaEntity.kt b/dms-persistence/src/main/kotlin/team/aliens/dms/persistence/volunteer/entity/VolunteerJpaEntity.kt index 71bc4fbb8..63d7b1e4f 100644 --- a/dms-persistence/src/main/kotlin/team/aliens/dms/persistence/volunteer/entity/VolunteerJpaEntity.kt +++ b/dms-persistence/src/main/kotlin/team/aliens/dms/persistence/volunteer/entity/VolunteerJpaEntity.kt @@ -9,7 +9,7 @@ import jakarta.persistence.JoinColumn import jakarta.persistence.ManyToOne import jakarta.persistence.Table import team.aliens.dms.domain.student.model.Sex -import team.aliens.dms.domain.volunteer.model.GradeCondition +import team.aliens.dms.domain.volunteer.model.AvailableGrade import team.aliens.dms.persistence.BaseEntity import team.aliens.dms.persistence.school.entity.SchoolJpaEntity import java.util.UUID @@ -39,9 +39,9 @@ class VolunteerJpaEntity( @Enumerated(EnumType.STRING) val availableSex: Sex, - @Column(columnDefinition = "VARCHAR(14)", nullable = false) + @Column(columnDefinition = "VARCHAR(16)", nullable = false) @Enumerated(EnumType.STRING) - val availableGrade: GradeCondition, + val availableGrade: AvailableGrade, @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "school_id", columnDefinition = "BINARY(16)", nullable = false) diff --git a/dms-persistence/src/main/kotlin/team/aliens/dms/persistence/volunteer/repository/VolunteerApplicationJpaRepository.kt b/dms-persistence/src/main/kotlin/team/aliens/dms/persistence/volunteer/repository/VolunteerApplicationJpaRepository.kt index 14c3eeab2..3cd8a8381 100644 --- a/dms-persistence/src/main/kotlin/team/aliens/dms/persistence/volunteer/repository/VolunteerApplicationJpaRepository.kt +++ b/dms-persistence/src/main/kotlin/team/aliens/dms/persistence/volunteer/repository/VolunteerApplicationJpaRepository.kt @@ -8,5 +8,7 @@ import java.util.UUID @Repository interface VolunteerApplicationJpaRepository : CrudRepository { - fun findByStudentId(studentId: UUID): List + fun deleteAllByVolunteerId(volunteerId: UUID) + + fun findByStudentIdAndVolunteerId(studentId: UUID, volunteerId: UUID): VolunteerApplicationJpaEntity? } diff --git a/dms-persistence/src/main/kotlin/team/aliens/dms/persistence/volunteer/repository/vo/QueryCurrentVolunteerApplicantVO.kt b/dms-persistence/src/main/kotlin/team/aliens/dms/persistence/volunteer/repository/vo/QueryCurrentVolunteerApplicantVO.kt index 13da5c1af..ce31632a5 100644 --- a/dms-persistence/src/main/kotlin/team/aliens/dms/persistence/volunteer/repository/vo/QueryCurrentVolunteerApplicantVO.kt +++ b/dms-persistence/src/main/kotlin/team/aliens/dms/persistence/volunteer/repository/vo/QueryCurrentVolunteerApplicantVO.kt @@ -1,12 +1,18 @@ package team.aliens.dms.persistence.volunteer.repository.vo import com.querydsl.core.annotations.QueryProjection +import team.aliens.dms.domain.student.model.Sex +import team.aliens.dms.domain.volunteer.model.AvailableGrade import team.aliens.dms.domain.volunteer.spi.vo.CurrentVolunteerApplicantVO class QueryCurrentVolunteerApplicantVO @QueryProjection constructor( volunteerName: String, + availableSex: Sex, + availableGrade: AvailableGrade, applicants: List ) : CurrentVolunteerApplicantVO( volunteerName = volunteerName, + availableSex = availableSex, + availableGrade = availableGrade, applicants = applicants ) diff --git a/dms-presentation/src/main/kotlin/team/aliens/dms/domain/volunteer/VolunteerWebAdapter.kt b/dms-presentation/src/main/kotlin/team/aliens/dms/domain/volunteer/VolunteerWebAdapter.kt index e3d98323f..61463bbb5 100644 --- a/dms-presentation/src/main/kotlin/team/aliens/dms/domain/volunteer/VolunteerWebAdapter.kt +++ b/dms-presentation/src/main/kotlin/team/aliens/dms/domain/volunteer/VolunteerWebAdapter.kt @@ -57,13 +57,13 @@ class VolunteerWebAdapter( ) { @ResponseStatus(HttpStatus.CREATED) - @PostMapping("/apply/{volunteer-application-id}") + @PostMapping("/application/{volunteer-application-id}") fun applyVolunteer(@PathVariable("volunteer-application-id") @NotNull volunteerApplicationId: UUID) { applyVolunteerUseCase.execute(volunteerApplicationId) } @ResponseStatus(HttpStatus.NO_CONTENT) - @DeleteMapping("/cancel/{volunteer-application-id}") + @DeleteMapping("/cancellation/{volunteer-application-id}") fun unapplyVolunteer(@PathVariable("volunteer-application-id") @NotNull volunteerApplicationId: UUID) { unapplyVolunteerUseCase.execute(volunteerApplicationId) } @@ -123,19 +123,19 @@ class VolunteerWebAdapter( } @ResponseStatus(HttpStatus.NO_CONTENT) - @PostMapping("/approve/{volunteer-application-id}") + @PostMapping("/approval/{volunteer-application-id}") fun approveVolunteerApplication(@PathVariable("volunteer-application-id") volunteerApplicationId: UUID) { approveVolunteerApplicationUseCase.execute(volunteerApplicationId) } @ResponseStatus(HttpStatus.NO_CONTENT) - @DeleteMapping("/reject/{volunteer-application-id}") + @DeleteMapping("/rejection/{volunteer-application-id}") fun rejectVolunteerApplication(@PathVariable("volunteer-application-id") volunteerApplicationId: UUID) { rejectVolunteerApplicationUseCase.execute(volunteerApplicationId) } @ResponseStatus(HttpStatus.NO_CONTENT) - @DeleteMapping("/exclude/{volunteer-application-id}") + @DeleteMapping("/exception/{volunteer-application-id}") fun excludeVolunteerApplication(@PathVariable("volunteer-application-id") volunteerApplicationId: UUID) { excludeVolunteerApplicationUseCase.execute(volunteerApplicationId) } diff --git a/dms-presentation/src/main/kotlin/team/aliens/dms/domain/volunteer/dto/request/CreateVolunteerWebRequest.kt b/dms-presentation/src/main/kotlin/team/aliens/dms/domain/volunteer/dto/request/CreateVolunteerWebRequest.kt index c40ddd17e..83f8660c5 100644 --- a/dms-presentation/src/main/kotlin/team/aliens/dms/domain/volunteer/dto/request/CreateVolunteerWebRequest.kt +++ b/dms-presentation/src/main/kotlin/team/aliens/dms/domain/volunteer/dto/request/CreateVolunteerWebRequest.kt @@ -2,7 +2,8 @@ package team.aliens.dms.domain.volunteer.dto.request import jakarta.validation.constraints.NotBlank import jakarta.validation.constraints.NotNull -import jakarta.validation.constraints.Size +import team.aliens.dms.domain.student.model.Sex +import team.aliens.dms.domain.volunteer.model.AvailableGrade data class CreateVolunteerWebRequest( @@ -12,18 +13,17 @@ data class CreateVolunteerWebRequest( @field:NotBlank val content: String, - @field:Size(min = 1, max = 6) - @field:NotBlank - val availableSex: String, + @field:NotNull + val availableSex: Sex, - @field:Size(min = 1, max = 14) - @field:NotBlank - val availableGrade: String, + @field:NotNull + val availableGrade: AvailableGrade, @field:NotNull val score: Int, - val optionalScore: Int = 0, + @field:NotNull + val optionalScore: Int, @field:NotNull val maxApplicants: Int diff --git a/dms-presentation/src/main/kotlin/team/aliens/dms/domain/volunteer/dto/request/UpdateVolunteerWebRequest.kt b/dms-presentation/src/main/kotlin/team/aliens/dms/domain/volunteer/dto/request/UpdateVolunteerWebRequest.kt index 8a819a3bf..f088619d3 100644 --- a/dms-presentation/src/main/kotlin/team/aliens/dms/domain/volunteer/dto/request/UpdateVolunteerWebRequest.kt +++ b/dms-presentation/src/main/kotlin/team/aliens/dms/domain/volunteer/dto/request/UpdateVolunteerWebRequest.kt @@ -2,7 +2,8 @@ package team.aliens.dms.domain.volunteer.dto.request import jakarta.validation.constraints.NotBlank import jakarta.validation.constraints.NotNull -import jakarta.validation.constraints.Size +import team.aliens.dms.domain.student.model.Sex +import team.aliens.dms.domain.volunteer.model.AvailableGrade data class UpdateVolunteerWebRequest( @@ -12,18 +13,17 @@ data class UpdateVolunteerWebRequest( @field:NotBlank val content: String, - @field:Size(min = 1, max = 6) - @field:NotBlank - val availableSex: String, + @field:NotNull + val availableSex: Sex, - @field:Size(min = 1, max = 14) - @field:NotBlank - val availableGrade: String, + @field:NotNull + val availableGrade: AvailableGrade, @field:NotNull val score: Int, - val optionalScore: Int = 0, + @field:NotNull + val optionalScore: Int, @field:NotNull val maxApplicants: Int