package com.kym.entity.typehandle;

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

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
 * @date 2023-10-31 16:34
 */
public class InvoiceOrderDetailListTypeHandle extends JacksonTypeHandler {
    public InvoiceOrderDetailListTypeHandle(Class<?> type) {
        super(type);
    }

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