1 Star 1 Fork 1

xiaoyutab / xgotool

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
get_user_role.go 462 Bytes
一键复制 编辑 原始数据 按行查看 历史
xiaoyutab 提交于 2024-01-17 15:14 . 代码优化
package xauth
// 获取用户角色列表
//
// uid 用户ID
func GetUserRole(uid uint) []uint {
_cache.Lock()
defer _cache.Unlock()
if v, ok := _cache.UserRole[uid]; ok {
return v
}
mod := []uint{}
// 从数据库中进行查询
err := _default.DB.Table(_default.RoleUserName).Select("role_id").Where("user_id", uid).Find(&mod).Error
if err != nil {
errFun("用户角色获取失败", err)
return nil
}
_cache.UserRole[uid] = mod
return mod
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/xiaoyutab/xgotool.git
git@gitee.com:xiaoyutab/xgotool.git
xiaoyutab
xgotool
xgotool
v0.3.14

搜索帮助

344bd9b3 5694891 D2dac590 5694891