package com.hotent.base.util;

import com.hotent.base.model.CommonResult;

/**
 * 将以前旧的CommonResult规范化，构造新的CommonResult，添加上code和errorcode
 */
public class CommonResultUtil{
    public static <E> CommonResult<E> getResult(CommonResult<E> commonResult){
        if(!commonResult.getState()){
            return CommonResult.<E>error().message(commonResult.getMessage()).value(commonResult.getValue());
        }
        return CommonResult.<E>ok().message(commonResult.getMessage()).value(commonResult.getValue());
    }
}
