refactor(api/v1): DRY/SOLID 违约技术债务清理#270
Merged
Merged
Conversation
…e to resolve OCP violation
…ervice god struct Extract authentication utilities into standalone package-level functions that accept *store.Store as parameter. This is the prerequisite for extracting individual domain services from the god struct. Also fixes recursive call bug in requireAI method.
…actors Replace all hardcoded strings.Split(name, "/") patterns with standardized resource name extractors. Added compound extractors: - ExtractUserAndShortcutIDFromName - ExtractUserAndWebhookIDFromName - ExtractUserAndSettingKeyFromName - ExtractUserAndPATIDFromName - ExtractWebhookIDFromResourceName
…t domain services 1. Extracted 9 dedicated domain struct receivers (UserService, MemoService, etc.) 2. Migrated all pseudo-stub methods (UnimplementedXxx) out of APIV1Service. 3. Repurposed APIV1Service as a pure Gateway and Dependency Injector. 4. Rewired all gRPC Gateway interceptors and Connect service delegators to target domain receivers seamlessly. 5. Standardized common dependencies and decoupled generic filter validator. 6. Cleaned up remaining backward compatibility wrapper functions and staticcheck warnings.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
对
server/router/api/v1包进行 DRY/SOLID 原则重构,清理技术债务。Resolves #268
Changes
Phase 1: SRP 违约修复
拆分
user_service.go:1444 行巨文件拆分为 6 个独立文件user_service_crud.go- 用户 CRUD 操作user_service_settings.go- 用户设置user_service_tokens.go- Token 管理user_service_webhooks.go- Webhook 管理user_service_notifications.go- 通知设置user_service_converter.go- 数据转换器解耦
APIV1ServiceGod Struct:拆分为独立领域服务user_access.go- 用户访问控制ai_access.go- AI 服务访问检查resource_name.go- 资源名称解析器Phase 2: DRY 违约清理
requireUserAccess和requireAI:消除 10+ 处重复代码resource_name.go解析逻辑ScheduleService.UpdateSchedule解决 OCP 违约Phase 3: 测试验证
test_cc_cli_multiplex.pyTest plan
go build ./...编译通过go test ./...测试通过make check-all检查通过