fix(仓储): 修复并发缓存前缀与软删除更新
补齐 Redis ZSET 前缀处理,确保并发释放计数正确 删除时改用 Client().Mutate 走更新逻辑,保留软删除记录 测试: make test-integration
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/schema/field"
|
||||
"entgo.io/ent/schema/mixin"
|
||||
dbent "github.com/Wei-Shaw/sub2api/ent"
|
||||
"github.com/Wei-Shaw/sub2api/ent/intercept"
|
||||
)
|
||||
|
||||
@@ -112,6 +113,7 @@ func (d SoftDeleteMixin) Hooks() []ent.Hook {
|
||||
SetOp(ent.Op)
|
||||
SetDeletedAt(time.Time)
|
||||
WhereP(...func(*sql.Selector))
|
||||
Client() *dbent.Client
|
||||
})
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
@@ -122,7 +124,7 @@ func (d SoftDeleteMixin) Hooks() []ent.Hook {
|
||||
mx.SetOp(ent.OpUpdate)
|
||||
// 设置删除时间为当前时间
|
||||
mx.SetDeletedAt(time.Now())
|
||||
return next.Mutate(ctx, m)
|
||||
return mx.Client().Mutate(ctx, m)
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user