package cokr.xit.ens.modules.common.ctgy.sys.mng.service.strategy;

import cokr.xit.ens.core.exception.EnsException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
public abstract class TmpltMngStrategyTemplate<P, D> extends TmpltMngCacheSupport<D> implements TmpltMngStrategy<P> {

    protected ObjectMapper mapper = new ObjectMapper();

    @Override
    final public void add(P params) throws EnsException {
        addProc(validate(params));
    }

    @Override
    final public void modify(P params) throws EnsException {
        modifyProc(validate(params));
    }

    protected abstract D validate(P params);

    protected abstract void addProc(D dto);

    protected abstract void modifyProc(D dto);

}
