feat(storage): implement user-group level file management dashboard and APIs

- Expose user-scoped CRUD APIs under `/api/v1/upload` (my files query, stats, rename, delete)
- Update backend handlers and routers with ownership validation checks
- Create a dedicated frontend personal file manager card-list and upload button under `/files`
- Add comprehensive backend test coverage and update API docs
This commit is contained in:
ryan
2026-06-13 16:14:22 +08:00
parent 8b19ffed90
commit 5b13d5b464
13 changed files with 1421 additions and 21 deletions
+16 -7
View File
@@ -14,6 +14,15 @@ import (
"github.com/gin-gonic/gin"
)
const (
catImage = "图片"
catVideo = "视频"
catAudio = "音频"
catDocument = "文档"
catArchive = "压缩包"
catOther = "其他"
)
type trendItem struct {
Date string `json:"date"`
Count int64 `json:"count"`
@@ -110,7 +119,7 @@ func GetFileStats(c *gin.Context) {
catCount := make(map[string]int64)
catSize := make(map[string]int64)
categoriesList := []string{"图片", "视频", "音频", "文档", "压缩包", "其他"}
categoriesList := []string{catImage, catVideo, catAudio, catDocument, catArchive, catOther}
for _, cat := range categoriesList {
catCount[cat] = 0
catSize[cat] = 0
@@ -190,21 +199,21 @@ func getFileCategory(mimeType, ext string) string {
ext = strings.ToLower(ext)
if strings.HasPrefix(mimeType, "image/") || isImageExtension(ext) {
return "图片"
return catImage
}
if strings.HasPrefix(mimeType, "video/") {
return "视频"
return catVideo
}
if strings.HasPrefix(mimeType, "audio/") {
return "音频"
return catAudio
}
if isArchiveExtension(ext) || strings.Contains(mimeType, "zip") || strings.Contains(mimeType, "tar") || strings.Contains(mimeType, "gzip") {
return "压缩包"
return catArchive
}
if isDocumentExtension(ext) || strings.HasPrefix(mimeType, "text/") || mimeType == "application/pdf" {
return "文档"
return catDocument
}
return "其他"
return catOther
}
func isArchiveExtension(ext string) bool {