|
|
|
@@ -76,10 +76,9 @@ func (datasets DatasetList) loadAttributes(e Engine) error { |
|
|
|
} |
|
|
|
|
|
|
|
type SearchDatasetOptions struct { |
|
|
|
Keyword string |
|
|
|
doerID int64 |
|
|
|
OwnerID int64 |
|
|
|
IsPublic bool |
|
|
|
Keyword string |
|
|
|
OwnerID int64 |
|
|
|
IncludePublic bool |
|
|
|
ListOptions |
|
|
|
SearchOrderBy |
|
|
|
} |
|
|
|
@@ -100,27 +99,17 @@ func SearchDataset(opts *SearchDatasetOptions) (DatasetList, int64, error) { |
|
|
|
func SearchDatasetCondition(opts *SearchDatasetOptions) builder.Cond { |
|
|
|
var cond = builder.NewCond() |
|
|
|
cond = cond.And(builder.Neq{"status": DatasetStatusDeleted}) |
|
|
|
|
|
|
|
if len(opts.Keyword) > 0 { |
|
|
|
cond = cond.And(builder.Like{"title", opts.Keyword}) |
|
|
|
} |
|
|
|
|
|
|
|
if opts.doerID > 0 { |
|
|
|
doer, err := GetUserByID(opts.doerID) |
|
|
|
if err != nil { |
|
|
|
return nil |
|
|
|
} |
|
|
|
if doer.IsAdmin { |
|
|
|
|
|
|
|
if opts.IncludePublic { |
|
|
|
cond = cond.And(builder.Eq{"status": DatasetStatusPublic}) |
|
|
|
if opts.OwnerID > 0 { |
|
|
|
cond = cond.Or(builder.Eq{"user_id": opts.OwnerID}) |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
if opts.IsPublic { |
|
|
|
cond = cond.And(builder.Eq{"status": DatasetStatusPublic}) |
|
|
|
if opts.OwnerID > 0 { |
|
|
|
cond = cond.Or(builder.Eq{"user_id": opts.OwnerID}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if opts.OwnerID > 0 { |
|
|
|
cond = cond.And(builder.Eq{"user_id": opts.OwnerID}) |
|
|
|
} |
|
|
|
|