refactor: 清理死代码 + 修复ISP接口注释

- 移除未使用的DTO类型(ChangePasswordRequest/DeleteAccountRequest)
- 移除service层未引用的错误重导出(auth_service/audit_service)
- 删除未使用的SiteSettingRepo(数据访问由config.SiteSettings直接处理)
- 删除未使用的FindByStatus方法(user_repo)
- 删除未使用的AutoMigrate方法(audit_repo/notification_repo)
- 删除未使用的PaginatedResult/NewPaginatedResult(pagination.go)
- 修复接口注释:notifProvider(5→4)、auditUseCase(4→3)、siteSettingUseCase(3→4)
- 移除auditStatusProvider未使用的FindByUsername方法
- 统一使用common.ErrXxx直接引用,消除跨service错误重导出耦合
This commit is contained in:
2026-05-27 13:52:42 +08:00
parent be91f5470b
commit f26da8f06e
11 changed files with 28 additions and 139 deletions

View File

@ -59,14 +59,6 @@ func NewAuditService(auditRepo auditRepo, userRepo userProfileStore, settings si
}
}
// ErrXxx 重导出
var (
ErrAuditNotFound = common.ErrAuditNotFound
ErrAuditNotPending = common.ErrAuditNotPending
ErrAuditDisabled = common.ErrAuditDisabled
ErrAuditTypeOff = common.ErrAuditTypeOff
)
// ShouldAudit 判断指定用户是否需要走审核流程
// 规则admin 及以上角色免审
func (s *AuditService) ShouldAudit(userID uint) (bool, error) {
@ -85,12 +77,12 @@ func (s *AuditService) ShouldAudit(userID uint) (bool, error) {
func (s *AuditService) Submit(userID uint, auditType, newValue string) error {
// 检查总开关
if !s.settings.IsAuditEnabled() {
return ErrAuditDisabled
return common.ErrAuditDisabled
}
// 检查类型开关
if !s.settings.IsAuditTypeEnabled(auditType, s.typeDefault(auditType)) {
return ErrAuditTypeOff
return common.ErrAuditTypeOff
}
// 用户名冲突检查(提交时即拦截,避免提交到后台后审核失败)
@ -101,7 +93,7 @@ func (s *AuditService) Submit(userID uint, auditType, newValue string) error {
return err
}
if exists {
return ErrUsernameTaken
return common.ErrUsernameTaken
}
// 2) 审核表中已有其他用户提交了同名 pending
pendingExists, err := s.auditRepo.ExistsPendingByTypeAndValue(auditType, newValue, userID)
@ -109,7 +101,7 @@ func (s *AuditService) Submit(userID uint, auditType, newValue string) error {
return err
}
if pendingExists {
return ErrUsernameTaken
return common.ErrUsernameTaken
}
}
@ -164,14 +156,14 @@ func (s *AuditService) review(reviewerID uint, submissionID uint, approved bool,
submission, err := s.auditRepo.FindByID(submissionID)
if err != nil {
if err == gorm.ErrRecordNotFound {
return ErrAuditNotFound
return common.ErrAuditNotFound
}
return err
}
// 2. 必须 pending
if submission.Status != model.AuditStatusPending {
return ErrAuditNotPending
return common.ErrAuditNotPending
}
// 3. 查审核人信息
@ -220,7 +212,7 @@ func (s *AuditService) applyApproval(submission *model.AuditSubmission) error {
return err
}
if exists {
return ErrUsernameTaken
return common.ErrUsernameTaken
}
user.Username = submission.NewValue
case model.AuditTypeAvatar: