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 com.kym.entity.wechat.FapiaoApplications;

import java.io.IOException;
import java.util.List;

/**
 * @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 InvoiceDetailItemsTypeHandle extends JacksonTypeHandler {
    public InvoiceDetailItemsTypeHandle(Class<?> type) {
        super(type);
    }

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