增加排序设置的简化操作

This commit is contained in:
白茶清欢 2023-04-03 15:10:33 +08:00
parent 4027af2a6c
commit c2548cd930

View File

@ -318,3 +318,31 @@ func WithOrder(orderRuleList ...string) SetOption {
o.Order = orderRuleList
}
}
// WithOrderDesc 降序排序
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 15:09 2023/4/3
func WithOrderDesc(field string) SetOption {
return func(o *Option) {
if nil == o.Order {
o.Order = make([]string, 0)
}
o.Order = append(o.Order, field+" desc")
}
}
// WithOrderAsc 升序排序
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 15:09 2023/4/3
func WithOrderAsc(field string) SetOption {
return func(o *Option) {
if nil == o.Order {
o.Order = make([]string, 0)
}
o.Order = append(o.Order, field+" asc")
}
}