package com.kym.entity.typehandle;

import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.fasterxml.jackson.core.type.TypeReference;
import com.kym.entity.wechat.FaPiao;

import java.io.IOException;

/**
 * @author skyline
 * @description 发票中购买方信息序列化处理
 * https://github.com/baomidou/mybatis-plus-samples/blob/master/mybatis-plus-sample-typehandler/src/main/java/com/baomidou/mybatisplus/samples/typehandler/WalletListTypeHandler.java
 */
public class InvoiceDetailBuyerInformationTypeHandle extends JacksonTypeHandler {
    public InvoiceDetailBuyerInformationTypeHandle(Class<?> type) {
        super(type);
    }

    @Override
    public Object parse(String json) {
        try {
            return getObjectMapper().readValue(json, new TypeReference<FaPiao.BuyerInformation>() {
            });
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
