支持后台支付配置管理

This commit is contained in:
yml
2026-06-06 17:49:22 +08:00
parent 13543b3dcb
commit 4d40883da6
29 changed files with 3173 additions and 198 deletions
@@ -196,6 +196,14 @@ func (r *Repository) loadRolesAndPerms(dto *AdminDTO) {
dto.Roles = roles
// 加载权限
for _, role := range roles {
if role.Code == "super_admin" {
dto.Permissions = []string{"*"}
cachePermissions(r, dto.ID, dto.Permissions)
return
}
}
var permCodes []string
r.db.Table("permissions").
Select("DISTINCT permissions.code").
@@ -206,12 +214,17 @@ func (r *Repository) loadRolesAndPerms(dto *AdminDTO) {
dto.Permissions = permCodes
// 缓存权限到 Redis
if r.redis != nil && len(permCodes) > 0 {
ctx := context.Background()
key := fmt.Sprintf("admin:perms:%d", dto.ID)
raw, _ := json.Marshal(permCodes)
r.redis.Set(ctx, key, string(raw), 2*time.Hour)
cachePermissions(r, dto.ID, permCodes)
}
func cachePermissions(r *Repository, adminID uint64, permCodes []string) {
if r.redis == nil || len(permCodes) == 0 {
return
}
ctx := context.Background()
key := fmt.Sprintf("admin:perms:%d", adminID)
raw, _ := json.Marshal(permCodes)
r.redis.Set(ctx, key, string(raw), 2*time.Hour)
}
func captchaKey(id string) string {