优化模块租户检查中间件,重构为函数式实现并添加超级管理员检查;新增MongoDB更新过滤构建工具;修复Redis消息消费错误处理
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user