mirror of
https://github.com/wgh136/nysoure.git
synced 2025-12-16 15:51:14 +00:00
Improve file tile
This commit is contained in:
@@ -41,6 +41,7 @@ func GetResourceByID(id uint) (model.Resource, error) {
|
||||
}).
|
||||
Preload("Files").
|
||||
Preload("Files.User").
|
||||
Preload("Files.Storage").
|
||||
First(&r, id).Error; err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return model.Resource{}, model.NewNotFoundError("Resource not found")
|
||||
|
||||
@@ -30,6 +30,7 @@ type FileView struct {
|
||||
User UserView `json:"user"`
|
||||
Resource *ResourceView `json:"resource,omitempty"`
|
||||
Hash string `json:"hash,omitempty"`
|
||||
StorageName string `json:"storage_name,omitempty"`
|
||||
}
|
||||
|
||||
func (f *File) ToView() *FileView {
|
||||
@@ -41,6 +42,7 @@ func (f *File) ToView() *FileView {
|
||||
IsRedirect: f.RedirectUrl != "",
|
||||
User: f.User.ToView(),
|
||||
Hash: f.Hash,
|
||||
StorageName: f.Storage.Name,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user