package role import ( "slices" "wechat-robot/internal/database" ) // CheckIsSuperAdminUser // @description: 检查是否是超级管理员用户 // @param userId string 用户Id // @return flag bool 是否是超级管理员用户 func CheckIsSuperAdminUser(userId string) (flag bool) { var codes []string // 获取用户角色代码 database.Client.Table("t_role AS tr"). Joins("LEFT JOIN t_admin_user_role AS tur ON tur.role_id = tr.id"). Select("tr.code"). Where("tur.user_id = ?", userId). Where("tr.is_del IS FALSE"). Take(&codes) return slices.Contains(codes, "admin") }