Files
junhong_cmp_fiber/pkg/constants/redis.go
huang 743db126f7 重构数据权限模型并清理旧RBAC代码
核心变更:
- 数据权限过滤从基于账号层级改为基于用户类型的多策略过滤
- 移除 AccountStore 中的 GetSubordinateIDs 等旧方法
- 重构认证中间件,支持 enterprise_id 和 customer_id
- 更新 GORM Callback,根据用户类型自动选择过滤策略(代理/企业/个人客户)
- 更新所有集成测试以适配新的 API 签名
- 添加功能总结文档和 OpenSpec 归档

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-10 15:08:11 +08:00

49 lines
1.5 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package constants
import "fmt"
// RedisAuthTokenKey 生成认证令牌的 Redis 键
func RedisAuthTokenKey(token string) string {
return fmt.Sprintf("auth:token:%s", token)
}
// RedisRateLimitKey 生成限流的 Redis 键
func RedisRateLimitKey(ip string) string {
return fmt.Sprintf("ratelimit:%s", ip)
}
// RedisTaskLockKey 生成任务锁的 Redis 键
// 用途:幂等性控制,防止重复执行
// 过期时间24 小时
func RedisTaskLockKey(requestID string) string {
return fmt.Sprintf("task:lock:%s", requestID)
}
// RedisTaskStatusKey 生成任务状态的 Redis 键
// 用途:存储任务执行状态
// 过期时间7 天
func RedisTaskStatusKey(taskID string) string {
return fmt.Sprintf("task:status:%s", taskID)
}
// RedisShopSubordinatesKey 生成店铺下级 ID 列表的 Redis 键
// 用途:缓存递归查询的下级店铺 ID 列表
// 过期时间30 分钟
func RedisShopSubordinatesKey(shopID uint) string {
return fmt.Sprintf("shop:subordinates:%d", shopID)
}
// RedisVerificationCodeKey 生成验证码的 Redis 键
// 用途:存储手机验证码
// 过期时间5 分钟
func RedisVerificationCodeKey(phone string) string {
return fmt.Sprintf("verification:code:%s", phone)
}
// RedisVerificationCodeLimitKey 生成验证码发送频率限制的 Redis 键
// 用途:限制验证码发送频率
// 过期时间60 秒
func RedisVerificationCodeLimitKey(phone string) string {
return fmt.Sprintf("verification:limit:%s", phone)
}