package com.dxhy.erp.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author guoker
 * @date 2020-12-30
 */
public abstract class AbstractServiceAdapter {
    protected final Logger logger = LoggerFactory.getLogger(getClass());

    private <T> ServiceResult<T> getResult(boolean result, String msg, T data) {
        return new ServiceResult<T>().setResult(result).setMsg(msg).setData(data);
    }

    protected <T> ServiceResult<T> ok(T data) {
        return getResult(true, "ok", data);
    }

    protected <T> ServiceResult<T> ok() {
        return getResult(true, "ok", null);
    }

    protected <T> ServiceResult<T> fail(String errMsg) {
        return getResult(false, errMsg, null);
    }
}
