Files
junhong_cmp_fiber/pkg/constants/constants.go
huang 9c6d4a3bd4 实现个人客户微信认证和短信验证功能
- 添加个人客户微信登录和手机验证码登录接口
- 实现个人客户设备、ICCID、手机号关联管理
- 添加短信发送服务(HTTP 客户端)
- 添加微信认证服务(含 mock 实现)
- 添加 JWT Token 生成和验证工具
- 创建数据库迁移脚本(personal_customer 关联表)
- 修复测试文件中的路由注册参数错误
- 重构 scripts 目录结构(分离独立脚本到子目录)

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

116 lines
3.0 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 "time"
// Fiber Locals 的上下文键
const (
ContextKeyRequestID = "requestid" // 请求记录ID
ContextKeyStartTime = "start_time" //请求开始时间
ContextKeyUserID = "user_id" // 用户ID
ContextKeyUserType = "user_type" //用户类型
ContextKeyShopID = "shop_id" //店铺ID
ContextKeyUserInfo = "user_info" //完整的用户信息
)
// 配置环境变量
const (
EnvConfigPath = "CONFIG_PATH"
EnvConfigEnv = "CONFIG_ENV" // dev, staging, prod
)
// 默认配置值
const (
DefaultConfigPath = "configs/config.yaml"
DefaultServerAddr = ":3000"
DefaultRedisAddr = "localhost:6379"
)
// 数据库配置常量
const (
DefaultMaxOpenConns = 25
DefaultMaxIdleConns = 10
DefaultConnMaxLifetime = 5 * time.Minute
DefaultPageSize = 20
MaxPageSize = 100
SlowQueryThreshold = 100 * time.Millisecond
)
// 任务类型常量
const (
TaskTypeEmailSend = "email:send" // 发送邮件
TaskTypeDataSync = "data:sync" // 数据同步
TaskTypeSIMStatusSync = "sim:status:sync" // SIM 卡状态同步
TaskTypeCommission = "commission:calculate" // 分佣计算
)
// 用户状态常量
const (
UserStatusActive = "active" // 激活
UserStatusInactive = "inactive" // 未激活
UserStatusSuspended = "suspended" // 暂停
)
// RBAC 用户类型常量
const (
UserTypeSuperAdmin = 1 // 超级管理员(跳过数据权限过滤)
UserTypePlatform = 2 // 平台用户
UserTypeAgent = 3 // 代理账号
UserTypeEnterprise = 4 // 企业账号
)
// RBAC 角色类型常量
const (
RoleTypePlatform = 1 // 平台角色(适用于平台用户)
RoleTypeCustomer = 2 // 客户角色(适用于代理/企业账号)
)
// RBAC 权限类型常量
const (
PermissionTypeMenu = 1 // 菜单权限
PermissionTypeButton = 2 // 按钮权限
)
// RBAC 权限端口常量
const (
PlatformAll = "all" // 全部端口Web + H5
PlatformWeb = "web" // Web 后台
PlatformH5 = "h5" // H5 端
)
// RBAC 状态常量
const (
StatusDisabled = 0 // 禁用
StatusEnabled = 1 // 启用
)
// 订单状态常量
const (
OrderStatusPending = "pending" // 待支付
OrderStatusPaid = "paid" // 已支付
OrderStatusProcessing = "processing" // 处理中
OrderStatusCompleted = "completed" // 已完成
OrderStatusCancelled = "cancelled" // 已取消
)
// 队列配置常量
const (
QueueCritical = "critical" // 关键任务队列
QueueDefault = "default" // 默认队列
QueueLow = "low" // 低优先级队列
DefaultRetryMax = 5
DefaultTimeout = 10 * time.Minute
DefaultConcurrency = 10
)
// 店铺配置常量
const (
MaxShopLevel = 7 // 店铺最大层级
)
// 验证码配置常量
const (
VerificationCodeLength = 6 // 验证码长度6位数字
VerificationCodeExpiration = 5 * time.Minute // 验证码过期时间5分钟
VerificationCodeRateLimit = 60 * time.Second // 验证码发送频率限制60秒
)