diff --git a/backend/server/services/project.go b/backend/server/services/project.go index e119979ab05..8e87d1c81b4 100644 --- a/backend/server/services/project.go +++ b/backend/server/services/project.go @@ -32,6 +32,14 @@ import ( // ProjectQuery used to query projects as the api project input type ProjectQuery struct { Pagination + Keyword *string `json:"keyword" form:"keyword"` +} + +func (query *ProjectQuery) GetKeyword() string { + if query != nil && query.Keyword != nil { + return *query.Keyword + } + return "" } // GetProjects returns a paginated list of Projects based on `query` @@ -43,6 +51,9 @@ func GetProjects(query *ProjectQuery) ([]*models.ApiOutputProject, int64, errors clauses := []dal.Clause{ dal.From(&models.Project{}), } + if query.Keyword != nil { + clauses = append(clauses, dal.Where("name LIKE ?", "%"+query.GetKeyword()+"%")) + } count, err := db.Count(clauses...) if err != nil { diff --git a/backend/server/services/store.go b/backend/server/services/store.go index 1eb4b717c48..5b4e250c281 100644 --- a/backend/server/services/store.go +++ b/backend/server/services/store.go @@ -25,7 +25,6 @@ import ( "github.com/apache/incubator-devlake/core/models" ) -// GetProjects returns a paginated list of Projects based on `query` func GetStore(storeKey string) (*models.Store, errors.Error) { clauses := []dal.Clause{ dal.From(&models.Store{}),