🎨 优化机器人查询

This commit is contained in:
2025-10-11 16:14:37 +08:00
parent 4fc979aaad
commit 481635d333

View File

@@ -1,6 +1,7 @@
package bot
import (
"errors"
"git.echol.cn/loser/lckt/global"
"git.echol.cn/loser/lckt/model/bot"
botReq "git.echol.cn/loser/lckt/model/bot/request"
@@ -9,6 +10,7 @@ import (
"git.echol.cn/loser/lckt/utils/user_jwt"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
"gorm.io/gorm"
"strings"
)
@@ -188,6 +190,13 @@ func (btApi *BotApi) FindKey(c *gin.Context) {
userId := user_jwt.GetUserID(c)
bt, err := btService.GetBotPublic(req, userId)
// 判断是否查询为空
if errors.Is(err, gorm.ErrRecordNotFound) {
// 没有找到记录的处理逻辑
response.OkWithData(bt, c)
return
}
if err != nil {
global.GVA_LOG.Error("获取失败!", zap.Error(err))
response.FailWithMessage("获取失败:"+err.Error(), c)