This commit is contained in:
2026-04-28 17:55:09 +08:00
parent 83a1c5ca8a
commit 0817e73dc4
3 changed files with 41 additions and 0 deletions
+20
View File
@@ -85,7 +85,27 @@ var (
)
func updateSysAdminsCash() {
// 查询 admins 用户组的 ID
var adminGroup TabUserGroups
if models.DB.Where("name = ?", "admins").First(&adminGroup).Error != nil {
// admins 组不存在,清空缓存
sysAdmins = []uint{}
return
}
// 查询 admins 组的所有成员
var binds []TabUserGroupBinds
if models.DB.Where("group_id = ?", adminGroup.ID).Find(&binds).Error != nil {
sysAdmins = []uint{}
return
}
// 更新缓存
newAdmins := make([]uint, 0, len(binds))
for _, bind := range binds {
newAdmins = append(newAdmins, bind.UserID)
}
sysAdmins = newAdmins
}
// recordLoginFail 记录登录失败日志,更新连续失败次数