增加检查租户模块开通状态的中间件。修改mongo查询list中多字段排序。utils中增加结构体转换

This commit is contained in:
2026-01-08 19:09:47 +08:00
committed by 张斌
parent 9b900c1159
commit 91dd762cc6
4 changed files with 155 additions and 4 deletions

View File

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