package com.prolog.cs.base.gsp.utils;

import cn.hutool.core.lang.Assert;
import com.alibaba.fastjson.JSONObject;
import com.prolog.framework.common.message.RestMessage;
import lombok.extern.slf4j.Slf4j;

import static com.prolog.cs.base.gsp.constant.MsgTemplate.NO_RESPONSE;

/**
 * 味精助手
 *
 * @author 鄢菁KingYan
 * @date 2022/07/08
 */
@Slf4j
public class RestMsgHelper {

    public static <T> T unpack(RestMessage<T> msg) {
        log.info("unpack==========>result:{}", JSONObject.toJSONString(msg));
        Assert.notNull(msg, NO_RESPONSE);
        Assert.isTrue(msg.isSuccess(), msg.getMessage());
        return msg.getData();
    }

}
