优化模块租户检查中间件,重构为函数式实现并添加超级管理员检查;新增MongoDB更新过滤构建工具;修复Redis消息消费错误处理

This commit is contained in:
2026-01-14 18:34:56 +08:00
committed by 张斌
parent 86cb177625
commit cc940c27b7
4 changed files with 71 additions and 40 deletions

View File

@@ -544,6 +544,18 @@ func (m *MongoDB) Count(ctx context.Context, filter bson.M, collection string) (
return
}
func BuildUpdateFilter(ctx context.Context, req interface{}) (filter bson.M, err error) {
_ = ctx
filter = bson.M{}
reqMap := gconv.Map(req)
for mk, mv := range reqMap {
if mk != "id" && !g.IsEmpty(mv) {
filter[mk] = mv
}
}
return
}
// EntityToBson 将 *entity/entity 转换为 bson.M
func EntityToBson(entity interface{}) (bson.M, error) {
return EntityToBsonWithFilter(entity, false)