增加检查租户模块开通状态的中间件。修改mongo查询list中多字段排序。utils中增加结构体转换
This commit is contained in:
@@ -279,12 +279,12 @@ func (m *MongoDB) Find(ctx context.Context, filter bson.M, result interface{}, c
|
||||
if orderBy == nil {
|
||||
opt.SetSort(bson.M{"createdAt": -1})
|
||||
} else {
|
||||
orderBson := bson.M{}
|
||||
orderBson := bson.D{}
|
||||
for _, v := range orderBy {
|
||||
if v.Order == beans.Asc {
|
||||
orderBson[v.Field] = 1
|
||||
orderBson = append(orderBson, bson.E{Key: v.Field, Value: 1}) // 1 表示升序
|
||||
} else {
|
||||
orderBson[v.Field] = -1
|
||||
orderBson = append(orderBson, bson.E{Key: v.Field, Value: -1}) // -1 表示降序
|
||||
}
|
||||
}
|
||||
opt.SetSort(orderBson)
|
||||
|
||||
Reference in New Issue
Block a user