Skip to content

Commit 6271b7e

Browse files
author
zhangyi01
committed
fix(backend): 填充 admin handler 空壳实现,管理后台 CRUD 功能可用
根因: gen/http/handler/admin/admin_service.go 的 handler 全是 thrift 生成的 空壳(只 new(Resp) 直接返回),未调用 service 层,导致所有 admin API 返回 code:0, data:null。 填充的 handler: - AdminStats: 调 GetStats(),返回真实统计(用户/文件/存储/今日上传) - AdminListUsers: 调 GetUsers(),映射 UserResp→UserItem(status: active=1) - AdminListFiles: 调 GetFiles(),映射 FileCode→FileItem(文件名/大小/过期) - AdminGetConfig: 调 GetConfig(),返回配置结构 - AdminUpdateUserStatus: 调 UpdateUserStatus(),int↔string 状态转换 - AdminDeleteFile: 兼容 code 和 id 删除(前端传 8 位 code,绕过 int64 绑定) service 层新增 GetFileByCode 方法。 实测验证: 统计/用户列表/文件列表加载真实数据,用户禁用、文件删除 CRUD 全链路通过。
1 parent de0a964 commit 6271b7e

3 files changed

Lines changed: 172 additions & 16 deletions

File tree

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,6 @@ uploads/
6161
temp/
6262
backend/bin/
6363
backend/bin/
64+
65+
# 浏览器测试缓存
66+
.playwright-mcp/

‎backend/gen/http/handler/admin/admin_service.go‎

Lines changed: 164 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎backend/internal/app/admin/service.go‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,11 @@ func (s *Service) DeleteFile(ctx context.Context, fileID uint) error {
165165
return s.fileCodeRepo.Delete(ctx, fileID)
166166
}
167167

168+
// GetFileByCode 按取件码获取文件
169+
func (s *Service) GetFileByCode(ctx context.Context, code string) (*model.FileCode, error) {
170+
return s.fileCodeRepo.GetByCode(ctx, code)
171+
}
172+
168173
// GetTransferLogs 获取传输日志
169174
func (s *Service) GetTransferLogs(ctx context.Context, query model.TransferLogQuery) ([]*model.TransferLog, int64, error) {
170175
return s.transferLogRepo.List(ctx, query)

0 commit comments

Comments
 (0)