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

dataset.go 1.4 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package models
  2. import (
  3. "fmt"
  4. "code.gitea.io/gitea/modules/timeutil"
  5. )
  6. // Issue represents an issue or pull request of repository.
  7. type Dataset struct {
  8. ID int64 `xorm:"pk autoincr"`
  9. Title string `xorm:"INDEX NOT NULL"`
  10. Status int32 `xorm:"INDEX"`
  11. Category string
  12. Description string `xorm:"TEXT"`
  13. DownloadTimes int64
  14. License string
  15. Task string
  16. ReleaseID int64 `xorm:"INDEX"`
  17. UserID int64 `xorm:"INDEX"`
  18. CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
  19. UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
  20. Attachments []*Attachment `xorm:"-"`
  21. }
  22. func CreateDataset(dataset *Dataset) (err error) {
  23. if _, err = x.Insert(dataset); err != nil {
  24. return err
  25. }
  26. return nil
  27. }
  28. // AddReleaseAttachments adds a release attachments
  29. func AddDatasetAttachments(DatasetID int64, attachmentUUIDs []string) (err error) {
  30. // Check attachments
  31. attachments, err := GetAttachmentsByUUIDs(attachmentUUIDs)
  32. if err != nil {
  33. return fmt.Errorf("GetAttachmentsByUUIDs [uuids: %v]: %v", attachmentUUIDs, err)
  34. }
  35. for i := range attachments {
  36. attachments[i].DatasetID = DatasetID
  37. // No assign value could be 0, so ignore AllCols().
  38. if _, err = x.ID(attachments[i].ID).Update(attachments[i]); err != nil {
  39. return fmt.Errorf("update attachment [%d]: %v", attachments[i].ID, err)
  40. }
  41. }
  42. return
  43. }