mirror of
https://github.com/wgh136/nysoure.git
synced 2025-09-27 12:17:24 +00:00
Add user files.
This commit is contained in:
@@ -21,12 +21,13 @@ 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"`
|
||||
User UserView `json:"user"`
|
||||
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"`
|
||||
Resource *ResourceView `json:"resource,omitempty"`
|
||||
}
|
||||
|
||||
func (f *File) ToView() *FileView {
|
||||
@@ -39,3 +40,21 @@ func (f *File) ToView() *FileView {
|
||||
User: f.User.ToView(),
|
||||
}
|
||||
}
|
||||
|
||||
func (f *File) ToViewWithResource() *FileView {
|
||||
var resource *ResourceView
|
||||
if f.Resource.ID != 0 {
|
||||
rv := f.Resource.ToView()
|
||||
resource = &rv
|
||||
}
|
||||
|
||||
return &FileView{
|
||||
ID: f.UUID,
|
||||
Filename: f.Filename,
|
||||
Description: f.Description,
|
||||
Size: f.Size,
|
||||
IsRedirect: f.RedirectUrl != "",
|
||||
User: f.User.ToView(),
|
||||
Resource: resource,
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user