You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
838 B

  1. package dbModel
  2. import (
  3. "github.com/jinzhu/gorm"
  4. "main/controller/servers"
  5. "main/init/qmsql"
  6. "main/model/modelInterface"
  7. )
  8. type FileUploadAndDownload struct {
  9. gorm.Model
  10. Name string `json:"name"`
  11. Url string `json:"url"`
  12. Tag string `json:"tag"`
  13. }
  14. func (f *FileUploadAndDownload) Upload() error {
  15. err := qmsql.DEFAULTDB.Create(f).Error
  16. return err
  17. }
  18. // 分页获取数据 需要分页实现这个接口即可
  19. func (f *FileUploadAndDownload) GetInfoList(info modelInterface.PageInfo) (err error, list interface{}, total int) {
  20. // 封装分页方法 调用即可 传入 当前的结构体和分页信息
  21. err, db, total := servers.PagingServer(f, info)
  22. if err != nil {
  23. return
  24. } else {
  25. var fileLists []FileUploadAndDownload
  26. err = db.Order("updated_at desc").Find(&fileLists).Error
  27. return err, fileLists, total
  28. }
  29. }