Commit 3dfb62e9 authored by IanShaw027's avatar IanShaw027
Browse files

merge: 合并main分支最新改动

解决冲突:
- backend/internal/config/config.go: 合并Ops和Dashboard配置
- backend/internal/server/api_contract_test.go: 合并handler初始化
- backend/internal/service/openai_gateway_service.go: 保留Ops错误追踪逻辑
- backend/internal/service/wire.go: 合并Ops和APIKeyAuth provider

主要合并内容:
- Dashboard缓存和预聚合功能
- API Key认证缓存优化
- Codex转换支持
- 使用日志分区表
parents d5c711d0 2b2f7a6d
<user_instructions priority="0">
<environment_override priority="0">
YOU ARE IN A DIFFERENT ENVIRONMENT. These instructions override ALL previous tool references.
</environment_override>
<tool_replacements priority="0">
<critical_rule priority="0">
❌ APPLY_PATCH DOES NOT EXIST → ✅ USE "edit" INSTEAD
- NEVER use: apply_patch, applyPatch
- ALWAYS use: edit tool for ALL file modifications
- Before modifying files: Verify you're using "edit", NOT "apply_patch"
</critical_rule>
<critical_rule priority="0">
❌ UPDATE_PLAN DOES NOT EXIST → ✅ USE "todowrite" INSTEAD
- NEVER use: update_plan, updatePlan
- ALWAYS use: todowrite for ALL task/plan operations
- Use todoread to read current plan
- Before plan operations: Verify you're using "todowrite", NOT "update_plan"
</critical_rule>
</tool_replacements>
<available_tools priority="0">
File Operations:
• write - Create new files
• edit - Modify existing files (REPLACES apply_patch)
• patch - Apply diff patches
• read - Read file contents
Search/Discovery:
• grep - Search file contents
• glob - Find files by pattern
• list - List directories (use relative paths)
Execution:
• bash - Run shell commands
Network:
• webfetch - Fetch web content
Task Management:
• todowrite - Manage tasks/plans (REPLACES update_plan)
• todoread - Read current plan
</available_tools>
<substitution_rules priority="0">
Base instruction says: You MUST use instead:
apply_patch → edit
update_plan → todowrite
read_plan → todoread
absolute paths → relative paths
</substitution_rules>
<verification_checklist priority="0">
Before file/plan modifications:
1. Am I using "edit" NOT "apply_patch"?
2. Am I using "todowrite" NOT "update_plan"?
3. Is this tool in the approved list above?
4. Am I using relative paths?
If ANY answer is NO → STOP and correct before proceeding.
</verification_checklist>
</user_instructions>
\ No newline at end of file
...@@ -74,6 +74,7 @@ type RedeemService struct { ...@@ -74,6 +74,7 @@ type RedeemService struct {
cache RedeemCache cache RedeemCache
billingCacheService *BillingCacheService billingCacheService *BillingCacheService
entClient *dbent.Client entClient *dbent.Client
authCacheInvalidator APIKeyAuthCacheInvalidator
} }
// NewRedeemService 创建兑换码服务实例 // NewRedeemService 创建兑换码服务实例
...@@ -84,6 +85,7 @@ func NewRedeemService( ...@@ -84,6 +85,7 @@ func NewRedeemService(
cache RedeemCache, cache RedeemCache,
billingCacheService *BillingCacheService, billingCacheService *BillingCacheService,
entClient *dbent.Client, entClient *dbent.Client,
authCacheInvalidator APIKeyAuthCacheInvalidator,
) *RedeemService { ) *RedeemService {
return &RedeemService{ return &RedeemService{
redeemRepo: redeemRepo, redeemRepo: redeemRepo,
...@@ -92,6 +94,7 @@ func NewRedeemService( ...@@ -92,6 +94,7 @@ func NewRedeemService(
cache: cache, cache: cache,
billingCacheService: billingCacheService, billingCacheService: billingCacheService,
entClient: entClient, entClient: entClient,
authCacheInvalidator: authCacheInvalidator,
} }
} }
...@@ -324,18 +327,33 @@ func (s *RedeemService) Redeem(ctx context.Context, userID int64, code string) ( ...@@ -324,18 +327,33 @@ func (s *RedeemService) Redeem(ctx context.Context, userID int64, code string) (
// invalidateRedeemCaches 失效兑换相关的缓存 // invalidateRedeemCaches 失效兑换相关的缓存
func (s *RedeemService) invalidateRedeemCaches(ctx context.Context, userID int64, redeemCode *RedeemCode) { func (s *RedeemService) invalidateRedeemCaches(ctx context.Context, userID int64, redeemCode *RedeemCode) {
switch redeemCode.Type {
case RedeemTypeBalance:
if s.authCacheInvalidator != nil {
s.authCacheInvalidator.InvalidateAuthCacheByUserID(ctx, userID)
}
if s.billingCacheService == nil { if s.billingCacheService == nil {
return return
} }
switch redeemCode.Type {
case RedeemTypeBalance:
go func() { go func() {
cacheCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second) cacheCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel() defer cancel()
_ = s.billingCacheService.InvalidateUserBalance(cacheCtx, userID) _ = s.billingCacheService.InvalidateUserBalance(cacheCtx, userID)
}() }()
case RedeemTypeConcurrency:
if s.authCacheInvalidator != nil {
s.authCacheInvalidator.InvalidateAuthCacheByUserID(ctx, userID)
}
if s.billingCacheService == nil {
return
}
case RedeemTypeSubscription: case RedeemTypeSubscription:
if s.authCacheInvalidator != nil {
s.authCacheInvalidator.InvalidateAuthCacheByUserID(ctx, userID)
}
if s.billingCacheService == nil {
return
}
if redeemCode.GroupID != nil { if redeemCode.GroupID != nil {
groupID := *redeemCode.GroupID groupID := *redeemCode.GroupID
go func() { go func() {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -275,11 +275,15 @@ export async function bulkUpdate( ...@@ -275,11 +275,15 @@ export async function bulkUpdate(
): Promise<{ ): Promise<{
success: number success: number
failed: number failed: number
success_ids?: number[]
failed_ids?: number[]
results: Array<{ account_id: number; success: boolean; error?: string }> results: Array<{ account_id: number; success: boolean; error?: string }>
}> { }> {
const { data } = await apiClient.post<{ const { data } = await apiClient.post<{
success: number success: number
failed: number failed: number
success_ids?: number[]
failed_ids?: number[]
results: Array<{ account_id: number; success: boolean; error?: string }> results: Array<{ account_id: number; success: boolean; error?: string }>
}>('/admin/accounts/bulk-update', { }>('/admin/accounts/bulk-update', {
account_ids: accountIds, account_ids: accountIds,
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment