refactor: useless toLong()

This commit is contained in:
SOR
2026-07-06 13:52:00 +08:00
parent bc07b17f20
commit 7c3f8b0af5
@@ -23,9 +23,9 @@ class FlowLimitFilter(
@param:Value($$"${app.flow-limit.count}") @param:Value($$"${app.flow-limit.count}")
private val limitCount: Int, private val limitCount: Int,
@param:Value($$"${app.flow-limit.limit-time}") @param:Value($$"${app.flow-limit.limit-time}")
private val limitTime: Int, private val limitTime: Long,
@param:Value($$"${app.flow-limit.ban-time}") @param:Value($$"${app.flow-limit.ban-time}")
private val expireTime: Int, private val expireTime: Long,
) : WebFilter { ) : WebFilter {
override fun filter(exchange: ServerWebExchange, chain: WebFilterChain): Mono<Void> { override fun filter(exchange: ServerWebExchange, chain: WebFilterChain): Mono<Void> {
@@ -61,14 +61,14 @@ class FlowLimitFilter(
if (count == 1L) { if (count == 1L) {
template.expire( template.expire(
counterKey, counterKey,
Duration.ofSeconds(limitTime.toLong()) Duration.ofSeconds(limitTime)
).thenReturn(true) ).thenReturn(true)
} else if (count > limitCount) { } else if (count > limitCount) {
template.opsForValue() template.opsForValue()
.set( .set(
blockKey, blockKey,
"1", "1",
Duration.ofSeconds(expireTime.toLong()) Duration.ofSeconds(expireTime)
) )
.thenReturn(false) .thenReturn(false)
} else { } else {