package xyz.wbsite.action.ajax.wframe;

import xyz.wbsite.frame.base.DictLoadRequest;
import xyz.wbsite.frame.base.DictLoadResponse;
import xyz.wbsite.frame.provider.DictProvider;
import xyz.wbsite.frame.provider.FrameProvider;
import xyz.wbsite.frame.utils.ValidationUtil;

public class DictAjax {

    public DictLoadResponse load(DictLoadRequest request) {
        DictLoadResponse response = new DictLoadResponse();

        ValidationUtil.validate(request, response);
        if (response.hasError()) {
            return response;
        }

        DictProvider dictProvider = FrameProvider.getInstance().getDictProvider();
        response.setResult(dictProvider.getDict(request.getDictName()));
        return response;
    }
}
