diff --git a/src/main/kotlin/com/msg/gauth/domain/admin/services/ExcelParsingService.kt b/src/main/kotlin/com/msg/gauth/domain/admin/services/ExcelParsingService.kt index 6bb5bc27..4195d838 100644 --- a/src/main/kotlin/com/msg/gauth/domain/admin/services/ExcelParsingService.kt +++ b/src/main/kotlin/com/msg/gauth/domain/admin/services/ExcelParsingService.kt @@ -3,6 +3,7 @@ package com.msg.gauth.domain.admin.services import com.msg.gauth.domain.admin.exception.FileExtensionInvalidException import com.msg.gauth.domain.user.enums.Gender import com.msg.gauth.domain.user.repository.UserRepository +import com.msg.gauth.global.annotation.service.TransactionalService import com.msg.gauth.global.util.ExcelUtil import org.apache.commons.compress.utils.FileNameUtils import org.apache.poi.hssf.usermodel.HSSFWorkbook @@ -10,15 +11,12 @@ import org.apache.poi.ss.usermodel.Sheet import org.apache.poi.ss.usermodel.Workbook import org.apache.poi.xssf.usermodel.XSSFWorkbook import org.apache.tika.Tika -import org.springframework.stereotype.Service -import org.springframework.transaction.annotation.Transactional import org.springframework.web.multipart.MultipartFile -@Service +@TransactionalService class ExcelParsingService( private val userRepository: UserRepository, ){ - @Transactional(rollbackFor = [Exception::class]) fun execute(file: MultipartFile){ val tika = Tika() val detect = tika.detect(file.bytes) diff --git a/src/main/kotlin/com/msg/gauth/domain/auth/services/InitPasswordService.kt b/src/main/kotlin/com/msg/gauth/domain/auth/services/InitPasswordService.kt index 71d7861c..61d3b12d 100644 --- a/src/main/kotlin/com/msg/gauth/domain/auth/services/InitPasswordService.kt +++ b/src/main/kotlin/com/msg/gauth/domain/auth/services/InitPasswordService.kt @@ -5,17 +5,15 @@ import com.msg.gauth.domain.user.exception.EmailNotVerifiedException import com.msg.gauth.domain.user.exception.UserNotFoundException import com.msg.gauth.domain.auth.presentation.dto.request.PasswordInitReqDto import com.msg.gauth.domain.user.repository.UserRepository +import com.msg.gauth.global.annotation.service.TransactionalService import org.springframework.security.crypto.password.PasswordEncoder -import org.springframework.stereotype.Service -import org.springframework.transaction.annotation.Transactional -@Service +@TransactionalService class InitPasswordService( private val userRepository: UserRepository, private val emailAuthRepository: EmailAuthRepository, private val passwordEncoder: PasswordEncoder, ){ - @Transactional(rollbackFor = [Exception::class]) fun execute(passwordInitReqDto: PasswordInitReqDto){ val emailAuth = emailAuthRepository.findById(passwordInitReqDto.email) .orElseThrow { throw EmailNotVerifiedException() } diff --git a/src/main/kotlin/com/msg/gauth/domain/auth/services/LogoutService.kt b/src/main/kotlin/com/msg/gauth/domain/auth/services/LogoutService.kt index 3a085f9d..41204c77 100644 --- a/src/main/kotlin/com/msg/gauth/domain/auth/services/LogoutService.kt +++ b/src/main/kotlin/com/msg/gauth/domain/auth/services/LogoutService.kt @@ -2,15 +2,13 @@ package com.msg.gauth.domain.auth.services import com.msg.gauth.domain.auth.repository.RefreshTokenRepository import com.msg.gauth.domain.user.utils.UserUtil -import org.springframework.stereotype.Service -import org.springframework.transaction.annotation.Transactional +import com.msg.gauth.global.annotation.service.TransactionalService -@Service +@TransactionalService class LogoutService( private val userUtil: UserUtil, private val refreshTokenRepository: RefreshTokenRepository ) { - @Transactional(rollbackFor = [Exception::class]) fun execute() { val currentUser = userUtil.fetchCurrentUser() refreshTokenRepository.findByUserId(currentUser.id)?.let { diff --git a/src/main/kotlin/com/msg/gauth/domain/auth/services/RefreshService.kt b/src/main/kotlin/com/msg/gauth/domain/auth/services/RefreshService.kt index 51e0c9a9..a16f7367 100644 --- a/src/main/kotlin/com/msg/gauth/domain/auth/services/RefreshService.kt +++ b/src/main/kotlin/com/msg/gauth/domain/auth/services/RefreshService.kt @@ -5,16 +5,14 @@ import com.msg.gauth.domain.auth.exception.ExpiredRefreshTokenException import com.msg.gauth.domain.auth.exception.InvalidRefreshTokenException import com.msg.gauth.domain.auth.presentation.dto.response.RefreshResponseDto import com.msg.gauth.domain.auth.repository.RefreshTokenRepository +import com.msg.gauth.global.annotation.service.TransactionalService import com.msg.gauth.global.security.jwt.JwtTokenProvider -import org.springframework.stereotype.Service -import org.springframework.transaction.annotation.Transactional -@Service +@TransactionalService class RefreshService( private val jwtTokenProvider: JwtTokenProvider, private val refreshTokenRepository: RefreshTokenRepository ) { - @Transactional(rollbackFor = [Exception::class]) fun execute(refreshToken: String): RefreshResponseDto { val refreshToken = jwtTokenProvider.parseToken(refreshToken) ?: throw InvalidRefreshTokenException() val email = jwtTokenProvider.exactEmailFromRefreshToken(refreshToken) diff --git a/src/main/kotlin/com/msg/gauth/domain/auth/services/SignInService.kt b/src/main/kotlin/com/msg/gauth/domain/auth/services/SignInService.kt index bca2362a..4b2fc793 100644 --- a/src/main/kotlin/com/msg/gauth/domain/auth/services/SignInService.kt +++ b/src/main/kotlin/com/msg/gauth/domain/auth/services/SignInService.kt @@ -10,20 +10,17 @@ import com.msg.gauth.domain.user.User import com.msg.gauth.domain.user.enums.UserState import com.msg.gauth.domain.user.exception.UserNotFoundException import com.msg.gauth.domain.user.repository.UserRepository +import com.msg.gauth.global.annotation.service.TransactionalService import com.msg.gauth.global.security.jwt.JwtTokenProvider import org.springframework.security.crypto.password.PasswordEncoder -import org.springframework.stereotype.Service -import org.springframework.transaction.annotation.Transactional -@Service +@TransactionalService class SignInService( private val jwtTokenProvider: JwtTokenProvider, private val userRepository: UserRepository, private val refreshTokenRepository: RefreshTokenRepository, private val passwordEncoder: PasswordEncoder ) { - - @Transactional(rollbackFor = [Exception::class]) fun execute(dto: SigninRequestDto): SigninResponseDto { val user: User = userRepository.findByEmail(dto.email) ?: throw UserNotFoundException() if (!passwordEncoder.matches(dto.password, user.password)) diff --git a/src/main/kotlin/com/msg/gauth/domain/auth/services/SignUpService.kt b/src/main/kotlin/com/msg/gauth/domain/auth/services/SignUpService.kt index 557c8e04..596c267a 100644 --- a/src/main/kotlin/com/msg/gauth/domain/auth/services/SignUpService.kt +++ b/src/main/kotlin/com/msg/gauth/domain/auth/services/SignUpService.kt @@ -5,18 +5,16 @@ import com.msg.gauth.domain.email.repository.EmailAuthRepository import com.msg.gauth.domain.user.User import com.msg.gauth.domain.user.exception.EmailNotVerifiedException import com.msg.gauth.domain.user.repository.UserRepository +import com.msg.gauth.global.annotation.service.TransactionalService import com.msg.gauth.global.exception.exceptions.DuplicateEmailException import org.springframework.security.crypto.password.PasswordEncoder -import org.springframework.stereotype.Service -import org.springframework.transaction.annotation.Transactional -@Service +@TransactionalService class SignUpService( private val userRepository: UserRepository, private val passwordEncoder: PasswordEncoder, private val emailAuthRepository: EmailAuthRepository ) { - @Transactional(rollbackFor = [Exception::class]) fun execute(signUpDto: SignUpDto): Long { if (userRepository.existsByEmail(signUpDto.email)) { throw DuplicateEmailException() diff --git a/src/main/kotlin/com/msg/gauth/domain/auth/services/SignupImageUploadService.kt b/src/main/kotlin/com/msg/gauth/domain/auth/services/SignupImageUploadService.kt index b69d0dfc..b66f95b2 100644 --- a/src/main/kotlin/com/msg/gauth/domain/auth/services/SignupImageUploadService.kt +++ b/src/main/kotlin/com/msg/gauth/domain/auth/services/SignupImageUploadService.kt @@ -4,11 +4,11 @@ import com.msg.gauth.domain.auth.presentation.dto.response.SignupImageResDto import com.msg.gauth.domain.email.exception.AuthCodeExpiredException import com.msg.gauth.domain.email.exception.AuthCodeNotVerificationException import com.msg.gauth.domain.email.repository.EmailAuthRepository +import com.msg.gauth.global.annotation.service.TransactionalService import com.msg.gauth.global.aws.s3.S3Util -import org.springframework.stereotype.Service import org.springframework.web.multipart.MultipartFile -@Service +@TransactionalService class SignupImageUploadService( private val s3Util: S3Util, private val emailAuthRepository: EmailAuthRepository, diff --git a/src/main/kotlin/com/msg/gauth/domain/client/services/DeleteClientService.kt b/src/main/kotlin/com/msg/gauth/domain/client/services/DeleteClientService.kt index 11954e50..1648e0ee 100644 --- a/src/main/kotlin/com/msg/gauth/domain/client/services/DeleteClientService.kt +++ b/src/main/kotlin/com/msg/gauth/domain/client/services/DeleteClientService.kt @@ -4,16 +4,14 @@ import com.msg.gauth.domain.client.exception.ClientNotFindException import com.msg.gauth.domain.client.exception.UserNotMatchException import com.msg.gauth.domain.client.repository.ClientRepository import com.msg.gauth.domain.user.utils.UserUtil +import com.msg.gauth.global.annotation.service.TransactionalService import org.springframework.data.repository.findByIdOrNull -import org.springframework.stereotype.Service -import org.springframework.transaction.annotation.Transactional -@Service +@TransactionalService class DeleteClientService( private val clientRepository: ClientRepository, private val userUtil: UserUtil, ){ - @Transactional(rollbackFor = [Exception::class]) fun execute(id: Long){ val client = clientRepository.findByIdOrNull(id) ?: throw ClientNotFindException() diff --git a/src/main/kotlin/com/msg/gauth/domain/client/services/GetAllClientsService.kt b/src/main/kotlin/com/msg/gauth/domain/client/services/GetAllClientsService.kt index 901ef0fb..6e23b9ea 100644 --- a/src/main/kotlin/com/msg/gauth/domain/client/services/GetAllClientsService.kt +++ b/src/main/kotlin/com/msg/gauth/domain/client/services/GetAllClientsService.kt @@ -2,12 +2,9 @@ package com.msg.gauth.domain.client.services import com.msg.gauth.domain.client.persentation.dto.response.SingleClientResDto import com.msg.gauth.domain.client.repository.ClientRepository -import com.msg.gauth.domain.user.utils.UserUtil -import org.springframework.stereotype.Service -import org.springframework.transaction.annotation.Transactional +import com.msg.gauth.global.annotation.service.ReadOnlyService -@Service -@Transactional(readOnly = true, rollbackFor = [Exception::class]) +@ReadOnlyService class GetAllClientsService( private val clientRepository: ClientRepository ) { diff --git a/src/main/kotlin/com/msg/gauth/domain/client/services/GetMyDetailClientService.kt b/src/main/kotlin/com/msg/gauth/domain/client/services/GetMyDetailClientService.kt index ad623735..e9d1c5c0 100644 --- a/src/main/kotlin/com/msg/gauth/domain/client/services/GetMyDetailClientService.kt +++ b/src/main/kotlin/com/msg/gauth/domain/client/services/GetMyDetailClientService.kt @@ -4,11 +4,9 @@ import com.msg.gauth.domain.client.exception.ClientNotFindException import com.msg.gauth.domain.client.persentation.dto.response.ClientDetailResDto import com.msg.gauth.domain.client.repository.ClientRepository import com.msg.gauth.domain.user.utils.UserUtil -import org.springframework.stereotype.Service -import org.springframework.transaction.annotation.Transactional +import com.msg.gauth.global.annotation.service.ReadOnlyService -@Service -@Transactional(readOnly = true, rollbackFor = [Exception::class]) +@ReadOnlyService class GetMyDetailClientService( private val clientRepository: ClientRepository, private val userUtil: UserUtil diff --git a/src/main/kotlin/com/msg/gauth/domain/client/services/RegisterClientService.kt b/src/main/kotlin/com/msg/gauth/domain/client/services/RegisterClientService.kt index 6656d7fb..e0754ec3 100644 --- a/src/main/kotlin/com/msg/gauth/domain/client/services/RegisterClientService.kt +++ b/src/main/kotlin/com/msg/gauth/domain/client/services/RegisterClientService.kt @@ -4,16 +4,14 @@ import com.msg.gauth.domain.client.persentation.dto.request.ClientRegisterReqDto import com.msg.gauth.domain.client.persentation.dto.response.ClientRegisterResDto import com.msg.gauth.domain.client.repository.ClientRepository import com.msg.gauth.domain.user.utils.UserUtil -import org.springframework.stereotype.Service -import org.springframework.transaction.annotation.Transactional +import com.msg.gauth.global.annotation.service.TransactionalService import java.util.UUID -@Service +@TransactionalService class RegisterClientService( private val clientRepository: ClientRepository, private val userUtil: UserUtil ) { - @Transactional(rollbackFor = [Exception::class]) fun execute(clientRegisterDto: ClientRegisterReqDto): ClientRegisterResDto { val clientSecret = createUUID() val clientId = createUUID() diff --git a/src/main/kotlin/com/msg/gauth/domain/client/services/UpdateClientService.kt b/src/main/kotlin/com/msg/gauth/domain/client/services/UpdateClientService.kt index d0039c61..b400d5ca 100644 --- a/src/main/kotlin/com/msg/gauth/domain/client/services/UpdateClientService.kt +++ b/src/main/kotlin/com/msg/gauth/domain/client/services/UpdateClientService.kt @@ -4,15 +4,13 @@ import com.msg.gauth.domain.client.exception.ClientNotFindException import com.msg.gauth.domain.client.persentation.dto.request.ClientUpdateReqDto import com.msg.gauth.domain.client.repository.ClientRepository import com.msg.gauth.domain.user.utils.UserUtil -import org.springframework.stereotype.Service -import org.springframework.transaction.annotation.Transactional +import com.msg.gauth.global.annotation.service.TransactionalService -@Service +@TransactionalService class UpdateClientService( private val clientRepository: ClientRepository, private val userUtil: UserUtil ) { - @Transactional(rollbackFor = [Exception::class]) fun updateClient(id: Long, clientUpdateReqDto: ClientUpdateReqDto){ val client = clientRepository.findByIdAndCreatedBy(id, userUtil.fetchCurrentUser()) ?: throw ClientNotFindException() clientRepository.save(client.updateClient(clientUpdateReqDto)) diff --git a/src/main/kotlin/com/msg/gauth/domain/email/services/MailVerificationService.kt b/src/main/kotlin/com/msg/gauth/domain/email/services/MailVerificationService.kt index b487163b..d83b0728 100644 --- a/src/main/kotlin/com/msg/gauth/domain/email/services/MailVerificationService.kt +++ b/src/main/kotlin/com/msg/gauth/domain/email/services/MailVerificationService.kt @@ -2,15 +2,12 @@ package com.msg.gauth.domain.email.services import com.msg.gauth.domain.email.exception.AuthCodeExpiredException import com.msg.gauth.domain.email.repository.EmailAuthRepository -import org.springframework.stereotype.Service -import org.springframework.transaction.annotation.Transactional +import com.msg.gauth.global.annotation.service.TransactionalService -@Service +@TransactionalService class MailVerificationService( private val emailAuthRepository: EmailAuthRepository ) { - - @Transactional(rollbackFor = [Exception::class]) fun execute(email: String, uuid: String) { val emailAuth = emailAuthRepository.findById(email) .orElseThrow { AuthCodeExpiredException() } diff --git a/src/main/kotlin/com/msg/gauth/domain/oauth/services/GetServiceNameService.kt b/src/main/kotlin/com/msg/gauth/domain/oauth/services/GetServiceNameService.kt index 12717da8..85c02b7e 100644 --- a/src/main/kotlin/com/msg/gauth/domain/oauth/services/GetServiceNameService.kt +++ b/src/main/kotlin/com/msg/gauth/domain/oauth/services/GetServiceNameService.kt @@ -3,14 +3,12 @@ package com.msg.gauth.domain.oauth.services import com.msg.gauth.domain.oauth.presentation.dto.response.ServiceNameResponseDto import com.msg.gauth.domain.client.exception.ClientNotFindException import com.msg.gauth.domain.client.repository.ClientRepository -import org.springframework.stereotype.Service -import org.springframework.transaction.annotation.Transactional +import com.msg.gauth.global.annotation.service.ReadOnlyService -@Service +@ReadOnlyService class GetServiceNameService( private val clientRepository: ClientRepository, ){ - @Transactional(readOnly = true, rollbackFor = [Exception::class]) fun execute(clientId: String): ServiceNameResponseDto { val client = (clientRepository.findByClientId(clientId) ?: throw ClientNotFindException()) diff --git a/src/main/kotlin/com/msg/gauth/domain/oauth/services/OauthCodeService.kt b/src/main/kotlin/com/msg/gauth/domain/oauth/services/OauthCodeService.kt index 8898aa0d..6a5d4ae6 100644 --- a/src/main/kotlin/com/msg/gauth/domain/oauth/services/OauthCodeService.kt +++ b/src/main/kotlin/com/msg/gauth/domain/oauth/services/OauthCodeService.kt @@ -9,19 +9,16 @@ import com.msg.gauth.domain.oauth.repository.OauthCodeRepository import com.msg.gauth.domain.user.enums.UserState import com.msg.gauth.domain.user.exception.UserNotFoundException import com.msg.gauth.domain.user.repository.UserRepository -import org.springframework.data.redis.core.RedisTemplate +import com.msg.gauth.global.annotation.service.ReadOnlyService import org.springframework.security.crypto.password.PasswordEncoder -import org.springframework.stereotype.Service -import org.springframework.transaction.annotation.Transactional import java.util.* -@Service +@ReadOnlyService class OauthCodeService( private val userRepository: UserRepository, private val passwordEncoder: PasswordEncoder, private val oauthCodeRepository: OauthCodeRepository, ){ - @Transactional(readOnly = true, rollbackFor = [Exception::class]) fun execute(oauthLoginRequestDto: OauthCodeRequestDto): OauthCodeResponseDto { val user = userRepository.findByEmail(oauthLoginRequestDto.email) ?: throw UserNotFoundException() if (!passwordEncoder.matches(oauthLoginRequestDto.password, user.password)) diff --git a/src/main/kotlin/com/msg/gauth/domain/oauth/services/OauthRefreshService.kt b/src/main/kotlin/com/msg/gauth/domain/oauth/services/OauthRefreshService.kt index 8cd43b15..a33a72e5 100644 --- a/src/main/kotlin/com/msg/gauth/domain/oauth/services/OauthRefreshService.kt +++ b/src/main/kotlin/com/msg/gauth/domain/oauth/services/OauthRefreshService.kt @@ -7,10 +7,11 @@ import com.msg.gauth.domain.oauth.presentation.dto.response.UserTokenResponseDto import com.msg.gauth.domain.oauth.repository.OauthRefreshTokenRepository import com.msg.gauth.domain.user.exception.UserNotFoundException import com.msg.gauth.domain.user.repository.UserRepository +import com.msg.gauth.global.annotation.service.TransactionalService import com.msg.gauth.global.security.jwt.JwtTokenProvider import org.springframework.stereotype.Service -@Service +@TransactionalService class OauthRefreshService( private val tokenRepository: OauthRefreshTokenRepository, private val tokenProvider: JwtTokenProvider, diff --git a/src/main/kotlin/com/msg/gauth/domain/oauth/services/OauthTokenService.kt b/src/main/kotlin/com/msg/gauth/domain/oauth/services/OauthTokenService.kt index b6d67b99..b9cb0558 100644 --- a/src/main/kotlin/com/msg/gauth/domain/oauth/services/OauthTokenService.kt +++ b/src/main/kotlin/com/msg/gauth/domain/oauth/services/OauthTokenService.kt @@ -1,13 +1,11 @@ package com.msg.gauth.domain.oauth.services -import com.msg.gauth.domain.auth.exception.PasswordMismatchException import com.msg.gauth.domain.client.Client import com.msg.gauth.domain.client.exception.ClientNotFindException import com.msg.gauth.domain.client.repository.ClientRepository import com.msg.gauth.domain.oauth.OauthRefreshToken import com.msg.gauth.domain.oauth.exception.ClientSecretMismatchException import com.msg.gauth.domain.oauth.exception.OauthCodeExpiredException -import com.msg.gauth.domain.oauth.presentation.dto.request.OauthLoginReqDto import com.msg.gauth.domain.oauth.presentation.dto.request.UserTokenRequestDto import com.msg.gauth.domain.oauth.presentation.dto.response.UserTokenResponseDto import com.msg.gauth.domain.oauth.repository.OauthCodeRepository @@ -15,12 +13,11 @@ import com.msg.gauth.domain.oauth.repository.OauthRefreshTokenRepository import com.msg.gauth.domain.user.User import com.msg.gauth.domain.user.exception.UserNotFoundException import com.msg.gauth.domain.user.repository.UserRepository +import com.msg.gauth.global.annotation.service.ReadOnlyService import com.msg.gauth.global.security.jwt.JwtTokenProvider import org.springframework.security.crypto.password.PasswordEncoder -import org.springframework.stereotype.Service -import org.springframework.transaction.annotation.Transactional -@Service +@ReadOnlyService class OauthTokenService( private val clientRepository: ClientRepository, private val userRepository: UserRepository, @@ -29,7 +26,6 @@ class OauthTokenService( private val oauthCodeRepository: OauthCodeRepository, private val passwordEncoder: PasswordEncoder, ){ - @Transactional(rollbackFor = [Exception::class], readOnly = true) fun execute(userTokenRequestDto: UserTokenRequestDto): UserTokenResponseDto{ val client = (clientRepository.findByClientId(userTokenRequestDto.clientId) ?: throw ClientNotFindException()) diff --git a/src/main/kotlin/com/msg/gauth/domain/user/services/ChangePasswordService.kt b/src/main/kotlin/com/msg/gauth/domain/user/services/ChangePasswordService.kt index 8ffaca67..75191c58 100644 --- a/src/main/kotlin/com/msg/gauth/domain/user/services/ChangePasswordService.kt +++ b/src/main/kotlin/com/msg/gauth/domain/user/services/ChangePasswordService.kt @@ -2,22 +2,19 @@ package com.msg.gauth.domain.user.services import com.msg.gauth.domain.email.repository.EmailAuthRepository import com.msg.gauth.domain.user.exception.EmailNotVerifiedException -import com.msg.gauth.domain.user.exception.UserNotFoundException import com.msg.gauth.domain.user.presentation.dto.request.PasswordChangeReqDto import com.msg.gauth.domain.user.repository.UserRepository import com.msg.gauth.domain.user.utils.UserUtil +import com.msg.gauth.global.annotation.service.TransactionalService import org.springframework.security.crypto.password.PasswordEncoder -import org.springframework.stereotype.Service -import org.springframework.transaction.annotation.Transactional -@Service +@TransactionalService class ChangePasswordService( private val emailAuthRepository: EmailAuthRepository, private val userUtil: UserUtil, private val userRepository: UserRepository, private val passwordEncoder: PasswordEncoder, ){ - @Transactional(rollbackFor = [Exception::class]) fun execute(passwordChangeReqDto: PasswordChangeReqDto){ val currentUser = userUtil.fetchCurrentUser() val emailAuth = emailAuthRepository.findById(currentUser.email) diff --git a/src/main/kotlin/com/msg/gauth/domain/user/services/MyProfileService.kt b/src/main/kotlin/com/msg/gauth/domain/user/services/MyProfileService.kt index 728c35b1..5f59c4ad 100644 --- a/src/main/kotlin/com/msg/gauth/domain/user/services/MyProfileService.kt +++ b/src/main/kotlin/com/msg/gauth/domain/user/services/MyProfileService.kt @@ -3,9 +3,9 @@ package com.msg.gauth.domain.user.services import com.msg.gauth.domain.client.repository.ClientRepository import com.msg.gauth.domain.user.presentation.dto.response.MyProfileResDto import com.msg.gauth.domain.user.utils.UserUtil -import org.springframework.stereotype.Service +import com.msg.gauth.global.annotation.service.ReadOnlyService -@Service +@ReadOnlyService class MyProfileService( private val userUtil: UserUtil, private val clientRepository: ClientRepository diff --git a/src/main/kotlin/com/msg/gauth/domain/user/services/UploadProfileService.kt b/src/main/kotlin/com/msg/gauth/domain/user/services/UploadProfileService.kt index 0aea37d1..b5893b82 100644 --- a/src/main/kotlin/com/msg/gauth/domain/user/services/UploadProfileService.kt +++ b/src/main/kotlin/com/msg/gauth/domain/user/services/UploadProfileService.kt @@ -2,19 +2,16 @@ package com.msg.gauth.domain.user.services import com.msg.gauth.domain.user.repository.UserRepository import com.msg.gauth.domain.user.utils.UserUtil +import com.msg.gauth.global.annotation.service.TransactionalService import com.msg.gauth.global.aws.s3.S3Util -import org.springframework.stereotype.Service -import org.springframework.transaction.annotation.Transactional import org.springframework.web.multipart.MultipartFile -@Service +@TransactionalService class UploadProfileService( private val s3Util: S3Util, private val userUtil: UserUtil, private val userRepository: UserRepository, ){ - - @Transactional(rollbackFor = [Exception::class]) fun execute(file: MultipartFile){ val url = s3Util.upload(file) val user = userUtil.fetchCurrentUser() diff --git a/src/main/kotlin/com/msg/gauth/global/annotation/service/ReadOnlyService.kt b/src/main/kotlin/com/msg/gauth/global/annotation/service/ReadOnlyService.kt new file mode 100644 index 00000000..6d1baf3d --- /dev/null +++ b/src/main/kotlin/com/msg/gauth/global/annotation/service/ReadOnlyService.kt @@ -0,0 +1,8 @@ +package com.msg.gauth.global.annotation.service + +import org.springframework.stereotype.Service +import org.springframework.transaction.annotation.Transactional + +@Service +@Transactional(readOnly = true, rollbackFor = [Exception::class]) +annotation class ReadOnlyService() diff --git a/src/main/kotlin/com/msg/gauth/global/annotation/service/TransactionalService.kt b/src/main/kotlin/com/msg/gauth/global/annotation/service/TransactionalService.kt new file mode 100644 index 00000000..a1f1615a --- /dev/null +++ b/src/main/kotlin/com/msg/gauth/global/annotation/service/TransactionalService.kt @@ -0,0 +1,8 @@ +package com.msg.gauth.global.annotation.service + +import org.springframework.stereotype.Service +import org.springframework.transaction.annotation.Transactional + +@Service +@Transactional(rollbackFor = [Exception::class]) +annotation class TransactionalService()