file.go 981 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package orm
  2. import (
  3. "fmt"
  4. "net/http"
  5. "path/filepath"
  6. "github.com/jinzhu/gorm"
  7. )
  8. type File struct {
  9. gorm.Model
  10. Path string
  11. JobID uint
  12. }
  13. func (f *File) String() string { return filepath.Base(f.Path) }
  14. func (f *File) Create(args map[string]string, r *http.Request) (interface{}, error) {
  15. return nil, fmt.Errorf("Not implemented")
  16. }
  17. func (f *File) Read(args map[string]string, r *http.Request) (interface{}, error) {
  18. var file File
  19. if err := DB().First(&file, args["id"]).Error; err != nil {
  20. return nil, err
  21. }
  22. return map[string]string{"filename": file.Path}, nil
  23. }
  24. func (f *File) ReadAll(args map[string]string, r *http.Request) (interface{}, error) {
  25. return nil, fmt.Errorf("Not implemented")
  26. }
  27. func (f *File) Update(args map[string]string, r *http.Request) (interface{}, error) {
  28. return nil, fmt.Errorf("Not implemented")
  29. }
  30. func (f *File) Delete(args map[string]string, r *http.Request) (interface{}, error) {
  31. return nil, fmt.Errorf("Not implemented")
  32. }