From 5e8f7297f504b25a8a59a87d5182cdc4adb415bc Mon Sep 17 00:00:00 2001 From: wang yan Date: Tue, 15 Oct 2019 11:36:11 +0800 Subject: [PATCH] fix list robot account API return an internal error Signed-off-by: wang yan --- src/core/api/robot.go | 3 ++- src/pkg/robot/dao/robot.go | 20 -------------------- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/core/api/robot.go b/src/core/api/robot.go index 1f6c2bdfd..ded3a8d58 100644 --- a/src/core/api/robot.go +++ b/src/core/api/robot.go @@ -108,6 +108,7 @@ func (r *RobotAPI) Post() { return } robotReq.Visible = true + robotReq.ProjectID = r.project.ProjectID if err := validateRobotReq(r.project, &robotReq); err != nil { r.SendBadRequestError(err) @@ -144,7 +145,7 @@ func (r *RobotAPI) List() { } keywords := make(map[string]interface{}) - keywords["ProjectID"] = r.robot.ProjectID + keywords["ProjectID"] = r.project.ProjectID keywords["Visible"] = true query := &q.Query{ Keywords: keywords, diff --git a/src/pkg/robot/dao/robot.go b/src/pkg/robot/dao/robot.go index fbfe1509d..eef25fdf5 100644 --- a/src/pkg/robot/dao/robot.go +++ b/src/pkg/robot/dao/robot.go @@ -99,23 +99,3 @@ func (r *robotAccountDao) DeleteRobotAccount(id int64) error { _, err := dao.GetOrmer().QueryTable(&model.Robot{}).Filter("ID", id).Delete() return err } - -func getRobotQuerySetter(query *model.RobotQuery) orm.QuerySeter { - qs := dao.GetOrmer().QueryTable(&model.Robot{}) - - if query == nil { - return qs - } - - if len(query.Name) > 0 { - if query.FuzzyMatchName { - qs = qs.Filter("Name__icontains", query.Name) - } else { - qs = qs.Filter("Name", query.Name) - } - } - if query.ProjectID != 0 { - qs = qs.Filter("ProjectID", query.ProjectID) - } - return qs -}