From ee7f11b93690622a6c2e2a88c8b7cea82baffde2 Mon Sep 17 00:00:00 2001 From: Umjiseung <127853946+Umjiseung@users.noreply.github.com> Date: Thu, 9 May 2024 13:53:33 +0900 Subject: [PATCH 1/4] =?UTF-8?q?delete=20::=20=EC=82=AC=EC=9A=A9=EB=90=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8A=94=20api=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/user/presentation/UserController.kt | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/main/kotlin/com/msg/gauth/domain/user/presentation/UserController.kt b/src/main/kotlin/com/msg/gauth/domain/user/presentation/UserController.kt index 9e2ddbba..c2bcf112 100644 --- a/src/main/kotlin/com/msg/gauth/domain/user/presentation/UserController.kt +++ b/src/main/kotlin/com/msg/gauth/domain/user/presentation/UserController.kt @@ -17,9 +17,7 @@ class UserController( private val changePasswordService: ChangePasswordService, private val getMyProfileService: GetMyProfileService, private val getAcceptedUsersService: GetAcceptedUsersService, - private val acceptTeacherSignUpService: AcceptTeacherSignUpService, private val getPendingUsersService: GetPendingUsersService, - private val acceptStudentSignUpService: AcceptStudentSignUpService, private val getMyRolesService: GetMyRolesService, private val acceptUserSignUpService: AcceptUserSignUpService, private val rejectUserSignUpService: RejectUserSignUpService, @@ -72,18 +70,4 @@ class UserController( rejectUserSignUpService.execute(id) return ResponseEntity.noContent().build() } - - @Deprecated("This api is deprecated. Use acceptUser instead") - @PatchMapping("/accept-teacher") - fun acceptTeacher(@RequestBody @Valid acceptTeacherReqDto: AcceptTeacherReqDto): ResponseEntity{ - acceptTeacherSignUpService.execute(acceptTeacherReqDto) - return ResponseEntity.noContent().build() - } - - @Deprecated("This api is deprecated. Use acceptUser instead") - @PatchMapping("/accept-student") - fun acceptStudent(@RequestBody @Valid acceptedStudentReqDto: AcceptStudentReqDto): ResponseEntity { - acceptStudentSignUpService.execute(acceptedStudentReqDto) - return ResponseEntity.noContent().build() - } } \ No newline at end of file From 8b0ddde28f4c9a4f56474a3318f734305686c773 Mon Sep 17 00:00:00 2001 From: Umjiseung <127853946+Umjiseung@users.noreply.github.com> Date: Thu, 9 May 2024 13:54:04 +0900 Subject: [PATCH 2/4] =?UTF-8?q?delete=20::=20AcceptStudentSignUp=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/request/AcceptStudentReqDto.kt | 40 ------------------- .../service/AcceptStudentSignUpService.kt | 19 --------- 2 files changed, 59 deletions(-) delete mode 100644 src/main/kotlin/com/msg/gauth/domain/user/presentation/dto/request/AcceptStudentReqDto.kt delete mode 100644 src/main/kotlin/com/msg/gauth/domain/user/service/AcceptStudentSignUpService.kt diff --git a/src/main/kotlin/com/msg/gauth/domain/user/presentation/dto/request/AcceptStudentReqDto.kt b/src/main/kotlin/com/msg/gauth/domain/user/presentation/dto/request/AcceptStudentReqDto.kt deleted file mode 100644 index 908466e7..00000000 --- a/src/main/kotlin/com/msg/gauth/domain/user/presentation/dto/request/AcceptStudentReqDto.kt +++ /dev/null @@ -1,40 +0,0 @@ -package com.msg.gauth.domain.user.presentation.dto.request - -import com.msg.gauth.domain.user.User -import com.msg.gauth.domain.user.enums.Gender -import com.msg.gauth.domain.user.enums.UserState -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 -) { - - fun toEntity(user: User): User = - User( - id = this.id, - email = user.email, - password = user.password, - gender = user.gender, - name = this.name, - grade = this.grade, - classNum = this.classNum, - num = this.num, - state = UserState.CREATED, - profileUrl = user.profileUrl, - wrongPasswordCount = user.wrongPasswordCount, - oauthWrongPasswordCount = user.oauthWrongPasswordCount - ) - - -} \ No newline at end of file diff --git a/src/main/kotlin/com/msg/gauth/domain/user/service/AcceptStudentSignUpService.kt b/src/main/kotlin/com/msg/gauth/domain/user/service/AcceptStudentSignUpService.kt deleted file mode 100644 index bc51b484..00000000 --- a/src/main/kotlin/com/msg/gauth/domain/user/service/AcceptStudentSignUpService.kt +++ /dev/null @@ -1,19 +0,0 @@ -package com.msg.gauth.domain.user.service - -import com.msg.gauth.domain.user.enums.UserRoleType -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.findByIdAndStateAndUserRole(acceptedStudentReqDto.id, UserState.PENDING, UserRoleType.ROLE_STUDENT) - ?: throw UserNotFoundException() - userRepository.save(acceptedStudentReqDto.toEntity(user)) - } -} \ No newline at end of file From 0c69b34e7f944a0e3fe9114ef707a67ee676b085 Mon Sep 17 00:00:00 2001 From: Umjiseung <127853946+Umjiseung@users.noreply.github.com> Date: Thu, 9 May 2024 13:54:17 +0900 Subject: [PATCH 3/4] =?UTF-8?q?delete=20::=20AcceptTeacherSignUp=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/request/AcceptTeacherReqDto.kt | 28 ------------------- .../service/AcceptTeacherSignUpService.kt | 22 --------------- 2 files changed, 50 deletions(-) delete mode 100644 src/main/kotlin/com/msg/gauth/domain/user/presentation/dto/request/AcceptTeacherReqDto.kt delete mode 100644 src/main/kotlin/com/msg/gauth/domain/user/service/AcceptTeacherSignUpService.kt diff --git a/src/main/kotlin/com/msg/gauth/domain/user/presentation/dto/request/AcceptTeacherReqDto.kt b/src/main/kotlin/com/msg/gauth/domain/user/presentation/dto/request/AcceptTeacherReqDto.kt deleted file mode 100644 index 184aa381..00000000 --- a/src/main/kotlin/com/msg/gauth/domain/user/presentation/dto/request/AcceptTeacherReqDto.kt +++ /dev/null @@ -1,28 +0,0 @@ -package com.msg.gauth.domain.user.presentation.dto.request - -import com.msg.gauth.domain.user.User -import com.msg.gauth.domain.user.UserRole -import com.msg.gauth.domain.user.enums.Gender -import com.msg.gauth.domain.user.enums.UserRoleType -import com.msg.gauth.domain.user.enums.UserState -import javax.validation.constraints.NotBlank - -data class AcceptTeacherReqDto( - val id: Long, - @field:NotBlank - val name: String, - val gender: Gender -){ - fun toEntity(user: User): User = - User( - id = this.id, - email = user.email, - name = user.name, - password = user.password, - gender = this.gender, - state = UserState.CREATED, - profileUrl = user.profileUrl, - wrongPasswordCount = user.wrongPasswordCount, - oauthWrongPasswordCount = user.oauthWrongPasswordCount - ) -} diff --git a/src/main/kotlin/com/msg/gauth/domain/user/service/AcceptTeacherSignUpService.kt b/src/main/kotlin/com/msg/gauth/domain/user/service/AcceptTeacherSignUpService.kt deleted file mode 100644 index 603a4674..00000000 --- a/src/main/kotlin/com/msg/gauth/domain/user/service/AcceptTeacherSignUpService.kt +++ /dev/null @@ -1,22 +0,0 @@ -package com.msg.gauth.domain.user.service - -import com.msg.gauth.domain.user.User -import com.msg.gauth.domain.user.enums.UserRoleType -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.AcceptTeacherReqDto -import com.msg.gauth.domain.user.repository.UserRepository -import com.msg.gauth.global.annotation.service.TransactionalService - -@TransactionalService -class AcceptTeacherSignUpService( - private val userRepository: UserRepository -) { - - fun execute(acceptTeacherReqDto: AcceptTeacherReqDto) { - val user: User = userRepository.findByIdAndStateAndUserRole(acceptTeacherReqDto.id, UserState.PENDING, UserRoleType.ROLE_TEACHER) - ?: throw UserNotFoundException() - - userRepository.save(acceptTeacherReqDto.toEntity(user)) - } -} \ No newline at end of file From 17b386fb53c75f30cb4f301e2087f2d6c493f18b Mon Sep 17 00:00:00 2001 From: Umjiseung <127853946+Umjiseung@users.noreply.github.com> Date: Thu, 9 May 2024 14:01:27 +0900 Subject: [PATCH 4/4] =?UTF-8?q?delete=20::=20=EC=93=B0=EC=9D=B4=EC=A7=80?= =?UTF-8?q?=20=EC=95=8A=EB=8A=94=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/auth/repository/RefreshTokenRepository.kt | 1 - .../msg/gauth/domain/user/repository/UserRepository.kt | 9 --------- 2 files changed, 10 deletions(-) diff --git a/src/main/kotlin/com/msg/gauth/domain/auth/repository/RefreshTokenRepository.kt b/src/main/kotlin/com/msg/gauth/domain/auth/repository/RefreshTokenRepository.kt index 2b84808d..4cee41a1 100644 --- a/src/main/kotlin/com/msg/gauth/domain/auth/repository/RefreshTokenRepository.kt +++ b/src/main/kotlin/com/msg/gauth/domain/auth/repository/RefreshTokenRepository.kt @@ -4,6 +4,5 @@ import com.msg.gauth.global.util.count.auth.RefreshToken import org.springframework.data.repository.CrudRepository interface RefreshTokenRepository: CrudRepository{ - fun findByUserId(userId: Long): RefreshToken? fun findByToken(token: String): RefreshToken? } \ No newline at end of file diff --git a/src/main/kotlin/com/msg/gauth/domain/user/repository/UserRepository.kt b/src/main/kotlin/com/msg/gauth/domain/user/repository/UserRepository.kt index 4c17b4e2..4dfe069c 100644 --- a/src/main/kotlin/com/msg/gauth/domain/user/repository/UserRepository.kt +++ b/src/main/kotlin/com/msg/gauth/domain/user/repository/UserRepository.kt @@ -1,24 +1,15 @@ package com.msg.gauth.domain.user.repository import com.msg.gauth.domain.user.User -import com.msg.gauth.domain.user.enums.UserRoleType import com.msg.gauth.domain.user.enums.UserState -import org.springframework.data.domain.Page -import org.springframework.data.domain.Pageable import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository -import org.springframework.data.jpa.repository.Query interface UserRepository: JpaRepository, CustomUserRepository { @EntityGraph(attributePaths = ["userRole"]) fun findByEmail(email: String): User? fun findByEmailIn(emailList: List): List fun existsByEmail(email: String): Boolean - @Query("select user.email from User user") - fun findAllEmail(): List fun findAllByState(state: UserState): List - fun findAllByState(state: UserState, pageable: Pageable): Page fun findByIdAndState(id: Long, roles: UserState): User? - @Query("select user from User user where user.id = :id and user.state = :state and user.userRole = :userRole") - fun findByIdAndStateAndUserRole(id: Long, state: UserState, userRole: UserRoleType): User? } \ No newline at end of file