Skip to content

Commit

Permalink
update :: ktlint auto formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
KimTaeO committed Jul 4, 2024
1 parent b06cc74 commit 36b60c3
Show file tree
Hide file tree
Showing 73 changed files with 125 additions and 168 deletions.
2 changes: 1 addition & 1 deletion src/main/kotlin/com/msg/gauth/GauthBackendApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ class GauthBackendApplication
fun main(args: Array<String>) {
TimeZone.setDefault(TimeZone.getTimeZone("Asia/Seoul"))
runApplication<GauthBackendApplication>(*args)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ class ExcelParsingService(
private val userRepository: UserRepository,
) {

fun execute(file: MultipartFile){
fun execute(file: MultipartFile) {
val tika = Tika()
val detect = tika.detect(file.bytes)
val extension = FileNameUtils.getExtension(file.originalFilename)

if(!ExcelUtil.isExcel(detect, extension))
if (!ExcelUtil.isExcel(detect, extension))
throw FileExtensionInvalidException()

val workBook: Workbook =
Expand All @@ -34,10 +34,10 @@ class ExcelParsingService(
else
HSSFWorkbook(file.inputStream)

val workSheet:Sheet = workBook.getSheetAt(0)
val workSheet: Sheet = workBook.getSheetAt(0)
val map = hashMapOf<String, UpdateDto>()

for(i in 1 until workSheet.physicalNumberOfRows){
for (i in 1 until workSheet.physicalNumberOfRows) {
val row = workSheet.getRow(i)
val email = row.getCell(4).stringCellValue

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import org.springframework.http.HttpEntity
import org.springframework.http.HttpHeaders
import org.springframework.http.MediaType
import org.springframework.stereotype.Component
import org.springframework.transaction.event.TransactionPhase
import org.springframework.transaction.event.TransactionalEventListener
import org.springframework.web.client.RestTemplate

@Component
Expand Down Expand Up @@ -51,4 +49,4 @@ class AuthEventHandler(
val entity = HttpEntity(jsonObject.toString(), headers)
restTemplate.postForObject(discordProperties.url, entity, String::class.java)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ class AuthController(
return ResponseEntity.ok(result)
}


@PatchMapping("/password/initialize")
fun initPassword(@Valid @RequestBody initPasswordRequestDto: InitPasswordRequestDto): ResponseEntity<Void> {
initPasswordService.execute(initPasswordRequestDto)
Expand All @@ -84,5 +83,4 @@ class AuthController(
signUpEmailVerificationService.execute(email)
return ResponseEntity.ok().build()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import javax.validation.constraints.NotBlank
import javax.validation.constraints.NotNull
import javax.validation.constraints.Pattern

data class SignUpV2RequestDto (
data class SignUpV2RequestDto(
@field:NotBlank
@field:Pattern(regexp = "^[a-zA-Z0-9.][email protected]$")
val email: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ import com.msg.gauth.global.util.count.auth.RefreshToken
import org.springframework.data.repository.CrudRepository

interface RefreshTokenRepository : CrudRepository<RefreshToken, Long> {

fun findByToken(token: String): RefreshToken?
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class InitPasswordService(
val emailAuth = emailAuthRepository.findByIdOrNull(initPasswordRequestDto.email)
?: throw EmailNotVerifiedException()

if(!emailAuth.authentication)
if (!emailAuth.authentication)
throw EmailNotVerifiedException()

val user = userRepository.findByEmail(initPasswordRequestDto.email)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class RefreshService(
throw InvalidRefreshTokenException()

val (access, refresh) = jwtTokenProvider.run {
generateAccessToken(email) to generateRefreshToken(email)}
generateAccessToken(email) to generateRefreshToken(email)
}

val newRefreshToken = RefreshToken(
userId = existingRefreshToken.userId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class SignInService(
throw PasswordMismatchException()
}

if(user.state == UserState.PENDING)
if (user.state == UserState.PENDING)
throw UserIsPendingException()

tempUserUtil.resetWrongPasswordCount(user)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ class SignUpImageUploadService(
val emailAuth = emailAuthRepository.findByIdOrNull(email)
?: throw AuthCodeExpiredException()

if(!emailAuth.authentication)
if (!emailAuth.authentication)
throw AuthCodeNotVerificationException()

if(previousUrl != null)
if (previousUrl != null)
s3Util.deleteImage(previousUrl)

return SignUpImageResDto(s3Util.imageUpload(image))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class SignUpMemberV2Service(
) {

fun execute(signUpV2RequestDto: SignUpV2RequestDto) {
if(userRepository.existsByEmail(signUpV2RequestDto.email))
if (userRepository.existsByEmail(signUpV2RequestDto.email))
throw DuplicateEmailException()

if (userRepository.existsByGradeAndClassNumAndNum(signUpV2RequestDto.grade, signUpV2RequestDto.classNum, signUpV2RequestDto.num))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ data class ClientUpdateReqDto(

@Enumerated(EnumType.STRING)
val serviceScope: ServiceScope = ServiceScope.PUBLIC,

val serviceImgUrl: String = ""
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ data class ClientDetailResDto(
val serviceImgUrl: String
) {

constructor(client: Client): this(
constructor(client: Client) : this(
id = client.id,
clientId = client.clientId,
clientSecret = client.clientSecret,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ data class ClientRegisterResDto(
val serviceImgUrl: String
) {

constructor(client: Client): this(
constructor(client: Client) : this(
id = client.id,
clientId = client.clientId,
clientSecret = client.clientSecret,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ data class ClientResDto(
val serviceImgUrl: String
) {

constructor(client: Client): this(
constructor(client: Client) : this(
clientId = client.id,
serviceName = client.serviceName,
serviceUri = client.serviceUri,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ data class SingleClientResDto(
val serviceImgUrl: String
) {

constructor(client: Client): this(
constructor(client: Client) : this(
id = client.id,
clientId = client.clientId,
serviceName = client.serviceName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import com.msg.gauth.domain.user.User
import org.springframework.data.domain.Page
import org.springframework.data.domain.Pageable
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Query
import java.util.*

interface ClientRepository : JpaRepository<Client, Long>, CustomClientRepository {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import org.springframework.stereotype.Repository
@Repository
class CustomClientRepositoryImpl(
private val jpaQueryFactory: JPAQueryFactory
): CustomClientRepository {
) : CustomClientRepository {

override fun deleteAllByIdsAndCreatedBy(ids: List<Long>, createdBy: User) {
jpaQueryFactory.delete(client)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class DelegateOwnerService(
val user = userUtil.fetchCurrentUser()

if (delegateUserId == user.id)
throw BadDelegateUserIdRequestException()
throw BadDelegateUserIdRequestException()

val client = clientRepository.findByIdOrNull(clientId)
?: throw ClientNotFindException()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ class DeleteClientService(
private val userUtil: UserUtil,
) {

fun execute(id: Long){
fun execute(id: Long) {
val client = clientRepository.findByIdOrNull(id)
?: throw ClientNotFindException()

if(client.createdBy != userUtil.fetchCurrentUser())
if (client.createdBy != userUtil.fetchCurrentUser())
throw UserNotMatchException()

clientRepository.delete(client)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class UpdateClientService(
private val userUtil: UserUtil
) {

fun updateClient(id: Long, clientUpdateReqDto: ClientUpdateReqDto){
fun updateClient(id: Long, clientUpdateReqDto: ClientUpdateReqDto) {
val client = clientRepository.findByIdAndCreatedBy(id, userUtil.fetchCurrentUser())
?: throw ClientNotFindException()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.msg.gauth.domain.email

import org.hibernate.annotations.ColumnDefault
import org.hibernate.validator.constraints.Length
import org.springframework.data.annotation.Id
import org.springframework.data.redis.core.RedisHash
Expand Down Expand Up @@ -30,7 +29,7 @@ class EmailAuthEntity(
return EmailAuthEntity(
email = this.email,
authentication = this.authentication,
attemptCount = this.attemptCount+1,
attemptCount = this.attemptCount + 1,
randomValue = uuid,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,4 @@ class EmailController(
checkMailVerificationService.execute(email)
return ResponseEntity.ok().build()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class CheckMailVerificationService(
val authEntity = emailAuthRepository.findByIdOrNull(email)
?: throw AuthCodeNotVerificationException()

if(!authEntity.authentication)
if (!authEntity.authentication)
throw AuthCodeNotVerificationException()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class SendMailService(
attemptCount = 0
)

if(authEntity.authentication)
if (authEntity.authentication)
throw AlreadyAuthenticatedEmailException()

if (authEntity.attemptCount >= 5)
Expand Down Expand Up @@ -65,7 +65,7 @@ class SendMailService(
private fun createMailTemplate(email: String, code: String): String {
val context = Context()

val url = "https://port-0-gauth-backend-85phb42bluutn9a7.sel5.cloudtype.app/email/authentication?email=${email}&uuid=${code}"
val url = "https://port-0-gauth-backend-85phb42bluutn9a7.sel5.cloudtype.app/email/authentication?email=$email&uuid=$code"

context.setVariables(
mapOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ package com.msg.gauth.domain.oauth.exception
import com.msg.gauth.global.exception.ErrorCode
import com.msg.gauth.global.exception.exceptions.BasicException

class UserStatePendingException: BasicException(
class UserStatePendingException : BasicException(
ErrorCode.USER_STATE_PENDING
)
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class OauthController(
) {

@PostMapping("/code")
fun generateOauthCode(@Valid @RequestBody oauthCodeRequestDto : OauthCodeRequestDto): ResponseEntity<OauthCodeResponseDto> {
fun generateOauthCode(@Valid @RequestBody oauthCodeRequestDto: OauthCodeRequestDto): ResponseEntity<OauthCodeResponseDto> {
val result = generateOauthCodeService.execute(oauthCodeRequestDto)
return ResponseEntity.ok(result)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ data class OauthLoginReqDto(

@field:NotBlank
val password: String
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class GenerateOauthCodeService(
throw PasswordMismatchException()
}

if(user.state == UserState.PENDING)
if (user.state == UserState.PENDING)
throw UserStatePendingException()

tempUserUtil.resetOAuthWrongPasswordCount(user)
Expand All @@ -58,7 +58,7 @@ class GenerateOauthCodeService(
tempUserUtil.isUserBan(user)
tooManyOAuthRequestValidUtil.validRequest(user.email)

if(user.state == UserState.PENDING)
if (user.state == UserState.PENDING)
throw UserStatePendingException()

val code = UUID.randomUUID().toString().split(".")[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ class GenerateOauthTokenService(
private val oauthCodeRepository: OauthCodeRepository
) {

fun execute(oauthTokenRequestDto: OauthTokenRequestDto): OauthTokenResponseDto{
val client = (clientRepository.findByClientIdAndRedirectUri(oauthTokenRequestDto.clientId, oauthTokenRequestDto.redirectUri)
?: throw ClientNotFindException())
fun execute(oauthTokenRequestDto: OauthTokenRequestDto): OauthTokenResponseDto {
val client = (
clientRepository.findByClientIdAndRedirectUri(oauthTokenRequestDto.clientId, oauthTokenRequestDto.redirectUri)
?: throw ClientNotFindException()
)

if(client.clientSecret != oauthTokenRequestDto.clientSecret)
if (client.clientSecret != oauthTokenRequestDto.clientSecret)
throw ClientSecretMismatchException()

val oauthCode = oauthCodeRepository.findByIdOrNull(oauthTokenRequestDto.code)
Expand All @@ -40,8 +42,10 @@ class GenerateOauthTokenService(

oauthCodeRepository.delete(oauthCode)

val user = (userRepository.findByEmail(email)
?: throw UserNotFoundException())
val user = (
userRepository.findByEmail(email)
?: throw UserNotFoundException()
)

return tokenResponseDto(email, client, user)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ class GetServiceNameService(
) {

fun execute(clientId: String): ServiceNameResponseDto {
val client = (clientRepository.findByClientId(clientId)
?: throw ClientNotFindException())
val client = (
clientRepository.findByClientId(clientId)
?: throw ClientNotFindException()
)

return ServiceNameResponseDto(
client.serviceName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class RefreshOauthTokenService(
private val tokenParser: TokenParser
) {

fun execute(requestToken: String): OauthTokenResponseDto{
fun execute(requestToken: String): OauthTokenResponseDto {
val refreshToken = tokenParser.parseToken(requestToken)
?: throw InvalidRefreshTokenException()

Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/com/msg/gauth/domain/user/User.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ class User(

val oauthWrongPasswordCount: Int = 0

) : BaseIdEntity(id)
) : BaseIdEntity(id)
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ enum class UserRoleType : GrantedAuthority {

override fun getAuthority(): String =
name
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import com.msg.gauth.domain.user.presentation.dto.response.SinglePendingListResD
import com.msg.gauth.domain.user.service.*
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.*
import org.springframework.web.multipart.MultipartFile
import javax.validation.Valid

@RestController
Expand Down
Loading

0 comments on commit 36b60c3

Please sign in to comment.