Skip to content

Commit

Permalink
添加条件判断
Browse files Browse the repository at this point in the history
  • Loading branch information
hulutech-web committed Oct 11, 2024
1 parent abc999d commit 200c45a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion paginator.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type PageResult struct {

// SearchByParams
// ?name=xxx&pageSize=1&currentPage=1&sort=xxx&order=xxx
func (h *HttpResult) SearchByParams(params map[string]string, excepts ...string) *HttpResult {
func (h *HttpResult) SearchByParams(params map[string]string, conditionMap map[string]interface{}, excepts ...string) *HttpResult {
for _, except := range excepts {
delete(params, except)
}
Expand All @@ -47,6 +47,9 @@ func (h *HttpResult) SearchByParams(params map[string]string, excepts ...string)
q = q.Raw(key+" like ?", "%"+value+"%").(orm.Query)
}
}
for key, val := range conditionMap {
q = q.Raw(key+" = ?", val).(orm.Query)
}
return q
}(query)
return h
Expand Down

0 comments on commit 200c45a

Please sign in to comment.