.gitignore
This commit is contained in:
@@ -9,9 +9,10 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"gitee.com/red-future---jilin-g/common/log/consts"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"gitee.com/red-future---jilin-g/common/log/consts"
|
||||||
|
|
||||||
"gitee.com/red-future---jilin-g/common/beans"
|
"gitee.com/red-future---jilin-g/common/beans"
|
||||||
"gitee.com/red-future---jilin-g/common/log/model/entity"
|
"gitee.com/red-future---jilin-g/common/log/model/entity"
|
||||||
"gitee.com/red-future---jilin-g/common/redis"
|
"gitee.com/red-future---jilin-g/common/redis"
|
||||||
@@ -460,16 +461,16 @@ func (m *MongoDB) Delete(ctx context.Context, filter bson.M, collection string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DeleteSoft 假删除记录
|
// DeleteSoft 假删除记录
|
||||||
func (m *MongoDB) DeleteSoft(ctx context.Context, filter bson.M, collection string, opts ...options.Lister[options.UpdateManyOptions]) (result *mongo.UpdateResult, err error) {
|
func (m *MongoDB) DeleteSoft(ctx context.Context, filter bson.M, collection string, opts ...options.Lister[options.UpdateManyOptions]) (modifiedCount int64, err error) {
|
||||||
update := bson.M{"$set": bson.M{"isDeleted": true}}
|
update := bson.M{"$set": bson.M{"isDeleted": true}}
|
||||||
return m.Update(ctx, filter, update, collection, opts...)
|
return m.Update(ctx, filter, update, collection, opts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update 修改记录
|
// Update 修改记录
|
||||||
func (m *MongoDB) Update(ctx context.Context, filter bson.M, update bson.M, collection string, opts ...options.Lister[options.UpdateManyOptions]) (result *mongo.UpdateResult, err error) {
|
func (m *MongoDB) Update(ctx context.Context, filter bson.M, update bson.M, collection string, opts ...options.Lister[options.UpdateManyOptions]) (modifiedCount int64, err error) {
|
||||||
source, err := m.getDataSource()
|
source, err := m.getDataSource()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return 0, err
|
||||||
}
|
}
|
||||||
db := source.Database()
|
db := source.Database()
|
||||||
|
|
||||||
@@ -507,10 +508,11 @@ func (m *MongoDB) Update(ctx context.Context, filter bson.M, update bson.M, coll
|
|||||||
}
|
}
|
||||||
setDoc["updatedAt"] = gtime.Now().Time
|
setDoc["updatedAt"] = gtime.Now().Time
|
||||||
update["$set"] = setDoc
|
update["$set"] = setDoc
|
||||||
result, err = db.Collection(collection).UpdateMany(ctx, filter, update, opts...)
|
result, err := db.Collection(collection).UpdateMany(ctx, filter, update, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
modifiedCount = result.ModifiedCount
|
||||||
// 清理redis
|
// 清理redis
|
||||||
err = m.CleanRedis(ctx, filter, user.TenantId, collection)
|
err = m.CleanRedis(ctx, filter, user.TenantId, collection)
|
||||||
// 写日志
|
// 写日志
|
||||||
|
|||||||
Reference in New Issue
Block a user