mirror of
https://github.com/SOR2171/Springboot4-Vue3_Demo.git
synced 2026-10-23 19:41:12 +08:00
refactor: useless toLong()
This commit is contained in:
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user