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
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 != "" {

View File

@ -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
}

View File

@ -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)