diff --git a/model/query.go b/model/query.go index 8c01bbb..84413f3 100644 --- a/model/query.go +++ b/model/query.go @@ -13,10 +13,21 @@ type CommonQuery struct { Keyword string RoleID string Status string + Deleted string Sort interface{} Other map[string]interface{} } +// AssignDeleted ... +func (q *CommonQuery) AssignDeleted(cond bson.M) { + if q.Deleted == "true" { + cond["deleted"] = true + } + if q.Deleted == "false" { + cond["deleted"] = false + } +} + // AssignKeyword ... func (q *CommonQuery) AssignKeyword(cond bson.M) { if q.Keyword != "" { diff --git a/model/user_request.go b/model/user_request.go index 42678b2..9e3f2a3 100644 --- a/model/user_request.go +++ b/model/user_request.go @@ -40,6 +40,7 @@ type UserAllQuery struct { Keyword string RoleID string Status string + Deleted string // true or false Sort interface{} Other map[string]interface{} // query fields in other object } diff --git a/user/handle.go b/user/handle.go index b011edf..dae3dc9 100644 --- a/user/handle.go +++ b/user/handle.go @@ -112,6 +112,7 @@ func All(queryParams model.UserAllQuery) (r model.UserAll) { Status: queryParams.Status, Sort: queryParams.Sort, Other: queryParams.Other, + Deleted: queryParams.Deleted, } // Assign condition @@ -119,6 +120,7 @@ func All(queryParams model.UserAllQuery) (r model.UserAll) { query.AssignKeyword(cond) query.AssignRoleID(cond) query.AssignStatus(cond) + query.AssignDeleted(cond) query.AssignOther(cond) wg.Add(1)