refactor: 文件行数超标拆解(7个文件→14个文件,全部≤200行)
- 移动本地接口定义到 interfaces.go 和 admin/interfaces.go - favorite_controller.go → favorite_item_controller.go - space_controller.go → space_loaders.go - settings_controller.go → settings_api_audit.go - admin_energy_controller.go → admin_energy_api_controller.go - admin_post_controller.go → admin_post_action_controller.go - comment_repo.go → comment_mention_repo.go - post_repo.go → post_stats_repo.go
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"metazone.cc/metalab/internal/middleware"
|
||||
"metazone.cc/metalab/internal/model"
|
||||
"metazone.cc/metalab/internal/service"
|
||||
@ -130,3 +132,56 @@ type followUseCase interface {
|
||||
ListFollowers(userID, currentUserID uint, page, pageSize int) (*service.FollowListResult, error)
|
||||
ListFollowing(userID, currentUserID uint, page, pageSize int) (*service.FollowListResult, error)
|
||||
}
|
||||
|
||||
// favoriteUseCase FavoriteController 对 FavoriteService 的最小依赖(ISP:9 个方法)
|
||||
type favoriteUseCase interface {
|
||||
ListFolders(userID uint) (*service.FavoriteListResult, error)
|
||||
CreateFolder(userID uint, name, description string, isPublic bool) (*model.Folder, error)
|
||||
UpdateFolder(userID, folderID uint, name, description string, isPublic bool) error
|
||||
DeleteFolder(userID, folderID uint) error
|
||||
ListFolderItems(userID, folderID uint, page, pageSize int) (*service.FolderItemsResult, error)
|
||||
AddFavorite(userID, postID uint, folderID *uint) error
|
||||
RemoveFavorite(userID, postID uint) error
|
||||
ToggleFavorite(userID, postID uint) (bool, error)
|
||||
GetPostFavoriteStatus(userID, postID uint) (*service.FavoriteStatus, error)
|
||||
}
|
||||
|
||||
// profileProvider SettingsController 对 AuthService 的最小依赖(ISP:4 个方法)
|
||||
type profileProvider interface {
|
||||
GetProfile(userID uint) (*model.User, error)
|
||||
UpdateProfile(userID uint, username, bio string) error
|
||||
ChangePassword(userID uint, currentPassword, newPassword string) error
|
||||
DeleteAccount(userID uint, password, reason string) error
|
||||
}
|
||||
|
||||
// avatarProvider SettingsController 头像上传对 Service 的最小依赖(ISP:2 个方法)
|
||||
type avatarProvider interface {
|
||||
ProcessAvatar(userID uint, file io.Reader, contentType string, cropX, cropY, cropSize int) (string, error)
|
||||
ProcessImage(userID uint, file io.Reader, contentType string, cropX, cropY, cropSize int) (string, error)
|
||||
}
|
||||
|
||||
// auditSubmittable SettingsController 对 AuditService 的依赖(ISP:4 个方法)
|
||||
type auditSubmittable interface {
|
||||
ShouldAudit(userID uint) (bool, error)
|
||||
SubmitProfileChanges(userID uint, currentUser *model.User, newUsername, newBio string) error
|
||||
Submit(userID uint, auditType, newValue string) error
|
||||
GetPendingTypes(userID uint) ([]string, error)
|
||||
}
|
||||
|
||||
// sessionConfig SettingsController 对配置的最小依赖(ISP:2 个方法)
|
||||
type sessionConfig interface {
|
||||
GetIdleTimeout() int
|
||||
GetRememberTimeout() int
|
||||
}
|
||||
|
||||
// taskCompleter SettingsController 对 LevelService 的依赖(ISP:2 个方法)
|
||||
type taskCompleter interface {
|
||||
CompleteTask(userID uint, taskType string) (newExp int, levelUp bool, err error)
|
||||
HasCompletedTask(userID uint, taskType string) (bool, error)
|
||||
}
|
||||
|
||||
// notifyPrefReader SettingsController 通知偏好的接口(ISP)
|
||||
type notifyPrefReader interface {
|
||||
GetNotifyPrefs(userID uint) (map[string]bool, error)
|
||||
UpdateNotifyPref(userID uint, key string, enabled bool) error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user