-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #103 from GSM-MSG/feat/accept-student
Feat/accept student
- Loading branch information
Showing
5 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
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
19 changes: 19 additions & 0 deletions
19
src/main/kotlin/com/msg/gauth/domain/user/presentation/dto/request/AcceptStudentReqDto.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 com.msg.gauth.domain.user.presentation.dto.request | ||
|
||
import com.msg.gauth.domain.user.enums.Gender | ||
import javax.validation.constraints.NotBlank | ||
import javax.validation.constraints.NotNull | ||
|
||
data class AcceptStudentReqDto( | ||
@field: NotNull | ||
val id: Long, | ||
@field: NotBlank | ||
val name: String, | ||
val gender: Gender, | ||
@field: NotNull | ||
val grade: Int, | ||
@field: NotNull | ||
val classNum: Int, | ||
@field: NotNull | ||
val num: Int | ||
) |
20 changes: 20 additions & 0 deletions
20
src/main/kotlin/com/msg/gauth/domain/user/services/AcceptStudentSignUpService.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,20 @@ | ||
package com.msg.gauth.domain.user.services | ||
|
||
import com.msg.gauth.domain.user.enums.UserRole | ||
import com.msg.gauth.domain.user.enums.UserState | ||
import com.msg.gauth.domain.user.exception.UserNotFoundException | ||
import com.msg.gauth.domain.user.presentation.dto.request.AcceptStudentReqDto | ||
import com.msg.gauth.domain.user.repository.UserRepository | ||
import com.msg.gauth.global.annotation.service.TransactionalService | ||
|
||
@TransactionalService | ||
class AcceptStudentSignUpService( | ||
val userRepository: UserRepository | ||
) { | ||
fun execute(acceptedStudentReqDto: AcceptStudentReqDto) { | ||
val user = userRepository.findByIdAndStateAndRoles(acceptedStudentReqDto.id, UserState.PENDING, mutableListOf(UserRole.ROLE_STUDENT)) | ||
?: throw UserNotFoundException() | ||
|
||
userRepository.save(user.update(acceptedStudentReqDto)) | ||
} | ||
} |
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