mirror of
https://github.com/wgh136/nysoure.git
synced 2025-09-27 12:17:24 +00:00
Show file uploader.
This commit is contained in:
@@ -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")
|
||||
|
@@ -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(),
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user