package mixins

import (
	"git.noahlan.cn/noahlan/ntool-biz/core/orm/nent/mixins"
)

type SoftDeleteMixin struct {
	mixins.SoftDeleteMixin
}

// Interceptors of the SoftDeleteMixin.
//func (d SoftDeleteMixin) Interceptors() []ent.Interceptor {
//	return []ent.Interceptor{
//		intercept.TraverseFunc(func(ctx context.Context, q intercept.Query) error {
//			// Skip soft-delete, means include soft-deleted entities.
//			if skip, _ := ctx.Value(mixins.SoftDeleteKey{}).(bool); skip {
//				return nil
//			}
//			d.SoftDeleteWhere(q)
//			return nil
//		}),
//	}
//}

// Hooks of the SoftDeleteMixin.
//func (d SoftDeleteMixin) Hooks() []ent.Hook {
//	return []ent.Hook{
//		hook.On(
//			func(next ent.Mutator) ent.Mutator {
//				return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) {
//					// Skip soft-delete, means delete the entity permanently.
//					if skip, _ := ctx.Value(mixins.SoftDeleteKey{}).(bool); skip {
//						return next.Mutate(ctx, m)
//					}
//					mx, ok := m.(interface {
//						SetOp(ent.Op)
//						Client() *ent2.Client
//						SetDeletedAt(time.Time)
//						WhereP(...func(*sql.Selector))
//					})
//					if !ok {
//						return nil, fmt.Errorf("unexpected mutation type %T", m)
//					}
//					d.SoftDeleteWhere(mx)
//					mx.SetOp(ent.OpUpdate)
//					mx.SetDeletedAt(time.Now())
//
//					//return next.Mutate(ctx, m)
//					return mx.Client().Mutate(ctx, m)
//				})
//			},
//			ent.OpDeleteOne|ent.OpDelete,
//		),
//	}
//}
