update UserAllQuery

This commit is contained in:
Hoang 2021-11-20 22:00:00 +07:00
parent 41c52b6fc6
commit 3c4eab8977
3 changed files with 14 additions and 0 deletions

View File

@ -13,10 +13,21 @@ type CommonQuery struct {
Keyword string Keyword string
RoleID string RoleID string
Status string Status string
Deleted string
Sort interface{} Sort interface{}
Other map[string]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 ... // AssignKeyword ...
func (q *CommonQuery) AssignKeyword(cond bson.M) { func (q *CommonQuery) AssignKeyword(cond bson.M) {
if q.Keyword != "" { if q.Keyword != "" {

View File

@ -40,6 +40,7 @@ type UserAllQuery struct {
Keyword string Keyword string
RoleID string RoleID string
Status string Status string
Deleted string // true or false
Sort interface{} Sort interface{}
Other map[string]interface{} // query fields in other object Other map[string]interface{} // query fields in other object
} }

View File

@ -112,6 +112,7 @@ func All(queryParams model.UserAllQuery) (r model.UserAll) {
Status: queryParams.Status, Status: queryParams.Status,
Sort: queryParams.Sort, Sort: queryParams.Sort,
Other: queryParams.Other, Other: queryParams.Other,
Deleted: queryParams.Deleted,
} }
// Assign condition // Assign condition
@ -119,6 +120,7 @@ func All(queryParams model.UserAllQuery) (r model.UserAll) {
query.AssignKeyword(cond) query.AssignKeyword(cond)
query.AssignRoleID(cond) query.AssignRoleID(cond)
query.AssignStatus(cond) query.AssignStatus(cond)
query.AssignDeleted(cond)
query.AssignOther(cond) query.AssignOther(cond)
wg.Add(1) wg.Add(1)