Show file uploader.

This commit is contained in:
2025-07-05 20:40:48 +08:00
parent 2dfa2e3e02
commit a169918b93
5 changed files with 49 additions and 22 deletions

View File

@@ -38,6 +38,7 @@ func GetResourceByID(id uint) (model.Resource, error) {
Preload("Images").
Preload("Tags").
Preload("Files").
Preload("Files.User").
First(&r, id).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return model.Resource{}, model.NewNotFoundError("Resource not found")

View File

@@ -21,12 +21,12 @@ type File struct {
}
type FileView struct {
ID string `json:"id"`
Filename string `json:"filename"`
Description string `json:"description"`
Size int64 `json:"size"`
IsRedirect bool `json:"is_redirect"`
UserID uint `json:"user_id"`
ID string `json:"id"`
Filename string `json:"filename"`
Description string `json:"description"`
Size int64 `json:"size"`
IsRedirect bool `json:"is_redirect"`
User UserView `json:"user"`
}
func (f *File) ToView() *FileView {
@@ -36,6 +36,6 @@ func (f *File) ToView() *FileView {
Description: f.Description,
Size: f.Size,
IsRedirect: f.RedirectUrl != "",
UserID: f.UserID,
User: f.User.ToView(),
}
}