From 8dae755df2c31388cf63335abe07a0b725246284 Mon Sep 17 00:00:00 2001 From: YGXB_net Date: Mon, 27 Jul 2026 00:44:25 +0800 Subject: [PATCH] =?UTF-8?q?refactor(token):=20=E7=AE=80=E5=8C=96=E5=BE=AA?= =?UTF-8?q?=E7=8E=AF=E4=B8=AD=E7=9A=84=E6=9D=A1=E4=BB=B6=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 使用 min 函数替代 if-else 条件判断 - 减少代码行数提高可读性 - 保持原有功能不变 --- internal/controller/tokenController.go | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/internal/controller/tokenController.go b/internal/controller/tokenController.go index f55770a..787ab7c 100644 --- a/internal/controller/tokenController.go +++ b/internal/controller/tokenController.go @@ -248,11 +248,7 @@ func DeleteTokenInfoHandler(c *gin.Context) { for i := num; i > 0; i -= 20_0000 { a := 0 - if i > 20_0000 { - a = 20_0000 - } else { - a = i - } + a = min(i, 20_0000) //获得要删的值(列表) result := global.RDB.LRange(global.RCtx, "delete-list:"+input.Token, int64(-a), -1).Val() @@ -310,11 +306,7 @@ func DeleteTokenInfoHandler(c *gin.Context) { for i := num; i > 0; i -= 20_0000 { a := 0 - if i > 20_0000 { - a = 20_0000 - } else { - a = i - } + a = min(i, 20_0000) result := global.RDB.LRange(global.RCtx, "delete-list:"+input.Token, int64(-a), -1).Val() _, err = global.RDB.TxPipelined(global.RCtx, func(pipe redis.Pipeliner) error {