Skip to content

Commit

Permalink
Merge pull request #344 from GSM-MSG/343-feat/ktlint-for-code-formatting
Browse files Browse the repository at this point in the history
🔀 :: 343 feat/ktlint for code formatting
  • Loading branch information
KimTaeO authored Jul 7, 2024
2 parents ffb204d + ef9163b commit c77ed4a
Show file tree
Hide file tree
Showing 76 changed files with 157 additions and 170 deletions.
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 4
insert_final_newline = false
tab_width = 4

[*.kt]
ij_kotlin_packages_to_use_import_on_demand = unset
ij_kotlin_allow_trailing_comma = false
ij_kotlin_allow_trailing_comma_on_call_site = false
18 changes: 17 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ plugins {
id("org.springframework.boot") version PluginVersion.SPRING_BOOT_VERSION
id("io.spring.dependency-management") version PluginVersion.DEPENDENCY_MANAGER_VERSION
id("com.ewerk.gradle.plugins.querydsl") version PluginVersion.QUERY_DSL_PLUGIN_VERSION
id("org.jlleitschuh.gradle.ktlint") version "10.2.0"

kotlin("jvm") version PluginVersion.JVM_VERSION
kotlin("plugin.spring") version PluginVersion.SPRING_PLUGIN_VERSION
kotlin("plugin.jpa") version PluginVersion.JPA_PLUGIN_VERSION
kotlin("kapt") version PluginVersion.KAPT_VERSION
idea
application
}

group = "com.msg"
Expand Down Expand Up @@ -78,7 +80,6 @@ dependencies {
implementation(Dependencies.PROMETHEUS_MICROMETER)
}


tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
Expand All @@ -97,3 +98,18 @@ idea {
tasks.withType<Test> {
useJUnitPlatform()
}

application {
mainClass.set("com.msg.gauth.GauthBackendApplicationKt")
}

ktlint {
verbose.set(true)
android.set(false)
outputToConsole.set(true)
coloredOutput.set(false)
ignoreFailures.set(false)
enableExperimentalRules.set(false)

disabledRules.set(setOf("no-wildcard-imports", "import-ordering"))
}
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
rootProject.name = "gauth"
rootProject.name = "gauth"
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
Loading

0 comments on commit c77ed4a

Please sign in to comment.