forked from wine-area/DMS-Backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
48 changed files
with
1,205 additions
and
20 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
...re/src/main/kotlin/team/aliens/dms/domain/volunteer/dto/request/CreateVolunteerRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package team.aliens.dms.domain.volunteer.dto.request | ||
|
||
data class CreateVolunteerRequest( | ||
val name: String, | ||
val content: String, | ||
val availableSex: String, | ||
val availableGrade: String, | ||
val score: Int, | ||
val optionalScore: Int, | ||
val maxApplicants: Int | ||
) |
14 changes: 14 additions & 0 deletions
14
...re/src/main/kotlin/team/aliens/dms/domain/volunteer/dto/request/UpdateVolunteerRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package team.aliens.dms.domain.volunteer.dto.request | ||
|
||
import java.util.UUID | ||
|
||
data class UpdateVolunteerRequest( | ||
val name: String, | ||
val content: String, | ||
val availableSex: String, | ||
val availableGrade: String, | ||
val score: Int, | ||
val optionalScore: Int, | ||
val maxApplicants: Int, | ||
val volunteerId: UUID | ||
) |
7 changes: 7 additions & 0 deletions
7
...e/src/main/kotlin/team/aliens/dms/domain/volunteer/dto/response/ApplyVolunteerResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package team.aliens.dms.domain.volunteer.dto.response | ||
|
||
import java.util.UUID | ||
|
||
data class ApplyVolunteerResponse( | ||
val volunteerApplicationId: UUID | ||
) |
134 changes: 134 additions & 0 deletions
134
dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/dto/response/VolunteerResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
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.Volunteer | ||
import team.aliens.dms.domain.volunteer.model.VolunteerApplication | ||
import team.aliens.dms.domain.volunteer.spi.vo.CurrentVolunteerApplicantVO | ||
import team.aliens.dms.domain.volunteer.spi.vo.VolunteerApplicantVO | ||
import java.util.UUID | ||
|
||
data class QueryMyVolunteerApplicationResponse( | ||
val volunteerApplications: List<VolunteerApplicationResponse> | ||
) { | ||
companion object { | ||
fun of( | ||
applicationsWithVolunteers: List<Pair<VolunteerApplication, Volunteer>> | ||
): QueryMyVolunteerApplicationResponse { | ||
return QueryMyVolunteerApplicationResponse( | ||
volunteerApplications = applicationsWithVolunteers.map { (application, volunteer) -> | ||
VolunteerApplicationResponse.of(application, volunteer) | ||
} | ||
) | ||
} | ||
} | ||
} | ||
|
||
data class VolunteerApplicationResponse( | ||
val id: UUID, | ||
val volunteerId: UUID, | ||
val approved: Boolean, | ||
val name: String, | ||
) { | ||
companion object { | ||
fun of(volunteerApplication: VolunteerApplication, volunteer: Volunteer): VolunteerApplicationResponse { | ||
return VolunteerApplicationResponse( | ||
id = volunteerApplication.id, | ||
volunteerId = volunteerApplication.volunteerId, | ||
approved = volunteerApplication.approved, | ||
name = volunteer.name | ||
) | ||
} | ||
} | ||
} | ||
|
||
data class VolunteerResponse( | ||
val id: UUID, | ||
val name: String, | ||
val content: String, | ||
val score: Int, | ||
val optionalScore: Int, | ||
val maxApplicants: Int, | ||
val availableSex: Sex, | ||
val availableGrade: GradeCondition | ||
) { | ||
companion object { | ||
fun of(volunteer: Volunteer): VolunteerResponse { | ||
return VolunteerResponse( | ||
id = volunteer.id, | ||
name = volunteer.name, | ||
content = volunteer.content, | ||
score = volunteer.score, | ||
optionalScore = volunteer.optionalScore, | ||
maxApplicants = volunteer.maxApplicants, | ||
availableSex = volunteer.availableSex, | ||
availableGrade = volunteer.availableGrade | ||
) | ||
} | ||
} | ||
} | ||
|
||
data class VolunteersResponse( | ||
val volunteers: List<VolunteerResponse> | ||
) | ||
|
||
data class VolunteerApplicantResponse( | ||
val id: UUID, | ||
val gcd: String, | ||
val name: String, | ||
) { | ||
companion object { | ||
fun of(applicants: VolunteerApplicantVO) = VolunteerApplicantResponse( | ||
id = applicants.id, | ||
gcd = applicants.gcn, | ||
name = applicants.name | ||
) | ||
} | ||
} | ||
|
||
data class VolunteerApplicantsResponse( | ||
val applicants: List<VolunteerApplicantResponse> | ||
) | ||
|
||
data class CurrentVolunteerApplicantResponse( | ||
val volunteerName: String, | ||
val applicants: List<VolunteerApplicantResponse> | ||
) { | ||
companion object { | ||
fun of(currentVolunteerApplicant: CurrentVolunteerApplicantVO) = CurrentVolunteerApplicantResponse( | ||
volunteerName = currentVolunteerApplicant.volunteerName, | ||
applicants = currentVolunteerApplicant.applicants | ||
.map { VolunteerApplicantResponse.of(it) } | ||
) | ||
} | ||
} | ||
|
||
data class CurrentVolunteerApplicantsResponse( | ||
val volunteers: List<CurrentVolunteerApplicantResponse> | ||
) | ||
|
||
data class AvailableVolunteerResponse( | ||
val id: UUID, | ||
val name: String, | ||
val content: String, | ||
val score: Int, | ||
val optionalScore: Int, | ||
val maxApplicants: Int | ||
) { | ||
companion object { | ||
fun of(volunteer: Volunteer): AvailableVolunteerResponse { | ||
return AvailableVolunteerResponse( | ||
id = volunteer.id, | ||
name = volunteer.name, | ||
content = volunteer.content, | ||
score = volunteer.score, | ||
optionalScore = volunteer.optionalScore, | ||
maxApplicants = volunteer.maxApplicants | ||
) | ||
} | ||
} | ||
} | ||
|
||
data class AvailableVolunteersResponse( | ||
val volunteers: List<AvailableVolunteerResponse> | ||
) |
22 changes: 22 additions & 0 deletions
22
dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/exception/VolunteerErrorCode.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package team.aliens.dms.domain.volunteer.exception | ||
|
||
import team.aliens.dms.common.error.ErrorProperty | ||
import team.aliens.dms.common.error.ErrorStatus | ||
|
||
enum class VolunteerErrorCode( | ||
private val status: Int, | ||
private val message: String, | ||
private val sequence: Int | ||
) : ErrorProperty { | ||
|
||
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) | ||
; | ||
|
||
override fun status(): Int = status | ||
override fun message(): String = message | ||
override fun code(): String = "Volunteer-$status-$sequence" | ||
} |
19 changes: 19 additions & 0 deletions
19
dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/exception/VolunteerExceptions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package team.aliens.dms.domain.volunteer.exception | ||
|
||
import team.aliens.dms.common.error.DmsException | ||
|
||
object VolunteerApplicationNotFoundException : DmsException( | ||
VolunteerErrorCode.VOLUNTEER_APPLICATION_NOT_FOUND | ||
) | ||
|
||
object VolunteerApplicationAlreadyAssigned : DmsException( | ||
VolunteerErrorCode.VOLUNTEER_APPLICATION_ALREADY_ASSIGNED | ||
) | ||
|
||
object VolunteerApplicationNotAssigned : DmsException( | ||
VolunteerErrorCode.VOLUNTEER_APPLICATION_NOT_ASSIGNED | ||
) | ||
|
||
object VolunteerNotFoundException : DmsException( | ||
VolunteerErrorCode.VOLUNTEER_NOT_FOUND | ||
) |
18 changes: 10 additions & 8 deletions
18
dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/model/GradeCondition.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
package team.aliens.dms.domain.volunteer.model | ||
|
||
enum class GradeCondition { | ||
ALL, | ||
FIRST, | ||
SECOND, | ||
THIRD, | ||
FIRSTANDSECOND, | ||
SECONDANDTHIRD, | ||
FIRSTANDTHIRD | ||
enum class GradeCondition( | ||
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)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/service/CommandVolunteerService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package team.aliens.dms.domain.volunteer.service | ||
|
||
import team.aliens.dms.domain.volunteer.model.Volunteer | ||
import team.aliens.dms.domain.volunteer.model.VolunteerApplication | ||
|
||
interface CommandVolunteerService { | ||
|
||
fun saveVolunteerApplication(volunteerApplication: VolunteerApplication): VolunteerApplication | ||
|
||
fun deleteVolunteerApplication(volunteerApplication: VolunteerApplication) | ||
|
||
fun saveVolunteer(volunteer: Volunteer): Volunteer | ||
|
||
fun deleteVolunteer(volunteer: Volunteer) | ||
} |
28 changes: 28 additions & 0 deletions
28
...e/src/main/kotlin/team/aliens/dms/domain/volunteer/service/CommandVolunteerServiceImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package team.aliens.dms.domain.volunteer.service | ||
|
||
import team.aliens.dms.common.annotation.Service | ||
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 | ||
|
||
@Service | ||
class CommandVolunteerServiceImpl( | ||
private val commandVolunteerApplicationPort: CommandVolunteerApplicationPort, | ||
private val commandVolunteerPort: CommandVolunteerPort | ||
) : CommandVolunteerService { | ||
|
||
override fun saveVolunteerApplication(volunteerApplication: VolunteerApplication): VolunteerApplication = | ||
commandVolunteerApplicationPort.saveVolunteerApplication(volunteerApplication) | ||
|
||
override fun deleteVolunteerApplication(volunteerApplication: VolunteerApplication) { | ||
commandVolunteerApplicationPort.deleteVolunteerApplication(volunteerApplication) | ||
} | ||
|
||
override fun saveVolunteer(volunteer: Volunteer): Volunteer = | ||
commandVolunteerPort.saveVolunteer(volunteer) | ||
|
||
override fun deleteVolunteer(volunteer: Volunteer) { | ||
commandVolunteerPort.deleteVolunteer(volunteer) | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/service/GetVolunteerService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package team.aliens.dms.domain.volunteer.service | ||
|
||
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 | ||
import team.aliens.dms.domain.volunteer.spi.vo.VolunteerApplicantVO | ||
import java.util.UUID | ||
|
||
interface GetVolunteerService { | ||
|
||
fun getVolunteerApplicationById(volunteerApplicationId: UUID): VolunteerApplication | ||
|
||
fun getVolunteerById(volunteerId: UUID): Volunteer | ||
|
||
fun getVolunteerByStudentId(studentId: UUID): 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>> | ||
} |
46 changes: 46 additions & 0 deletions
46
dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/service/GetVolunteerServiceImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package team.aliens.dms.domain.volunteer.service | ||
|
||
import team.aliens.dms.common.annotation.Service | ||
import team.aliens.dms.domain.volunteer.exception.VolunteerApplicationNotFoundException | ||
import team.aliens.dms.domain.volunteer.exception.VolunteerNotFoundException | ||
import team.aliens.dms.domain.volunteer.model.Volunteer | ||
import team.aliens.dms.domain.volunteer.model.VolunteerApplication | ||
import team.aliens.dms.domain.volunteer.spi.QueryVolunteerApplicationPort | ||
import team.aliens.dms.domain.volunteer.spi.QueryVolunteerPort | ||
import team.aliens.dms.domain.volunteer.spi.vo.CurrentVolunteerApplicantVO | ||
import team.aliens.dms.domain.volunteer.spi.vo.VolunteerApplicantVO | ||
import java.util.UUID | ||
|
||
@Service | ||
class GetVolunteerServiceImpl( | ||
private val queryVolunteerApplicationPort: QueryVolunteerApplicationPort, | ||
private val queryVolunteerPort: QueryVolunteerPort, | ||
) : GetVolunteerService { | ||
|
||
override fun getVolunteerApplicationById(volunteerApplicationId: UUID): VolunteerApplication = | ||
queryVolunteerApplicationPort.queryVolunteerApplicationById(volunteerApplicationId) | ||
?: throw VolunteerApplicationNotFoundException | ||
|
||
override fun getVolunteerById(volunteerId: UUID): Volunteer = | ||
queryVolunteerPort.queryVolunteerById(volunteerId) | ||
?: throw VolunteerNotFoundException | ||
|
||
override fun getVolunteerByStudentId(studentId: UUID): List<Volunteer> = | ||
queryVolunteerPort.queryVolunteerByStudentId(studentId) | ||
|
||
override fun getAllVolunteersBySchoolId(schoolId: UUID): List<Volunteer> = | ||
queryVolunteerPort.queryAllVolunteersBySchoolId(schoolId) | ||
|
||
override fun getAllApplicantsByVolunteerId(volunteerId: UUID): List<VolunteerApplicantVO> = | ||
queryVolunteerApplicationPort.queryAllApplicantsByVolunteerId(volunteerId) | ||
|
||
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) | ||
} | ||
} |
Oops, something went wrong.