Skip to content

Commit 06c1693

Browse files
authored
merge: (#827) 모범 학생 후보 제외 학생 제거 api 생성
2 parents ec89ade + 53fdf9f commit 06c1693

File tree

12 files changed

+58
-4
lines changed

12 files changed

+58
-4
lines changed

dms-core/src/main/kotlin/team/aliens/dms/domain/vote/exception/VoteExceptions.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,7 @@ object ExcludedStudentAlreadyExistsException : DmsException(
4646
object IsNotAuthorizedVoteDeletionException : DmsException(
4747
VoteErrorCode.UNAUTHORIZED_VOTE_DELETION
4848
)
49+
50+
object ExcludedStudentNotFoundException : DmsException(
51+
VoteErrorCode.EXCLUDED_STUDENT_NOT_FOUND
52+
)

dms-core/src/main/kotlin/team/aliens/dms/domain/vote/exception/error/VoteErrorCode.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ enum class VoteErrorCode(
2020
VOTING_TOPIC_NOT_FOUND(ErrorStatus.NOT_FOUND, "Voting topic not found", 3),
2121
VOTING_OPTION_NOT_FOUND(ErrorStatus.NOT_FOUND, "Voting option not found", 4),
2222
VOTE_NOT_FOUND(ErrorStatus.NOT_FOUND, "Vote not found", 5),
23+
EXCLUDED_STUDENT_NOT_FOUND(ErrorStatus.NOT_FOUND, "Execluded student not found", 6),
2324
ALREADY_VOTED(ErrorStatus.CONFLICT, "Already voted", 1),
2425
VOTING_TOPIC_NAME_ALREADY_EXIST(ErrorStatus.CONFLICT, "Voting Topic Already Exist", 2),
2526
EXCLUDED_STUDENT_ALREADY_EXISTS(ErrorStatus.CONFLICT, "Excluded Student Already Exist", 3)

dms-core/src/main/kotlin/team/aliens/dms/domain/vote/service/CommandVoteService.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,6 @@ interface CommandVoteService {
2727
fun checkVotingTopic(name: String): Boolean
2828

2929
fun saveExcludedStudent(excludedStudent: ExcludedStudent): ExcludedStudent
30+
31+
fun deleteExcludedStudentById(excludedStudentId: UUID)
3032
}

dms-core/src/main/kotlin/team/aliens/dms/domain/vote/service/CommandVoteServiceImpl.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@ import team.aliens.dms.domain.vote.spi.CommandExcludedStudentPort
1010
import team.aliens.dms.domain.vote.spi.CommandVotePort
1111
import team.aliens.dms.domain.vote.spi.CommandVotingOptionPort
1212
import team.aliens.dms.domain.vote.spi.CommandVotingTopicPort
13-
import team.aliens.dms.domain.vote.spi.QueryVotePort
1413
import team.aliens.dms.domain.vote.spi.QueryVotingTopicPort
1514
import java.util.UUID
1615

1716
@Service
1817
class CommandVoteServiceImpl(
19-
val queryVotePort: QueryVotePort,
2018
val commandVotePort: CommandVotePort,
2119
val commandVotingTopicPort: CommandVotingTopicPort,
2220
val queryVotingTopicPort: QueryVotingTopicPort,
@@ -58,4 +56,8 @@ class CommandVoteServiceImpl(
5856
override fun saveExcludedStudent(excludedStudent: ExcludedStudent): ExcludedStudent {
5957
return commandExcludedStudentPort.saveExcludedStudent(excludedStudent)
6058
}
59+
60+
override fun deleteExcludedStudentById(excludedStudentId: UUID) {
61+
commandExcludedStudentPort.deleteExcludedStudentById(excludedStudentId)
62+
}
6163
}

dms-core/src/main/kotlin/team/aliens/dms/domain/vote/service/GetVoteService.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,6 @@ interface GetVoteService {
2525
fun getVoteById(voteId: UUID): Vote
2626

2727
fun getAllExcludedStudents(): List<ExcludedStudent>
28+
29+
fun getExcludedStudentById(excludedStudentId: UUID): ExcludedStudent
2830
}

dms-core/src/main/kotlin/team/aliens/dms/domain/vote/service/GetVoteServiceImpl.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package team.aliens.dms.domain.vote.service
22

33
import team.aliens.dms.common.annotation.Service
4+
import team.aliens.dms.domain.vote.exception.ExcludedStudentNotFoundException
45
import team.aliens.dms.domain.vote.exception.VoteNotFoundException
56
import team.aliens.dms.domain.vote.exception.VotingOptionNotFoundException
67
import team.aliens.dms.domain.vote.exception.VotingTopicNotFoundException
@@ -53,4 +54,8 @@ class GetVoteServiceImpl(
5354
override fun getAllExcludedStudents(): List<ExcludedStudent> {
5455
return queryExcludedStudentPort.queryAllExcludedStudents()
5556
}
57+
58+
override fun getExcludedStudentById(excludedStudentId: UUID): ExcludedStudent {
59+
return queryExcludedStudentPort.queryExcludedStudentById(excludedStudentId) ?: throw ExcludedStudentNotFoundException
60+
}
5661
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package team.aliens.dms.domain.vote.spi
22

33
import team.aliens.dms.domain.vote.model.ExcludedStudent
4+
import java.util.UUID
45

56
interface CommandExcludedStudentPort {
67

78
fun saveExcludedStudent(excludedStudent: ExcludedStudent): ExcludedStudent
9+
10+
fun deleteExcludedStudentById(excludedStudentId: UUID)
811
}

dms-core/src/main/kotlin/team/aliens/dms/domain/vote/spi/QueryExcludedStudentPort.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ interface QueryExcludedStudentPort {
88
fun existExcludedStudentById(excludedStudentId: UUID): Boolean
99

1010
fun queryAllExcludedStudents(): List<ExcludedStudent>
11+
12+
fun queryExcludedStudentById(excludedStudentId: UUID): ExcludedStudent?
1113
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package team.aliens.dms.domain.vote.usecase
2+
3+
import team.aliens.dms.common.annotation.UseCase
4+
import team.aliens.dms.domain.vote.model.ExcludedStudent
5+
import team.aliens.dms.domain.vote.service.VoteService
6+
import java.util.UUID
7+
8+
@UseCase
9+
class DeleteExcludedStudentUseCase(
10+
private val voteService: VoteService
11+
) {
12+
13+
fun execute(excludedStudentId: UUID) {
14+
val excludedStudent: ExcludedStudent = voteService.getExcludedStudentById(excludedStudentId)
15+
voteService.deleteExcludedStudentById(excludedStudent.studentId)
16+
}
17+
}

dms-infrastructure/src/main/kotlin/team/aliens/dms/global/security/SecurityConfig.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ class SecurityConfig(
234234
.requestMatchers(HttpMethod.POST,"/votes/excluded-student").hasAuthority(MANAGER.name)
235235
.requestMatchers(HttpMethod.GET,"/votes").hasAnyAuthority(MANAGER.name, STUDENT.name)
236236
.requestMatchers(HttpMethod.GET,"/votes/excluded-student").hasAuthority(MANAGER.name)
237-
237+
.requestMatchers(HttpMethod.DELETE, "/votes/excluded-student/{excluded-student-id}").hasAuthority(MANAGER.name)
238238
.anyRequest().denyAll()
239239
}
240240
http

0 commit comments

Comments
 (0)