Skip to content

Commit ba65274

Browse files
committed
apply KtLint
1 parent 2bddba7 commit ba65274

105 files changed

Lines changed: 1328 additions & 1004 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

api/src/main/kotlin/filter/ErrorWebFilter.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ class ErrorWebFilter(
2626
override fun filter(
2727
exchange: ServerWebExchange,
2828
chain: WebFilterChain,
29-
): Mono<Void> {
30-
return chain.filter(exchange)
29+
): Mono<Void> =
30+
chain
31+
.filter(exchange)
3132
.onErrorResume { throwable ->
3233
val errorBody: ErrorBody
3334
val httpStatusCode: HttpStatusCode
@@ -79,11 +80,9 @@ class ErrorWebFilter(
7980
Mono.empty()
8081
}
8182
}
82-
}
8383

84-
private fun makeErrorBody(exception: SnuttException): ErrorBody {
85-
return ErrorBody(exception.error.errorCode, exception.errorMessage, exception.displayMessage, exception.ext)
86-
}
84+
private fun makeErrorBody(exception: SnuttException): ErrorBody =
85+
ErrorBody(exception.error.errorCode, exception.errorMessage, exception.displayMessage, exception.ext)
8786
}
8887

8988
private data class ErrorBody(

api/src/main/kotlin/handler/BuildingHandler.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ class BuildingHandler(
1818
suspend fun searchBuildings(req: ServerRequest): ServerResponse =
1919
handle(req) {
2020
val placesQuery =
21-
req.parseRequiredQueryParam<String>("places")
21+
req
22+
.parseRequiredQueryParam<String>("places")
2223
.split(",")
2324
.flatMap { PlaceInfo.getValuesOf(it) }
2425
.distinct()

api/src/main/kotlin/handler/FriendHandler.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ class FriendHandler(
9797
val userId = req.userId
9898
val requestToken = req.pathVariable("requestToken")
9999

100-
friendService.acceptFriendByLink(userId, requestToken)
101-
.let {
102-
(friend, partner) ->
100+
friendService
101+
.acceptFriendByLink(userId, requestToken)
102+
.let { (friend, partner) ->
103103
FriendResponse(
104104
id = friend.id!!,
105105
userId = partner.id!!,

api/src/main/kotlin/handler/FriendTableHandler.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ class FriendTableHandler(
1818
suspend fun getPrimaryTable(req: ServerRequest) =
1919
handle(req) {
2020
val friend =
21-
friendService.get(req.pathVariable("friendId"))
21+
friendService
22+
.get(req.pathVariable("friendId"))
2223
?.takeIf { it.isAccepted && it.includes(req.userId) }
2324
?: throw FriendNotFoundException
2425

@@ -30,7 +31,8 @@ class FriendTableHandler(
3031
suspend fun getCoursebooks(req: ServerRequest) =
3132
handle(req) {
3233
val friend =
33-
friendService.get(req.pathVariable("friendId"))
34+
friendService
35+
.get(req.pathVariable("friendId"))
3436
?.takeIf { it.isAccepted && it.includes(req.userId) }
3537
?: throw FriendNotFoundException
3638

api/src/main/kotlin/handler/LectureSearchHandler.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ data class SearchQueryLegacy(
4747
val sortCriteria: String? = null,
4848
val categoryPre2025: List<String>? = null,
4949
) {
50-
fun toSearchDto(): SearchDto {
51-
return SearchDto(
50+
fun toSearchDto(): SearchDto =
51+
SearchDto(
5252
year = year,
5353
semester = semester,
5454
query = title,
@@ -67,5 +67,4 @@ data class SearchQueryLegacy(
6767
sortBy = sortCriteria,
6868
categoryPre2025 = categoryPre2025,
6969
)
70-
}
7170
}

api/src/main/kotlin/handler/RequestContext.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ data class RequestContext(
1212
val clientInfo: ClientInfo? = null,
1313
)
1414

15-
fun ServerRequest.getContext(): RequestContext {
16-
return this.attributes().getOrPut(CONTEXT_ATTRIBUTE_KEY) { RequestContext() } as RequestContext
17-
}
15+
fun ServerRequest.getContext(): RequestContext = this.attributes().getOrPut(CONTEXT_ATTRIBUTE_KEY) { RequestContext() } as RequestContext
1816

1917
fun ServerRequest.setContext(value: RequestContext) {
2018
this.attributes()[CONTEXT_ATTRIBUTE_KEY] = value

api/src/main/kotlin/handler/ServiceHandler.kt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import org.springframework.web.reactive.function.server.ServerResponse
1010
import org.springframework.web.reactive.function.server.buildAndAwait
1111
import org.springframework.web.reactive.function.server.queryParamOrNull
1212

13-
abstract class ServiceHandler(val handlerMiddleware: Middleware = Middleware.NoOp) {
13+
abstract class ServiceHandler(
14+
val handlerMiddleware: Middleware = Middleware.NoOp,
15+
) {
1416
protected suspend fun <T : Any> handle(
1517
req: ServerRequest,
1618
additionalMiddleware: Middleware = Middleware.NoOp,
@@ -20,9 +22,7 @@ abstract class ServiceHandler(val handlerMiddleware: Middleware = Middleware.NoO
2022
return function()?.toResponse() ?: ServerResponse.ok().buildAndAwait()
2123
}
2224

23-
private suspend fun <T : Any> T.toResponse(): ServerResponse {
24-
return ServerResponse.ok().bodyValue(this).awaitSingle()
25-
}
25+
private suspend fun <T : Any> T.toResponse(): ServerResponse = ServerResponse.ok().bodyValue(this).awaitSingle()
2626

2727
fun <T> ServerRequest.parseRequiredQueryParam(
2828
name: String,
@@ -35,15 +35,17 @@ abstract class ServiceHandler(val handlerMiddleware: Middleware = Middleware.NoO
3535
name: String,
3636
convert: (String) -> T?,
3737
): T? =
38-
this.queryParamOrNull(name)?.runCatching { convert(this)!! }
38+
this
39+
.queryParamOrNull(name)
40+
?.runCatching { convert(this)!! }
3941
?.getOrElse { throw InvalidQueryParameterException(name) }
4042

4143
inline fun <reified T> ServerRequest.parseRequiredQueryParam(name: String): T =
4244
parseQueryParam<T>(name)
4345
?: throw MissingRequiredParameterException(name)
4446

45-
inline fun <reified T> ServerRequest.parseQueryParam(name: String): T? {
46-
return when (T::class) {
47+
inline fun <reified T> ServerRequest.parseQueryParam(name: String): T? =
48+
when (T::class) {
4749
String::class -> this.parseQueryParam(name) { it } as T?
4850
Int::class -> this.parseQueryParam(name) { it.toIntOrNull() } as T?
4951
Long::class -> this.parseQueryParam(name) { it.toLongOrNull() } as T?
@@ -52,5 +54,4 @@ abstract class ServiceHandler(val handlerMiddleware: Middleware = Middleware.NoO
5254
Boolean::class -> this.parseQueryParam(name) { it.toBooleanStrictOrNull() } as T?
5355
else -> throw IllegalArgumentException("파싱을 지원하지 않는 쿼리 파라미터 타입입니다. type: ${T::class}")
5456
}
55-
}
5657
}

api/src/main/kotlin/handler/StaticPageHandler.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ class StaticPageHandler {
1414
private val privacyPolicyHtml = ClassPathResource("$RESOURCE_PATH/privacy_policy.html")
1515
private val termsOfServiceHtml = ClassPathResource("$RESOURCE_PATH/terms_of_service.html")
1616
private val staticResponse =
17-
ServerResponse.ok()
17+
ServerResponse
18+
.ok()
1819
.cacheControl(CacheControl.maxAge(Duration.ofDays(1)))
1920
.header("Content-Type", "text/html; charset=utf-8")
2021
}

api/src/main/kotlin/handler/TimetableHandler.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ class TimetableHandler(
3232
handle(req) {
3333
val userId = req.userId
3434

35-
timetableService.getMostRecentlyUpdatedTimetable(userId)
35+
timetableService
36+
.getMostRecentlyUpdatedTimetable(userId)
3637
.let { timetableService.convertTimetableToTimetableLegacyDto(it) }
3738
}
3839

@@ -43,7 +44,9 @@ class TimetableHandler(
4344
val semester =
4445
Semester.getOfValue(req.pathVariable("semester").toInt()) ?: throw InvalidPathParameterException("semester")
4546

46-
timetableService.getTimetablesBySemester(userId, year, semester).toList()
47+
timetableService
48+
.getTimetablesBySemester(userId, year, semester)
49+
.toList()
4750
.map { timetableService.convertTimetableToTimetableLegacyDto(it) }
4851
}
4952

@@ -66,7 +69,8 @@ class TimetableHandler(
6669
val userId = req.userId
6770
val timetableId = req.pathVariable("timetableId")
6871

69-
timetableService.getTimetable(userId, timetableId)
72+
timetableService
73+
.getTimetable(userId, timetableId)
7074
.let { timetableService.convertTimetableToTimetableLegacyDto(it) }
7175
}
7276

@@ -111,7 +115,8 @@ class TimetableHandler(
111115
val timetableId = req.pathVariable("timetableId")
112116
val body = req.awaitBody<TimetableModifyThemeRequestDto>()
113117

114-
timetableService.modifyTimetableTheme(userId, timetableId, body.theme, body.themeId)
118+
timetableService
119+
.modifyTimetableTheme(userId, timetableId, body.theme, body.themeId)
115120
.let { timetableService.convertTimetableToTimetableLegacyDto(it) }
116121
}
117122

api/src/main/kotlin/handler/TimetableLectureHandler.kt

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@ class TimetableLectureHandler(
2727
val customTimetable = req.awaitBody<CustomTimetableLectureAddLegacyRequestDto>()
2828
val isForced = req.parseQueryParam<Boolean>("isForced") ?: customTimetable.isForced
2929

30-
timetableLectureService.addCustomTimetableLecture(
31-
userId = userId,
32-
timetableId = timetableId,
33-
timetableLectureRequest = customTimetable,
34-
isForced = isForced,
35-
).let { timetableService.convertTimetableToTimetableLegacyDto(it) }
30+
timetableLectureService
31+
.addCustomTimetableLecture(
32+
userId = userId,
33+
timetableId = timetableId,
34+
timetableLectureRequest = customTimetable,
35+
isForced = isForced,
36+
).let { timetableService.convertTimetableToTimetableLegacyDto(it) }
3637
}
3738

3839
suspend fun addLecture(req: ServerRequest): ServerResponse =
@@ -42,12 +43,13 @@ class TimetableLectureHandler(
4243
val lectureId = req.pathVariable("lectureId")
4344
val isForced = req.parseQueryParam<Boolean>("isForced") ?: req.awaitBodyOrNull<ForcedReq>()?.isForced ?: false
4445

45-
timetableLectureService.addLecture(
46-
userId = userId,
47-
timetableId = timetableId,
48-
lectureId = lectureId,
49-
isForced = isForced,
50-
).let { timetableService.convertTimetableToTimetableLegacyDto(it) }
46+
timetableLectureService
47+
.addLecture(
48+
userId = userId,
49+
timetableId = timetableId,
50+
lectureId = lectureId,
51+
isForced = isForced,
52+
).let { timetableService.convertTimetableToTimetableLegacyDto(it) }
5153
}
5254

5355
suspend fun resetTimetableLecture(req: ServerRequest): ServerResponse =
@@ -57,12 +59,13 @@ class TimetableLectureHandler(
5759
val timetableLectureId = req.pathVariable("timetableLectureId")
5860
val isForced = req.parseQueryParam<Boolean>("isForced") ?: req.awaitBodyOrNull<ForcedReq>()?.isForced ?: false
5961

60-
timetableLectureService.resetTimetableLecture(
61-
userId = userId,
62-
timetableId = timetableId,
63-
timetableLectureId = timetableLectureId,
64-
isForced,
65-
).let { timetableService.convertTimetableToTimetableLegacyDto(it) }
62+
timetableLectureService
63+
.resetTimetableLecture(
64+
userId = userId,
65+
timetableId = timetableId,
66+
timetableLectureId = timetableLectureId,
67+
isForced,
68+
).let { timetableService.convertTimetableToTimetableLegacyDto(it) }
6669
}
6770

6871
suspend fun modifyTimetableLecture(req: ServerRequest): ServerResponse =
@@ -73,13 +76,14 @@ class TimetableLectureHandler(
7376
val modifyRequestDto = req.awaitBody<TimetableLectureModifyLegacyRequestDto>()
7477
val isForced = req.parseQueryParam<Boolean>("isForced") ?: modifyRequestDto.isForced
7578

76-
timetableLectureService.modifyTimetableLecture(
77-
userId = userId,
78-
timetableId = timetableId,
79-
timetableLectureId = timetableLectureId,
80-
modifyTimetableLectureRequestDto = modifyRequestDto,
81-
isForced = isForced,
82-
).let { timetableService.convertTimetableToTimetableLegacyDto(it) }
79+
timetableLectureService
80+
.modifyTimetableLecture(
81+
userId = userId,
82+
timetableId = timetableId,
83+
timetableLectureId = timetableLectureId,
84+
modifyTimetableLectureRequestDto = modifyRequestDto,
85+
isForced = isForced,
86+
).let { timetableService.convertTimetableToTimetableLegacyDto(it) }
8387
}
8488

8589
suspend fun deleteTimetableLecture(req: ServerRequest): ServerResponse =
@@ -88,11 +92,12 @@ class TimetableLectureHandler(
8892
val timetableId = req.pathVariable("timetableId")
8993
val timetableLectureId = req.pathVariable("timetableLectureId")
9094

91-
timetableLectureService.deleteTimetableLecture(
92-
userId = userId,
93-
timetableId = timetableId,
94-
timetableLectureId = timetableLectureId,
95-
).let { timetableService.convertTimetableToTimetableLegacyDto(it) }
95+
timetableLectureService
96+
.deleteTimetableLecture(
97+
userId = userId,
98+
timetableId = timetableId,
99+
timetableLectureId = timetableLectureId,
100+
).let { timetableService.convertTimetableToTimetableLegacyDto(it) }
96101
}
97102

98103
data class ForcedReq(

0 commit comments

Comments
 (0)