Browse Source

数据集不能创建多个

tags/v1.22.3.2^2
ychao_1983 3 years ago
parent
commit
bfdd694ad2
1 changed files with 19 additions and 2 deletions
  1. +19
    -2
      models/dataset.go

+ 19
- 2
models/dataset.go View File

@@ -101,11 +101,28 @@ type SearchDatasetOptions struct {
}

func CreateDataset(dataset *Dataset) (err error) {
if _, err = x.Insert(dataset); err != nil {

sess := x.NewSession()
defer sess.Close()

if err := sess.Begin(); err != nil {
return err
}

return nil
datasetByRepoId := &Dataset{RepoID: dataset.RepoID}
has, err := sess.Get(datasetByRepoId)
if err != nil {
return err
}
if has {
return fmt.Errorf("The dataset already exists.")
}

if _, err = sess.Insert(dataset); err != nil {
return err
}
return sess.Commit()

}

func SearchDataset(opts *SearchDatasetOptions) (DatasetList, int64, error) {


Loading…
Cancel
Save