file.go 949 B

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