@@ -139,20 +139,7 @@ func SearchDatasetCondition(opts *SearchDatasetOptions) builder.Cond { | |||||
var cond = builder.NewCond() | var cond = builder.NewCond() | ||||
cond = cond.And(builder.Neq{"dataset.status": DatasetStatusDeleted}) | cond = cond.And(builder.Neq{"dataset.status": DatasetStatusDeleted}) | ||||
if len(opts.Keyword) > 0 { | |||||
cond = cond.And(builder.Or(builder.Like{"dataset.title", opts.Keyword}, builder.Like{"dataset.description", opts.Keyword})) | |||||
} | |||||
if len(opts.Category) > 0 { | |||||
cond = cond.And(builder.Eq{"dataset.category": opts.Category}) | |||||
} | |||||
if len(opts.Task) > 0 { | |||||
cond = cond.And(builder.Eq{"dataset.task": opts.Task}) | |||||
} | |||||
if len(opts.License) > 0 { | |||||
cond = cond.And(builder.Eq{"dataset.license": opts.License}) | |||||
} | |||||
cond = generateFilterCond(opts, cond) | |||||
if opts.RepoID > 0 { | if opts.RepoID > 0 { | ||||
cond = cond.And(builder.Eq{"dataset.repo_id": opts.RepoID}) | cond = cond.And(builder.Eq{"dataset.repo_id": opts.RepoID}) | ||||
@@ -162,14 +149,12 @@ func SearchDatasetCondition(opts *SearchDatasetOptions) builder.Cond { | |||||
cond = cond.And(builder.Eq{"dataset.status": DatasetStatusPublic}) | cond = cond.And(builder.Eq{"dataset.status": DatasetStatusPublic}) | ||||
cond = cond.And(builder.Eq{"attachment.is_private": false}) | cond = cond.And(builder.Eq{"attachment.is_private": false}) | ||||
if opts.OwnerID > 0 { | if opts.OwnerID > 0 { | ||||
if len(opts.Keyword) == 0 { | |||||
cond = cond.Or(builder.Eq{"repository.owner_id": opts.OwnerID}) | |||||
} else { | |||||
subCon := builder.NewCond() | |||||
subCon = subCon.And(builder.Eq{"repository.owner_id": opts.OwnerID}, builder.Or(builder.Like{"dataset.title", opts.Keyword}, builder.Like{"dataset.description", opts.Keyword})) | |||||
cond = cond.Or(subCon) | |||||
} | |||||
subCon := builder.NewCond() | |||||
subCon = subCon.And(builder.Eq{"repository.owner_id": opts.OwnerID}) | |||||
subCon = generateFilterCond(opts, subCon) | |||||
cond = cond.Or(subCon) | |||||
} | } | ||||
} else if opts.OwnerID > 0 { | } else if opts.OwnerID > 0 { | ||||
cond = cond.And(builder.Eq{"repository.owner_id": opts.OwnerID}) | cond = cond.And(builder.Eq{"repository.owner_id": opts.OwnerID}) | ||||
@@ -182,6 +167,25 @@ func SearchDatasetCondition(opts *SearchDatasetOptions) builder.Cond { | |||||
return cond | return cond | ||||
} | } | ||||
func generateFilterCond(opts *SearchDatasetOptions, cond builder.Cond) builder.Cond { | |||||
if len(opts.Keyword) > 0 { | |||||
cond = cond.And(builder.Or(builder.Like{"dataset.title", opts.Keyword}, builder.Like{"dataset.description", opts.Keyword})) | |||||
} | |||||
if len(opts.Category) > 0 { | |||||
cond = cond.And(builder.Eq{"dataset.category": opts.Category}) | |||||
} | |||||
if len(opts.Task) > 0 { | |||||
cond = cond.And(builder.Eq{"dataset.task": opts.Task}) | |||||
} | |||||
if len(opts.License) > 0 { | |||||
cond = cond.And(builder.Eq{"dataset.license": opts.License}) | |||||
} | |||||
return cond | |||||
} | |||||
func SearchDatasetByCondition(opts *SearchDatasetOptions, cond builder.Cond) (DatasetList, int64, error) { | func SearchDatasetByCondition(opts *SearchDatasetOptions, cond builder.Cond) (DatasetList, int64, error) { | ||||
if opts.Page <= 0 { | if opts.Page <= 0 { | ||||
opts.Page = 1 | opts.Page = 1 | ||||
Dear OpenI User
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.
For more agreement content, please refer to the《Openl Qizhi Community AI Collaboration Platform Usage Agreement》