fix(用户): 修复删除用户软删除钩子
避免软删除钩子类型断言失败导致 500\n删除无记录时返回未找到错误并记录日志
This commit is contained in:
@@ -112,9 +112,6 @@ func (d SoftDeleteMixin) Hooks() []ent.Hook {
|
||||
// 类型断言,获取 mutation 的扩展接口
|
||||
mx, ok := m.(interface {
|
||||
SetOp(ent.Op)
|
||||
Client() interface {
|
||||
Mutate(context.Context, ent.Mutation) (ent.Value, error)
|
||||
}
|
||||
SetDeletedAt(time.Time)
|
||||
WhereP(...func(*sql.Selector))
|
||||
})
|
||||
@@ -127,7 +124,7 @@ func (d SoftDeleteMixin) Hooks() []ent.Hook {
|
||||
mx.SetOp(ent.OpUpdate)
|
||||
// 设置删除时间为当前时间
|
||||
mx.SetDeletedAt(time.Now())
|
||||
return mx.Client().Mutate(ctx, m)
|
||||
return next.Mutate(ctx, m)
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user