package cn.axzo.msg.center.message.service.todo.mybatis;

import lombok.AccessLevel;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

/**
 * @author yanglin
 */
@Getter
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
public enum Replacement {

    TO_MESSAGE_RECORD_COLD("message_record", "message_record_cold", true)

    ;

    private final String srcTable;
    private final String destTable;
    private final boolean insertPreserveId;

    public void run(Runnable runnable) {
        ReplaceInterceptor.enable(this);
        try {
            runnable.run();
        } finally {
            ReplaceInterceptor.disable();
        }
    }
}