Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
4mjeo committed Sep 27, 2024
2 parents fa87b2d + 93c2b35 commit dbc9317
Show file tree
Hide file tree
Showing 42 changed files with 214 additions and 113 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ interface CheckOutingService {
outingTime: LocalTime,
arrivalTime: LocalTime
)

fun checkOutingApplicationQueryAble() : Boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,10 @@ class CheckOutingServiceImpl(
}
}
}

override fun checkOutingApplicationQueryAble(): Boolean {
val currentTime = LocalTime.now()

return currentTime.isBefore(LocalTime.of(20, 0))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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?,
Expand All @@ -60,4 +62,5 @@ class GetOutingServiceImpl(
override fun getOutingAvailableTimeById(outingAvailableTimeId: UUID): OutingAvailableTime =
queryOutingAvailableTimePort.queryOutingAvailableTimeById(outingAvailableTimeId)
?: throw OutingAvailableTimeNotFoundException

}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?,
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -92,11 +92,15 @@ data class VolunteerApplicantsResponse(

data class CurrentVolunteerApplicantResponse(
val volunteerName: String,
val availableSex: Sex,
val availableGrade: AvailableGrade,
val applicants: List<VolunteerApplicantResponse>
) {
companion object {
fun of(currentVolunteerApplicant: CurrentVolunteerApplicantVO) = CurrentVolunteerApplicantResponse(
volunteerName = currentVolunteerApplicant.volunteerName,
availableSex = currentVolunteerApplicant.availableSex,
availableGrade = currentVolunteerApplicant.availableGrade,
applicants = currentVolunteerApplicant.applicants
.map { VolunteerApplicantResponse.of(it) }
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand All @@ -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
)
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package team.aliens.dms.domain.volunteer.model

enum class GradeCondition(
enum class AvailableGrade(
val grades: Set<Int>
) {
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))
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package team.aliens.dms.domain.volunteer.service

import java.util.UUID

interface CheckVolunteerService {

fun checkVolunteerApplicationExists(studentId: UUID, volunteerId: UUID)
}
Original file line number Diff line number Diff line change
@@ -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
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ 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 {

fun saveVolunteerApplication(volunteerApplication: VolunteerApplication): VolunteerApplication

fun deleteVolunteerApplication(volunteerApplication: VolunteerApplication)

fun deleteAllVolunteerApplicationsByVolunteerId(volunteerId: UUID)

fun saveVolunteer(volunteer: Volunteer): Volunteer

fun deleteVolunteer(volunteer: Volunteer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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)

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -12,15 +13,13 @@ interface GetVolunteerService {

fun getVolunteerById(volunteerId: UUID): Volunteer

fun getVolunteerByStudentId(studentId: UUID): List<Volunteer>
fun getVolunteerByStudent(student: Student): List<Volunteer>

fun getAllVolunteersBySchoolId(schoolId: UUID): List<Volunteer>

fun getAllApplicantsByVolunteerId(volunteerId: UUID): List<VolunteerApplicantVO>

fun getAllApplicantsBySchoolIdGroupByVolunteer(schoolId: UUID): List<CurrentVolunteerApplicantVO>

fun getAllVolunteers(): List<Volunteer>

fun getVolunteerApplicationsWithVolunteersByStudentId(studentId: UUID): List<Pair<VolunteerApplication, Volunteer>>
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 =
Expand All @@ -25,8 +26,13 @@ class GetVolunteerServiceImpl(
queryVolunteerPort.queryVolunteerById(volunteerId)
?: throw VolunteerNotFoundException

override fun getVolunteerByStudentId(studentId: UUID): List<Volunteer> =
queryVolunteerPort.queryVolunteerByStudentId(studentId)
override fun getVolunteerByStudent(student: Student): List<Volunteer> {
val volunteers = queryVolunteerPort.queryAllVolunteersBySchoolId(student.schoolId)

return volunteers.filter { volunteer ->
volunteer.isAvailable(student)
}
}

override fun getAllVolunteersBySchoolId(schoolId: UUID): List<Volunteer> =
queryVolunteerPort.queryAllVolunteersBySchoolId(schoolId)
Expand All @@ -37,9 +43,6 @@ class GetVolunteerServiceImpl(
override fun getAllApplicantsBySchoolIdGroupByVolunteer(schoolId: UUID): List<CurrentVolunteerApplicantVO> =
queryVolunteerApplicationPort.queryAllApplicantsBySchoolIdGroupByVolunteer(schoolId)

override fun getAllVolunteers(): List<Volunteer> =
queryVolunteerPort.queryAllVolunteers()

override fun getVolunteerApplicationsWithVolunteersByStudentId(studentId: UUID): List<Pair<VolunteerApplication, Volunteer>> {
return queryVolunteerApplicationPort.getVolunteerApplicationsWithVolunteersByStudentId(studentId)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ interface QueryVolunteerApplicationPort {

fun queryAllApplicantsBySchoolIdGroupByVolunteer(schoolId: UUID): List<CurrentVolunteerApplicantVO>

fun queryVolunteerApplicationByStudentIdAndVolunteerId(studentId: UUID, volunteerId: UUID): VolunteerApplication?

fun getVolunteerApplicationsWithVolunteersByStudentId(studentId: UUID): List<Pair<VolunteerApplication, Volunteer>>
}
Loading

0 comments on commit dbc9317

Please sign in to comment.