feat(admin): 添加临时不可调度功能
当账号触发特定错误码和关键词匹配时,自动临时禁用调度: 后端: - 新增 TempUnschedCache Redis 缓存层 - RateLimitService 支持规则匹配和状态管理 - 添加 GET/DELETE /accounts/:id/temp-unschedulable API - 数据库迁移添加 temp_unschedulable_until/reason 字段 前端: - 账号状态指示器显示临时不可调度状态 - 新增 TempUnschedStatusModal 详情弹窗 - 创建/编辑账号时支持配置规则和预设模板 - 完整的中英文国际化支持
This commit is contained in:
22
backend/internal/service/temp_unsched.go
Normal file
22
backend/internal/service/temp_unsched.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
// TempUnschedState 临时不可调度状态
|
||||
type TempUnschedState struct {
|
||||
UntilUnix int64 `json:"until_unix"` // 解除时间(Unix 时间戳)
|
||||
TriggeredAtUnix int64 `json:"triggered_at_unix"` // 触发时间(Unix 时间戳)
|
||||
StatusCode int `json:"status_code"` // 触发的错误码
|
||||
MatchedKeyword string `json:"matched_keyword"` // 匹配的关键词
|
||||
RuleIndex int `json:"rule_index"` // 触发的规则索引
|
||||
ErrorMessage string `json:"error_message"` // 错误消息
|
||||
}
|
||||
|
||||
// TempUnschedCache 临时不可调度缓存接口
|
||||
type TempUnschedCache interface {
|
||||
SetTempUnsched(ctx context.Context, accountID int64, state *TempUnschedState) error
|
||||
GetTempUnsched(ctx context.Context, accountID int64) (*TempUnschedState, error)
|
||||
DeleteTempUnsched(ctx context.Context, accountID int64) error
|
||||
}
|
||||
Reference in New Issue
Block a user